1 --- eventum-1.7.1/js/global.js 2006-05-09 00:45:20.430458749 +0300
2 +++ /home/glen/global.js 2006-05-09 00:46:12.751624134 +0300
7 -function updateTimeFields(form_name, year_field, month_field, day_field, hour_field, minute_field)
8 +function updateTimeFields(form_name, year_field, month_field, day_field, hour_field, minute_field, date)
10 var f = getForm(form_name);
11 - var current_date = new Date();
12 - selectOption(f, month_field, padDateValue(current_date.getMonth()+1));
13 - selectOption(f, day_field, padDateValue(current_date.getDate()));
14 - selectOption(f, year_field, current_date.getFullYear());
15 - selectOption(f, hour_field, padDateValue(current_date.getHours()));
16 - selectOption(f, minute_field, padDateValue(current_date.getMinutes()));
17 + if (typeof date == 'undefined') {
20 + selectOption(f, month_field, padDateValue(date.getMonth()+1));
21 + selectOption(f, day_field, padDateValue(date.getDate()));
22 + selectOption(f, year_field, date.getFullYear());
23 + selectOption(f, hour_field, padDateValue(date.getHours()));
24 + // minutes need special case due the 5 minute granularity
25 + var minutes = Math.floor(date.getMinutes() / 5) * 5;
26 + selectOption(f, minute_field, padDateValue(minutes));
29 function padDateValue(str)
30 --- eventum-1.7.1/templates/en/add_time_tracking.tpl.html 2006-05-09 00:45:21.270477456 +0300
31 +++ /home/glen/add_time_tracking.tpl.html 2006-05-09 00:49:05.375471751 +0300
37 +function calcDateDiff(f, type)
41 + if duration is filled
42 + - if start time is modified, the end time is calculated
43 + - if end time is modified, the start time is calculated
45 + if duration is empty then duration is calculated when you change either
48 + clicking refresh icon on either times will make that time current date and
49 + recalculate duration
52 + var duration = f.elements['time_spent'].value;
53 + duration = Math.floor(duration / 5) * 5;
55 + var d1 = new Date();
56 + d1.setFullYear(f.elements['date[Year]'].value);
57 + d1.setMonth(f.elements['date[Month]'].value - 1);
58 + d1.setDate(f.elements['date[Day]'].value);
59 + d1.setHours(f.elements['date[Hour]'].value);
60 + d1.setMinutes(f.elements['date[Minute]'].value);
63 + var d2 = new Date();
64 + d2.setFullYear(f.elements['date2[Year]'].value);
65 + d2.setMonth(f.elements['date2[Month]'].value - 1);
66 + d2.setDate(f.elements['date2[Day]'].value);
67 + d2.setHours(f.elements['date2[Hour]'].value);
68 + d2.setMinutes(f.elements['date2[Minute]'].value);
71 + var minute = 1000 * 60;
72 + /* decide which time user changed */
73 + if (duration && type != 3) {
74 + // user changed start time or filled duration
75 + if (type == 1 || type == 0) {
76 + d2.setTime(d1.getTime() + duration * minute)
78 + // user changed end time
79 + } else if (type == 2) {
80 + d1.setTime(d2.getTime() - duration * minute)
83 + duration = (d2.getTime() - d1.getTime()) / minute
86 + /* refill form after calculation */
87 + updateTimeFields(f.name, 'date[Year]', 'date[Month]', 'date[Day]', 'date[Hour]', 'date[Minute]', d1)
88 + updateTimeFields(f.name, 'date2[Year]', 'date2[Month]', 'date2[Day]', 'date2[Hour]', 'date2[Minute]', d2)
91 + f.elements['time_spent'].value = parseInt(duration);
99 {include file="error_icon.tpl.html" field="category"}
105 <td bgcolor="{$internal_color}" class="default_white" width="190" nowrap><b>Time Spent:</b></td>
106 - <td bgcolor="{$light_color}" width="100%"><input class="default" type="text" size="5" name="time_spent" class="default"> <span class="default">(in minutes)</span>{include file="error_icon.tpl.html" field="time_spent"}</td>
107 + <td bgcolor="{$light_color}" width="100%"><input class="default" type="text" size="5" name="time_spent" class="default" onChange="calcDateDiff(this.form, 0)"> <span class="default">(in minutes)</span>{include file="error_icon.tpl.html" field="time_spent"}</td>
111 + <td bgcolor="{$internal_color}" class="default_white" width="190" nowrap><b>Work started:</b></td>
112 + <td bgcolor="{$light_color}" width="100%">
113 + {html_select_date start_year='-1' day_value_format='%02d' field_array='date' prefix='' all_extra=' class="default" onChange="calcDateDiff(this.form, 1)"'}
114 + {html_select_time minute_interval=5 field_array='date' prefix='' all_extra=' class="default" onChange="calcDateDiff(this.form, 1)"' display_seconds=false}
115 + <a href="javascript:void(null);" onClick="javascript:updateTimeFields('add_time_form', 'date[Year]', 'date[Month]', 'date[Day]', 'date[Hour]', 'date[Minute]');calcDateDiff(getForm('add_time_form'), 3)"><img src="images/icons/refresh.gif" border="0"></a>
119 - <td bgcolor="{$internal_color}" class="default_white" width="190" nowrap><b>Date of Work:</b></td>
122 + <td bgcolor="{$internal_color}" class="default_white" width="190" nowrap><b>Work ended:</b></td>
123 <td bgcolor="{$light_color}" width="100%">
124 - {html_select_date start_year='-1' day_value_format='%02d' field_array='date' prefix='' all_extra=' class="default"'}
125 - {html_select_time minute_interval=5 field_array='date' prefix='' all_extra=' class="default"' display_seconds=false}
126 - <a href="javascript:void(null);" onClick="javascript:updateTimeFields('add_time_form', 'date[Year]', 'date[Month]', 'date[Day]', 'date[Hour]', 'date[Minute]');"><img src="images/icons/refresh.gif" border="0"></a>
127 + {html_select_date start_year='-1' day_value_format='%02d' field_array='date2' prefix='' all_extra=' class="default" onChange="calcDateDiff(this.form, 2)"'}
128 + {html_select_time minute_interval=5 field_array='date2' prefix='' all_extra=' class="default" onChange="calcDateDiff(this.form, 2)"' display_seconds=false}
129 + <a href="javascript:void(null);" onClick="javascript:updateTimeFields('add_time_form', 'date2[Year]', 'date2[Month]', 'date2[Day]', 'date2[Hour]', 'date2[Minute]'); calcDateDiff(getForm('add_time_form'), 3)"><img src="images/icons/refresh.gif" border="0"></a>
135 <td colspan="2" bgcolor="{$internal_color}" align="center" width="100%" nowrap>
136 <input type="submit" value="Add Time Entry" class="button">
139 <script language="JavaScript">
141 updateTimeFields('add_time_form', 'date[Year]', 'date[Month]', 'date[Day]', 'date[Hour]', 'date[Minute]');
142 +updateTimeFields('add_time_form', 'date2[Year]', 'date2[Month]', 'date2[Day]', 'date2[Hour]', 'date2[Minute]');
145 {include file="app_info.tpl.html"}
147 -{include file="footer.tpl.html"}
148 \ No newline at end of file
149 +{include file="footer.tpl.html"}