]> git.pld-linux.org Git - packages/eventum.git/blame - eventum-timetracking-advanced-logic.patch
- fix upgrade dir
[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)
f59d3a7e
ER
30--- eventum-20060717/templates/add_time_tracking.tpl.html 2006-07-18 01:37:24.232815764 +0300
31+++ eventum-20060725/templates/add_time_tracking.tpl.html 2006-08-02 10:54:00.044804730 +0300
32@@ -28,6 +28,24 @@
33 {literal}
34 <script language="JavaScript">
35 <!--
a32992b0 36+
f59d3a7e
ER
37+/**
38+ * Make javascript Date() object from datetime form selection.
39+ *
40+ * @param Object f Form object.
41+ * @param String name Form element prefix for date.
42+ */
43+function makeDate(f, name) {
44+ var d = new Date();
45+ d.setFullYear(f.elements[name + '[Year]'].value);
46+ d.setMonth(f.elements[name + '[Month]'].value - 1);
47+ d.setDate(f.elements[name + '[Day]'].value);
48+ d.setHours(f.elements[name + '[Hour]'].value);
49+ d.setMinutes(f.elements[name + '[Minute]'].value);
50+ d.setSeconds(0);
51+ return d;
52+}
a32992b0 53+
f59d3a7e
ER
54 function validateTimeForm(f)
55 {
56 if (isWhitespace(f.summary.value)) {
57@@ -49,7 +67,68 @@
58 alert('{/literal}{t}Please select a valid date of work.{/t}{literal}');
59 return false;
60 }
61- return true;
a32992b0 62+
f59d3a7e
ER
63+ var now = new Date();
64+ var d1 = makeDate(f, 'date');
65+ if (d1 > now) {
66+ alert('{/literal}{t}Start time in the future.{/t}{literal}');
67+ return false;
68+ }
69+ var d2 = makeDate(f, 'date2');
70+ if (d2 > now) {
71+ alert('{/literal}{t}End time in the future.{/t}{literal}');
72+ return false;
73+ }
74+ return true;
75+}
a32992b0 76+
f59d3a7e
ER
77+/**
78+ * @param Object f Form object
79+ * @param Integer type The type of update occouring.
80+ * 0 = Duration was updated.
81+ * 1 = Start time was updated.
82+ * 2 = End time was updated.
83+ * 11 = Start time refresh icon was clicked.
84+ * 12 = End time refresh icon was clicked.
85+ */
86+function calcDateDiff(f, type)
87+{
a32992b0 88+ var duration = f.elements['time_spent'].value;
f59d3a7e 89+ // enforce 5 minute granuality.
a32992b0
ER
90+ duration = Math.floor(duration / 5) * 5;
91+
f59d3a7e
ER
92+ var d1 = makeDate(f, 'date');
93+ var d2 = makeDate(f, 'date2');
a32992b0
ER
94+
95+ var minute = 1000 * 60;
f59d3a7e
ER
96+ /*
97+ - if time is adjusted, duration is calculated,
98+ - if duration is adjusted, the end time is adjusted,
99+ - clicking refresh icon on either icons will make that time current date
100+ and recalculate duration.
101+ */
a32992b0 102+
f59d3a7e
ER
103+ if (type == 0) { // duration
104+ d1.setTime(d2.getTime() - duration * minute);
105+ } else if (type == 1) { // start time
106+ duration = (d2.getTime() - d1.getTime()) / minute;
107+ } else if (type == 2) { // end time
108+ duration = (d2.getTime() - d1.getTime()) / minute;
109+ } else if (type == 11) { // refresh start time
110+ d2.setTime(d1.getTime() + duration * minute);
111+ } else if (type == 12) { // refresh end time
112+ d1.setTime(d2.getTime() - duration * minute);
a32992b0
ER
113+ }
114+
115+ /* refill form after calculation */
116+ updateTimeFields(f.name, 'date[Year]', 'date[Month]', 'date[Day]', 'date[Hour]', 'date[Minute]', d1)
117+ updateTimeFields(f.name, 'date2[Year]', 'date2[Month]', 'date2[Day]', 'date2[Hour]', 'date2[Minute]', d2)
118+
f59d3a7e 119+ duration = parseInt(duration);
a32992b0 120+ if (duration > 0) {
f59d3a7e 121+ f.elements['time_spent'].value = duration;
a32992b0
ER
122+ }
123+
f59d3a7e 124 }
a32992b0
ER
125 //-->
126 </script>
f59d3a7e 127@@ -82,18 +161,30 @@
a32992b0
ER
128 {include file="error_icon.tpl.html" field="category"}
129 </td>
130 </tr>
a32992b0 131+
f59d3a7e 132 <tr>
465c3ab7
ER
133 <td bgcolor="{$internal_color}" class="default_white" width="190" nowrap><b>{t}Time Spent{/t}:</b></td>
134- <td bgcolor="{$light_color}" width="100%"><input class="default" type="text" size="5" name="time_spent" class="default"> <span class="default">({t}in minutes{/t})</span>{include file="error_icon.tpl.html" field="time_spent"}</td>
135+ <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">({t}in minutes{/t})</span>{include file="error_icon.tpl.html" field="time_spent"}</td>
a32992b0
ER
136+ </tr>
137+
138+ <tr>
465c3ab7 139+ <td bgcolor="{$internal_color}" class="default_white" width="190" nowrap><b>{t}Work started{/t}:</b></td>
a32992b0
ER
140+ <td bgcolor="{$light_color}" width="100%">
141+ {html_select_date start_year='-1' day_value_format='%02d' field_array='date' prefix='' all_extra=' class="default" onChange="calcDateDiff(this.form, 1)"'}&nbsp;
142+ {html_select_time minute_interval=5 field_array='date' prefix='' all_extra=' class="default" onChange="calcDateDiff(this.form, 1)"' display_seconds=false}
f59d3a7e 143+ <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'), 11)"><img src="images/icons/refresh.gif" border="0"></a>
a32992b0
ER
144+ </td>
145 </tr>
a32992b0 146+
f59d3a7e
ER
147 <tr>
148- <td bgcolor="{$internal_color}" class="default_white" width="190" nowrap><b>{t}Date of Work{/t}:</b></td>
a32992b0
ER
149+ <td bgcolor="{$internal_color}" class="default_white" width="190" nowrap><b>Work ended:</b></td>
150 <td bgcolor="{$light_color}" width="100%">
151- {html_select_date start_year='-1' day_value_format='%02d' field_array='date' prefix='' all_extra=' class="default"'}&nbsp;
152- {html_select_time minute_interval=5 field_array='date' prefix='' all_extra=' class="default"' display_seconds=false}
153- <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>
154+ {html_select_date start_year='-1' day_value_format='%02d' field_array='date2' prefix='' all_extra=' class="default" onChange="calcDateDiff(this.form, 2)"'}&nbsp;
155+ {html_select_time minute_interval=5 field_array='date2' prefix='' all_extra=' class="default" onChange="calcDateDiff(this.form, 2)"' display_seconds=false}
f59d3a7e 156+ <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'), 12)"><img src="images/icons/refresh.gif" border="0"></a>
a32992b0
ER
157 </td>
158 </tr>
a32992b0 159+
f59d3a7e 160 <tr>
a32992b0
ER
161 <td colspan="2" bgcolor="{$internal_color}" align="center" width="100%" nowrap>
162 <input type="submit" value="Add Time Entry" class="button">
f59d3a7e 163@@ -111,6 +202,7 @@
a32992b0
ER
164 <script language="JavaScript">
165 <!--
166 updateTimeFields('add_time_form', 'date[Year]', 'date[Month]', 'date[Day]', 'date[Hour]', 'date[Minute]');
167+updateTimeFields('add_time_form', 'date2[Year]', 'date2[Month]', 'date2[Day]', 'date2[Hour]', 'date2[Minute]');
168 //-->
169 </script>
170 {include file="app_info.tpl.html"}
This page took 0.280426 seconds and 4 git commands to generate.