// then rank restriction does not apply.
$max_rank = $this->behalfGroup ? MAX_RANK : $this->rank;
- $sql = "select u.id, u.name, u.login, u.role_id, u.client_id, u.status, u.rate, u.email from tt_users u".
+ $sql = "select u.id, u.name, u.login, u.role_id, u.client_id, u.status, u.rate, u.quota_percent, u.email from tt_users u".
" left join tt_roles r on (u.role_id = r.id)".
" where u.id = $user_id and u.group_id = $group_id and u.org_id = $org_id and u.status is not null".
" and (r.rank < $max_rank or (r.rank = $max_rank and u.id = $this->id))"; // Users with lesser roles or self.
$group_id = (int) $fields['group_id'];
$org_id = (int) $fields['org_id'];
$rate = str_replace(',', '.', isset($fields['rate']) ? $fields['rate'] : 0);
+ $quota_percent = str_replace(',', '.', isset($fields['quota_percent']) ? $fields['quota_percent'] : 100);
if($rate == '')
$rate = 0;
if (array_key_exists('status', $fields)) { // Key exists and may be NULL during migration of deleted acounts.
$created_ip_v = ', '.$mdb2->quote($_SERVER['REMOTE_ADDR']);
$created_by_v = ', '.$user->id;
- $sql = "insert into tt_users (name, login, password, group_id, org_id, role_id, client_id, rate, email, created, created_ip, created_by $status_f) values (".
+ $sql = "insert into tt_users (name, login, password, group_id, org_id, role_id, client_id, rate, quota_percent, email, created, created_ip, created_by $status_f) values (".
$mdb2->quote($fields['name']).", ".$mdb2->quote($fields['login']).
- ", $password, $group_id, $org_id, ".$mdb2->quote($fields['role_id']).", ".$mdb2->quote($fields['client_id']).", $rate, ".$mdb2->quote($email).", now() $created_ip_v $created_by_v $status_v)";
+ ", $password, $group_id, $org_id, ".$mdb2->quote($fields['role_id']).", ".$mdb2->quote($fields['client_id']).", $rate, $quota_percent, ".$mdb2->quote($email).", now() $created_ip_v $created_by_v $status_v)";
$affected = $mdb2->exec($sql);
// Now deal with project assignment.
$rate_part = ", rate = ".$mdb2->quote($rate);
}
+ if (array_key_exists('quota_percent', $fields)) {
+ $quota_percent = str_replace(',', '.', isset($fields['quota_percent']) ? $fields['quota_percent'] : 100);
+ $quota_percent_part = ", quota_percent = ".$mdb2->quote($quota_percent);
+ }
+
if (isset($fields['email']))
$email_part = ', email = '.$mdb2->quote($fields['email']);
}
$modified_part = ', modified = now(), modified_ip = '.$mdb2->quote($_SERVER['REMOTE_ADDR']).', modified_by = '.$user->id;
- $parts = ltrim($login_part.$pass_part.$name_part.$role_part.$client_part.$rate_part.$email_part.$modified_part.$status_part, ',');
+ $parts = ltrim($login_part.$pass_part.$name_part.$role_part.$client_part.$rate_part.$quota_percent_part.$email_part.$modified_part.$status_part, ',');
$sql = "update tt_users set $parts".
" where id = $user_id and group_id = $group_id and org_id = $org_id";
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.18.34.4672 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.18.34.4673 | 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>
<td align="right">{$i18n.form.users.default_rate} (0{$user->getDecimalMark()}00):</td>
<td>{$forms.userForm.rate.control}</td>
</tr>
-{if ($smarty.const.MODE_PROJECTS == $user->getTrackingMode() || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) && $show_projects}
+{if $show_quota}
+ <tr>
+ <td align="right">{$i18n.form.quota.quota} (%):</td>
+ <td>{$forms.userForm.quota_percent.control}</td>
+ </tr>
+{/if}
+{if $show_projects}
<tr><td> </td></tr>
<tr valign="top">
<td align="right">{$i18n.label.projects}:</td>
<td align="right">{$i18n.form.users.default_rate} (0{$user->getDecimalMark()}00):</td>
<td>{$forms.userForm.rate.control}</td>
</tr>
-{if ($smarty.const.MODE_PROJECTS == $user->getTrackingMode() || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->getTrackingMode()) && $show_projects}
+{if $show_quota}
+ <tr>
+ <td align="right">{$i18n.form.quota.quota} (%):</td>
+ <td>{$forms.userForm.quota_percent.control}</td>
+ </tr>
+{/if}
+{if $show_projects}
<tr><td> </td></tr>
<tr valign="top">
<td align="right">{$i18n.label.projects}:</td>
// The "limit" plugin is not required for normal operation of Time Tracker.
@include('plugins/limit/user_add.php');
+$show_quota = $user->isPluginEnabled('mq');
if ($user->isPluginEnabled('cl'))
$clients = ttGroupHelper::getActiveClients();
$cl_role_id = $request->getParameter('role');
$cl_client_id = $request->getParameter('client');
$cl_rate = $request->getParameter('rate');
+ $cl_quota_percent = $request->getParameter('quota_percent');
$cl_projects = $request->getParameter('projects');
if (is_array($cl_projects)) {
foreach ($cl_projects as $p) {
$form->addInput(array('type'=>'combobox','name'=>'client','value'=>$cl_client_id,'data'=>$clients,'datakeys'=>array('id', 'name'),'empty'=>array(''=>$i18n->get('dropdown.select'))));
$form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'rate','format'=>'.2','value'=>$cl_rate));
+if ($show_quota)
+ $form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'quota_percent','format'=>'.2','value'=>$cl_quota_percent));
-$projects = ttGroupHelper::getActiveProjects();
+$show_projects = MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode();
+if ($show_projects) {
+ $projects = ttGroupHelper::getActiveProjects();
+ if (count($projects) == 0) $show_projects = false;
+}
// Define classes for the projects table.
class NameCellRenderer extends DefaultCellRenderer {
// Require selection of a client for a client role.
if ($user->isPluginEnabled('cl') && ttRoleHelper::isClientRole($cl_role_id) && !$cl_client_id) $err->add($i18n->get('error.client'));
if (!ttValidFloat($cl_rate, true)) $err->add($i18n->get('error.field'), $i18n->get('form.users.default_rate'));
+ if (!ttValidFloat($cl_quota_percent, true)) $err->add($i18n->get('error.field'), $i18n->get('form.quota.quota'));
if ($err->no()) {
if (!ttUserHelper::getUserByLogin($cl_login)) {
'login' => $cl_login,
'password' => $cl_password1,
'rate' => $cl_rate,
+ 'quota_percent' => $cl_quota_percent,
'group_id' => $user->getGroup(),
'org_id' => $user->org_id,
'role_id' => $cl_role_id,
$smarty->assign('auth_external', $auth->isPasswordExternal());
$smarty->assign('active_roles', $active_roles);
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
-$smarty->assign('show_projects', count($projects) > 0);
+$smarty->assign('show_quota', $show_quota);
+$smarty->assign('show_projects', $show_projects);
$smarty->assign('onload', 'onLoad="document.userForm.name.focus();handleClientControl();"');
$smarty->assign('title', $i18n->get('title.add_user'));
$smarty->assign('content_page_name', 'user_add.tpl');
}
// End of access checks.
+$show_quota = $user->isPluginEnabled('mq');
if ($user->isPluginEnabled('cl'))
$clients = ttGroupHelper::getActiveClients();
-$projects = ttGroupHelper::getActiveProjects();
+$show_projects = MODE_PROJECTS == $user->getTrackingMode() || MODE_PROJECTS_AND_TASKS == $user->getTrackingMode();
+if ($show_projects) {
+ $projects = ttGroupHelper::getActiveProjects();
+ if (count($projects) == 0) $show_projects = false;
+}
$assigned_projects = array();
if ($request->isPost()) {
$cl_client_id = $request->getParameter('client');
$cl_status = $request->getParameter('status');
$cl_rate = $request->getParameter('rate');
+ $cl_quota_percent = $request->getParameter('quota_percent');
$cl_projects = $request->getParameter('projects');
if (is_array($cl_projects)) {
foreach ($cl_projects as $p) {
$cl_login = $user_details['login'];
$cl_email = $user_details['email'];
$cl_rate = str_replace('.', $user->getDecimalMark(), $user_details['rate']);
+ $cl_quota_percent = str_replace('.', $user->getDecimalMark(), $user_details['quota_percent']);
$cl_role_id = $user_details['role_id'];
$cl_client_id = $user_details['client_id'];
$cl_status = $user_details['status'];
$form->addInput(array('type'=>'combobox','name'=>'status','value'=>$cl_status,
'data'=>array(ACTIVE=>$i18n->get('dropdown.status_active'),INACTIVE=>$i18n->get('dropdown.status_inactive'))));
$form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'rate','format'=>'.2','value'=>$cl_rate));
+if ($show_quota)
+ $form->addInput(array('type'=>'floatfield','maxlength'=>'10','name'=>'quota_percent','format'=>'.2','value'=>$cl_quota_percent));
// Define classes for the projects table.
class NameCellRenderer extends DefaultCellRenderer {
// Require selection of a client for a client role.
if ($user->isPluginEnabled('cl') && ttRoleHelper::isClientRole($cl_role_id) && !$cl_client_id) $err->add($i18n->get('error.client'));
if (!ttValidFloat($cl_rate, true)) $err->add($i18n->get('error.field'), $i18n->get('form.users.default_rate'));
+ if (!ttValidFloat($cl_quota_percent, true)) $err->add($i18n->get('error.field'), $i18n->get('form.quota.quota'));
if ($err->no()) {
$existing_user = ttUserHelper::getUserByLogin($cl_login);
'email' => $cl_email,
'status' => $cl_status,
'rate' => $cl_rate,
+ 'quota_percent' => $cl_quota_percent,
'projects' => $assigned_projects);
if (in_array('manage_users', $user->rights) && $cl_role_id) {
$fields['role_id'] = $cl_role_id;
$smarty->assign('auth_external', $auth->isPasswordExternal());
$smarty->assign('active_roles', $active_roles);
$smarty->assign('can_swap', $can_swap);
-$smarty->assign('show_projects', count($projects) > 0);
+$smarty->assign('show_quota', $show_quota);
+$smarty->assign('show_projects', $show_projects);
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('onload', 'onLoad="document.userForm.name.focus();handleClientControl();"');
$smarty->assign('user_id', $user_id);