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()) {
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')) {
<td>{$i18n.label.required_fields}</td>
</tr>
<tr><td> </td></tr>
-{if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
+{if $show_projects}
<tr>
<td align="right">{$i18n.label.projects}:</td>
<td>{$forms.clientForm.projects.control}</td>
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.29.4576 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.29.4578 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
$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');
}
}
+$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));
$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')));
} // 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');