Fixed import and export for latest changes.
authorNik Okuntseff <support@anuko.com>
Wed, 14 Feb 2018 15:58:48 +0000 (15:58 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 14 Feb 2018 15:58:48 +0000 (15:58 +0000)
WEB-INF/lib/ttExportHelper.class.php
WEB-INF/lib/ttImportHelper.class.php
WEB-INF/lib/ttTeamHelper.class.php
WEB-INF/lib/ttUser.class.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/mobile/users.tpl
WEB-INF/templates/users.tpl
dbinstall.php
mobile/users.php
mysql.sql
users.php

index bf43f28..0e11647 100644 (file)
@@ -64,8 +64,9 @@ class ttExportHelper {
     fwrite($file, "<team currency=\"".$user->currency."\" decimal_mark=\"".$user->decimal_mark."\" lang=\"".$user->lang.
       "\" date_format=\"".$user->date_format."\" time_format=\"".$user->time_format."\" week_start=\"".$user->week_start.
       "\" tracking_mode=\"".$user->tracking_mode."\" project_required=\"".$user->project_required."\" task_required=\"".$user->task_required.
-      "\" record_type=\"".$user->record_type."\" uncompleted_indicators=\"".$user->uncompleted_indicators."\" bcc_email=\"".$user->bcc_email.
-      "\" plugins=\"".$user->plugins."\" lock_spec=\"".$user->lock_spec."\" workday_hours=\"".$user->workday_hours.
+      "\" record_type=\"".$user->record_type."\" bcc_email=\"".$user->bcc_email.
+      "\" plugins=\"".$user->plugins."\" lock_spec=\"".$user->lock_spec."\" workday_minutes=\"".$user->workday_minutes.
+      "\" config=\"".$user->config.
       "\">\n");
     fwrite($file, "  <name><![CDATA[".$user->team."]]></name>\n");
     fwrite($file, "</team>\n");
@@ -206,7 +207,7 @@ class ttExportHelper {
     $quotas = ttTeamHelper::getMonthlyQuotas($user->team_id);
     fwrite($file, "<monthly_quotas>\n");
     foreach ($quotas as $quota) {
-      fwrite($file, "  <monthly_quota year=\"".$quota['year']."\" month=\"".$quota['month']."\" quota=\"".$quota['quota']."\"/>\n");
+      fwrite($file, "  <monthly_quota year=\"".$quota['year']."\" month=\"".$quota['month']."\" minutes=\"".$quota['minutes']."\"/>\n");
     }
     fwrite($file, "</monthly_quotas>\n");
 
index da4176c..9b1aad2 100644 (file)
@@ -126,11 +126,11 @@ class ttImportHelper {
           'project_required' => $this->teamData['PROJECT_REQUIRED'],
           'task_required' => $this->teamData['TASK_REQUIRED'],
           'record_type' => $this->teamData['RECORD_TYPE'],
-          'uncompleted_indicators' => $this->teamData['UNCOMPLETED_INDICATORS'],
           'bcc_email' => $this->teamData['BCC_EMAIL'],
           'plugins' => $this->teamData['PLUGINS'],
           'lock_spec' => $this->teamData['LOCK_SPEC'],
-          'workday_hours' => $this->teamData['WORKDAY_HOURS']));
+          'workday_minutes' => $this->teamData['WORKDAY_MINUTES'],
+          'config' => $this->teamData['CONFIG']));
         if ($team_id) {
           $this->team_id = $team_id;
           foreach ($this->users as $key=>$user_item) {
@@ -216,7 +216,7 @@ class ttImportHelper {
     }
 
     if ($name == 'MONTHLY_QUOTA' && $this->canImport) {
-      $this->insertMonthlyQuota($this->team_id, $this->currentElement['YEAR'], $this->currentElement['MONTH'], $this->currentElement['QUOTA']);
+      $this->insertMonthlyQuota($this->team_id, $this->currentElement['YEAR'], $this->currentElement['MONTH'], $this->currentElement['MINUTES']);
     }
 
     if ($name == 'LOG_ITEM' && $this->canImport) {
@@ -410,9 +410,9 @@ class ttImportHelper {
   }
 
   // insertMonthlyQuota - a helper function to insert a monthly quota.
-  private function insertMonthlyQuota($team_id, $year, $month, $quota) {
+  private function insertMonthlyQuota($team_id, $year, $month, $minutes) {
     $mdb2 = getConnection();
-    $sql = "INSERT INTO tt_monthly_quotas (team_id, year, month, quota) values ($team_id, $year, $month, $quota)";
+    $sql = "INSERT INTO tt_monthly_quotas (team_id, year, month, minutes) values ($team_id, $year, $month, $minutes)";
     $affected = $mdb2->exec($sql);
     return (!is_a($affected, 'PEAR_Error'));
   }
index c0baa3d..a58c2cd 100644 (file)
@@ -548,7 +548,7 @@ class ttTeamHelper {
     $mdb2 = getConnection();
 
     $result = array();
-    $sql = "select year, month, quota from tt_monthly_quotas where team_id = $team_id";
+    $sql = "select year, month, minutes from tt_monthly_quotas where team_id = $team_id";
     $res = $mdb2->query($sql);
     $result = array();
     if (!is_a($res, 'PEAR_Error')) {
@@ -727,15 +727,6 @@ class ttTeamHelper {
       $record_type_v = '';
     }
 
-    $uncompleted_indicators = $fields['uncompleted_indicators'];
-    if ($uncompleted_indicators !== null) {
-      $uncompleted_indicators_f = ', uncompleted_indicators';
-      $uncompleted_indicators_v = ', ' . (int)$uncompleted_indicators;
-    } else {
-      $uncompleted_indicators_f = '';
-      $uncompleted_indicators_v = '';
-    }
-
     $bcc_email = $fields['bcc_email'];
     if ($bcc_email !== null) {
       $bcc_email_f = ', bcc_email';
@@ -763,19 +754,28 @@ class ttTeamHelper {
       $lockspec_v = '';
     }
 
-    $workday_hours = $fields['workday_hours'];
-    if ($workday_hours !== null) {
-      $workday_hours_f = ', workday_hours';
-      $workday_hours_v = ', ' . (int)$workday_hours;
+    $workday_minutes = $fields['workday_minutes'];
+    if ($workday_minutes !== null) {
+      $workday_minutes_f = ', workday_minutes';
+      $workday_minutes_v = ', ' . (int)$workday_minutes;
+    } else {
+      $workday_minutes_f = '';
+      $workday_minutes_v = '';
+    }
+
+    $config = $fields['config'];
+    if ($config !== null) {
+      $config_f = ', config';
+      $config_v = ', ' . $mdb2->quote($config);
     } else {
-      $workday_hours_f = '';
-      $workday_hours_v = '';
+      $config_f = '';
+      $config_f = '';
     }
 
-    $sql = "insert into tt_teams (name, currency $decimal_mark_f, lang $date_format_f $time_format_f $week_start_f $tracking_mode_f $project_required_f $task_required_f $record_type_f $uncompleted_indicators_f $bcc_email_f $plugins_f $lockspec_f $workday_hours_f)
+    $sql = "insert into tt_teams (name, currency $decimal_mark_f, lang $date_format_f $time_format_f $week_start_f $tracking_mode_f $project_required_f $task_required_f $record_type_f $bcc_email_f $plugins_f $lockspec_f $workday_minutes_f $config_f)
       values(".$mdb2->quote(trim($fields['name'])).
       ", ".$mdb2->quote(trim($fields['currency']))." $decimal_mark_v, ".$mdb2->quote($lang).
-      "$date_format_v $time_format_v $week_start_v $tracking_mode_v $project_required_v $task_required_v $record_type_v $uncompleted_indicators_v $bcc_email_v $plugins_v $lockspec_v $workday_hours_v)";
+      "$date_format_v $time_format_v $week_start_v $tracking_mode_v $project_required_v $task_required_v $record_type_v $bcc_email_v $plugins_v $lockspec_v $workday_minutes_v $config_v)";
     $affected = $mdb2->exec($sql);
 
     if (!is_a($affected, 'PEAR_Error')) {
@@ -800,7 +800,6 @@ class ttTeamHelper {
     $tracking_mode_part = '';
     $task_required_part = ' , task_required = '.(int) $fields['task_required'];
     $record_type_part = '';
-    $uncompleted_indicators_part = '';
     $bcc_email_part = '';
     $plugins_part = '';
     $config_part = '';
@@ -815,7 +814,6 @@ class ttTeamHelper {
     if (isset($fields['week_start'])) $week_start_part = ', week_start = '.(int) $fields['week_start'];
     if (isset($fields['tracking_mode'])) $tracking_mode_part = ', tracking_mode = '.(int) $fields['tracking_mode'];
     if (isset($fields['record_type'])) $record_type_part = ', record_type = '.(int) $fields['record_type'];
-    if (isset($fields['uncompleted_indicators'])) $uncompleted_indicators_part = ', uncompleted_indicators = '.(int) $fields['uncompleted_indicators'];
     if (isset($fields['bcc_email'])) $bcc_email_part = ', bcc_email = '.$mdb2->quote($fields['bcc_email']);
     if (isset($fields['plugins'])) $plugins_part = ', plugins = '.$mdb2->quote($fields['plugins']);
     if (isset($fields['config'])) $config_part = ', config = '.$mdb2->quote($fields['config']);
@@ -824,7 +822,7 @@ class ttTeamHelper {
 
     $sql = "update tt_teams set $name_part $currency_part $lang_part $decimal_mark_part
       $date_format_part $time_format_part $week_start_part $tracking_mode_part $task_required_part $record_type_part
-      $uncompleted_indicators_part $bcc_email_part $plugins_part $config_part $lock_spec_part $workday_minutes_part where id = $team_id";
+      $bcc_email_part $plugins_part $config_part $lock_spec_part $workday_minutes_part where id = $team_id";
     $affected = $mdb2->exec($sql);
     if (is_a($affected, 'PEAR_Error')) return false;
 
index f2fa1cb..f64a76c 100644 (file)
@@ -69,7 +69,7 @@ class ttUser {
 
     $sql = "SELECT u.id, u.login, u.name, u.team_id, u.role, u.client_id, u.email, t.name as team_name, 
       t.currency, t.lang, t.decimal_mark, t.date_format, t.time_format, t.week_start,
-      t.tracking_mode, t.project_required, t.task_required, t.record_type, t.uncompleted_indicators,
+      t.tracking_mode, t.project_required, t.task_required, t.record_type,
       t.bcc_email, t.plugins, t.config, t.lock_spec, t.workday_minutes, t.custom_logo
       FROM tt_users u LEFT JOIN tt_teams t ON (u.team_id = t.id) WHERE ";
     if ($id)
@@ -101,7 +101,6 @@ class ttUser {
       $this->project_required = $val['project_required'];
       $this->task_required = $val['task_required'];
       $this->record_type = $val['record_type'];
-      // $this->uncompleted_indicators = $val['uncompleted_indicators']; // TODO: remove the field from query and drop the field.
       $this->bcc_email = $val['bcc_email'];
       $this->team = $val['team_name'];
       $this->currency = $val['currency'];
index 3fd1c79..12aac3e 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.17.18.3988 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.17.19.3989 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index 956ee55..5ca38fe 100644 (file)
@@ -19,7 +19,7 @@
     {foreach $active_users as $u}
         <tr bgcolor="{cycle values="#f5f5f5,#ffffff"}">
           <td>
-            {if $smarty.const.UNCOMPLETED_INDICATORS == $user->uncompleted_indicators}
+            {if $user->uncompleted_indicators}
               <span class="uncompleted-entry{if $u.has_uncompleted_entry} active{/if}"{if $u.has_uncompleted_entry} title="{$i18n.form.users.uncompleted_entry}"{/if}></span>
             {/if}
             {if $user->isManager()}
index c84039d..95ff280 100644 (file)
@@ -21,7 +21,7 @@
     {foreach $active_users as $u}
         <tr bgcolor="{cycle values="#f5f5f5,#ffffff"}">
           <td>
-          {if $smarty.const.UNCOMPLETED_INDICATORS == $user->uncompleted_indicators}
+          {if $user->uncompleted_indicators}
             <span class="uncompleted-entry{if $u.has_uncompleted_entry} active{/if}"{if $u.has_uncompleted_entry} title="{$i18n.form.users.uncompleted_entry}"{/if}></span>
           {/if}
             {$u.name|escape}
index dd36011..4d4de7e 100755 (executable)
@@ -709,7 +709,7 @@ if ($_POST) {
     setChange("ALTER TABLE `tt_log` ADD `paid` tinyint(4) NULL default '0' AFTER `billable`");
   }
 
-  if ($_POST["convert11400to11715"]) {
+  if ($_POST["convert11400to11719"]) {
     setChange("ALTER TABLE `tt_teams` DROP `address`");
     setChange("ALTER TABLE `tt_fav_reports` ADD `report_spec` text default NULL AFTER `user_id`");
     setChange("ALTER TABLE `tt_fav_reports` ADD `paid_status` tinyint(4) default NULL AFTER `invoice`");
@@ -724,6 +724,7 @@ if ($_POST) {
     setChange("ALTER TABLE `tt_teams` DROP `workday_hours`");
     setChange("UPDATE `tt_monthly_quotas` SET `minutes` = 60 * `quota`");
     setChange("ALTER TABLE `tt_monthly_quotas` DROP `quota`");
+    setChange("ALTER TABLE `tt_teams` DROP `uncompleted_indicators`");
   }
 
   if ($_POST["cleanup"]) {
@@ -768,7 +769,7 @@ if ($_POST) {
 <h2>DB Install</h2>
 <table width="80%" border="1" cellpadding="10" cellspacing="0">
   <tr>
-    <td width="80%"><b>Create database structure (v1.17.15)</b>
+    <td width="80%"><b>Create database structure (v1.17.19)</b>
     <br>(applies only to new installations, do not execute when updating)</br></td><td><input type="submit" name="crstructure" value="Create"></td>
   </tr>
 </table>
@@ -804,8 +805,8 @@ if ($_POST) {
     <td><input type="submit" name="convert1600to11400" value="Update"><br></td>
   </tr>
   <tr valign="top">
-    <td>Update database structure (v1.14 to v1.17.15)</td>
-    <td><input type="submit" name="convert11400to11715" value="Update"><br></td>
+    <td>Update database structure (v1.14 to v1.17.19)</td>
+    <td><input type="submit" name="convert11400to11719" value="Update"><br></td>
   </tr>
 </table>
 
index d565fc6..1eee608 100644 (file)
@@ -45,7 +45,7 @@ if($user->canManageTeam()) {
 }
 
 // Check if the team is set to show indicators for uncompleted time entries.
-if (UNCOMPLETED_INDICATORS == $user->uncompleted_indicators) {
+if ($user->uncompleted_indicators) {
   // Check each active user if they have an uncompleted time entry.
   foreach ($active_users as $key => $user) {
     $active_users[$key]['has_uncompleted_entry'] = (bool) ttTimeHelper::getUncompleted($user['id']);
index d771126..a09c3f4 100644 (file)
--- a/mysql.sql
+++ b/mysql.sql
@@ -26,12 +26,10 @@ CREATE TABLE `tt_teams` (
   `project_required` smallint(2) NOT NULL DEFAULT '0',       # whether a project selection is required or optional
   `task_required` smallint(2) NOT NULL DEFAULT '0',          # whether a task selection is required or optional
   `record_type` smallint(2) NOT NULL DEFAULT '0',            # time record type ("start and finish", "duration", or both)
-  `uncompleted_indicators` smallint(2) NOT NULL DEFAULT '0', # whether to show indicators for users with uncompleted time entries
   `bcc_email` varchar(100) default NULL,                     # bcc email to copy all reports to
   `plugins` varchar(255) default NULL,                       # a list of enabled plugins for team
   `lock_spec` varchar(255) default NULL,                     # Cron specification for record locking,
                                                              # for example: "0 10 * * 1" for "weekly on Mon at 10:00".
-  `workday_hours` decimal(5,2) DEFAULT '8.00',               # number of work hours in a regular day
   `workday_minutes` smallint(4) DEFAULT '480',               # number of work minutes in a regular working day
   `custom_logo` tinyint(4) default '0',                      # whether to use a custom logo or not
   `config` text default NULL,                                # miscellaneous team configuration settings
index da57040..354ea1d 100644 (file)
--- a/users.php
+++ b/users.php
@@ -45,7 +45,7 @@ if($user->canManageTeam()) {
 }
 
 // Check if the team is set to show indicators for uncompleted time entries.
-if (UNCOMPLETED_INDICATORS == $user->uncompleted_indicators) {
+if ($user->uncompleted_indicators) {
   // Check each active user if they have an uncompleted time entry.
   foreach ($active_users as $key => $user) {
     $active_users[$key]['has_uncompleted_entry'] = (bool) ttTimeHelper::getUncompleted($user['id']);