From: Nik Okuntseff Date: Tue, 4 Dec 2018 12:59:29 +0000 (+0000) Subject: Some more refactoring for subgroups. X-Git-Tag: timetracker_1.19-1~488 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=f5d19e5d5fd205d81367ab2c82d41c154cad50ff;p=timetracker.git Some more refactoring for subgroups. --- diff --git a/WEB-INF/lib/ttClientHelper.class.php b/WEB-INF/lib/ttClientHelper.class.php index 42eb128a..02014f1f 100644 --- a/WEB-INF/lib/ttClientHelper.class.php +++ b/WEB-INF/lib/ttClientHelper.class.php @@ -270,14 +270,17 @@ class ttClientHelper { static function getAssignedProjects($client_id) { global $user; + $mdb2 = getConnection(); + + $group_id = $user->getGroup(); + $org_id = $user->org_id; $result = array(); - $mdb2 = getConnection(); // Do a query with inner join to get assigned projects. $sql = "select p.id, p.name from tt_projects p". " inner join tt_client_project_binds cpb on (cpb.client_id = $client_id and cpb.project_id = p.id)". - " where p.group_id = ".$user->getGroup()." and p.status = 1 order by p.name"; + " where p.group_id = $group_id and p.org_id = $org_id and p.status = 1 order by p.name"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { while ($val = $res->fetchRow()) { @@ -291,15 +294,19 @@ class ttClientHelper { static function getClientsForUser() { global $user; + $mdb2 = getConnection(); + $user_id = $user->getUser(); + $group_id = $user->getGroup(); + $org_id = $user->org_id; $result = array(); - $mdb2 = getConnection(); - $sql = "select distinct c.id, c.name, c.projects from tt_user_project_binds upb - inner join tt_client_project_binds cpb on (cpb.project_id = upb.project_id) - inner join tt_clients c on (c.id = cpb.client_id and c.status = 1) - where upb.user_id = $user_id and upb.status = 1 order by upper(c.name)"; + $sql = "select distinct c.id, c.name, c.projects from tt_user_project_binds upb". + " inner join tt_client_project_binds cpb on (cpb.project_id = upb.project_id)". + " inner join tt_clients c on (c.id = cpb.client_id and c.status = 1)". + " where upb.user_id = $user_id and upb.group_id = $group_id and upb.org_id = $org_id". + " and upb.status = 1 order by upper(c.name)"; $res = $mdb2->query($sql); if (!is_a($res, 'PEAR_Error')) { diff --git a/WEB-INF/templates/client_edit.tpl b/WEB-INF/templates/client_edit.tpl index 12f6bf0d..2abf70dc 100644 --- a/WEB-INF/templates/client_edit.tpl +++ b/WEB-INF/templates/client_edit.tpl @@ -24,7 +24,7 @@ {$i18n.label.required_fields}   -{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)} +{if $show_projects} {$i18n.label.projects}: {$forms.clientForm.projects.control} diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 2031cbf1..5bb1100a 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.29.4576 | Copyright © Anuko | +  Anuko Time Tracker 1.18.29.4578 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/client_add.php b/client_add.php index 4d26e2a1..820a32fd 100644 --- a/client_add.php +++ b/client_add.php @@ -88,7 +88,7 @@ if ($request->isPost()) { $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('onload', 'onLoad="document.clientForm.name.focus()"'); -$smarty->assign('show_projects',$show_projects); +$smarty->assign('show_projects', $show_projects); $smarty->assign('title', $i18n->get('title.add_client')); $smarty->assign('content_page_name', 'client_add.tpl'); $smarty->display('index.tpl'); diff --git a/client_edit.php b/client_edit.php index 0dc3bb65..2b26d86d 100644 --- a/client_edit.php +++ b/client_edit.php @@ -64,6 +64,8 @@ if ($request->isPost()) { } } +$show_projects = (MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) && count($projects) > 0; + $form = new Form('clientForm'); $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_id)); $form->addInput(array('type'=>'text','name'=>'name','maxlength'=>'100','style'=>'width: 350px;','value'=>$cl_name)); @@ -71,7 +73,7 @@ $form->addInput(array('type'=>'textarea','name'=>'address','maxlength'=>'255','s $form->addInput(array('type'=>'floatfield','name'=>'tax','size'=>'10','format'=>'.2','value'=>$cl_tax)); $form->addInput(array('type'=>'combobox','name'=>'status','value'=>$cl_status, 'data'=>array(ACTIVE=>$i18n->get('dropdown.status_active'),INACTIVE=>$i18n->get('dropdown.status_inactive')))); -if (MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) +if ($show_projects) $form->addInput(array('type'=>'checkboxgroup','name'=>'projects','data'=>$projects,'datakeys'=>array('id','name'),'layout'=>'H','value'=>$cl_projects)); $form->addInput(array('type'=>'submit','name'=>'btn_save','value'=>$i18n->get('button.save'))); $form->addInput(array('type'=>'submit','name'=>'btn_copy','value'=>$i18n->get('button.copy'))); @@ -122,6 +124,7 @@ if ($request->isPost()) { } // isPost $smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('show_projects', $show_projects); $smarty->assign('title', $i18n->get('title.edit_client')); $smarty->assign('content_page_name', 'client_edit.tpl'); $smarty->display('index.tpl');