Starting to use on behalf group properties.
[timetracker.git] / WEB-INF / templates / user_add.tpl
1 <script>
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.
4 roles = new Array();
5 var idx = 0;
6 {foreach $active_roles as $active_role}
7 roles[idx] = new Array({$active_role.id}, '{$active_role.is_client}');
8 idx++;
9 {/foreach}
10
11 // The setDefaultRate function sets / unsets default rate for a project
12 // when a corresponding checkbox is ticked.
13 function setDefaultRate(element) {
14   var default_rate = document.userForm.rate.value;
15   if (default_rate == '') {
16     // No default rate, nothing to do!
17     return;
18   }
19   // Iterate through elements of the form to find and set the project rate. 
20   for (var i = 0; i < userForm.elements.length; i++) {
21     if ((userForm.elements[i].type == 'text') && (userForm.elements[i].name == ('rate_'+element.value))) {
22       if (element.checked) {
23         userForm.elements[i].value = default_rate;
24       } else {
25         userForm.elements[i].value = '';
26       }
27       break; // Element is found and set, nothing more to do, break out of the loop.
28     }
29   }
30 }
31
32 // handleClientControl - controls visibility of the client dropdown depending on the selected user role.
33 // We need to show it only when the "Client" user role is selected.
34 function handleClientControl() {
35   var selectedRoleId = document.getElementById("role").value;
36   var clientControl = document.getElementById("client");
37   var len = roles.length;
38   for (var i = 0; i < len; i++) {
39     if (selectedRoleId == roles[i][0]) {
40       var isClient = roles[i][1];
41       if (isClient == 1)
42         clientControl.style.visibility = "visible";
43       else
44         clientControl.style.visibility = "hidden";
45       break;
46     }
47   }
48 }
49 </script>
50
51 {$forms.userForm.open}
52 <table cellspacing="4" cellpadding="7" border="0">
53   <table cellspacing="1" cellpadding="2" border="0">
54     <tr>
55       <td align="right">{$i18n.label.person_name} (*):</td>
56       <td>{$forms.userForm.name.control}</td>
57     </tr>
58     <tr>
59       <td align="right">{$i18n.label.login} (*):</td>
60       <td>{$forms.userForm.login.control}</td>
61     </tr>
62 {if !$auth_external}
63     <tr>
64       <td align="right">{$i18n.label.password} (*):</td>
65       <td>{$forms.userForm.pas1.control}</td>
66     </tr>
67     <tr>
68       <td align="right">{$i18n.label.confirm_password} (*):</td>
69       <td>{$forms.userForm.pas2.control}</td>
70     </tr>
71 {/if}
72     <tr>
73       <td align="right" nowrap>{$i18n.label.email}:</td>
74       <td>{$forms.userForm.email.control}</td>
75     </tr>
76     <tr>
77       <td align="right">{$i18n.form.users.role}:</td>
78       <td>{$forms.userForm.role.control} {$forms.userForm.client.control}</td>
79     </tr>
80     <tr>
81       <td align="right">{$i18n.form.users.default_rate}&nbsp;(0{$user->getDecimalMark()}00):</td>
82       <td>{$forms.userForm.rate.control}</td>
83     </tr>
84 {if ($smarty.const.MODE_PROJECTS == $user->getTrackingMode() || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->getTrackingMode())}
85     <tr valign="top">
86       <td align="right">{$i18n.label.projects}:</td>
87       <td>{$forms.userForm.projects.control}</td>
88     </tr>
89     <tr>
90       <td colspan="2" align="center">{$i18n.label.required_fields}</td>
91     </tr>
92 {/if}
93     <tr>
94       <td colspan="2" align="center" height="50">{$forms.userForm.btn_submit.control}</td>
95     </tr>
96   </table>
97 </table>
98 {$forms.userForm.close}