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.expensesForm.open}
72 <table cellspacing="4" cellpadding="0" border="0">
76 {if $on_behalf_control}
78 <td align="right">{$i18n.label.user}:</td>
79 <td>{$forms.expensesForm.onBehalfUser.control}</td>
82 {if in_array('cl', explode(',', $user->plugins))}
84 <td align="right">{$i18n.label.client}{if in_array('cm', explode(',', $user->plugins))} (*){/if}:</td>
85 <td>{$forms.expensesForm.client.control}</td>
88 {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
90 <td align="right">{$i18n.label.project} (*):</td>
91 <td>{$forms.expensesForm.project.control}</td>
95 <td align="right">{$i18n.label.item} (*):</td>
96 <td>{$forms.expensesForm.item_name.control}</td>
99 <td align="right">{$i18n.label.cost} (*):</td>
100 <td>{$forms.expensesForm.cost.control} {$user->currency|escape:'html'}</td>
106 <tr><td>{$forms.expensesForm.date.control}</td></tr>
114 <td align="center" colspan="2">{$forms.expensesForm.btn_submit.control}</td>
122 <table border="0" cellpadding="3" cellspacing="1" width="100%">
124 {if in_array('cl', explode(',', $user->plugins))}
125 <td width="20%" class="tableHeader">{$i18n.label.client}</td>
127 {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
128 <td class="tableHeader">{$i18n.label.project}</td>
130 <td class="tableHeader">{$i18n.label.item}</td>
131 <td width="5%" class="tableHeaderCentered">{$i18n.label.cost}</td>
132 <td width="5%" class="tableHeader">{$i18n.label.edit}</td>
134 {foreach $expense_items as $item}
135 <tr bgcolor="{cycle values="#f5f5f5,#ccccce"}">
136 {if in_array('cl', explode(',', $user->plugins))}
137 <td valign='top'>{$item.client|escape:'html'}</td>
139 {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
140 <td valign='top'>{$item.project|escape:'html'}</td>
142 <td valign='top'>{$item.item|escape:'html'}</td>
143 <td valign='top' align='right'>{$item.cost}</td>
144 <td valign='top' align='center'>
145 {if $item.invoice_id}
148 <a href='expense_edit.php?id={$item.id}'>{$i18n.label.edit}</a>
155 <table border="0" cellpadding="3" cellspacing="1" width="100%">
157 <td nowrap align="right">{$i18n.label.day_total}: {$user->currency|escape:'html'} {$day_total}</td>
166 {$forms.expensesForm.close}