1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
|
<?php /** * editmonth.php * * Displays the edit month dialog * * @package TeamCalPro * @version 3.3.001 * @author George Lewe * @copyright Copyright (c) 2004-2010 by George Lewe * @link http://www.lewe.com * @license http://www.lewe.com/tcpro/doc/license.txt Extended GNU Public License */
//echo "<script type=\"text/javascript\">alert(\"Debug: \");</script>";
/** * Set parent flag to control access to child scripts */ define( '_VALID_TCPRO', 1 );
/** * Includes */ require ("config.tcpro.php"); require_once ("includes/functions.tcpro.php"); getOptions(); if (strlen($CONF['options']['lang'])) require ("includes/lang/" . $CONF['options']['lang'] . ".tcpro.php"); else require ("includes/lang/english.tcpro.php");
require_once ("includes/tcconfig.class.php"); require_once ("includes/tcdaynote.class.php"); require_once ("includes/tcholiday.class.php"); require_once ("includes/tclogin.class.php"); require_once ("includes/tclog.class.php"); require_once ("includes/tcmonth.class.php"); require_once ("includes/tcuser.class.php");
if (isset ($_REQUEST['region'])) $region = $_REQUEST['region']; if (isset ($_REQUEST['Year'])) $Year = $_REQUEST['Year']; if (isset ($_REQUEST['Month'])) $Month = $_REQUEST['Month'];
$C = new tcConfig; $H = new tcHoliday; $H2 = new tcHoliday; $L = new tcLogin; $LOG = new tcLog; $M = new tcMonth; $N = new tcDaynote; $UL = new tcUser;
$error = false; $weekdays = $LANG['weekdays'];
/** * Check authorization */ if (!checkAuth("editMonth")) {
$error = true; $err_short = $LANG['err_not_authorized_short']; $err_long = $LANG['err_not_authorized_long']; $err_module = "editcalendar.php";
} else {
/** * First create a timestamp */ $mytime = $Month . " 1," . $Year; $myts = strtotime($mytime); /** * Get number of days in month */ $nofdays = date("t", $myts); /** * Get first weekday of the month */ $mydate = getdate($myts); $monthno = sprintf("%02d", intval($mydate['mon'])); $weekday1 = $mydate['wday']; if ($weekday1 == "0") $weekday1 = "7"; $dayofweek = intval($weekday1);
$found = $M->findByName($region, $Year.$monthno);
if (!$found || !$M->template) { /** * Seems there is no template yet. Let's create a default one */ $M->region = $region; $M->yearmonth = $Year . $monthno; $M->template = createMonthTemplate($Year, $Month); $M->create(); /** * Log this event */ $LOG->log("logMonth", $L->checkLogin(), "Month template created: " . $M->region . " " . $M->yearmonth . " " . $M->template); }
if (isset ($_POST['btn_apply'])) { /** * First clear out the template */ $template = ""; $dayofweek = intval($weekday1); for ($i = 1; $i <= $nofdays; $i++) { switch ($dayofweek) { case 1 : $template .= '0'; break; case 2 : $template .= '0'; break; case 3 : $template .= '0'; break; case 4 : $template .= '0'; break; case 5 : $template .= '0'; break; case 6 : $template .= '1'; break; case 7 : $template .= '1'; break; } $dayofweek += 1; if ($dayofweek == 8) { $dayofweek = 1; } }
/** * Now add the check marks * If several check marks are set for the same day the last day type * row wins. */ foreach ($_POST as $key => $value) { $cfgname = substr($key, 0, 5); if ($H->findByName($cfgname)) { $day = substr($key, 5, 2); $index = intval($day) - 1; $template[$index] = $H->cfgsym; } } /** * Write the new template */ $M->template = $template; $M->update($M->region, $M->yearmonth); /** * Log this event */ $LOG->log("logMonth", $L->checkLogin(), "Month template updated: " . $M->region . " " . $M->yearmonth . " " . $M->template); /** * Send notification e-Mails */ $subject = $LANG['monthnames'][intval($monthno)] . " " . trim($Year); sendNotification("monthchange", $subject, ""); } else if (isset ($_POST['btn_clear'])) { /** * First clear out the template */ $template = ""; $dayofweek = intval($weekday1); for ($i = 1; $i <= $nofdays; $i++) { switch ($dayofweek) { case 1 : $template .= '0'; break; case 2 : $template .= '0'; break; case 3 : $template .= '0'; break; case 4 : $template .= '0'; break; case 5 : $template .= '0'; break; case 6 : $template .= '1'; break; case 7 : $template .= '1'; break; } $dayofweek += 1; if ($dayofweek == 8) { $dayofweek = 1; } }
/** * Write the new template */ $M->template = $template; $M->update($M->region, $M->yearmonth); /** * Log this event */ $LOG->log("logMonth", $L->checkLogin(), "Month template updated: " . $M->region . " " . $M->yearmonth . " " . $M->template); /** * Send notification e-Mails */ $subject = $LANG['monthnames'][intval($monthno)] . " " . trim($Year); sendNotification("monthchange", $subject, ""); } }
/** * Include HTML header */ $currlang = $CONF['options']['lang']; require("includes/header.html.inc.php"); $CONF['options']['lang']=$currlang;
/** * Display error message or the page */ if ($error) { include ("error.php"); } else { ?>
<body> <form name="monthform" method="POST" action="<?=($_SERVER['PHP_SELF']."?lang=".$CONF['options']['lang']."&region=".$region."&Year=".$Year."&Month=".$Month)?>"> <table class="dlg"> <tr> <td class="dlg-header"> <?php printDialogTop($LANG['month_edit']." ".$LANG['monthnames'][intval($monthno)]." ".$Year." (".$LANG['month_region'].": ".$region.")","month_template.html","ico_holidays.png"); ?> </td> </tr> <tr> <td class="dlg-body"> <?php /** * Month frame: Day of month */ ?> <br> <table class="month" cellspacing="0"> <tr> <td class="month"><?=$LANG['monthnames'][intval($monthno)] . " " . trim($Year)?></td> <td class="month-button"> </td> <?php for ($i = 1; $i <= $nofdays; $i = $i +1) { if ($H->findBySymbol($M->template[$i -1])) { if ($H->cfgname == 'busi') { // A business day has a special bgcolor in this dayofmonth row echo "<td class=\"daynum\">" . $i . "</td>"; } else { echo "<td class=\"daynum-" . $H->cfgname . "\">" . $i . "</td>"; } } else { echo "<td class=\"daynum\">" . $i . "</td>"; } }
/** * Month frame: Weekdays */ $x = intval($weekday1); echo " </tr> <tr> <td class=\"title\"> </td> <td class=\"title-button\"> </td>"; for ($i = 1; $i <= $nofdays; $i = $i +1) { if ($H->findBySymbol($M->template[$i -1])) { if ($H->cfgname == 'busi') { // A business day has a special bgcolor in this dayofweek row echo "<td class=\"weekday\">" . $weekdays[$x] . "</td>"; } else { echo "<td class=\"weekday-" . $H->cfgname . "\">" . $weekdays[$x] . "</td>"; } } else { echo "<td class=\"weekday\">" . $weekdays[$x] . "</td>"; } if ($x <= 6) $x += 1; else $x = 1; } echo "</tr>";
/** * Month frame: Daynotes */ $x = intval($weekday1); echo " <tr> <td class=\"name\">" . $LANG['month_daynote'] . "</td> <td class=\"name-button\"> </td>"; for ($i = 1; $i <= $nofdays; $i = $i +1) { if ($i < 10) $dd = "0" . strval($i); else $dd = strval($i); if ($H->findBySymbol($M->template[$i -1])) { if ($H->cfgname == 'busi') { if ($N->findByDay($Year . $monthno . $dd, "all", $region)) $style = "weekday-note"; else $style = "weekday"; } else { if ($N->findByDay($Year . $monthno . $dd, "all", $region)) $style = "weekday-" . $H->cfgname . "-note"; else $style = "weekday-" . $H->cfgname; } } else { if ($N->findByDay($Year . $monthno . $dd, "all", $region)) $style = "weekday-note"; else $style = "weekday"; } echo " <td class=\"" . $style . "\"> <a href=\"javascript:this.blur(); openPopup('daynote.php?lang=" . $CONF['options']['lang'] . "&date=$Year$monthno$dd&daynotefor=all&region=$region&datestring=$dd.%20" . $LANG['monthnames'][intval($monthno)] . "%20$Year','daynote','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,titlebar=0,resizable=0,dependent=1,width=600,height=340');\"> <img src=\"themes/".$theme."/img/ico_daynote.png\" alt=\"\" title=\"" . $LANG['month_daynote_tooltip'] . "\" border=\"0\"> </a> </td>\n"; if ($x <= 6) $x += 1; else $x = 1; } echo "</tr>";
/** * Holiday loop */ $query = "SELECT * FROM `" . $H->table . "` ORDER BY `cfgsym`;"; $result = $H->db->db_query($query); $i = 1; while ($row = $H->db->db_fetch_array($result, MYSQL_ASSOC)) { // Show a row for each type of day except business and weekend. if ($row['cfgsym'] != '0' && $row['cfgsym'] != '1') { echo " <tr> <td class=\"name\">" . $row['dspname'] . "</td> <td class=\"name-button\"> </td>"; for ($count = 0; $count < strlen($M->template); $count++) { if ($M->template[$count] == $row['cfgsym']) { echo " <td class=\"day-" . $row['cfgname'] . "\"> <input name=\"" . $row['cfgname'] . strval($count +1) . "\" id=\"" . $row['cfgname'] . strval($count +1) . "\" type=\"checkbox\" value=\"" . $row['cfgname'] . strval($count +1) . "\" CHECKED>"; } else { if ($H2->findBySymbol($M->template[$count])) { echo "<td class=\"day-" . $H2->cfgname . "\">"; } else { echo "<td class=\"day\">"; } echo "<input name=\"" . $row['cfgname'] . strval($count +1) . "\" id=\"" . $row['cfgname'] . strval($count +1) . "\" type=\"checkbox\" value=\"" . $row['cfgname'] . strval($count +1) . "\">"; } echo "</td>"; } echo "</tr>"; } } echo "</table>"; ?> <br /> </td> </tr> <tr> <td class="dlg-menu"> <input name="btn_clear" type="submit" class="button" value="<?=$LANG['btn_clear']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';"> <input name="btn_apply" type="submit" class="button" value="<?=$LANG['btn_apply']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';"> <input name="btn_help" type="button" class="button" onclick="javascript:this.blur(); openPopup('help/<?=$CONF['options']['helplang']?>/html/index.html?month_template.html','help','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,titlebar=0,resizable=0,dependent=1,width=750,height=500');" value="<?=$LANG['btn_help']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';"> <input name="btn_close" type="button" class="button" onclick="javascript:window.close();" value="<?=$LANG['btn_close']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';"> <input name="btn_done" type="button" class="button" onclick="javascript:closeme();" value="<?=$LANG['btn_done']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';"> </td> </tr> </table> </form> <?php
} require("includes/footer.html.inc.php"); ?>
|