--- /dev/null
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// | notice or license removed or altered. (Distributing in compiled
+// | forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// | that bears insufficient indications that the modifications are
+// | not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+
+// Class ttPredefinedExpenseHelper is used to help with predefined expense related tasks.
+class ttPredefinedExpenseHelper {
+
+ // get - gets predefined expense details.
+ static function get($id)
+ {
+ global $user;
+
+ $mdb2 = getConnection();
+
+ $sql = "select id, name, cost from tt_predefined_expenses
+ where id = $id and team_id = $user->team_id";
+ $res = $mdb2->query($sql);
+ if (!is_a($res, 'PEAR_Error')) {
+ $val = $res->fetchRow();
+ if ($val && $val['id'])
+ return $val;
+ }
+ return false;
+ }
+
+ // delete - deletes a predefined expense from tt_predefined_expenses table.
+ static function delete($id) {
+ global $user;
+
+ $mdb2 = getConnection();
+
+ $sql = "delete from tt_predefined_expenses where id = $id and team_id = $user->team_id";
+ $affected = $mdb2->exec($sql);
+ if (is_a($affected, 'PEAR_Error'))
+ return false;
+
+ return true;
+ }
+
+ // insert function inserts a new predefined expense into database.
+ static function insert($fields)
+ {
+ $mdb2 = getConnection();
+
+ $team_id = (int) $fields['team_id'];
+ $name = $fields['name'];
+ $cost = $fields['cost'];
+
+ $sql = "insert into tt_predefined_expenses (team_id, name, cost)
+ values ($team_id, ".$mdb2->quote($name).", ".$mdb2->quote($cost).")";
+ $affected = $mdb2->exec($sql);
+ if (is_a($affected, 'PEAR_Error'))
+ return false;
+
+ return true;
+ }
+
+ // update function - updates a predefined expense in database.
+ static function update($fields)
+ {
+ $mdb2 = getConnection();
+
+ $predefined_expense_id = (int) $fields['id'];
+ $team_id = (int) $fields['team_id'];
+ $name = $fields['name'];
+ $cost = $fields['cost'];
+
+ $sql = "update tt_predefined_expenses set name = ".$mdb2->quote($name).", cost = ".$mdb2->quote($cost).
+ " where id = $predefined_expense_id and team_id = $team_id";
+ $affected = $mdb2->exec($sql);
+ return (!is_a($affected, 'PEAR_Error'));
+ }
+}
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.9.37.3574 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.9.37.3575 | Copyright © <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>
--- /dev/null
+{$forms.predefinedExpensesForm.open}
+<table cellspacing="0" cellpadding="7" border="0" width="720">
+ <tr>
+ <td valign="top">
+{if $user->canManageTeam()}
+ <table cellspacing="1" cellpadding="3" border="0" width="100%">
+ <tr>
+ <td class="tableHeader">{$i18n.label.thing_name}</td>
+ <td class="tableHeader">{$i18n.label.cost}</td>
+ <td class="tableHeader">{$i18n.label.edit}</td>
+ <td class="tableHeader">{$i18n.label.delete}</td>
+ </tr>
+ {if $predefined_expenses}
+ {foreach $predefined_expenses as $predefined_expense}
+ <tr bgcolor="{cycle values="#f5f5f5,#dedee5"}">
+ <td>{$predefined_expense['name']|escape}</td>
+ <td>{$predefined_expense['cost']|escape}</td>
+ <td><a href="predefined_expense_edit.php?id={$predefined_expense['id']}">{$i18n.label.edit}</a></td>
+ <td><a href="predefined_expense_delete.php?id={$predefined_expense['id']}">{$i18n.label.delete}</a></td>
+ </tr>
+ {/foreach}
+ {/if}
+ </table>
+
+ <table width="100%">
+ <tr><td align="center"><br>{$forms.predefinedExpensesForm.btn_add.control}</td></tr>
+ </table>
+{/if}
+ </td>
+ </tr>
+</table>
+{$forms.predefinedExpensesForm.close}
--- /dev/null
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// | notice or license removed or altered. (Distributing in compiled
+// | forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// | that bears insufficient indications that the modifications are
+// | not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+import('form.Form');
+import('ttTeamHelper');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team) || !$user->isPluginEnabled('ex')) {
+ header('Location: access_denied.php');
+ exit();
+}
+
+$form = new Form('predefinedExpensesForm');
+
+if ($request->isPost()) {
+ if ($request->getParameter('btn_add')) {
+ // The Add button clicked. Redirect to predefined_expense_add.php page.
+ header('Location: predefined_expense_add.php');
+ exit();
+ }
+} else {
+ $form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));
+ $predefinedExpenses = ttTeamHelper::getPredefinedExpenses($user->team_id);
+}
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('predefined_expenses', $predefinedExpenses);
+$smarty->assign('title', $i18n->getKey('title.predefined_expenses'));
+$smarty->assign('content_page_name', 'predefined_expenses.tpl');
+$smarty->display('index.tpl');