2 // We need a few arrays to populate project dropdown.
3 // When client selection changes, the project dropdown must be re-populated with only relevant projects.
5 // project_ids[143] = "325,370,390,400"; // Comma-separated list of project ids for client.
6 // project_names[325] = "Time Tracker"; // Project name.
8 // Prepare an array of project ids for clients.
9 project_ids = new Array();
10 {foreach $client_list as $client}
11 project_ids[{$client.id}] = "{$client.projects}";
13 // Prepare an array of project names.
14 project_names = new Array();
15 {foreach $project_list as $project}
16 project_names[{$project.id}] = "{$project.name|escape:'javascript'}";
18 // We'll use this array to populate project dropdown when client is not selected.
20 projects = new Array();
21 {foreach $project_list as $project}
22 projects[idx] = new Array("{$project.id}", "{$project.name|escape:'javascript'}");
26 // Mandatory top option for project dropdown.
27 empty_label_project = "{$i18n.dropdown.select|escape:'javascript'}";
29 // The fillProjectDropdown function populates the project combo box with
30 // projects associated with a selected client (client id is passed here as id).
31 function fillProjectDropdown(id) {
32 var str_ids = project_ids[id];
33 var dropdown = document.getElementById("project");
34 // Determine previously selected item.
35 var selected_item = dropdown.options[dropdown.selectedIndex].value;
37 // Remove existing content.
39 // Add mandatory top option.
40 dropdown.options[0] = new Option(empty_label_project, '', true);
42 // Populate project dropdown.
44 // If we are here, client is not selected.
45 var len = projects.length;
46 for (var i = 0; i < len; i++) {
47 dropdown.options[i+1] = new Option(projects[i][1], projects[i][0]);
48 if (dropdown.options[i+1].value == selected_item)
49 dropdown.options[i+1].selected = true;
52 var ids = new Array();
53 ids = str_ids.split(",");
56 for (var i = 0; i < len; i++) {
58 dropdown.options[i+1] = new Option(project_names[p_id], p_id);
59 if (dropdown.options[i+1].value == selected_item)
60 dropdown.options[i+1].selected = true;
66 var date = new Date();
67 return date.strftime("%Y-%m-%d");
71 {$forms.expenseItemForm.open}
72 <table cellspacing="4" cellpadding="7" border="0">
75 <table width = "100%">
79 {if $user->isPluginEnabled('cl')}
81 <td align="right">{$i18n.label.client} {if $user->isPluginEnabled('cm')}(*){/if}:</td>
82 <td>{$forms.expenseItemForm.client.control}</td>
85 {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
87 <td align="right">{$i18n.label.project} (*):</td>
88 <td>{$forms.expenseItemForm.project.control}</td>
92 <td align="right">{$i18n.label.item}:</td>
93 <td>{$forms.expenseItemForm.item_name.control}</td>
96 <td align="right">{$i18n.label.cost}:</td>
97 <td>{$forms.expenseItemForm.cost.control} {$user->currency|escape}</td>
100 <td align="right">{$i18n.label.date}:</td>
101 <td>{$forms.expenseItemForm.date.control}</td>
104 <td colspan="2"> </td>
108 <td align="left">{$forms.expenseItemForm.btn_save.control} {$forms.expenseItemForm.btn_copy.control} {$forms.expenseItemForm.btn_delete.control}</td>
117 {$forms.expenseItemForm.close}