From: Nik Okuntseff Date: Thu, 8 Nov 2018 15:57:34 +0000 (+0000) Subject: Started to populate group_id and org_id in tt_user_project_binds. X-Git-Tag: timetracker_1.19-1~686 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=8fc038ec7505483c193e290423623b6a66ee3797;p=timetracker.git Started to populate group_id and org_id in tt_user_project_binds. --- diff --git a/WEB-INF/lib/ttImportHelper.class.php b/WEB-INF/lib/ttImportHelper.class.php index 64a32e0e..307be167 100644 --- a/WEB-INF/lib/ttImportHelper.class.php +++ b/WEB-INF/lib/ttImportHelper.class.php @@ -206,11 +206,19 @@ class ttImportHelper { 'status' => $this->currentElement['STATUS'])); } if ($name == 'USER_PROJECT_BIND' && $this->canImport) { - ttUserHelper::insertBind( +/* + ttUserHelper::insertBind( $this->userMap[$this->currentElement['USER_ID']], $this->projectMap[$this->currentElement['PROJECT_ID']], $this->currentElement['RATE'], - $this->currentElement['STATUS']); + $this->currentElement['STATUS']);*/ + ttUserHelper::insertBind2(array( + 'user_id' => $this->userMap[$this->currentElement['USER_ID']], + 'project_id' => $this->projectMap[$this->currentElement['PROJECT_ID']], + 'group_id' => $this->group_id, + 'org_id' => $this->org_id, + 'rate' => $this->currentElement['RATE'], + 'status' => $this->currentElement['STATUS'])); } if ($name == 'CLIENT' && $this->canImport) { diff --git a/WEB-INF/lib/ttProjectHelper.class.php b/WEB-INF/lib/ttProjectHelper.class.php index 72b71711..47783d59 100644 --- a/WEB-INF/lib/ttProjectHelper.class.php +++ b/WEB-INF/lib/ttProjectHelper.class.php @@ -214,8 +214,8 @@ class ttProjectHelper { $active_users = ttTeamHelper::getActiveUsers(array('getAllFields'=>true)); foreach ($active_users as $u) { if(in_array($u['id'], $users)) { - $sql = "insert into tt_user_project_binds (project_id, user_id, status, rate) values( - $last_id, ".$u['id'].", 1, ".$u['rate'].")"; + $sql = "insert into tt_user_project_binds (project_id, user_id, group_id, org_id, status, rate) values( + $last_id, ".$u['id'].", $group_id, $org_id, 1, ".$u['rate'].")"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; @@ -271,8 +271,11 @@ class ttProjectHelper { while ($row = $res->fetchRow()) { $user_rate[$row['id']] = $row['rate']; } + $group_id = $user->getActiveGroup(); + $org_id = $user->org_id; foreach ($users_to_add as $id) { - $sql = "insert into tt_user_project_binds (user_id, project_id, rate, status) values($id, $project_id, ".$user_rate[$id].", 1)"; + $sql = "insert into tt_user_project_binds (user_id, project_id, group_id, org_id, rate, status)". + " values($id, $project_id, $group_id, $org_id, ".$user_rate[$id].", 1)"; $affected = $mdb2->exec($sql); if (is_a($affected, 'PEAR_Error')) return false; diff --git a/WEB-INF/lib/ttUserHelper.class.php b/WEB-INF/lib/ttUserHelper.class.php index 28175080..bd5e46b8 100644 --- a/WEB-INF/lib/ttUserHelper.class.php +++ b/WEB-INF/lib/ttUserHelper.class.php @@ -134,7 +134,8 @@ class ttUserHelper { else $p['rate'] = str_replace(',', '.', $p['rate']); - $sql = "insert into tt_user_project_binds (project_id, user_id, rate, status) values(".$p['id'].",".$last_id.",".$p['rate'].", 1)"; + $sql = "insert into tt_user_project_binds (project_id, user_id, group_id, org_id, rate, status)". + " values(".$p['id'].", $last_id, $group_id, $org_id, ".$p['rate'].", 1)"; $affected = $mdb2->exec($sql); } } @@ -309,10 +310,33 @@ class ttUserHelper { // insertBind - inserts a user to project bind into tt_user_project_binds table. static function insertBind($user_id, $project_id, $rate, $status) { + global $user; + $mdb2 = getConnection(); + + $group_id = $user->getActiveGroup(); + $org_id = $user->org_id; + $sql = "insert into tt_user_project_binds (user_id, project_id, group_id, org_id, rate, status)". + " values($user_id, $project_id, $group_id, $org_id, ".$mdb2->quote($rate).", $status)"; + $affected = $mdb2->exec($sql); + return (!is_a($affected, 'PEAR_Error')); + } + + // insertBind2 - inserts a user to project bind into tt_user_project_binds table. + static function insertBind2($fields) { + global $user; $mdb2 = getConnection(); - $sql = "insert into tt_user_project_binds (user_id, project_id, rate, status) - values($user_id, $project_id, ".$mdb2->quote($rate).", $status)"; + // This may be used during import. Use the following until we have import refactored. + $group_id = $fields['group_id'] ? (int) $fields['group_id'] : $user->getActiveGroup(); + $org_id = $fields['org_id'] ? (int) $fields['org_id'] : $user->org_id; + + $user_id = (int) $fields['user_id']; + $project_id = (int) $fields['project_id']; + $rate = $mdb2->quote($fields['rate']); + $status = $mdb2->quote($fields['status']); + + $sql = "insert into tt_user_project_binds (user_id, project_id, group_id, org_id, rate, status)". + " values($user_id, $project_id, $group_id, $org_id, $rate, $status)"; $affected = $mdb2->exec($sql); return (!is_a($affected, 'PEAR_Error')); } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index f807fe1c..ee8659bf 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.12.4387 | Copyright © Anuko | +  Anuko Time Tracker 1.18.12.4388 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/user_add.php b/user_add.php index ac2d8c4e..eb939147 100644 --- a/user_add.php +++ b/user_add.php @@ -150,7 +150,7 @@ if ($request->isPost()) { 'login' => $cl_login, 'password' => $cl_password1, 'rate' => $cl_rate, - 'group_id' => $user->group_id, // TODO: this needs to be fixed for on-behalf group work. + 'group_id' => $user->getActiveGroup(), 'org_id' => $user->org_id, 'role_id' => $cl_role_id, 'client_id' => $cl_client_id,