[opw-web] Add a late_submission boolean to the organization table



commit 4a2036693f19242280c36b3ce5b8a90a61b93884
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Tue Mar 18 11:29:08 2014 -0400

    Add a late_submission boolean to the organization table
    
    Add a flag for each organization indicating whether they are currently
    accepting late submissions, and allow editing it from the
    manage_organizations screens.

 lang/en-gb.php                                     |    1 +
 modules/mod_manage_organizations.php               |   16 +++++++++++-----
 schema.sql                                         |    1 +
 .../html/tpl_manage_organizations.html             |    1 +
 .../html/tpl_manage_organizations_editor.html      |    7 +++++++
 .../html/tpl_manage_organizations_item.html        |    4 ++++
 6 files changed, 25 insertions(+), 5 deletions(-)
---
diff --git a/lang/en-gb.php b/lang/en-gb.php
index 3b269f9..5e8dfa3 100644
--- a/lang/en-gb.php
+++ b/lang/en-gb.php
@@ -116,6 +116,7 @@ $lang_data = array(
     'add_organization'      => 'Add new organization',
     'edit_organization'     => 'Edit organization',
     'organization_title'    => 'Organization title',
+    'late_submissions'      => 'Late submissions?',
     'confirm_organization_del' => 'If you delete this organization, all projects associated with it will 
also get deleted. ' .
                                   'Do you want to continue?',
 
diff --git a/modules/mod_manage_organizations.php b/modules/mod_manage_organizations.php
index 4cb6929..2dabe35 100644
--- a/modules/mod_manage_organizations.php
+++ b/modules/mod_manage_organizations.php
@@ -12,6 +12,7 @@ $action = $core->variable('a', 'list');
 $id = $core->variable('o', 0);
 $program_id = 0 + $core->variable('prg', 0);
 $title = $core->variable('title', '', false, true);
+$late_submission = $core->variable('late_submission', '') == 'on' ? 1 : 0;
 $page = $core->variable('pg', 1);
 $limit_start = ($page - 1) * $config->per_page;
 
@@ -46,7 +47,8 @@ if ($action == 'list')
         // Assign data for this organization
         $skin->assign(array(
             'organization_id'          => $row['id'],
-            'organization_title'       => htmlspecialchars($row['title'])
+            'organization_title'       => htmlspecialchars($row['title']),
+            'late_submission'          => $lang->get($row['late_submission'] ? 'yes' : 'no')
         ));
 
         $organizations_list .= $skin->output('tpl_manage_organizations_item');
@@ -85,13 +87,15 @@ else if ($action == 'editor')
         {
             $params = array('id' => $id,
                             'title' => $title,
-                            'program_id' => $program_id);
+                            'program_id' => $program_id,
+                            'late_submission' => $late_submission);
 
             if ($id > 0)
             {
                 // Update organization data
                 $sql = "UPDATE {$db->prefix}organizations " .
-                       "SET title = :title " .
+                       "SET title = :title, " .
+                            "late_submission = :late_submission " .
                        "WHERE id = :id";
                 $db->query($sql, $params);
             }
@@ -99,8 +103,8 @@ else if ($action == 'editor')
             {
                 // Insert organization data
                 $sql = "INSERT INTO {$db->prefix}organizations " .
-                       "(title, program_id) " .
-                       "VALUES (:title, :program_id)";
+                       "(title, program_id, late_submission) " .
+                       "VALUES (:title, :program_id, :late_submission)";
                 $db->query($sql, $params);
 
                 // Get the new organization ID
@@ -124,12 +128,14 @@ else if ($action == 'editor')
 
         // Set loaded data
         $title = $row['title'];
+        $late_submission = $row['late_submission'];
     }
 
     // Assign skin data
     $skin->assign(array(
         'editor_title'      => $page_title,
         'title'             => htmlspecialchars($title),
+        'late_submission_checked' => $skin->checked($late_submission == 1),
         'error_message'     => isset($error_message) ? $error_message : '',
         'error_visibility'  => $skin->visibility(isset($error_message)),
         'delete_visibility' => $skin->visibility($id > 0),
diff --git a/schema.sql b/schema.sql
index f25895e..4e01028 100644
--- a/schema.sql
+++ b/schema.sql
@@ -22,6 +22,7 @@ CREATE TABLE `opw_organizations` (
   `id` mediumint(6) unsigned NOT NULL AUTO_INCREMENT,
   `program_id` mediumint(6) unsigned NOT NULL,
   `title` varchar(255) NOT NULL DEFAULT '',
+  `late_submission` tinyint(1) NOT NULL DEFAULT 0,
   PRIMARY KEY (`id`),
   FOREIGN KEY (`program_id`) REFERENCES `opw_programs`(`id`)
 ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
diff --git a/skins/easterngreen/html/tpl_manage_organizations.html 
b/skins/easterngreen/html/tpl_manage_organizations.html
index 52a020c..7130e3a 100644
--- a/skins/easterngreen/html/tpl_manage_organizations.html
+++ b/skins/easterngreen/html/tpl_manage_organizations.html
@@ -17,6 +17,7 @@
         <thead>
             <tr>
                 <th>{{organization_title}}</th>
+                <th>{{late_submissions}}</th>
                 <th style="width:20px">{{edit}}</th>
             </tr>
         </thead>
diff --git a/skins/easterngreen/html/tpl_manage_organizations_editor.html 
b/skins/easterngreen/html/tpl_manage_organizations_editor.html
index 8432494..82abc8d 100644
--- a/skins/easterngreen/html/tpl_manage_organizations_editor.html
+++ b/skins/easterngreen/html/tpl_manage_organizations_editor.html
@@ -17,6 +17,13 @@
     </div>
 </div>
 
+<div class="control-group">
+    <label class="control-label">{{late_submissions}}</label>
+    <div class="controls">
+        <input type="checkbox" name="late_submission" [[late_submission_checked]] />
+    </div>
+</div>
+
 <div class="form-actions">
     <button type="submit" name="organization_save" class="btn btn-primary">
         <i class="icon-ok-sign icon-white"></i>
diff --git a/skins/easterngreen/html/tpl_manage_organizations_item.html 
b/skins/easterngreen/html/tpl_manage_organizations_item.html
index 9082473..b2101ef 100644
--- a/skins/easterngreen/html/tpl_manage_organizations_item.html
+++ b/skins/easterngreen/html/tpl_manage_organizations_item.html
@@ -3,6 +3,10 @@
         [[organization_title]]
     </td>
 
+    <td>
+        [[late_submission]]
+    </td>
+
     <td class="align-center">
         <a href="?q=manage_organizations&amp;a=editor&amp;prg=[[program_id]]&amp;o=[[organization_id]]">
             <i class="icon-pencil"></i>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]