More work in progress on remote work plugin.
authorNik Okuntseff <support@anuko.com>
Mon, 22 Apr 2019 21:32:16 +0000 (21:32 +0000)
committerNik Okuntseff <support@anuko.com>
Mon, 22 Apr 2019 21:32:16 +0000 (21:32 +0000)
WEB-INF/lib/ttWorkHelper.class.php [new file with mode: 0644]
WEB-INF/templates/footer.tpl
WEB-INF/templates/work_add.tpl
mysql.sql
work_add.php

diff --git a/WEB-INF/lib/ttWorkHelper.class.php b/WEB-INF/lib/ttWorkHelper.class.php
new file mode 100644 (file)
index 0000000..b8d2fde
--- /dev/null
@@ -0,0 +1,46 @@
+<?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 ttWorkHelper is used to help with operations with the Remote work plugin.
+class ttWorkHelper {
+
+  // getCurrencies - obtains a list of supported currencies.
+  static function getCurrencies() {
+    $mdb2 = getConnection();
+
+    $sql = "select id, name from tt_work_currencies order by id";
+    $res = $mdb2->query($sql);
+    if (is_a($res, 'PEAR_Error')) return false;
+
+    while ($val = $res->fetchRow()) {
+      $result[] = $val;
+    }
+    return $result;
+  }
+}
index b54e2ba..675f20d 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.19.2.4973 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.19.2.4974 | 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 3992fa1..757a4e2 100644 (file)
           <td>{$forms.workForm.newfile.control}</td>
         </tr>
 {/if}
+        <tr>
+          <td align="right">{$i18n.label.currency}:</td>
+          <td>{$forms.workForm.currency.control}</td>
+        </tr>
         <tr>
           <td></td>
           <td>{$i18n.label.required_fields}</td>
index 56c217a..40065f0 100644 (file)
--- a/mysql.sql
+++ b/mysql.sql
@@ -576,6 +576,25 @@ create unique index currency_idx on tt_work_currencies(`name`);
 INSERT INTO `tt_work_currencies` (`id`, `name`) VALUES ('1', 'USD'), ('2', 'CAD'), ('3', 'AUD'), ('4', 'EUR'), ('5', 'NZD');
 
 
+#
+# Structure for table tt_work_categories. WORK IN PROGRESS!
+# This table keeps work categories supported by remote work plugin.
+#
+# CREATE TABLE `tt_work_categories` (
+#  `id` int(10) unsigned NOT NULL,            # category id
+#  `parent_id` int(10) unsigned default NULL, # parent category id
+#  `level` tinyint(4) default 0,              # sub-category level
+#
+#  Localized name fields below for all supported languages?
+#  `name_en` varhar(64) NOT NULL,             # English.
+#  `name_de` varhar(64) default NULL,         # German.
+#  `name_fr` varhar(64) default NULL,         # French.
+#  `name_ru` varhar(64) default NULL,         # Russian.
+#
+# PRIMARY KEY  (`id`)
+# );
+
+
 #
 # Structure for table tt_site_config. This table stores configuration data
 # for Time Tracker site as a whole.
index 20d0ac0..452e515 100644 (file)
@@ -31,6 +31,7 @@ import('form.Form');
 import('ttProjectHelper');
 import('ttGroupHelper');
 import('ttFileHelper');
+import('ttWorkHelper');
 
 // Access checks.
 if (!ttAccessAllowed('manage_work')) {
@@ -48,24 +49,27 @@ $showFiles = $user->isPluginEnabled('at');
 if ($request->isPost()) {
   $cl_name = trim($request->getParameter('work_name'));
   $cl_description = trim($request->getParameter('description'));
+  $cl_currency = $request->getParameter('currency');
 }
 
 $form = new Form('workForm');
-
-
-
-
 $form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'work_name','style'=>'width: 250px;','value'=>$cl_name));
 $form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description));
 if ($showFiles)
   $form->addInput(array('type'=>'upload','name'=>'newfile','value'=>$i18n->get('button.submit')));
+// Add a dropdown for currency.
+$currencies = ttWorkHelper::getCurrencies();
+$form->addInput(array('type'=>'combobox','name'=>'currency','data'=>$currencies,'datakeys'=>array('id','name'),'value'=>$cl_currency));
 
-// Should not we get it from server?
-// $CURRENCY_OPTIONS = array(array('id'=>'.','name'=>'.'),array('id'=>',','name'=>','));
-// $form->addInput(array('type'=>'combobox','name'=>'decimal_mark','style'=>'width: 150px','data'=>$DECIMAL_MARK_OPTIONS,'datakeys'=>array('id','name'),'value'=>$cl_decimal_mark,
-//  'onchange'=>'adjustDecimalPreview()'));
+// TODO: design how to handle one-time vs ongoing work. Apparently, with a conditional display of relevant controls.
+// Ongoing work - rate per hour control.
+// One-time work - budget dropdown control.
+// When selection changes, we hide and show required controls.
 
+// TODO: design how to handle categories and sub-categories.
+// One major complication is localization of names.
 
+// Coding and design are currently ongoing.
 
 
 if ($request->isPost()) {