From 903ed1bf71f570b2b0dc27c8819416e339736149 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 19 Mar 2018 17:48:35 +0000 Subject: [PATCH] Removed old timestamp field from tt_log. --- WEB-INF/lib/ttExportHelper.class.php | 2 +- WEB-INF/lib/ttTimeHelper.class.php | 20 ++++++-------------- dbinstall.php | 11 +++++++---- mysql.sql | 1 - 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/WEB-INF/lib/ttExportHelper.class.php b/WEB-INF/lib/ttExportHelper.class.php index ab691c99..77b2db1f 100644 --- a/WEB-INF/lib/ttExportHelper.class.php +++ b/WEB-INF/lib/ttExportHelper.class.php @@ -237,7 +237,7 @@ class ttExportHelper { foreach ($records as $record) { $key++; $this->logMap[$record['id']] = $key; - fwrite($file, " userMap[$record['user_id']]."\" date=\"".$record['date']."\" start=\"".$record['start']."\" finish=\"".$record['finish']."\" duration=\"".($record['start']?"":$record['duration'])."\" client_id=\"".$this->clientMap[$record['client_id']]."\" project_id=\"".$this->projectMap[$record['project_id']]."\" task_id=\"".$this->taskMap[$record['task_id']]."\" invoice_id=\"".$this->invoiceMap[$record['invoice_id']]."\" billable=\"".$record['billable']."\" paid=\"".$record['paid']."\" status=\"".$record['status']."\">\n"); + fwrite($file, " userMap[$record['user_id']]."\" date=\"".$record['date']."\" start=\"".$record['start']."\" finish=\"".$record['finish']."\" duration=\"".($record['start']?"":$record['duration'])."\" client_id=\"".$this->clientMap[$record['client_id']]."\" project_id=\"".$this->projectMap[$record['project_id']]."\" task_id=\"".$this->taskMap[$record['task_id']]."\" invoice_id=\"".$this->invoiceMap[$record['invoice_id']]."\" billable=\"".$record['billable']."\" paid=\"".$record['paid']."\" status=\"".$record['status']."\">\n"); fwrite($file, " \n"); fwrite($file, " \n"); } diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index aaccc3ab..bfb81cc3 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -389,7 +389,6 @@ class ttTimeHelper { global $user; $mdb2 = getConnection(); - $timestamp = isset($fields['timestamp']) ? $fields['timestamp'] : ''; $user_id = $fields['user_id']; $date = $fields['date']; $start = $fields['start']; @@ -417,21 +416,14 @@ class ttTimeHelper { if ('00:00' == $finish) $finish = '24:00'; } - if (!$timestamp) { - $timestamp = date('YmdHis'); //yyyymmddhhmmss - // TODO: this timestamp could be illegal if we hit inside DST switch deadzone, such as '2016-03-13 02:30:00' - // Anything between 2am and 3am on DST introduction date will not work if we run on a system with DST on. - // We need to address this properly to avoid potential complications. - } - $created_v = ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$mdb2->quote($user->id); if (!$billable) $billable = 0; if (!$paid) $paid = 0; if ($duration) { - $sql = "insert into tt_log (timestamp, user_id, date, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ". - "values ('$timestamp', $user_id, ".$mdb2->quote($date).", '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)"; + $sql = "insert into tt_log (user_id, date, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ". + "values ($user_id, ".$mdb2->quote($date).", '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -440,8 +432,8 @@ class ttTimeHelper { if ($duration === false) $duration = 0; if (!$duration && ttTimeHelper::getUncompleted($user_id)) return false; - $sql = "insert into tt_log (timestamp, user_id, date, start, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ". - "values ('$timestamp', $user_id, ".$mdb2->quote($date).", '$start', '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)"; + $sql = "insert into tt_log (user_id, date, start, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ". + "values ($user_id, ".$mdb2->quote($date).", '$start', '$duration', ".$mdb2->quote($client).", ".$mdb2->quote($project).", ".$mdb2->quote($task).", ".$mdb2->quote($invoice).", ".$mdb2->quote($note).", $billable, $paid $created_v $status_v)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -646,7 +638,7 @@ class ttTimeHelper { $mdb2 = getConnection(); - $sql = "select l.id as id, l.timestamp as timestamp, TIME_FORMAT(l.start, $sql_time_format) as start, + $sql = "select l.id as id, TIME_FORMAT(l.start, $sql_time_format) as start, TIME_FORMAT(sec_to_time(time_to_sec(l.start) + time_to_sec(l.duration)), $sql_time_format) as finish, TIME_FORMAT(l.duration, '%k:%i') as duration, p.name as project_name, t.name as task_name, l.comment, l.client_id, l.project_id, l.task_id, l.invoice_id, l.billable, l.paid, l.date @@ -672,7 +664,7 @@ class ttTimeHelper { $mdb2 = getConnection(); - $sql = "select l.id, l.timestamp, l.user_id, l.date, TIME_FORMAT(l.start, '%k:%i') as start, + $sql = "select l.id, l.user_id, l.date, TIME_FORMAT(l.start, '%k:%i') as start, TIME_FORMAT(sec_to_time(time_to_sec(l.start) + time_to_sec(l.duration)), '%k:%i') as finish, TIME_FORMAT(l.duration, '%k:%i') as duration, l.client_id, l.project_id, l.task_id, l.invoice_id, l.comment, l.billable, l.paid, l.status diff --git a/dbinstall.php b/dbinstall.php index 4fcbc224..ff0820b6 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -805,7 +805,7 @@ if ($_POST) { print "Updated $users_updated users...
\n"; } - if ($_POST["convert11744to11759"]) { + if ($_POST["convert11744to11764"]) { setChange("update `tt_roles` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.17.44') set rights = replace(rights, 'override_punch_mode,override_date_lock', 'override_punch_mode,override_own_punch_mode,override_date_lock')"); setChange("UPDATE `tt_site_config` SET param_value = '1.17.48' where param_name = 'version_db' and param_value = '1.17.44'"); setChange("update `tt_users` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.17.48') set role_id = (select id from tt_roles where team_id = 0 and rank = 512) where role = 324"); @@ -841,6 +841,9 @@ if ($_POST) { setChange("UPDATE `tt_site_config` SET param_value = '1.17.59', modified = now() where param_name = 'version_db' and param_value = '1.17.56'"); setChange("ALTER TABLE `tt_fav_reports` ADD `show_ip` tinyint(4) NOT NULL DEFAULT '0' AFTER `show_paid`"); setChange("UPDATE `tt_site_config` SET param_value = '1.17.61', modified = now() where param_name = 'version_db' and param_value = '1.17.59'"); + setChange("update `tt_log` l inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.17.61') set l.created = l.timestamp where l.created is null"); + setChange("ALTER TABLE `tt_log` drop `timestamp`"); + setChange("UPDATE `tt_site_config` SET param_value = '1.17.64', modified = now() where param_name = 'version_db' and param_value = '1.17.61'"); } if ($_POST["cleanup"]) { @@ -886,7 +889,7 @@ if ($_POST) {

DB Install

-
Create database structure (v1.17.59) + Create database structure (v1.17.64)
(applies only to new installations, do not execute when updating)
@@ -926,8 +929,8 @@ if ($_POST) {
- Update database structure (v1.17.44 to v1.17.59) - + Update database structure (v1.17.44 to v1.17.64) + diff --git a/mysql.sql b/mysql.sql index 6a763716..0a26f1fe 100644 --- a/mysql.sql +++ b/mysql.sql @@ -171,7 +171,6 @@ create index task_idx on tt_project_task_binds(task_id); # CREATE TABLE `tt_log` ( `id` bigint NOT NULL auto_increment, # time record id - `timestamp` timestamp default CURRENT_TIMESTAMP, # modification timestamp `user_id` int(11) NOT NULL, # user id `date` date NOT NULL, # date the record is for `start` time default NULL, # record start time (for example, 09:00) -- 2.20.1