From 7d4e14287bbbd83a07b093e97ac53266494b7628 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 22 Jan 2018 16:05:41 +0000 Subject: [PATCH] Added paid field and handling to expenses. --- WEB-INF/lib/ttReportHelper.class.php | 7 +++++++ WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/report.tpl | 3 +++ dbinstall.php | 9 ++++---- mysql.sql | 1 + report.php | 31 +++++++++++++++------------- 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 2e2113df..0a8e727c 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -147,6 +147,8 @@ class ttReportHelper { if ($bean->getAttribute('project')) $dropdown_parts .= ' and ei.project_id = '.$bean->getAttribute('project'); if ($bean->getAttribute('invoice')=='1') $dropdown_parts .= ' and ei.invoice_id is not NULL'; if ($bean->getAttribute('invoice')=='2') $dropdown_parts .= ' and ei.invoice_id is NULL'; + if ($bean->getAttribute('paid_status')=='1') $dropdown_parts .= ' and ei.paid = 1'; + if ($bean->getAttribute('paid_status')=='2') $dropdown_parts .= ' and ei.paid = 0'; // Prepare user list part. $userlist = -1; @@ -186,6 +188,8 @@ class ttReportHelper { if ($report['project_id']) $dropdown_parts .= ' and ei.project_id = '.$report['project_id']; if ($report['invoice']=='1') $dropdown_parts .= ' and ei.invoice_id is not NULL'; if ($report['invoice']=='2') $dropdown_parts .= ' and ei.invoice_id is NULL'; + if ($report['paid_status']=='1') $dropdown_parts .= ' and ei.paid = 1'; + if ($report['paid_status']=='2') $dropdown_parts .= ' and ei.paid = 0'; // Prepare user list part. $userlist = -1; @@ -350,6 +354,9 @@ class ttReportHelper { array_push($fields, 'ei.name as note'); array_push($fields, 'ei.cost as cost'); array_push($fields, 'ei.cost as expense'); + // Add paid status. + if ($user->canManageTeam() && $bean->getAttribute('chpaid')) + array_push($fields, 'ei.paid as paid'); // Add invoice name if it is selected. if (($user->canManageTeam() || $user->isClient()) && $bean->getAttribute('chinvoice')) array_push($fields, 'i.name as invoice'); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index bbe6e900..75853799 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- diff --git a/dbinstall.php b/dbinstall.php index 9a2078e0..6cf5a801 100755 --- a/dbinstall.php +++ b/dbinstall.php @@ -709,11 +709,12 @@ if ($_POST) { setChange("ALTER TABLE `tt_log` ADD `paid` tinyint(4) NULL default '0' AFTER `billable`"); } - if ($_POST["convert11400to11600"]) { + if ($_POST["convert11400to11700"]) { setChange("ALTER TABLE `tt_teams` DROP `address`"); setChange("ALTER TABLE `tt_fav_reports` ADD `report_spec` text default NULL AFTER `user_id`"); setChange("ALTER TABLE `tt_fav_reports` ADD `paid_status` tinyint(4) default NULL AFTER `invoice`"); setChange("ALTER TABLE `tt_fav_reports` ADD `show_paid` tinyint(4) NOT NULL DEFAULT '0' AFTER `show_invoice`"); + setChange("ALTER TABLE `tt_expense_items` ADD `paid` tinyint(4) NULL default '0' AFTER `invoice_id`"); } if ($_POST["cleanup"]) { @@ -758,7 +759,7 @@ if ($_POST) {

DB Install

 Anuko Time Tracker 1.16.0.3774 | Copyright © Anuko | +  Anuko Time Tracker 1.17.0.3775 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/report.tpl b/WEB-INF/templates/report.tpl index 432159d4..b6ee95ce 100644 --- a/WEB-INF/templates/report.tpl +++ b/WEB-INF/templates/report.tpl @@ -161,6 +161,9 @@ +{if $bean->getAttribute('paid_status') == 2} + +{/if}
-
Create database structure (v1.16.0) + Create database structure (v1.17.0)
(applies only to new installations, do not execute when updating)
@@ -794,8 +795,8 @@ if ($_POST) {
- Update database structure (v1.14 to v1.16) -
+ Update database structure (v1.14 to v1.17) +
diff --git a/mysql.sql b/mysql.sql index a450cadb..1e415c14 100644 --- a/mysql.sql +++ b/mysql.sql @@ -340,6 +340,7 @@ CREATE TABLE `tt_expense_items` ( `name` text NOT NULL, # expense item name (what is an expense for) `cost` decimal(10,2) default '0.00', # item cost (including taxes, etc.) `invoice_id` int(11) default NULL, # invoice id + `paid` tinyint(4) default '0', # whether the item is paid `status` tinyint(4) default '1', # item status PRIMARY KEY (`id`) ); diff --git a/report.php b/report.php index a18ff1f1..110d5ac4 100644 --- a/report.php +++ b/report.php @@ -65,21 +65,24 @@ if ($client_id && $bean->getAttribute('chinvoice') && ('no_grouping' == $bean->g } if ($request->isPost()) { - foreach($_POST as $key => $val) { - if ('log_id_' == substr($key, 0, 7)) - $time_log_ids[] = substr($key, 7); - if ('item_id_' == substr($key, 0, 8)) - $expense_item_ids[] = substr($key, 8); - if ('recent_invoice' == $key) - $invoice_id = $val; + if ($request->getParameter('btn_submit')) { + // User clicked the Submit button to assign some items to a recent invoice. + foreach($_POST as $key => $val) { + if ('log_id_' == substr($key, 0, 7)) + $time_log_ids[] = substr($key, 7); + if ('item_id_' == substr($key, 0, 8)) + $expense_item_ids[] = substr($key, 8); + if ('recent_invoice' == $key) + $invoice_id = $val; + } + if ($time_log_ids || $expense_item_ids) { + // Some records are checked for invoice editing. Adjust their invoice accordingly. + ttReportHelper::assignToInvoice($invoice_id, $time_log_ids, $expense_item_ids); + } + // Re-display this form. + header('Location: report.php'); + exit(); } - if ($time_log_ids || $expense_item_ids) { - // Some records are checked for invoice editing. Adjust their invoice accordingly. - ttReportHelper::assignToInvoice($invoice_id, $time_log_ids, $expense_item_ids); - } - // Re-display this form. - header('Location: report.php'); - exit(); } // isPost $group_by = $bean->getAttribute('group_by'); -- 2.20.1