From 2a2bb2cc8f9551d1e93de2d34e27b21201f9e44a Mon Sep 17 00:00:00 2001 From: Nik Okuntseff <support@anuko.com> Date: Mon, 22 Apr 2019 21:32:16 +0000 Subject: [PATCH] More work in progress on remote work plugin. --- WEB-INF/lib/ttWorkHelper.class.php | 46 ++++++++++++++++++++++++++++++ WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/work_add.tpl | 4 +++ mysql.sql | 19 ++++++++++++ work_add.php | 20 +++++++------ 5 files changed, 82 insertions(+), 9 deletions(-) create mode 100644 WEB-INF/lib/ttWorkHelper.class.php diff --git a/WEB-INF/lib/ttWorkHelper.class.php b/WEB-INF/lib/ttWorkHelper.class.php new file mode 100644 index 00000000..b8d2fde8 --- /dev/null +++ b/WEB-INF/lib/ttWorkHelper.class.php @@ -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; + } +} diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index b54e2baa..675f20d6 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@ <br> <table cellspacing="0" cellpadding="4" width="100%" border="0"> <tr> - <td align="center"> Anuko Time Tracker 1.19.2.4973 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> | + <td align="center"> Anuko Time Tracker 1.19.2.4974 | 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> diff --git a/WEB-INF/templates/work_add.tpl b/WEB-INF/templates/work_add.tpl index 3992fa15..757a4e22 100644 --- a/WEB-INF/templates/work_add.tpl +++ b/WEB-INF/templates/work_add.tpl @@ -17,6 +17,10 @@ <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> diff --git a/mysql.sql b/mysql.sql index 56c217a3..40065f06 100644 --- 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. diff --git a/work_add.php b/work_add.php index 20d0ac01..452e515b 100644 --- a/work_add.php +++ b/work_add.php @@ -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()) { -- 2.20.1