From 294895b702e4c5cb5bfc87292c464bed201f296b Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sun, 21 Jan 2018 16:01:39 +0000 Subject: [PATCH] Added paid checkbox to desktop time edit page. --- WEB-INF/lib/ttTimeHelper.class.php | 18 +++++++++++++----- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/time.tpl | 2 +- WEB-INF/templates/time_edit.tpl | 8 +++++++- time_edit.php | 11 +++++++++-- 5 files changed, 31 insertions(+), 10 deletions(-) diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index c92cf473..e1440105 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -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) diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 4b33c7f2..c08ed940 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - + {/if} diff --git a/WEB-INF/templates/time_edit.tpl b/WEB-INF/templates/time_edit.tpl index 9a13d4c5..1d346bba 100644 --- a/WEB-INF/templates/time_edit.tpl +++ b/WEB-INF/templates/time_edit.tpl @@ -20,6 +20,12 @@ {/if} +{if ($user->canManageTeam() && $user->isPluginEnabled('ps'))} + + + + +{/if} {if ($custom_fields && $custom_fields->fields[0])} @@ -33,7 +39,7 @@ {/if} {if ($smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} - + {/if} diff --git a/time_edit.php b/time_edit.php index 854c4463..b656c23d 100644 --- a/time_edit.php +++ b/time_edit.php @@ -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; -- 2.20.1
 Anuko Time Tracker 1.15.2.3764 | Copyright © Anuko | +  Anuko Time Tracker 1.15.2.3765 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/time.tpl b/WEB-INF/templates/time.tpl index 182f0127..355b9726 100644 --- a/WEB-INF/templates/time.tpl +++ b/WEB-INF/templates/time.tpl @@ -47,7 +47,7 @@ {/if} {if ($smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
{$i18n.label.task}:{$i18n.label.task}{if $user->task_required} (*){/if}: {$forms.timeRecordForm.task.control}
 
{$custom_fields->fields[0]['label']|escape}{if $custom_fields->fields[0]['required']} (*){/if}:{$forms.timeRecordForm.cf_1.control}
{$i18n.label.task}:{$i18n.label.task}{if $user->task_required} (*){/if}: {$forms.timeRecordForm.task.control}