Fixed export-import to accommodate new fields.
authorNik Okuntseff <support@anuko.com>
Sat, 20 Jan 2018 23:59:36 +0000 (23:59 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 20 Jan 2018 23:59:36 +0000 (23:59 +0000)
WEB-INF/lib/ttExportHelper.class.php
WEB-INF/lib/ttImportHelper.class.php
WEB-INF/lib/ttTeamHelper.class.php
WEB-INF/lib/ttTimeHelper.class.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/profile_edit.tpl

index aa8f6c7..a3f6485 100644 (file)
@@ -61,11 +61,12 @@ class ttExportHelper {
     fwrite($file, "<pack>\n");
 
     // Write team info.
-    fwrite($file, "<team currency=\"".$user->currency."\" lock_spec=\"".$user->lock_spec."\" lang=\"".$user->lang.
-      "\" decimal_mark=\"".$user->decimal_mark."\" date_format=\"".$user->date_format."\" time_format=\"".$user->time_format.
-      "\" week_start=\"".$user->week_start."\" workday_hours=\"".$user->workday_hours.
-      "\" plugins=\"".$user->plugins."\" tracking_mode=\"".$user->tracking_mode."\" task_required=\"".$user->task_required.
-      "\" record_type=\"".$user->record_type."\">\n");
+    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.
+      "\">\n");
     fwrite($file, "  <name><![CDATA[".$user->team."]]></name>\n");
     fwrite($file, "</team>\n");
 
@@ -217,7 +218,7 @@ class ttExportHelper {
       foreach ($records as $record) {
         $key++;
         $this->logMap[$record['id']] = $key;
-        fwrite($file, "  <log_item id=\"$key\" timestamp=\"".$record['timestamp']."\" user_id=\"".$this->userMap[$record['user_id']]."\" date=\"".$record['date']."\" start=\"".$record['start']."\" finish=\"".$record['finish']."\" duration=\"".($record['start']?"":$record['duration'])."\" client_id=\"".$this->clientMap[$record['client_id']]."\" project_id=\"".$this->projectMap[$record['project_id']]."\" task_id=\"".$this->taskMap[$record['task_id']]."\" invoice_id=\"".$this->invoiceMap[$record['invoice_id']]."\" billable=\"".$record['billable']."\" status=\"".$record['status']."\">\n");
+        fwrite($file, "  <log_item id=\"$key\" timestamp=\"".$record['timestamp']."\" user_id=\"".$this->userMap[$record['user_id']]."\" date=\"".$record['date']."\" start=\"".$record['start']."\" finish=\"".$record['finish']."\" duration=\"".($record['start']?"":$record['duration'])."\" client_id=\"".$this->clientMap[$record['client_id']]."\" project_id=\"".$this->projectMap[$record['project_id']]."\" task_id=\"".$this->taskMap[$record['task_id']]."\" invoice_id=\"".$this->invoiceMap[$record['invoice_id']]."\" billable=\"".$record['billable']."\" paid=\"".$record['paid']."\" status=\"".$record['status']."\">\n");
         fwrite($file, "    <comment><![CDATA[".$record['comment']."]]></comment>\n");
         fwrite($file, "  </log_item>\n");
       }
index 99b35e4..753dc16 100644 (file)
@@ -117,17 +117,20 @@ class ttImportHelper {
         $team_id = ttTeamHelper::insert(array(
           'name' => $this->teamData['NAME'],
           'currency' => $this->teamData['CURRENCY'],
-          'lock_spec' => $this->teamData['LOCK_SPEC'],
-          'workday_hours' => $this->teamData['WORKDAY_HOURS'],
-          'lang' => $this->teamData['LANG'],
           'decimal_mark' => $this->teamData['DECIMAL_MARK'],
+          'lang' => $this->teamData['LANG'],
           'date_format' => $this->teamData['DATE_FORMAT'],
           'time_format' => $this->teamData['TIME_FORMAT'],
           'week_start' => $this->teamData['WEEK_START'],
-          'plugins' => $this->teamData['PLUGINS'],
           'tracking_mode' => $this->teamData['TRACKING_MODE'],
+          'project_required' => $this->teamData['PROJECT_REQUIRED'],
           'task_required' => $this->teamData['TASK_REQUIRED'],
-          'record_type' => $this->teamData['RECORD_TYPE']));
+          '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']));
         if ($team_id) {
           $this->team_id = $team_id;
           foreach ($this->users as $key=>$user_item) {
@@ -231,6 +234,7 @@ class ttImportHelper {
           'invoice' => $this->invoiceMap[$this->currentElement['INVOICE_ID']],
           'note' => (isset($this->currentElement['COMMENT']) ? $this->currentElement['COMMENT'] : ''),
           'billable' => $this->currentElement['BILLABLE'],
+          'paid' => $this->currentElement['PAID'],
           'status' => $this->currentElement['STATUS']));
     }
 
index 0f3358f..6127123 100644 (file)
@@ -636,21 +636,6 @@ class ttTeamHelper {
 
     $mdb2 = getConnection();
 
-    $lock_spec = $fields['lock_spec'];
-    if ($lock_spec !== null) {
-      $lockspec_f = ', lock_spec';
-      $lockspec_v = ', ' . $mdb2->quote($lock_spec);
-    } else {
-      $lockspec_f = '';
-      $lockspec_v = '';
-    }
-
-    $lang = $fields['lang'];
-    if (!$lang) {
-      global $i18n;
-      $lang = $i18n->lang;
-    }
-
     $decimal_mark = $fields['decimal_mark'];
     if ($decimal_mark !== null) {
       $decimal_mark_f = ', decimal_mark';
@@ -660,6 +645,12 @@ class ttTeamHelper {
       $decimal_mark_v = '';
     }
 
+    $lang = $fields['lang'];
+    if (!$lang) {
+      global $i18n;
+      $lang = $i18n->lang;
+    }
+
     $date_format = $fields['date_format'];
     if ($date_format !== null) {
       $date_format_f = ', date_format';
@@ -696,15 +687,6 @@ class ttTeamHelper {
       $week_start_v = '';
     }
 
-    $plugins = $fields['plugins'];
-    if ($plugins !== null) {
-      $plugins_f = ', plugins';
-      $plugins_v = ', ' . $mdb2->quote($plugins);
-    } else {
-      $plugins_f = '';
-      $plugins_v = '';
-    }
-
     $tracking_mode = $fields['tracking_mode'];
     if ($tracking_mode !== null) {
       $tracking_mode_f = ', tracking_mode';
@@ -714,6 +696,15 @@ class ttTeamHelper {
       $tracking_mode_v = '';
     }
 
+    $project_required = $fields['project_required'];
+    if ($project_required !== null) {
+      $project_required_f = ', project_required';
+      $project_required_v = ', ' . (int)$project_required;
+    } else {
+      $project_required_f = '';
+      $project_required_v = '';
+    }
+
     $task_required = $fields['task_required'];
     if ($task_required !== null) {
       $task_required_f = ', task_required';
@@ -741,6 +732,33 @@ class ttTeamHelper {
       $uncompleted_indicators_v = '';
     }
 
+    $bcc_email = $fields['bcc_email'];
+    if ($bcc_email !== null) {
+      $bcc_email_f = ', bcc_email';
+      $bcc_email_v = ', ' . $mdb2->quote($bcc_email);
+    } else {
+      $bcc_email_f = '';
+      $bcc_email_v = '';
+    }
+
+    $plugins = $fields['plugins'];
+    if ($plugins !== null) {
+      $plugins_f = ', plugins';
+      $plugins_v = ', ' . $mdb2->quote($plugins);
+    } else {
+      $plugins_f = '';
+      $plugins_v = '';
+    }
+
+    $lock_spec = $fields['lock_spec'];
+    if ($lock_spec !== null) {
+      $lockspec_f = ', lock_spec';
+      $lockspec_v = ', ' . $mdb2->quote($lock_spec);
+    } else {
+      $lockspec_f = '';
+      $lockspec_v = '';
+    }
+
     $workday_hours = $fields['workday_hours'];
     if ($workday_hours !== null) {
       $workday_hours_f = ', workday_hours';
@@ -750,10 +768,10 @@ class ttTeamHelper {
       $workday_hours_v = '';
     }
 
-    $sql = "insert into tt_teams (name, currency $lockspec_f, lang $decimal_mark_f $date_format_f $time_format_f $week_start_f $plugins_f $tracking_mode_f $task_required_f $record_type_f $uncompleted_indicators_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 $uncompleted_indicators_f $bcc_email_f $plugins_f $lockspec_f $workday_hours_f)
       values(".$mdb2->quote(trim($fields['name'])).
-      ", ".$mdb2->quote(trim($fields['currency']))." $lockspec_v, ".$mdb2->quote($lang).
-      "$decimal_mark_v $date_format_v $time_format_v $week_start_v $plugins_v $tracking_mode_v $task_required_v $record_type_v $uncompleted_indicators_v $workday_hours_v)";
+      ", ".$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)";
     $affected = $mdb2->exec($sql);
 
     if (!is_a($affected, 'PEAR_Error')) {
index 9d3f8bb..44a1a8c 100644 (file)
@@ -370,6 +370,7 @@ class ttTimeHelper {
     $invoice = $fields['invoice'];
     $note = $fields['note'];
     $billable = $fields['billable'];
+    $paid = $fields['paid'];
     if (array_key_exists('status', $fields)) { // Key exists and may be NULL during migration of data.
       $status_f = ', status';
       $status_v = ', '.$mdb2->quote($fields['status']);
@@ -390,10 +391,11 @@ class ttTimeHelper {
     }
 
     if (!$billable) $billable = 0;
+    if (!$paid) $paid = 0;
 
     if ($duration) {
-      $sql = "insert into tt_log (timestamp, user_id, date, duration, client_id, project_id, task_id, invoice_id, comment, billable $status_f) ".
-        "values ('$timestamp', $user_id, ".$mdb2->quote($date).", '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable $status_v)";
+      $sql = "insert into tt_log (timestamp, user_id, date, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid $status_f) ".
+        "values ('$timestamp', $user_id, ".$mdb2->quote($date).", '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $status_v)";
       $affected = $mdb2->exec($sql);
       if (is_a($affected, 'PEAR_Error'))
         return false;
@@ -403,7 +405,7 @@ class ttTimeHelper {
       if (!$duration && ttTimeHelper::getUncompleted($user_id)) return false;
 
       $sql = "insert into tt_log (timestamp, user_id, date, start, duration, client_id, project_id, task_id, invoice_id, comment, billable $status_f) ".
-        "values ('$timestamp', $user_id, ".$mdb2->quote($date).", '$start', '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable $status_v)";
+        "values ('$timestamp', $user_id, ".$mdb2->quote($date).", '$start', '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $status_v)";
       $affected = $mdb2->exec($sql);
       if (is_a($affected, 'PEAR_Error'))
         return false;
@@ -625,7 +627,7 @@ class ttTimeHelper {
     $sql = "select l.id, l.timestamp, l.user_id, l.date, TIME_FORMAT(l.start, '%k:%i') as start,
       TIME_FORMAT(sec_to_time(time_to_sec(l.start) + time_to_sec(l.duration)), '%k:%i') as finish,
       TIME_FORMAT(l.duration, '%k:%i') as duration,
-      l.client_id, l.project_id, l.task_id, l.invoice_id, l.comment, l.billable, l.status
+      l.client_id, l.project_id, l.task_id, l.invoice_id, l.comment, l.billable, l.paid, l.status
       from tt_log l where l.user_id = $user_id order by l.id";
     $res = $mdb2->query($sql);
     if (!is_a($res, 'PEAR_Error')) {
index 2c504cf..c02ed1e 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.15.0.3762 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.15.1.3763 | 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 4a05bb0..e766ffb 100644 (file)
@@ -172,8 +172,8 @@ function handlePluginCheckboxes() {
 {/if}
           {* initialize preview text *}
           <script>
-            MakeFormatPreview("date_format_preview", document.getElementById("format_date"));
-            MakeFormatPreview("time_format_preview", document.getElementById("format_time"));
+            MakeFormatPreview("date_format_preview", document.getElementById("date_format"));
+            MakeFormatPreview("time_format_preview", document.getElementById("time_format"));
 
             function adjustDecimalPreview()
             {