move edit link to a different column in order to free up horizontal s… (#11)
[timetracker.git] / WEB-INF / templates / mobile / expenses.tpl
1 <script>
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.
4 // Format:
5 // project_ids[143] = "325,370,390,400";  // Comma-separated list of project ids for client.
6 // project_names[325] = "Time Tracker";   // Project name.
7
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}";
12 {/foreach}
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'}";
17 {/foreach}
18 // We'll use this array to populate project dropdown when client is not selected.
19 var idx = 0;
20 projects = new Array();
21 {foreach $project_list as $project}
22   projects[idx] = new Array("{$project.id}", "{$project.name|escape:'javascript'}");
23   idx++;
24 {/foreach}
25
26 // Mandatory top option for project dropdown.
27 empty_label_project = '{$i18n.dropdown.select|escape:'javascript'}';
28
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;
36
37   // Remove existing content.
38   dropdown.length = 0;
39   // Add mandatory top option.
40   dropdown.options[0] = new Option(empty_label_project, '', true);
41
42   // Populate project dropdown.
43   if (!id) {
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;
50     }
51   } else if (str_ids) {
52     var ids = new Array();
53     ids = str_ids.split(",");
54     var len = ids.length;
55
56     for (var i = 0; i < len; i++) {
57       var p_id = ids[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;
61     }
62   }
63 }
64
65 function get_date() {
66   var date = new Date();
67   return date.strftime("%Y-%m-%d");
68 }
69 </script>
70
71 <!-- Inserted from time.tpl -->
72 <table cellspacing="3" cellpadding="0" border="0" width="100%">
73   <tr>
74     <td class="sectionHeaderNoBorder" align="right"><a href="expenses.php?date={$prev_date}">&lt;&lt;</a></td>
75     <td class="sectionHeaderNoBorder" align="center">{$timestring}</td>
76     <td class="sectionHeaderNoBorder" align="left"><a href="expenses.php?date={$next_date}">&gt;&gt;</a></td>
77   </tr>
78 </table>
79
80 {$forms.expensesForm.open}
81 <table cellspacing="4" cellpadding="0" border="0">
82   <tr>
83     <td valign="top">
84       <table>
85 {if $on_behalf_control}
86         <tr>
87           <td align="right">{$i18n.label.user}:</td>
88           <td>{$forms.expensesForm.onBehalfUser.control}</td>
89         </tr>
90 {/if}
91 {if $user->isPluginEnabled('cl')}
92         <tr>
93           <td align="right">{$i18n.label.client}{if $user->isPluginEnabled('cm')} (*){/if}:</td>
94           <td>{$forms.expensesForm.client.control}</td>
95         </tr>
96 {/if}
97 {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
98         <tr>
99           <td align="right">{$i18n.label.project} (*):</td>
100           <td>{$forms.expensesForm.project.control}</td>
101         </tr>
102 {/if}
103         <tr>
104           <td align="right">{$i18n.label.item} (*):</td>
105           <td>{$forms.expensesForm.item_name.control}</td>
106         </tr>
107         <tr>
108           <td align="right">{$i18n.label.cost} (*):</td>
109           <td>{$forms.expensesForm.cost.control} {$user->currency|escape:'html'}</td>
110         </tr>
111       </table>
112     </td>
113     <!--
114     <td valign="top">
115       <table>
116         <tr><td>{$forms.expensesForm.date.control}</td></tr>
117       </table>
118     </td>
119     -->
120   </tr>
121 </table>
122
123 <table>
124   <tr>
125     <td align="center" colspan="2">{$forms.expensesForm.btn_submit.control}</td>
126   </tr>
127 </table>
128
129 <table class="mobile-table">
130 <tr>
131   <td valign="top">
132 {if $expense_items}
133       <table class="mobile-table-details">
134       <tr>
135   {if $user->isPluginEnabled('cl')}
136         <td width="20%" class="tableHeader">{$i18n.label.client}</td>
137   {/if}
138   {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
139         <td class="tableHeader">{$i18n.label.project}</td>
140   {/if}
141         <td class="tableHeader">{$i18n.label.item}</td>
142         <td width="5%" class="tableHeaderCentered">{$i18n.label.cost}</td>
143       </tr>
144   {foreach $expense_items as $item}
145       <tr bgcolor="{cycle values="#f5f5f5,#ccccce"}">
146     {if $user->isPluginEnabled('cl')}
147         <td valign='top'>{$item.client|escape:'html'}</td>
148     {/if}
149     {if ($smarty.const.MODE_PROJECTS == $user->tracking_mode || $smarty.const.MODE_PROJECTS_AND_TASKS == $user->tracking_mode)}
150         <td valign='top'>{$item.project|escape:'html'}</td>
151     {/if}
152         <td valign='top'>{if $item.invoice_id} {$item.item|escape:'html'} {else}<a href='expense_edit.php?id={$item.id}'>{$item.item|escape:'html'}</a>{/if}</td>
153         <td valign='top' align='right'>{$item.cost}</td>
154       </tr>
155   {/foreach}
156     </table>
157     <table border="0" cellpadding="3" cellspacing="1" width="100%">
158       <tr>
159         <td nowrap align="right">{$i18n.label.day_total}: {$user->currency|escape:'html'} {$day_total}</td>
160       </tr>
161     </table>
162 {/if}
163   </td>
164 </tr>
165 </table>
166
167 {$forms.expensesForm.close}