From: Nik Okuntseff Date: Sat, 28 Jul 2018 18:50:15 +0000 (+0000) Subject: More progress on storing group_id on new inserts. X-Git-Tag: timetracker_1.19-1~795 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=bcfe9680fdb90d26de543b2c43feabefdcac3c20;p=timetracker.git More progress on storing group_id on new inserts. --- diff --git a/WEB-INF/lib/ttExpenseHelper.class.php b/WEB-INF/lib/ttExpenseHelper.class.php index 8a4b1715..6d3128fd 100644 --- a/WEB-INF/lib/ttExpenseHelper.class.php +++ b/WEB-INF/lib/ttExpenseHelper.class.php @@ -36,6 +36,7 @@ class ttExpenseHelper { $date = $fields['date']; $user_id = (int) $fields['user_id']; + $group_id = (int) $fields['group_id']; $client_id = $fields['client_id']; $project_id = $fields['project_id']; $name = $fields['name']; @@ -45,8 +46,8 @@ class ttExpenseHelper { $paid = (int) $fields['paid']; $created = ', now(), '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', '.$mdb2->quote($user->id); - $sql = "insert into tt_expense_items (date, user_id, client_id, project_id, name, cost, invoice_id, paid, created, created_ip, created_by, status) ". - "values (".$mdb2->quote($date).", $user_id, ".$mdb2->quote($client_id).", ".$mdb2->quote($project_id). + $sql = "insert into tt_expense_items (date, user_id, group_id, client_id, project_id, name, cost, invoice_id, paid, created, created_ip, created_by, status) ". + "values (".$mdb2->quote($date).", $user_id, $group_id, ".$mdb2->quote($client_id).", ".$mdb2->quote($project_id). ", ".$mdb2->quote($name).", ".$mdb2->quote($cost).", ".$mdb2->quote($invoice_id).", $paid $created, ".$mdb2->quote($status).")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index 7b68ba7c..8be7a831 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -248,6 +248,7 @@ class ttImportHelper { $this->logMap[$this->currentElement['ID']] = ttTimeHelper::insert(array( 'user_id' => $this->userMap[$this->currentElement['USER_ID']], + 'group_id' => $this->group_id, 'date' => $this->currentElement['DATE'], 'start' => $this->currentElement['START'], 'finish' => $this->currentElement['FINISH'], @@ -292,6 +293,7 @@ class ttImportHelper { ttExpenseHelper::insert(array( 'date' => $this->currentElement['DATE'], 'user_id' => $this->userMap[$this->currentElement['USER_ID']], + 'group_id' => $this->group_id, 'client_id' => $this->clientMap[$this->currentElement['CLIENT_ID']], 'project_id' => $this->projectMap[$this->currentElement['PROJECT_ID']], 'name' => $this->currentElement['NAME'], diff --git a/WEB-INF/lib/ttTimeHelper.class.php b/WEB-INF/lib/ttTimeHelper.class.php index 5ad07e18..e3020354 100644 --- a/WEB-INF/lib/ttTimeHelper.class.php +++ b/WEB-INF/lib/ttTimeHelper.class.php @@ -389,8 +389,8 @@ class ttTimeHelper { global $user; $mdb2 = getConnection(); - $user_id = $fields['user_id']; - $group_id = $fields['group_id']; + $user_id = (int) $fields['user_id']; + $group_id = (int) $fields['group_id']; $date = $fields['date']; $start = $fields['start']; $finish = $fields['finish']; @@ -424,7 +424,7 @@ class ttTimeHelper { 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, ".$mdb2->quote($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)"; + "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)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -434,7 +434,7 @@ class ttTimeHelper { 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, ".$mdb2->quote($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)"; + "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)"; $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 27a1bbcf..dcb39af6 100644 --- a/WEB-INF/lib/ttWeekViewHelper.class.php +++ b/WEB-INF/lib/ttWeekViewHelper.class.php @@ -493,6 +493,7 @@ class ttWeekViewHelper { // Prepare an array of fields for regular insert function. $fields4insert = array(); $fields4insert['user_id'] = $user->getActiveUser(); + $fields4insert['group_id'] = $user->getActiveGroup(); $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 e20ac62d..df6d91d3 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.17.96.4297 | Copyright © Anuko | +  Anuko Time Tracker 1.17.96.4298 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/expense_edit.php b/expense_edit.php index 26cf3bba..353f5ce5 100644 --- a/expense_edit.php +++ b/expense_edit.php @@ -205,7 +205,7 @@ if ($request->isPost()) { // Now, a new insert. if ($err->no()) { - if (ttExpenseHelper::insert(array('date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(), + if (ttExpenseHelper::insert(array('date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(),'group_id'=>$user->getActiveGroup(), 'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'status'=>1))) { header('Location: expenses.php?date='.$new_date->toString(DB_DATEFORMAT)); exit(); diff --git a/expenses.php b/expenses.php index 7d7295d2..fa45ad44 100644 --- a/expenses.php +++ b/expenses.php @@ -188,7 +188,7 @@ if ($request->isPost()) { // Insert record. if ($err->no()) { - if (ttExpenseHelper::insert(array('date'=>$cl_date,'user_id'=>$user->getActiveUser(), + if (ttExpenseHelper::insert(array('date'=>$cl_date,'user_id'=>$user->getActiveUser(),'group_id'=>$user->getActiveGroup(), 'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'status'=>1))) { header('Location: expenses.php'); exit(); diff --git a/mobile/expense_edit.php b/mobile/expense_edit.php index f560f557..338e6c77 100644 --- a/mobile/expense_edit.php +++ b/mobile/expense_edit.php @@ -200,7 +200,7 @@ if ($request->isPost()) { // Now, a new insert. if ($err->no()) { - if (ttExpenseHelper::insert(array('date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(), + if (ttExpenseHelper::insert(array('date'=>$new_date->toString(DB_DATEFORMAT),'user_id'=>$user->getActiveUser(),'group_id'=>$user->getActiveGroup(), 'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'status'=>1))) { header('Location: expenses.php?date='.$new_date->toString(DB_DATEFORMAT)); exit(); diff --git a/mobile/expenses.php b/mobile/expenses.php index c853a2ca..25a1c602 100644 --- a/mobile/expenses.php +++ b/mobile/expenses.php @@ -192,7 +192,7 @@ if ($request->isPost()) { // Insert record. if ($err->no()) { - if (ttExpenseHelper::insert(array('date'=>$cl_date,'user_id'=>$user->getActiveUser(), + if (ttExpenseHelper::insert(array('date'=>$cl_date,'user_id'=>$user->getActiveUser(),'group_id'=>$user->getActiveGroup(), 'client_id'=>$cl_client,'project_id'=>$cl_project,'name'=>$cl_item_name,'cost'=>$cl_cost,'status'=>1))) { header('Location: expenses.php'); exit(); diff --git a/time_edit.php b/time_edit.php index fd1851dc..5f406882 100644 --- a/time_edit.php +++ b/time_edit.php @@ -365,6 +365,7 @@ if ($request->isPost()) { $id = ttTimeHelper::insert(array( 'date'=>$new_date->toString(DB_DATEFORMAT), 'user_id'=>$user->getActiveUser(), + 'group_id'=>$user->getActiveGroup(), 'client'=>$cl_client, 'project'=>$cl_project, 'task'=>$cl_task,