A few more replacements for canManageTeam.
[timetracker.git] / mobile / expense_edit.php
index c2df1ab..fff249e 100644 (file)
@@ -33,7 +33,7 @@ import('DateAndTime');
 import('ttExpenseHelper');
 
 // Access check.
-if (!ttAccessCheck(right_data_entry) || !$user->isPluginEnabled('ex')) {
+if (!ttAccessAllowed('track_own_expenses') || !$user->isPluginEnabled('ex')) {
   header('Location: access_denied.php');
   exit();
 }
@@ -119,6 +119,19 @@ if (MODE_PROJECTS == $user->tracking_mode || MODE_PROJECTS_AND_TASKS == $user->t
       'empty'=>array(''=>$i18n->getKey('dropdown.select'))));
   }
 }
+// If predefined expenses are configured, add controls to select an expense and quantity.
+$predefined_expenses = ttTeamHelper::getPredefinedExpenses($user->team_id);
+if ($predefined_expenses) {
+    $form->addInput(array('type'=>'combobox',
+      'onchange'=>'recalculateCost();',
+      'name'=>'predefined_expense',
+      'style'=>'width: 250px;',
+      'value'=>$cl_predefined_expense,
+      'data'=>$predefined_expenses,
+      'datakeys'=>array('id', 'name'),
+      'empty'=>array(''=>$i18n->getKey('dropdown.select'))));
+    $form->addInput(array('type'=>'text','onchange'=>'recalculateCost();','maxlength'=>'40','name'=>'quantity','style'=>'width: 100px;','value'=>$cl_quantity));
+}
 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'item_name','style'=>'width: 250px;','value'=>$cl_item_name));
 $form->addInput(array('type'=>'text','maxlength'=>'40','name'=>'cost','style'=>'width: 100px;','value'=>$cl_cost));
 $form->addInput(array('type'=>'datefield','name'=>'date','maxlength'=>'20','value'=>$cl_date));
@@ -144,7 +157,7 @@ if ($request->isPost()) {
   $new_date = new DateAndTime($user->date_format, $cl_date);
 
   // Prohibit creating entries in future.
-  if (defined('FUTURE_ENTRIES') && !isTrue(FUTURE_ENTRIES)) {
+  if (!$user->future_entries) {
     $browser_today = new DateAndTime(DB_DATEFORMAT, $request->getParameter('browser_today', null));
     if ($new_date->after($browser_today))
       $err->add($i18n->getKey('error.future_date'));
@@ -198,6 +211,7 @@ if ($request->isPost()) {
   }
 } // isPost
 
+$smarty->assign('predefined_expenses', $predefined_expenses);
 $smarty->assign('client_list', $client_list);
 $smarty->assign('project_list', $project_list);
 $smarty->assign('task_list', $task_list);