]> git.pld-linux.org Git - packages/eventum.git/blame - eventum-timetracking-advanced-logic.patch
- ugly hack unneccessary as it was caused by but which is fixed by eventum-unbalanced...
[packages/eventum.git] / eventum-timetracking-advanced-logic.patch
CommitLineData
a32992b0
ER
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
3@@ -143,15 +143,19 @@
4 popupWin.focus();
5 }
6
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)
9 {
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') {
18+ date = new Date();
19+ }
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));
27 }
28
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
32@@ -51,6 +51,65 @@
33 }
34 return true;
35 }
36+
37+function calcDateDiff(f, type)
38+{
39+ /*
40+ Logic:
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
44+
45+ if duration is empty then duration is calculated when you change either
46+ start or end time.
47+
48+ clicking refresh icon on either times will make that time current date and
49+ recalculate duration
50+
51+ */
52+ var duration = f.elements['time_spent'].value;
53+ duration = Math.floor(duration / 5) * 5;
54+
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);
61+ d1.setSeconds(0);
62+
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);
69+ d2.setSeconds(0);
70+
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)
77+
78+ // user changed end time
79+ } else if (type == 2) {
80+ d1.setTime(d2.getTime() - duration * minute)
81+ }
82+ } else if (type) {
83+ duration = (d2.getTime() - d1.getTime()) / minute
84+ }
85+
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)
89+
90+ if (duration > 0) {
91+ f.elements['time_spent'].value = parseInt(duration);
92+ }
93+
94+}
95 //-->
96 </script>
97 {/literal}
98@@ -82,19 +141,31 @@
99 {include file="error_icon.tpl.html" field="category"}
100 </td>
101 </tr>
102- <tr>
103+
104+ <tr>
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>
108+ </tr>
109+
110+ <tr>
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)"'}&nbsp;
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>
116+ </td>
117 </tr>
118- <tr>
119- <td bgcolor="{$internal_color}" class="default_white" width="190" nowrap><b>Date of Work:</b></td>
120+
121+ <tr>
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"'}&nbsp;
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)"'}&nbsp;
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>
130 </td>
131 </tr>
132- <tr>
133+
134+ <tr>
135 <td colspan="2" bgcolor="{$internal_color}" align="center" width="100%" nowrap>
136 <input type="submit" value="Add Time Entry" class="button">
137 </td>
138@@ -111,8 +182,9 @@
139 <script language="JavaScript">
140 <!--
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]');
143 //-->
144 </script>
145 {include file="app_info.tpl.html"}
146 {/if}
147-{include file="footer.tpl.html"}
148\ No newline at end of file
149+{include file="footer.tpl.html"}
This page took 0.072235 seconds and 4 git commands to generate.