2 // Prepare an array of rates.
3 // Format: project_rates[0] = Array(100, '25.00'), project_rates[1] = Array(120, '30.00'), etc...
4 // First element = project_id, second element = rate for project. Quotes needed for string representation of rates.
5 project_rates = new Array();
7 {foreach $rates as $rate}
8 project_rates[idx] = new Array({$rate.id}, '{$rate.rate}');
12 // getRate - returns a rate for the project. If rate was set for user previously we'll get this old rate
13 // if project time entries for user exists. Otherwise return user default rate.
14 function getRate(project_id) {
15 var length = project_rates.length;
16 for(var i = 0; i < length; i++) {
17 if(project_rates[i][0] == project_id) {
18 return project_rates[i][1];
21 var default_rate = document.userForm.rate.value;
25 // The setRate function sets / unsets user rate for a project when a corresponding checkbox is ticked.
26 function setRate(element) {
27 var default_rate = document.userForm.rate.value;
28 if (default_rate == '') {
29 // No default rate, nothing to do!
32 // Iterate through elements of the form to find and set the project rate.
33 for (var i = 0; i < userForm.elements.length; i++) {
34 if ((userForm.elements[i].type == 'text') && (userForm.elements[i].name == ('rate_'+element.value))) {
35 if (element.checked) {
36 userForm.elements[i].value = getRate(element.value);
38 userForm.elements[i].value = '';
40 break; // Element is found and set, nothing more to do, break out of the loop.
45 // handleClientControl - controls visibility of the client dropdown depending on the selected user role.
46 // We need to show it only when the "Client" user role is selected.
47 function handleClientControl() {
48 var clientControl = document.getElementById("client");
49 if ("16" == document.getElementById("role").value)
50 clientControl.style.visibility = "visible";
52 clientControl.style.visibility = "hidden";
56 {$forms.userForm.open}
57 <table cellspacing="4" cellpadding="7" border="0">
58 <table cellspacing="1" cellpadding="2" border="0">
60 <td align="right">{$i18n.label.person_name} (*):</td>
61 <td>{$forms.userForm.name.control}</td>
64 <td align="right">{$i18n.label.login} (*):</td>
65 <td>{$forms.userForm.login.control}</td>
69 <td align="right">{$i18n.label.password} (*):</td>
70 <td>{$forms.userForm.pas1.control}</td>
73 <td align="right">{$i18n.label.confirm_password} (*):</td>
74 <td>{$forms.userForm.pas2.control}</td>
78 <td align="right" nowrap>{$i18n.label.email}:</td>
79 <td>{$forms.userForm.email.control}</td>
81 {if $user->isManager() && ($user->id != $user_id)}
83 <td align="right">{$i18n.form.users.role}:</td>
84 <td>{$forms.userForm.role.control} {$forms.userForm.client.control}</td>
87 {* Prohibit deactivating team manager. Deactivating others is ok. *}
88 {if $user->canManageTeam() && !($user->isManager() && $user->id == $user_id)}
90 <td align="right">{$i18n.label.status}:</td>
91 <td>{$forms.userForm.status.control}</td>
95 <td align="right">{$i18n.form.users.default_rate} (0{$user->decimal_mark}00):</td>
96 <td>{$forms.userForm.rate.control}</td>
98 {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
100 <td align="right">{$i18n.label.projects}:</td>
101 <td>{$forms.userForm.projects.control}</td>
105 <td colspan="2" align="center">{$i18n.label.required_fields}</td>
108 <td colspan="2" align="center" height="50">{$forms.userForm.btn_submit.control}</td>
112 {$forms.userForm.close}