Added paid checkbox to desktop time edit page.
authorNik Okuntseff <support@anuko.com>
Sun, 21 Jan 2018 16:01:39 +0000 (16:01 +0000)
committerNik Okuntseff <support@anuko.com>
Sun, 21 Jan 2018 16:01:39 +0000 (16:01 +0000)
WEB-INF/lib/ttTimeHelper.class.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/time.tpl
WEB-INF/templates/time_edit.tpl
time_edit.php

index c92cf47..e144010 100644 (file)
@@ -418,6 +418,7 @@ class ttTimeHelper {
   // update - updates a record in log table. Does not update its custom fields.
   static function update($fields)
   {
+    global $user;
     $mdb2 = getConnection();
 
     $id = $fields['id'];
@@ -430,19 +431,26 @@ class ttTimeHelper {
     $finish = $fields['finish'];
     $duration = $fields['duration'];
     $note = $fields['note'];
-    $billable = $fields['billable'];
+
+    $billable_part = '';
+    if ($user->isPluginEnabled('iv')) {
+      $billable_part = $fields['billable'] ? ', billable = 1' : ', billable = 0';
+    }
+    $paid_part = '';
+    if ($user->canManageTeam() && $user->isPluginEnabled('ps')) {
+      $paid_part = $fields['paid'] ? ', paid = 1' : ', paid = 0';
+    }
 
     $start = ttTimeHelper::to24HourFormat($start);
     $finish = ttTimeHelper::to24HourFormat($finish);
     if ('00:00' == $finish) $finish = '24:00';
     $duration = ttTimeHelper::normalizeDuration($duration);
 
-    if (!$billable) $billable = 0;
     if ($start) $duration = '';
 
     if ($duration) {
       $sql = "UPDATE tt_log set start = NULL, duration = '$duration', client_id = ".$mdb2->quote($client).", project_id = ".$mdb2->quote($project).", task_id = ".$mdb2->quote($task).", ".
-        "comment = ".$mdb2->quote($note).", billable = $billable, date = '$date' WHERE id = $id";
+        "comment = ".$mdb2->quote($note)."$billable_part $paid_part, date = '$date' WHERE id = $id";
       $affected = $mdb2->exec($sql);
       if (is_a($affected, 'PEAR_Error'))
         return false;
@@ -455,7 +463,7 @@ class ttTimeHelper {
         return false;
 
       $sql = "UPDATE tt_log SET start = '$start', duration = '$duration', client_id = ".$mdb2->quote($client).", project_id = ".$mdb2->quote($project).", task_id = ".$mdb2->quote($task).", ".
-        "comment = ".$mdb2->quote($note).", billable = $billable, date = '$date' WHERE id = $id";
+        "comment = ".$mdb2->quote($note)."$billable_part $paid_part, date = '$date' WHERE id = $id";
       $affected = $mdb2->exec($sql);
       if (is_a($affected, 'PEAR_Error'))
         return false;
@@ -601,7 +609,7 @@ class ttTimeHelper {
     $sql = "select l.id as id, l.timestamp as timestamp, TIME_FORMAT(l.start, $sql_time_format) as start,
       TIME_FORMAT(sec_to_time(time_to_sec(l.start) + time_to_sec(l.duration)), $sql_time_format) as finish,
       TIME_FORMAT(l.duration, '%k:%i') as duration,
-      p.name as project_name, t.name as task_name, l.comment, l.client_id, l.project_id, l.task_id, l.invoice_id, l.billable, l.date
+      p.name as project_name, t.name as task_name, l.comment, l.client_id, l.project_id, l.task_id, l.invoice_id, l.billable, l.paid, l.date
       from tt_log l
       left join tt_projects p on (p.id = l.project_id)
       left join tt_tasks t on (t.id = l.task_id)
index 4b33c7f..c08ed94 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.2.3764 | 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.2.3765 | 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 182f012..355b972 100644 (file)
@@ -47,7 +47,7 @@
 {/if}
 {if ($smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
         <tr>
-          <td align="right">{$i18n.label.task}:</td>
+          <td align="right">{$i18n.label.task}{if $user->task_required} (*){/if}:</td>
           <td>{$forms.timeRecordForm.task.control}</td>
         </tr>
 {/if}
index 9a13d4c..1d346bb 100644 (file)
       <td><label>{$forms.timeRecordForm.billable.control}{$i18n.form.time.billable}</label></td>
     </tr>
 {/if}
+{if ($user->canManageTeam() && $user->isPluginEnabled('ps'))}
+    <tr>
+      <td align="right">&nbsp;</td>
+      <td><label>{$forms.timeRecordForm.paid.control}{$i18n.label.paid}</label></td>
+    </tr>
+{/if}
 {if ($custom_fields && $custom_fields->fields[0])} 
     <tr>
       <td align="right">{$custom_fields->fields[0]['label']|escape}{if $custom_fields->fields[0]['required']} (*){/if}:</td><td>{$forms.timeRecordForm.cf_1.control}</td>
@@ -33,7 +39,7 @@
 {/if}
 {if ($smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
     <tr>
-      <td align="right">{$i18n.label.task}:</td>
+      <td align="right">{$i18n.label.task}{if $user->task_required} (*){/if}:</td>
       <td>{$forms.timeRecordForm.task.control}</td>
     </tr>
 {/if}
index 854c446..b656c23 100644 (file)
@@ -72,6 +72,8 @@ if ($request->isPost()) {
   $cl_billable = 1;
   if ($user->isPluginEnabled('iv'))
     $cl_billable = $request->getParameter('billable');
+  if ($user->isPluginEnabled('ps'))
+    $cl_paid = $request->getParameter('paid');
 } else {
   $cl_client = $time_rec['client_id'];
   $cl_project = $time_rec['project_id'];
@@ -93,6 +95,7 @@ if ($request->isPost()) {
   }
 
   $cl_billable = $time_rec['billable'];
+  $cl_paid = $time_rec['paid'];
 
   // Add an info message to the form if we are editing an uncompleted record.
   if (strlen($cl_start) > 0 && $cl_start == $cl_finish && $cl_duration == '0:00') {
@@ -203,6 +206,8 @@ if ($custom_fields && $custom_fields->fields[0]) {
 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id));
 if ($user->isPluginEnabled('iv'))
   $form->addInput(array('type'=>'checkbox','name'=>'billable','value'=>$cl_billable));
+if ($user->isPluginEnabled('ps'))
+  $form->addInput(array('type'=>'checkbox','name'=>'paid','value'=>$cl_paid));
 $form->addInput(array('type'=>'hidden','name'=>'browser_today','value'=>'')); // User current date, which gets filled in on btn_save or btn_copy click.
 $form->addInput(array('type'=>'submit','name'=>'btn_save','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.save')));
 $form->addInput(array('type'=>'submit','name'=>'btn_copy','onclick'=>'browser_today.value=get_date()','value'=>$i18n->getKey('button.copy')));
@@ -307,7 +312,8 @@ if ($request->isPost()) {
         'finish'=>$cl_finish,
         'duration'=>$cl_duration,
         'note'=>$cl_note,
-        'billable'=>$cl_billable));
+        'billable'=>$cl_billable,
+        'paid'=>$cl_paid));
 
       // If we have custom fields - update values.
       if ($res && $custom_fields) {
@@ -366,7 +372,8 @@ if ($request->isPost()) {
         'finish'=>$cl_finish,
         'duration'=>$cl_duration,
         'note'=>$cl_note,
-        'billable'=>$cl_billable));
+        'billable'=>$cl_billable,
+        'paid'=>$cl_paid));
 
       // Insert a custom field if we have it.
       $res = true;