From: Nik Okuntseff Date: Mon, 22 Jan 2018 17:00:46 +0000 (+0000) Subject: Added manual editing of the paid status for expense items. X-Git-Tag: timetracker_1.19-1~1343 X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/commitdiff_plain/3e7b58457f94c49a154b2f108f0188682a114aa2 Added manual editing of the paid status for expense items. --- diff --git a/WEB-INF/lib/ttExpenseHelper.class.php b/WEB-INF/lib/ttExpenseHelper.class.php index c41a1416..ff7879c3 100644 --- a/WEB-INF/lib/ttExpenseHelper.class.php +++ b/WEB-INF/lib/ttExpenseHelper.class.php @@ -56,6 +56,7 @@ class ttExpenseHelper { // update - updates a record in tt_expense_items table. static function update($fields) { + global $user; $mdb2 = getConnection(); $id = (int) $fields['id']; @@ -67,9 +68,14 @@ class ttExpenseHelper { $cost = str_replace(',', '.', $fields['cost']); $invoice_id = $fields['invoice_id']; + $paid_part = ''; + if ($user->canManageTeam() && $user->isPluginEnabled('ps')) { + $paid_part = $fields['paid'] ? ', paid = 1' : ', paid = 0'; + } + $sql = "UPDATE tt_expense_items set date = ".$mdb2->quote($date).", user_id = $user_id, client_id = ".$mdb2->quote($client_id). ", project_id = ".$mdb2->quote($project_id).", name = ".$mdb2->quote($name). - ", cost = ".$mdb2->quote($cost).", invoice_id = ".$mdb2->quote($invoice_id). + ", cost = ".$mdb2->quote($cost)."$paid_part, invoice_id = ".$mdb2->quote($invoice_id). " WHERE id = $id"; $affected = $mdb2->exec($sql); @@ -122,7 +128,7 @@ class ttExpenseHelper { if ($user->isPluginEnabled('cl')) $left_joins .= " left join tt_clients c on (ei.client_id = c.id)"; - $sql = "select ei.id, ei.date, ei.client_id, ei.project_id, ei.name, ei.cost, ei.invoice_id $client_field, p.name as project_name + $sql = "select ei.id, ei.date, ei.client_id, ei.project_id, ei.name, ei.cost, ei.invoice_id, ei.paid $client_field, p.name as project_name from tt_expense_items ei $left_joins where ei.id = $id and ei.user_id = $user_id and ei.status = 1"; diff --git a/WEB-INF/templates/expense_edit.tpl b/WEB-INF/templates/expense_edit.tpl index bcd393a5..39198b88 100644 --- a/WEB-INF/templates/expense_edit.tpl +++ b/WEB-INF/templates/expense_edit.tpl @@ -150,6 +150,12 @@ function recalculateCost() { {$i18n.label.cost}: {$forms.expenseItemForm.cost.control} {$user->currency|escape} +{if ($user->canManageTeam() && $user->isPluginEnabled('ps'))} + +   + + +{/if} {$i18n.label.date}: {$forms.expenseItemForm.date.control} diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index fa6d5681..9e1b82ed 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.0.3776 | Copyright © Anuko | +  Anuko Time Tracker 1.17.1.3777 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/expense_edit.php b/expense_edit.php index 7a256d65..d7d815c3 100644 --- a/expense_edit.php +++ b/expense_edit.php @@ -56,12 +56,15 @@ if ($request->isPost()) { $cl_project = $request->getParameter('project'); $cl_item_name = trim($request->getParameter('item_name')); $cl_cost = trim($request->getParameter('cost')); + if ($user->isPluginEnabled('ps')) + $cl_paid = $request->getParameter('paid'); } else { $cl_date = $item_date->toString($user->date_format); $cl_client = $expense_item['client_id']; $cl_project = $expense_item['project_id']; $cl_item_name = $expense_item['name']; $cl_cost = $expense_item['cost']; + $cl_paid = $expense_item['paid']; } // Initialize elements of 'expenseItemForm'. @@ -134,6 +137,8 @@ if ($predefined_expenses) { } $form->addInput(array('type'=>'textarea','maxlength'=>'800','name'=>'item_name','style'=>'width: 250px; height:'.NOTE_INPUT_HEIGHT.'px;','value'=>$cl_item_name)); $form->addInput(array('type'=>'text','maxlength'=>'40','name'=>'cost','style'=>'width: 100px;','value'=>$cl_cost)); +if ($user->canManageTeam() && $user->isPluginEnabled('ps')) + $form->addInput(array('type'=>'checkbox','name'=>'paid','value'=>$cl_paid)); $form->addInput(array('type'=>'datefield','name'=>'date','maxlength'=>'20','value'=>$cl_date)); // Hidden control for record id. $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id)); @@ -181,7 +186,7 @@ if ($request->isPost()) { // Now, an update. if ($err->no()) { if (ttExpenseHelper::update(array('id'=>$cl_id,'date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(), - 'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost))) { + 'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'paid'=>$cl_paid))) { header('Location: expenses.php?date='.$new_date->toString(DB_DATEFORMAT)); exit(); } diff --git a/time_edit.php b/time_edit.php index b656c23d..6628ce34 100644 --- a/time_edit.php +++ b/time_edit.php @@ -206,7 +206,7 @@ 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')) +if ($user->canManageTeam() && $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')));