Started to work on week view config.
authorNik Okuntseff <support@anuko.com>
Fri, 2 Feb 2018 18:47:33 +0000 (18:47 +0000)
committerNik Okuntseff <support@anuko.com>
Fri, 2 Feb 2018 18:47:33 +0000 (18:47 +0000)
12 files changed:
WEB-INF/resources/ca.lang.php
WEB-INF/resources/cs.lang.php
WEB-INF/resources/da.lang.php
WEB-INF/resources/de.lang.php
WEB-INF/resources/en.lang.php
WEB-INF/resources/es.lang.php
WEB-INF/resources/et.lang.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/profile_edit.tpl
WEB-INF/templates/week_view.tpl [new file with mode: 0644]
profile_edit.php
week_view.php [new file with mode: 0644]

index 041db20..bba7630 100644 (file)
@@ -260,11 +260,7 @@ $i18n_key_words = array(
 // 'title.delete_predefined_expense' => 'Deleting Predefined Expense',
 'title.reports' => 'Informes',
 'title.report' => 'Informe',
-
-
-
-// TODO: refactoring ongoing down from here.
-
+// TODO: translate the following.
 // 'title.send_report' => 'Sending Report',
 // 'title.invoice' => 'Invoice',
 // 'title.send_invoice' => 'Sending Invoice',
@@ -309,6 +305,11 @@ $i18n_key_words = array(
 // NOTE TO TRANSLATORS: Locking is a feature to lock records from modifications (ex: weekly on Mondays we lock all previous weeks).
 // It is also a name for the Locking plugin on the Team profile page.
 // 'title.locking' => 'Locking',
+// 'title.week_view' => 'Week View',
+
+
+
+// TODO: refactoring ongoing down from here.
 
 // Section for common strings inside combo boxes on forms. Strings shared between forms shall be placed here.
 // Strings that are used in a single form must go to the specific form section.
index 94f19b7..71c9cf7 100644 (file)
@@ -267,6 +267,51 @@ $i18n_key_words = array(
 'title.reports' => 'Sestavy',
 // TODO: translate the following.
 // 'title.report' => 'Report',
+// 'title.send_report' => 'Sending Report',
+// 'title.invoice' => 'Invoice',
+// 'title.send_invoice' => 'Sending Invoice',
+// 'title.charts' => 'Charts',
+// 'title.projects' => 'Projects',
+// 'title.add_project' => 'Adding Project',
+// 'title.edit_project' => 'Editing Project',
+// 'title.delete_project' => 'Deleting Project',
+// 'title.tasks' => 'Tasks',
+// 'title.add_task' => 'Adding Task',
+// 'title.edit_task' => 'Editing Task',
+// 'title.delete_task' => 'Deleting Task',
+// 'title.users' => 'Users',
+// 'title.add_user' => 'Adding User',
+// 'title.edit_user' => 'Editing User',
+// 'title.delete_user' => 'Deleting User',
+// 'title.clients' => 'Clients',
+// 'title.add_client' => 'Adding Client',
+// 'title.edit_client' => 'Editing Client',
+// 'title.delete_client' => 'Deleting Client',
+// 'title.invoices' => 'Invoices',
+// 'title.add_invoice' => 'Adding Invoice',
+// 'title.view_invoice' => 'Viewing Invoice',
+// 'title.delete_invoice' => 'Deleting Invoice',
+// 'title.notifications' => 'Notifications',
+// 'title.add_notification' => 'Adding Notification',
+// 'title.edit_notification' => 'Editing Notification',
+// 'title.delete_notification' => 'Deleting Notification',
+// 'title.monthly_quotas' => 'Monthly Quotas',
+// 'title.export' => 'Exporting Team Data',
+// 'title.import' => 'Importing Team Data',
+// 'title.options' => 'Options',
+// 'title.profile' => 'Profile',
+// 'title.cf_custom_fields' => 'Custom Fields',
+// 'title.cf_add_custom_field' => 'Adding Custom Field',
+// 'title.cf_edit_custom_field' => 'Editing Custom Field',
+// 'title.cf_delete_custom_field' => 'Deleting Custom Field',
+// 'title.cf_dropdown_options' => 'Dropdown Options',
+// 'title.cf_add_dropdown_option' => 'Adding Option',
+// 'title.cf_edit_dropdown_option' => 'Editing Option',
+// 'title.cf_delete_dropdown_option' => 'Deleting Option',
+// NOTE TO TRANSLATORS: Locking is a feature to lock records from modifications (ex: weekly on Mondays we lock all previous weeks).
+// It is also a name for the Locking plugin on the Team profile page.
+// 'title.locking' => 'Locking',
+// 'title.week_view' => 'Week View',
 
 
 
index 040e5d3..65f27e7 100644 (file)
@@ -278,6 +278,8 @@ $i18n_key_words = array(
 'title.cf_edit_dropdown_option' => 'Redigér Mulighed',
 'title.cf_delete_dropdown_option' => 'Slet Mulighed',
 'title.locking' => 'Lås Registring',
+// TODO: translate the following.
+// 'title.week_view' => 'Week View',
 
 // Section for common strings inside combo boxes on forms. Strings shared between forms shall be placed here.
 // Strings that are used in a single form must go to the specific form section.
index b7d3fbc..042bae9 100644 (file)
@@ -269,6 +269,8 @@ $i18n_key_words = array(
 'title.cf_edit_dropdown_option' => 'Auswahlmöglichkeit bearbeiten',
 'title.cf_delete_dropdown_option' => 'Auswahlmöglichkeit löschen',
 'title.locking' => 'Sperren',
+// TODO: translate the following.
+// 'title.week_view' => 'Week View',
 
 // Section for common strings inside combo boxes on forms. Strings shared between forms shall be placed here.
 // Strings that are used in a single form must go to the specific form section.
index e895ceb..f8bf112 100644 (file)
@@ -275,6 +275,7 @@ $i18n_key_words = array(
 // NOTE TO TRANSLATORS: Locking is a feature to lock records from modifications (ex: weekly on Mondays we lock all previous weeks).
 // It is also a name for the Locking plugin on the Team profile page.
 'title.locking' => 'Locking',
+'title.week_view' => 'Week View',
 
 // Section for common strings inside combo boxes on forms. Strings shared between forms shall be placed here.
 // Strings that are used in a single form must go to the specific form section.
index 350b67d..97b4386 100644 (file)
@@ -317,6 +317,7 @@ $i18n_key_words = array(
 // NOTE TO TRANSLATORS: Locking is a feature to lock records from modifications (ex: weekly on Mondays we lock all previous weeks).
 // It is also a name for the Locking plugin on the Team profile page.
 // 'title.locking' => 'Locking',
+// 'title.week_view' => 'Week View',
 
 // Section for common strings inside combo boxes on forms. Strings shared between forms shall be placed here.
 // Strings that are used in a single form must go to the specific form section.
index e109bf8..3c5284f 100644 (file)
@@ -265,15 +265,57 @@ $i18n_key_words = array(
 'title.reports' => 'Raportid',
 // TODO: translate the following.
 // 'title.report' => 'Report',
+// 'title.send_report' => 'Sending Report',
+// 'title.invoice' => 'Invoice',
+// 'title.send_invoice' => 'Sending Invoice',
+// 'title.charts' => 'Charts',
+// 'title.projects' => 'Projects',
+// 'title.add_project' => 'Adding Project',
+// 'title.edit_project' => 'Editing Project',
+// 'title.delete_project' => 'Deleting Project',
+// 'title.tasks' => 'Tasks',
+// 'title.add_task' => 'Adding Task',
+// 'title.edit_task' => 'Editing Task',
+// 'title.delete_task' => 'Deleting Task',
+// 'title.users' => 'Users',
+// 'title.add_user' => 'Adding User',
+// 'title.edit_user' => 'Editing User',
+// 'title.delete_user' => 'Deleting User',
+// 'title.clients' => 'Clients',
+// 'title.add_client' => 'Adding Client',
+// 'title.edit_client' => 'Editing Client',
+// 'title.delete_client' => 'Deleting Client',
+// 'title.invoices' => 'Invoices',
+// 'title.add_invoice' => 'Adding Invoice',
+// 'title.view_invoice' => 'Viewing Invoice',
+// 'title.delete_invoice' => 'Deleting Invoice',
+// 'title.notifications' => 'Notifications',
+// 'title.add_notification' => 'Adding Notification',
+// 'title.edit_notification' => 'Editing Notification',
+// 'title.delete_notification' => 'Deleting Notification',
+// 'title.monthly_quotas' => 'Monthly Quotas',
+// 'title.export' => 'Exporting Team Data',
+// 'title.import' => 'Importing Team Data',
+'title.options' => 'Suvandid',
+// TODO: translate the following.
+// 'title.profile' => 'Profile',
+// 'title.cf_custom_fields' => 'Custom Fields',
+// 'title.cf_add_custom_field' => 'Adding Custom Field',
+// 'title.cf_edit_custom_field' => 'Editing Custom Field',
+// 'title.cf_delete_custom_field' => 'Deleting Custom Field',
+// 'title.cf_dropdown_options' => 'Dropdown Options',
+// 'title.cf_add_dropdown_option' => 'Adding Option',
+// 'title.cf_edit_dropdown_option' => 'Editing Option',
+// 'title.cf_delete_dropdown_option' => 'Deleting Option',
+// NOTE TO TRANSLATORS: Locking is a feature to lock records from modifications (ex: weekly on Mondays we lock all previous weeks).
+// It is also a name for the Locking plugin on the Team profile page.
+// 'title.locking' => 'Locking',
+// 'title.week_view' => 'Week View',
 
 
 
 // TODO: refactoring ongoing down from here.
 
-// Form titles.
-'title.options' => 'Suvandid',
-
-// TODO: file refactoring is ongoing down from here.
 "form.filter.project" => 'projekt',
 "form.filter.filter" => 'lemmikraport',
 "form.filter.filter_new" => 'salvesta lemmikuna',
index e1462dc..0c76fa2 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.17.10.3862 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.17.10.3863 | 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 dc4f5a6..6e3b81e 100644 (file)
@@ -229,6 +229,12 @@ function handlePluginCheckboxes() {
             <td align="right" nowrap>{$forms.profileForm.quotas.control}</td>
             <td><label for="quotas">{$i18n.label.monthly_quotas}</label> <span id="quotas_config"><a href="quotas.php">{$i18n.label.configure}</a></span></td>
           </tr>
+  {if $smarty.const.WEEK_VIEW_DEBUG == 1}
+          <tr>
+            <td align="right" nowrap>{$forms.profileForm.week_view.control}</td>
+            <td><label for="quotas">{$i18n.label.week_view}</label> <span id="week_view_config"><a href="week_view.php">{$i18n.label.configure}</a></span></td>
+          </tr>
+  {/if}
 {/if}
 
           <tr>
diff --git a/WEB-INF/templates/week_view.tpl b/WEB-INF/templates/week_view.tpl
new file mode 100644 (file)
index 0000000..5375a32
--- /dev/null
@@ -0,0 +1,45 @@
+<table cellspacing="0" cellpadding="7" border="0" width="720">
+  <tr><td valign="top">{$i18n.form.quota.hint}</td></tr>
+</table>
+
+{$forms.monthlyQuotasForm.open}
+<div style="padding: 0 0 10 0">
+  <table border="0" class="divider">
+    <tr>
+      <td align="center">
+        <table>
+          <tr>
+            <td>{$i18n.form.quota.workday_hours}:</td>
+            <td>{$forms.monthlyQuotasForm.workdayHours.control}</td>
+          </tr>
+        </table>
+      </td>
+    </tr>
+  </table>
+</div>
+<table>
+  <tr>
+    <td>{$i18n.form.quota.year}:</td>
+    <td>{$forms.monthlyQuotasForm.year.control}</td>
+  </tr>
+  <tr><td>&nbsp;</td></tr>
+  <tr>
+    <td colspan="2">
+      <table>
+        <tr>
+          <td class="tableHeaderCentered">{$i18n.form.quota.month}</td>
+          <td class="tableHeaderCentered">{$i18n.form.quota.quota}</td>
+        </tr>
+{foreach $months as $month}
+        <tr>
+          <td>{$month}:</td>
+          <td>{$forms.monthlyQuotasForm.$month.control}</td>
+        </tr>
+{/foreach}
+        <tr><td colspan="2">&nbsp;</td></tr>
+        <tr><td colspan="2" style="text-align:center;"><input type="submit" name="btn_submit" value="{$i18n.button.save}"></td></tr>
+      </table>
+    </td>
+  </tr>
+</table>
+{$forms.monthlyQuotasForm.close}
index a9e9a42..6d82bf7 100644 (file)
@@ -76,6 +76,7 @@ if ($request->isPost()) {
     $cl_notifications = $request->getParameter('notifications');
     $cl_locking = $request->getParameter('locking');
     $cl_quotas = $request->getParameter('quotas');
+    $cl_week_view = $request->getParameter('week_view');
   }
 } else {
   $cl_name = $user->name;
@@ -109,6 +110,7 @@ if ($request->isPost()) {
     $cl_notifications = in_array('no', $plugins);
     $cl_locking = in_array('lk', $plugins);
     $cl_quotas = in_array('mq', $plugins);
+    $cl_week_view = in_array('wv', $plugins);
   }
 }
 
@@ -205,6 +207,9 @@ if ($user->canManageTeam()) {
   $form->addInput(array('type'=>'checkbox','name'=>'notifications','value'=>$cl_notifications,'onchange'=>'handlePluginCheckboxes()'));
   $form->addInput(array('type'=>'checkbox','name'=>'locking','value'=>$cl_locking,'onchange'=>'handlePluginCheckboxes()'));
   $form->addInput(array('type'=>'checkbox','name'=>'quotas','value'=>$cl_quotas,'onchange'=>'handlePluginCheckboxes()'));
+  if (defined('WEEK_VIEW_DEBUG') && isTrue(WEEK_VIEW_DEBUG)) {
+    $form->addInput(array('type'=>'checkbox','name'=>'week_view','value'=>$cl_week_view));
+  }
 }
 $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->getKey('button.save')));
 
@@ -261,6 +266,8 @@ if ($request->isPost()) {
         $plugins .= ',lk';
       if ($cl_quotas)
         $plugins .= ',mq';
+      if ($cl_week_view)
+        $plugins .= ',wv';
       $plugins = trim($plugins, ',');
 
       $update_result = ttTeamHelper::update($user->team_id, array(
diff --git a/week_view.php b/week_view.php
new file mode 100644 (file)
index 0000000..319235b
--- /dev/null
@@ -0,0 +1,102 @@
+<?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');
+require_once('plugins/MonthlyQuota.class.php');
+import('form.Form');
+import('ttTeamHelper');
+import('ttTimeHelper');
+
+// Access check.
+if (!ttAccessCheck(right_manage_team) || !$user->isPluginEnabled('wv')) {
+  header('Location: access_denied.php');
+  exit();
+}
+
+
+// Get selected year from url parameter.
+$selectedYear = $request->getParameter('year');
+if (!$selectedYear or !ttValidInteger($selectedYear)){
+  $selectedYear = date('Y');
+} else {
+  $selectedYear = (int) $selectedYear;
+}
+
+// Months are zero indexed.
+$months = $i18n->monthNames;
+
+$quota = new MonthlyQuota();
+
+if ($request->isPost()){
+  // Validate user input.
+  if (!ttTimeHelper::isValidDuration($request->getParameter('workdayHours')))
+    $err->add($i18n->getKey('error.field'), $i18n->getKey('form.quota.workday_hours'));
+
+  for ($i = 0; $i < count($months); $i++){
+    $val = $request->getParameter($months[$i]);
+    if (!$quota->isValidQuota($val))
+      $err->add($i18n->getKey('error.field'), $months[$i]);
+  }
+  // Finished validating user input.
+
+  if ($err->no()) {
+
+    // Handle workday hours.
+    $hours = $quota->quotaToFloat($request->getParameter('workdayHours'));
+    if ($hours != $user->workday_hours) {
+      if (!ttTeamHelper::update($user->team_id, array('name'=>$user->team,'workday_hours'=>$hours)))
+        $err->add($i18n->getKey('error.db'));
+    }
+
+    // Handle monthly quotas for a selected year.
+    $selectedYear = (int) $request->getParameter('year');
+    for ($i = 0; $i < count($months); $i++){
+      if (!$quota->update($selectedYear, $i+1, $request->getParameter($months[$i])))
+        $err->add($i18n->getKey('error.db'));
+    }
+
+    if ($err->no()) {
+      // Redisplay the form.
+      header('Location: quotas.php?year='.$selectedYear);
+      exit();
+    }
+  }
+}
+
+// Get monthly quotas for the entire year.
+$monthsData = $quota->get($selectedYear);
+$workdayHours = ttTimeHelper::toAbsDuration($user->workday_hours * 60, true);
+
+$form = new Form('weekViewForm');
+$form->addInput(array('type'=>'checkbox','name'=>'week_note','value'=>$cl_week_note));
+$form->addInput(array('type'=>'checkbox','name'=>'week_list','value'=>$cl_week_list));
+
+$smarty->assign('forms', array($form->getName()=>$form->toArray()));
+$smarty->assign('title', $i18n->getKey('label.week_view'));
+$smarty->assign('content_page_name', 'week_view.tpl');
+$smarty->display('index.tpl');