}
return $result;
}
+
+ // getPredefinedExpenses - obtains predefined expenses for a group.
+ static function getPredefinedExpenses() {
+ global $user;
+ $mdb2 = getConnection();
+
+ $group_id = $user->getGroup();
+ $org_id = $user->org_id;
+
+ $result = array();
+ $sql = "select id, name, cost from tt_predefined_expenses".
+ " where group_id = $group_id and org_id = $org_id";
+ $res = $mdb2->query($sql);
+ $result = array();
+ if (!is_a($res, 'PEAR_Error')) {
+ $decimal_mark = $user->getDecimalMark();
+ $replaceDecimalMark = ('.' != $decimal_mark);
+
+ while ($val = $res->fetchRow()) {
+ if ($replaceDecimalMark)
+ $val['cost'] = str_replace('.', $decimal_mark, $val['cost']);
+ $result[] = $val;
+ }
+ return $result;
+ }
+ return false;
+ }
}
}
// insert function inserts a new predefined expense into database.
- static function insert($fields)
- {
+ static function insert($fields) {
global $user;
-
$mdb2 = getConnection();
$group_id = $user->getGroup();
$org_id = $user->org_id;
+
$name = $fields['name'];
$cost = $fields['cost'];
- if ('.' != $user->decimal_mark)
- $cost = str_replace($user->decimal_mark, '.', $cost);
+ if ('.' != $user->getDecimalMark())
+ $cost = str_replace($user->getDecimalMark, '.', $cost);
$sql = "insert into tt_predefined_expenses (group_id, org_id, name, cost)".
" values ($group_id, $org_id, ".$mdb2->quote($name).", ".$mdb2->quote($cost).")";
return false;
}
- // getPredefinedExpenses - obtains predefined expenses for a group.
- static function getPredefinedExpenses($group_id) {
- global $user;
- $replaceDecimalMark = ('.' != $user->decimal_mark);
-
- $mdb2 = getConnection();
-
- $result = array();
- $sql = "select id, name, cost from tt_predefined_expenses where group_id = $group_id";
- $res = $mdb2->query($sql);
- $result = array();
- if (!is_a($res, 'PEAR_Error')) {
- while ($val = $res->fetchRow()) {
- if ($replaceDecimalMark)
- $val['cost'] = str_replace('.', $user->decimal_mark, $val['cost']);
- $result[] = $val;
- }
- return $result;
- }
- return false;
- }
-
// getNotifications - obtains notification descriptions for a group.
static function getNotifications($group_id) {
$mdb2 = getConnection();
<td class="tableHeader" align="center">{$i18n.label.client}</td>
{/if}
-{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+{if $show_project}
<td class="tableHeader" align="center">{$i18n.label.project}</td>
{/if}
<td class="tableHeader" align="center">{$i18n.label.item}</td>
{if $user->isPluginEnabled('cl')}
<td>{$expense_item.client_name|escape}</td>
{/if}
-{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+{if $show_project}
<td>{$expense_item.project_name|escape}</td>
{/if}
<td>{$expense_item.name|escape}</td>
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.29.4584 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.29.4585 | 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>
<td class="tableHeader" align="center">{$i18n.label.client}</td>
{/if}
-{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+{if $show_project}
<td class="tableHeader" align="center">{$i18n.label.project}</td>
{/if}
<td class="tableHeader" align="center">{$i18n.label.item}</td>
{if $user->isPluginEnabled('cl')}
<td>{$expense_item.client_name|escape}</td>
{/if}
-{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+{if $show_project}
<td>{$expense_item.project_name|escape}</td>
{/if}
<td>{$expense_item.name|escape}</td>
header('Location: access_denied.php');
exit();
}
+// End of access checks.
if ($request->isPost()) {
if ($request->getParameter('delete_button')) { // Delete button pressed.
$form->addInput(array('type'=>'submit','name'=>'delete_button','value'=>$i18n->get('label.delete')));
$form->addInput(array('type'=>'submit','name'=>'cancel_button','value'=>$i18n->get('button.cancel')));
-$smarty->assign('expense_item', $expense_item);
+$show_project = MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode();
+
$smarty->assign('forms', array($form->getName() => $form->toArray()));
+$smarty->assign('expense_item', $expense_item);
+$smarty->assign('show_project', $show_project);
$smarty->assign('title', $i18n->get('title.delete_expense'));
$smarty->assign('content_page_name', 'expense_delete.tpl');
$smarty->display('index.tpl');
require_once('initialize.php');
import('form.Form');
-import('ttTeamHelper');
import('ttGroupHelper');
import('DateAndTime');
import('ttExpenseHelper');
header('Location: access_denied.php');
exit();
}
+// End of access checks.
$item_date = new DateAndTime(DB_DATEFORMAT, $expense_item['date']);
$confirm_save = $user->getConfigOption('confirm_save');
+$trackingMode = $user->getTrackingMode();
+$show_project = MODE_PROJECTS == $trackingMode || MODE_PROJECTS_AND_TASKS == $trackingMode;
// Initialize variables.
$cl_date = $cl_client = $cl_project = $cl_item_name = $cl_cost = null;
if ($user->isPluginEnabled('ps'))
$cl_paid = $request->getParameter('paid');
} else {
- $cl_date = $item_date->toString($user->date_format);
+ $cl_date = $item_date->toString($user->getDateFormat());
$cl_client = $expense_item['client_id'];
$cl_project = $expense_item['project_id'];
$cl_item_name = $expense_item['name'];
$form = new Form('expenseItemForm');
// Dropdown for clients in MODE_TIME. Use all active clients.
-if (MODE_TIME == $user->tracking_mode && $user->isPluginEnabled('cl')) {
+if (MODE_TIME == $trackingMode && $user->isPluginEnabled('cl')) {
$active_clients = ttGroupHelper::getActiveClients(true);
$form->addInput(array('type'=>'combobox',
'onchange'=>'fillProjectDropdown(this.value);',
// Note: in other modes the client list is filtered to relevant clients only. See below.
}
-if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
+if ($show_project) {
// Dropdown for projects assigned to user.
$project_list = $user->getAssignedProjects();
$form->addInput(array('type'=>'combobox',
}
}
// If predefined expenses are configured, add controls to select an expense and quantity.
-$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id);
+$predefined_expenses = ttGroupHelper::getPredefinedExpenses();
if ($predefined_expenses) {
$form->addInput(array('type'=>'combobox',
'onchange'=>'recalculateCost();',
// Validate user input.
if ($user->isPluginEnabled('cl') && $user->isPluginEnabled('cm') && !$cl_client)
$err->add($i18n->get('error.client'));
- if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->tracking_mode) {
+ if (MODE_PROJECTS == $trackingMode || MODE_PROJECTS_AND_TASKS == $trackingMode) {
if (!$cl_project) $err->add($i18n->get('error.project'));
}
if (!ttValidString($cl_item_name)) $err->add($i18n->get('error.field'), $i18n->get('label.item'));
require_once('initialize.php');
import('form.Form');
import('ttUserHelper');
-import('ttTeamHelper');
import('ttGroupHelper');
import('DateAndTime');
import('ttExpenseHelper');
}
}
// If predefined expenses are configured, add controls to select an expense and quantity.
-$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id);
+$predefined_expenses = ttGroupHelper::getPredefinedExpenses();
if ($predefined_expenses) {
$form->addInput(array('type'=>'combobox',
'onchange'=>'recalculateCost();',
header('Location: access_denied.php');
exit();
}
+// End of access checks.
if ($request->isPost()) {
if ($request->getParameter('delete_button')) { // Delete button pressed.
$form->addInput(array('type'=>'submit','name'=>'delete_button','value'=>$i18n->get('label.delete')));
$form->addInput(array('type'=>'submit','name'=>'cancel_button','value'=>$i18n->get('button.cancel')));
-$smarty->assign('expense_item', $expense_item);
+$show_project = MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode();
+
$smarty->assign('forms', array($form->getName() => $form->toArray()));
+$smarty->assign('expense_item', $expense_item);
+$smarty->assign('show_project', $show_project);
$smarty->assign('title', $i18n->get('title.delete_expense'));
$smarty->assign('content_page_name', 'mobile/expense_delete.tpl');
$smarty->display('mobile/index.tpl');
require_once('../initialize.php');
import('form.Form');
-import('ttTeamHelper');
import('ttGroupHelper');
import('DateAndTime');
import('ttExpenseHelper');
}
}
// If predefined expenses are configured, add controls to select an expense and quantity.
-$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id);
+$predefined_expenses = ttGroupHelper::getPredefinedExpenses();
if ($predefined_expenses) {
$form->addInput(array('type'=>'combobox',
'onchange'=>'recalculateCost();',
require_once('../initialize.php');
import('form.Form');
import('ttUserHelper');
-import('ttTeamHelper');
import('ttGroupHelper');
import('DateAndTime');
import('ttExpenseHelper');
}
}
// If predefined expenses are configured, add controls to select an expense and quantity.
-$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->group_id);
+$predefined_expenses = ttGroupHelper::getPredefinedExpenses();
if ($predefined_expenses) {
$form->addInput(array('type'=>'combobox',
'onchange'=>'recalculateCost();',
require_once('initialize.php');
import('form.Form');
-import('ttTeamHelper');
+import('ttGroupHelper');
// Access checks.
if (!ttAccessAllowed('manage_advanced_settings')) {
}
} else {
$form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->get('button.add')));
- $predefinedExpenses = ttTeamHelper::getPredefinedExpenses($user->group_id);
+ $predefinedExpenses = ttGroupHelper::getPredefinedExpenses();
}
$smarty->assign('forms', array($form->getName()=>$form->toArray()));