Refactored regular expense pages for subgroups.
authorNik Okuntseff <support@anuko.com>
Wed, 5 Dec 2018 19:31:43 +0000 (19:31 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 5 Dec 2018 19:31:43 +0000 (19:31 +0000)
WEB-INF/lib/common.lib.php
WEB-INF/lib/ttExpenseHelper.class.php
WEB-INF/lib/ttUserHelper.class.php
WEB-INF/templates/expense_edit.tpl
WEB-INF/templates/expenses.tpl
WEB-INF/templates/footer.tpl
expense_edit.php

index 4411fb5..0e9ff9e 100644 (file)
@@ -226,7 +226,7 @@ function ttValidFloat($val, $emptyValid = false)
     return ($emptyValid ? true : false);
     
   global $user;
-  $decimal = $user->decimal_mark;
+  $decimal = $user->getDecimalMark();
        
   if (!preg_match('/^-?[0-9'.$decimal.']+$/', $val))
     return false;
index 0b202c6..40a3e88 100644 (file)
@@ -60,12 +60,12 @@ class ttExpenseHelper {
     global $user;
     $mdb2 = getConnection();
 
+    $user_id = $user->getUser();
     $group_id = $user->getGroup();
     $org_id = $user->org_id;
 
     $id = (int) $fields['id'];
     $date = $fields['date'];
-    $user_id = (int) $fields['user_id'];
     $client_id = $fields['client_id'];
     $project_id = $fields['project_id'];
     $name = $fields['name'];
index 1d1b178..0d628f6 100644 (file)
@@ -189,7 +189,7 @@ class ttUserHelper {
       // otherwise de-activate the bind (set its status to inactive). This will keep the bind
       // and its rate in database for reporting.
 
-      $all_projects = ttTeamHelper::getAllProjects($user->group_id);
+      $all_projects = ttTeamHelper::getAllProjects($user->getGroup());
       $assigned_projects = isset($fields['projects']) ? $fields['projects'] : array();
 
       foreach($all_projects as $p) {
index d3a2737..850e644 100644 (file)
@@ -98,7 +98,7 @@ function recalculateCost() {
 
   var comment_control = document.getElementById("item_name");
   var cost_control = document.getElementById("cost");
-  var replaceDecimalMark = ("." != "{$user->decimal_mark}");
+  var replaceDecimalMark = ("." != "{$user->getDecimalMark()}");
 
   // Calculate cost.
   var dropdown = document.getElementById("predefined_expense");
@@ -114,10 +114,10 @@ function recalculateCost() {
     else {
       var expenseCost = defined_expenses[dropdown.selectedIndex - 1][2];
       if (replaceDecimalMark)
-        expenseCost = expenseCost.replace("{$user->decimal_mark}", ".");
+        expenseCost = expenseCost.replace("{$user->getDecimalMark()}", ".");
       var newCost = (quantity_control.value * expenseCost).toFixed(2);
       if (replaceDecimalMark)
-        newCost = newCost.replace(".", "{$user->decimal_mark}");
+        newCost = newCost.replace(".", "{$user->getDecimalMark()}");
       cost_control.value = newCost;
     }
   }
@@ -138,7 +138,7 @@ function recalculateCost() {
       <td>{$forms.expenseItemForm.client.control}</td>
     </tr>
 {/if}
-{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+{if $show_project}
     <tr>
       <td align="right">{$i18n.label.project} (*):</td>
       <td>{$forms.expenseItemForm.project.control}</td>
@@ -160,7 +160,7 @@ function recalculateCost() {
     </tr>
     <tr>
       <td align="right">{$i18n.label.cost}:</td>
-      <td>{$forms.expenseItemForm.cost.control} {$user->currency|escape}</td>
+      <td>{$forms.expenseItemForm.cost.control} {$user->getCurrency()|escape}</td>
     </tr>
 {if ($user->can('manage_invoices') && $user->isPluginEnabled('ps'))}
     <tr>
index 4eea0b8..45a8ef2 100644 (file)
@@ -151,7 +151,7 @@ function recalculateCost() {
         </tr>
         <tr>
           <td align="right">{$i18n.label.cost} (*):</td>
-          <td>{$forms.expensesForm.cost.control} {$user->currency|escape}</td>
+          <td>{$forms.expensesForm.cost.control} {$user->getCurrency()|escape}</td>
         </tr>
       </table>
     </td>
index 99e8d0e..20a0db7 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.18.29.4592 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.29.4593 | Copyright &copy; <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>
index 667d034..8eb7d4f 100644 (file)
@@ -194,7 +194,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->getUser(),
+      if (ttExpenseHelper::update(array('id'=>$cl_id,'date'=>$new_date->toString(DB_DATEFORMAT),
           '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();
@@ -229,11 +229,12 @@ if ($confirm_save) {
   $smarty->assign('confirm_save', true);
   $smarty->assign('entry_date', $cl_date);
 }
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('show_project', $show_project);
 $smarty->assign('predefined_expenses', $predefined_expenses);
 $smarty->assign('client_list', $client_list);
 $smarty->assign('project_list', $project_list);
 $smarty->assign('task_list', $task_list);
-$smarty->assign('forms', array($form->getName()=>$form->toArray()));
 $smarty->assign('title', $i18n->get('title.edit_expense'));
 $smarty->assign('content_page_name', 'expense_edit.tpl');
 $smarty->display('index.tpl');