From a8084d2e767dd2ea7e57f2348a27d4fc2da42a6f Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Fri, 1 Mar 2019 23:49:49 +0000 Subject: [PATCH] Added project_id to tt_timesheets table. --- WEB-INF/lib/ttTimesheetHelper.class.php | 21 +++++++++++++-------- WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/timesheet_view.tpl | 21 ++++++++++++++------- dbinstall.php | 10 ++++++---- mysql.sql | 3 ++- timesheet_view.php | 2 +- 6 files changed, 37 insertions(+), 22 deletions(-) diff --git a/WEB-INF/lib/ttTimesheetHelper.class.php b/WEB-INF/lib/ttTimesheetHelper.class.php index 636b1fcf..78e79016 100644 --- a/WEB-INF/lib/ttTimesheetHelper.class.php +++ b/WEB-INF/lib/ttTimesheetHelper.class.php @@ -66,6 +66,7 @@ class ttTimesheetHelper { $org_id = $user->org_id; $client_id = $fields['client_id']; + $project_id = $fields['project_id']; $name = $fields['name']; $comment = $fields['comment']; @@ -75,8 +76,8 @@ class ttTimesheetHelper { $end_date = new DateAndTime($user->date_format, $fields['end_date']); $end = $end_date->toString(DB_DATEFORMAT); - $sql = "insert into tt_timesheets (user_id, group_id, org_id, client_id, name, comment, start_date, end_date)". - " values ($user_id, $group_id, $org_id, ".$mdb2->quote($client_id).", ".$mdb2->quote($name). + $sql = "insert into tt_timesheets (user_id, group_id, org_id, client_id, project_id, name, comment, start_date, end_date)". + " values ($user_id, $group_id, $org_id, ".$mdb2->quote($client_id).", ".$mdb2->quote($project_id).", ".$mdb2->quote($name). ", ".$mdb2->quote($comment).", ".$mdb2->quote($start).", ".$mdb2->quote($end).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) @@ -175,8 +176,12 @@ class ttTimesheetHelper { $group_id = $user->getGroup(); $org_id = $user->org_id; - $sql = "select * from tt_timesheets". - " where id = $timesheet_id and user_id = $user_id and group_id = $group_id and org_id = $org_id and status is not null"; + $sql = "select ts.*, u.name as user_name, c.name as client_name,". + " p.name as project_name from tt_timesheets ts". + " left join tt_users u on (ts.user_id = u.id)". + " left join tt_clients c on (ts.client_id = c.id)". + " left join tt_projects p on (ts.project_id = p.id)". + " where ts.id = $timesheet_id and ts.user_id = $user_id and ts.group_id = $group_id and ts.org_id = $org_id and ts.status is not null"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { if ($val = $res->fetchRow()) @@ -329,9 +334,9 @@ class ttTimesheetHelper { // Even if mail part below does not work, this will get us a functioning workflow // (without email notifications). $timesheet_id = $fields['timesheet_id']; - $manager_comment = $fields['comment']; + $comment = $fields['comment']; - $sql = "update tt_timesheets set approval_status = 1, manager_comment = ".$mdb2->quote($manager_comment). + $sql = "update tt_timesheets set approve_status = 1, approve_comment = ".$mdb2->quote($comment). " where id = $timesheet_id and submit_status = 1 and group_id = $group_id and org_id = $org_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -352,9 +357,9 @@ class ttTimesheetHelper { // Even if mail part below does not work, this will get us a functioning workflow // (without email notifications). $timesheet_id = $fields['timesheet_id']; - $manager_comment = $fields['comment']; + $comment = $fields['comment']; - $sql = "update tt_timesheets set approval_status = 0, manager_comment = ".$mdb2->quote($manager_comment). + $sql = "update tt_timesheets set approve_status = 0, approve_comment = ".$mdb2->quote($comment). " where id = $timesheet_id and submit_status = 1 and group_id = $group_id and org_id = $org_id"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 246dfca2..bd0a554d 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- @@ -53,7 +60,7 @@ diff --git a/dbinstall.php b/dbinstall.php index 90b5669a..e33635aa 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -972,7 +972,7 @@ if ($_POST) { print "Updated $tt_expense_items_updated tt_expense_items records...
\n"; } - if ($_POST["convert11797to11849"]) { + if ($_POST["convert11797to11850"]) { ttExecute("ALTER TABLE `tt_fav_reports` CHANGE `group_by` `group_by1` varchar(20) default NULL"); ttExecute("ALTER TABLE `tt_fav_reports` ADD `group_by2` varchar(20) default NULL AFTER `group_by1`"); ttExecute("ALTER TABLE `tt_fav_reports` ADD `group_by3` varchar(20) default NULL AFTER `group_by2`"); @@ -1118,6 +1118,8 @@ if ($_POST) { ttExecute("update `tt_roles` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.48') set rights = replace(rights, 'manage_all_timesheets,', '')"); ttExecute("update `tt_roles` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.48') set rights = replace(rights, 'approve_all_timesheets,', 'approve_own_timesheets,')"); ttExecute("UPDATE `tt_site_config` SET param_value = '1.18.49', modified = now() where param_name = 'version_db' and param_value = '1.18.48'"); + ttExecute("ALTER TABLE `tt_timesheets` ADD `project_id` int(11) default NULL AFTER `client_id`"); + ttExecute("UPDATE `tt_site_config` SET param_value = '1.18.50', modified = now() where param_name = 'version_db' and param_value = '1.18.49'"); } if ($_POST["cleanup"]) { @@ -1166,7 +1168,7 @@ if ($_POST) {

DB Install

 Anuko Time Tracker 1.18.47.4803 | Copyright © Anuko | +  Anuko Time Tracker 1.18.50.4804 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/timesheet_view.tpl b/WEB-INF/templates/timesheet_view.tpl index bce187e7..76481eed 100644 --- a/WEB-INF/templates/timesheet_view.tpl +++ b/WEB-INF/templates/timesheet_view.tpl @@ -7,19 +7,26 @@ +{if $user->behalfUser} +{/if} {if $timesheet['client_id']} {/if} +{if $timesheet['project_id']} + +{/if} +{if $timesheet['comment']} + +{/if} +{if $timesheet['approve_status'] == null} -{if $timesheet['submitter_comment']} - {/if} -{if $timesheet['submit_status']} - {/if} +{if $timesheet['approve_status'] != null} + {/if} -{if $timesheet['manager_comment']} - +{if $timesheet['approve_comment']} + {/if}
{$timesheet['name']|escape}
{$i18n.label.user}: {$timesheet['user_name']|escape}
{$i18n.label.client}: {$timesheet['client_name']|escape}
{$i18n.label.project}: {$timesheet['project_name']|escape}
{$i18n.label.comment}: {$timesheet['comment']|escape}
{$i18n.label.submitted}: {if $timesheet.submit_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}
{$i18n.label.comment}: {$timesheet['submitter_comment']|escape}
{$i18n.label.approved}: {if $timesheet.approval_status != null}{if $timesheet.approval_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}
{$i18n.label.approved}: {if $timesheet.approve_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}
{$i18n.label.note}: {$timesheet['manager_comment']|escape}
{$i18n.label.note}: {$timesheet['approve_comment']|escape}
- +
{if $show_approvers}{$i18n.form.mail.to}: {$forms.timesheetForm.approver.control}{/if} {$forms.timesheetForm.btn_submit.control}
{if $show_approvers}{$i18n.form.mail.to}: {$forms.timesheetForm.approver.control}{/if} {$forms.timesheetForm.btn_submit.control}
-
Create database structure (v1.18.49) + Create database structure (v1.18.50)
(applies only to new installations, do not execute when updating)
@@ -1211,8 +1213,8 @@ if ($_POST) { - Update database structure (v1.17.97 to v1.18.49) - + Update database structure (v1.17.97 to v1.18.50) + diff --git a/mysql.sql b/mysql.sql index 3378fc0b..525a4769 100644 --- a/mysql.sql +++ b/mysql.sql @@ -495,6 +495,7 @@ CREATE TABLE `tt_timesheets` ( `group_id` int(11) default NULL, # group id `org_id` int(11) default NULL, # organization id `client_id` int(11) default NULL, # client id + `project_id` int(11) default NULL, # project id `name` varchar(80) COLLATE utf8mb4_bin NOT NULL, # timesheet name `comment` text, # timesheet comment `start_date` date NOT NULL, # timesheet start date @@ -526,4 +527,4 @@ CREATE TABLE `tt_site_config` ( PRIMARY KEY (`param_name`) ); -INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.18.49', now()); # TODO: change when structure changes. +INSERT INTO `tt_site_config` (`param_name`, `param_value`, `created`) VALUES ('version_db', '1.18.50', now()); # TODO: change when structure changes. diff --git a/timesheet_view.php b/timesheet_view.php index 813edffb..bde974e6 100644 --- a/timesheet_view.php +++ b/timesheet_view.php @@ -131,6 +131,6 @@ $smarty->assign('show_approvers', $showApprovers); $smarty->assign('show_submit', $showSubmit); $smarty->assign('show_approve', $showApprove); $smarty->assign('forms', array($form->getName()=>$form->toArray())); -$smarty->assign('title', $i18n->get('title.timesheet')); +$smarty->assign('title', $i18n->get('title.timesheet').": ".$timesheet['start_date']." - ".$timesheet['end_date']); $smarty->assign('content_page_name', 'timesheet_view.tpl'); $smarty->display('index.tpl'); -- 2.20.1