2 // Prepare an array of available roles. We need it for "is_client" property.
3 // It is used to selectively display client selector for client roles.
6 {foreach $active_roles as $active_role}
7 roles[idx] = new Array({$active_role.id}, '{$active_role.is_client}');
11 // Prepare an array of rates.
12 // Format: project_rates[0] = Array(100, '25.00'), project_rates[1] = Array(120, '30.00'), etc...
13 // First element = project_id, second element = rate for project. Quotes needed for string representation of rates.
14 project_rates = new Array();
16 {foreach $rates as $rate}
17 project_rates[idx] = new Array({$rate.id}, '{$rate.rate}');
21 // getRate - returns a rate for the project. If rate was set for user previously we'll get this old rate
22 // if project time entries for user exists. Otherwise return user default rate.
23 function getRate(project_id) {
24 var length = project_rates.length;
25 for(var i = 0; i < length; i++) {
26 if(project_rates[i][0] == project_id) {
27 return project_rates[i][1];
30 var default_rate = document.userForm.rate.value;
34 // The setRate function sets / unsets user rate for a project when a corresponding checkbox is ticked.
35 function setRate(element) {
36 var default_rate = document.userForm.rate.value;
37 if (default_rate == '') {
38 // No default rate, nothing to do!
41 // Iterate through elements of the form to find and set the project rate.
42 for (var i = 0; i < userForm.elements.length; i++) {
43 if ((userForm.elements[i].type == 'text') && (userForm.elements[i].name == ('rate_'+element.value))) {
44 if (element.checked) {
45 userForm.elements[i].value = getRate(element.value);
47 userForm.elements[i].value = '';
49 break; // Element is found and set, nothing more to do, break out of the loop.
54 // handleClientControl - controls visibility of the client dropdown depending on the selected user role.
55 // We need to show it only when the "Client" user role is selected.
56 function handleClientControl() {
57 var selectedRoleId = document.getElementById("role").value;
58 var clientControl = document.getElementById("client");
59 var len = roles.length;
60 for (var i = 0; i < len; i++) {
61 if (selectedRoleId == roles[i][0]) {
62 var isClient = roles[i][1];
64 clientControl.style.visibility = "visible";
66 clientControl.style.visibility = "hidden";
73 {$forms.userForm.open}
74 <table cellspacing="4" cellpadding="7" border="0">
75 <table cellspacing="1" cellpadding="2" border="0">
77 <td align="right">{$i18n.label.person_name} (*):</td>
78 <td>{$forms.userForm.name.control}</td>
81 <td align="right">{$i18n.label.login} (*):</td>
82 <td>{$forms.userForm.login.control}</td>
86 <td align="right">{$i18n.label.password} (*):</td>
87 <td>{$forms.userForm.pas1.control}</td>
90 <td align="right">{$i18n.label.confirm_password} (*):</td>
91 <td>{$forms.userForm.pas2.control}</td>
95 <td align="right" nowrap>{$i18n.label.email}:</td>
96 <td>{$forms.userForm.email.control}</td>
98 {if $user->id != $user_id}
100 <td align="right">{$i18n.form.users.role}:</td>
101 <td>{$forms.userForm.role.control} {$forms.userForm.client.control}</td>
104 <td align="right">{$i18n.label.status}:</td>
105 <td>{$forms.userForm.status.control}</td>
108 {if $user->id == $user_id}
110 <td align="right">{$i18n.form.users.role}:</td>
111 <td>{$user->role_name} {if $user->can('swap_roles')}<a href="swap_roles.php">{$i18n.form.profile.swap_roles}</a>{/if}</td>
115 <td align="right">{$i18n.form.users.default_rate} (0{$user->decimal_mark}00):</td>
116 <td>{$forms.userForm.rate.control}</td>
118 {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
120 <td align="right">{$i18n.label.projects}:</td>
121 <td>{$forms.userForm.projects.control}</td>
125 <td colspan="2" align="center">{$i18n.label.required_fields}</td>
128 <td colspan="2" align="center" height="50">{$forms.userForm.btn_submit.control}</td>
132 {$forms.userForm.close}