From: Nik Okuntseff Date: Wed, 7 Nov 2018 23:38:00 +0000 (+0000) Subject: Started to populate org_id in tt_log and tt_invoices tables. X-Git-Tag: timetracker_1.19-1~688 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3c5f822f90846e9a65866c9e33b7e1ff81b46b1f;p=timetracker.git Started to populate org_id in tt_log and tt_invoices tables. --- diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index 350b0c1f..64a32e0e 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -241,6 +241,7 @@ class ttImportHelper { $this->invoiceMap[$this->currentElement['ID']] = ttInvoiceHelper::insert(array( 'group_id' => $this->group_id, + 'org_id' => $this->org_id, 'name' => $this->currentElement['NAME'], 'date' => $this->currentElement['DATE'], 'client_id' => $this->clientMap[$this->currentElement['CLIENT_ID']], @@ -257,6 +258,7 @@ class ttImportHelper { ttTimeHelper::insert(array( 'user_id' => $this->userMap[$this->currentElement['USER_ID']], 'group_id' => $this->group_id, + 'org_id' => $this->org_id, 'date' => $this->currentElement['DATE'], 'start' => $this->currentElement['START'], 'finish' => $this->currentElement['FINISH'], diff --git a/WEB-INF/lib/ttInvoiceHelper.class.php b/WEB-INF/lib/ttInvoiceHelper.class.php index 5c5d7141..3a8dbe27 100644 --- a/WEB-INF/lib/ttInvoiceHelper.class.php +++ b/WEB-INF/lib/ttInvoiceHelper.class.php @@ -38,6 +38,7 @@ class ttInvoiceHelper { $mdb2 = getConnection(); $group_id = (int) $fields['group_id']; + $org_id = (int) $fields['org_id']; $name = $fields['name']; if (!$name) return false; @@ -49,8 +50,8 @@ class ttInvoiceHelper { } // Insert a new invoice record. - $sql = "insert into tt_invoices (group_id, name, date, client_id $status_f)". - " values($group_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id $status_v)"; + $sql = "insert into tt_invoices (group_id, org_id, name, date, client_id $status_f)". + " values($group_id, $org_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id $status_v)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -330,8 +331,8 @@ class ttInvoiceHelper { if (isset($fields['project_id'])) $project_id = (int) $fields['project_id']; // Create a new invoice record. - $sql = "insert into tt_invoices (group_id, name, date, client_id) values(". - $user->getActiveGroup().", ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)"; + $sql = "insert into tt_invoices (group_id, org_id, name, date, client_id) values(". + $user->getActiveGroup().", $user->org_id, ".$mdb2->quote($name).", ".$mdb2->quote($date).", $client_id)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index e3020354..24506780 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -391,6 +391,7 @@ class ttTimeHelper { $user_id = (int) $fields['user_id']; $group_id = (int) $fields['group_id']; + $org_id = (int) $fields['org_id']; $date = $fields['date']; $start = $fields['start']; $finish = $fields['finish']; @@ -423,8 +424,8 @@ class ttTimeHelper { if (!$paid) $paid = 0; if ($duration) { - $sql = "insert into tt_log (user_id, group_id, date, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ". - "values ($user_id, $group_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, group_id, org_id, date, duration, client_id, project_id, task_id, invoice_id, comment, billable, paid, created, created_ip, created_by $status_f) ". + "values ($user_id, $group_id, $org_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; @@ -433,8 +434,8 @@ class ttTimeHelper { if ($duration === false) $duration = 0; if (!$duration && ttTimeHelper::getUncompleted($user_id)) return false; - $sql = "insert into tt_log (user_id, group_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, $group_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, group_id, org_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, $group_id, $org_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; diff --git a/WEB-INF/lib/ttWeekViewHelper.class.php b/WEB-INF/lib/ttWeekViewHelper.class.php index dcb39af6..53065d38 100644 --- a/WEB-INF/lib/ttWeekViewHelper.class.php +++ b/WEB-INF/lib/ttWeekViewHelper.class.php @@ -494,6 +494,7 @@ class ttWeekViewHelper { $fields4insert = array(); $fields4insert['user_id'] = $user->getActiveUser(); $fields4insert['group_id'] = $user->getActiveGroup(); + $fields4insert['org_id'] = $user->org_id; $fields4insert['date'] = $entry_date; $fields4insert['duration'] = $fields['duration']; $fields4insert['client'] = ttWeekViewHelper::parseFromWeekViewRow($fields['row_id'], 'cl'); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 4f98ebca..98b2ad53 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.11.4385 | Copyright © Anuko | +  Anuko Time Tracker 1.18.11.4386 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/dbinstall.php b/dbinstall.php index a2ff4331..1c5fa900 100644 --- a/dbinstall.php +++ b/dbinstall.php @@ -982,6 +982,8 @@ if ($_POST) { setChange("ALTER TABLE `tt_log` ADD `org_id` int(11) default NULL AFTER `group_id`"); setChange("ALTER TABLE `tt_invoices` ADD `org_id` int(11) default NULL AFTER `group_id`"); setChange("UPDATE `tt_site_config` SET param_value = '1.18.11', modified = now() where param_name = 'version_db' and param_value = '1.18.10'"); + setChange("UPDATE `tt_log` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.11') set org_id = group_id where org_id is null"); + setChange("UPDATE `tt_invoices` inner join `tt_site_config` sc on (sc.param_name = 'version_db' and sc.param_value = '1.18.11') set org_id = group_id where org_id is null"); } if ($_POST["cleanup"]) { diff --git a/mobile/time.php b/mobile/time.php index 76296f64..a25cf90c 100644 --- a/mobile/time.php +++ b/mobile/time.php @@ -253,6 +253,7 @@ if ($request->isPost()) { 'date' => $cl_date, 'user_id' => $user->getActiveUser(), 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'client' => $cl_client, 'project' => $cl_project, 'task' => $cl_task, diff --git a/mobile/timer.php b/mobile/timer.php index 09500bd2..2f5dbad4 100644 --- a/mobile/timer.php +++ b/mobile/timer.php @@ -226,6 +226,7 @@ if ($request->isPost()) { 'date' => $cl_date, 'user_id' => $user->getActiveUser(), 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'client' => $cl_client, 'project' => $cl_project, 'task' => $cl_task, diff --git a/time.php b/time.php index 258f15c1..68aaf40e 100644 --- a/time.php +++ b/time.php @@ -313,6 +313,7 @@ if ($request->isPost()) { 'date' => $cl_date, 'user_id' => $user->getActiveUser(), 'group_id' => $user->getActiveGroup(), + 'org_id' => $user->org_id, 'client' => $cl_client, 'project' => $cl_project, 'task' => $cl_task, diff --git a/time_edit.php b/time_edit.php index 5f406882..21c3effa 100644 --- a/time_edit.php +++ b/time_edit.php @@ -366,6 +366,7 @@ if ($request->isPost()) { 'date'=>$new_date->toString(DB_DATEFORMAT), 'user_id'=>$user->getActiveUser(), 'group_id'=>$user->getActiveGroup(), + 'org_id' => $user->org_id, 'client'=>$cl_client, 'project'=>$cl_project, 'task'=>$cl_task,