C:\$Recycle.Bin\S-1-5-21-3967099092-2644009230-141905953-500\$R30CG93\tcpro\showyear.php


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
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
<?php
/**
 * showyear.php
 * 
 * Displays the yearly calendar view page 
 * 
 * @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');

/**
 * 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/functions.tcpro.php" );
require_once( 
"includes/tcabsence.class.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/tcmonth.class.php" );
require_once( 
"includes/tctemplate.class.php" );
require_once( 
"includes/tcuser.class.php" );
require_once( 
"includes/tcusergroup.class.php" );
require_once( 
"includes/tcuseroption.class.php" );

$A  = new tcAbsence;
$C  = new tcConfig;
$D  = new tcDaynote;
$H  = new tcHoliday;
$L  = new tcLogin;
$M  = new tcMonth;
$T  = new tcTemplate;
$U  = new tcUser;
$UG = new tcUserGroup;
$UL = new tcUser;
$UO = new tcUserOption;

/**
 * Compute date stuff 
 */
$monthnames $CONF['monthnames'];
$weekdays $CONF['weekdays'];
$today     getdate();
$curryear  $today['year'];  // A full numeric representation of todays' year, 4 digits
$currmonth $today['mon'];   // Numeric representation of todays' month
$currday   $today['mday'];  // Numeric representation of todays' day of the month

/**
 * Get the year to display 
 */
if (isset($_REQUEST['showyear']) && strlen($_REQUEST['showyear'])==&& is_numeric($_REQUEST['showyear']) ) $showyear $_REQUEST['showyear'];
else 
$showyear $curryear;
if (isset(
$_POST['year'])) $showyear trim($_POST['year']);

/**
 * Get the user to display 
 */
if (isset($_REQUEST['showuser'])) {
   if (
checkAuth("viewYearCalendar",$_REQUEST['showuser'])) $showuser trim($_REQUEST['showuser']);   
   else 
$showuser=$L->checkLogin();
}
else 
$showuser=$L->checkLogin();

if ( 
$showuser=="admin" ) {
   
$query  "SELECT username FROM `".$U->table."` WHERE username != 'admin' ORDER BY `lastname`,`firstname`;";
   
$result $U->db->db_query($query);
   
$row $U->db->db_fetch_array($result,MYSQL_ASSOC);
   
$showuser=$row['username'];
}
if (isset(
$_POST['user'])) $showuser trim($_POST['user']);

/**
 * Check authorization 
 */
if ( !checkAuth("viewYearCalendar",$showuser) ) {
   
// Not authorized. Get outta here
   
jsReload("index.php");
}
 
$U->findByName($showuser);
$showuserfullname $U->firstname." ".$U->lastname;
$showuserbday=$U->birthday;

/**
 * Build the year array
 * First, initialze
 */
$yarray = array (
   
=> array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
=> array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
=> array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
=> array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
=> array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
=> array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
=> array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
=> array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
=> array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
10 => array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
11 => array ( "nofdays"=> 31"fwday"=>1"tpl"=>""), 
   
12 => array ( "nofdays"=> 31"fwday"=>1"tpl"=>""
);

/**
 * Now get the real values into the array
 */
for ($i=1$i<=12$i++) {
   
$mytime $monthnames[$i] . " 1," $showyear;
   
$myts strtotime($mytime);
   
$yarray[$i]['nofdays']=date("t",$myts);
   
$mydate getdate($myts);
   
$monthno sprintf("%02d",intval($mydate['mon']));
   
$weekday1 $mydate['wday'];
   if (
$weekday1=="0"$weekday1="7";
   
$yarray[$i]['fwday'] = $weekday1;
   
$found $M->findByName($CONF['options']['region'],$showyear.$monthno);
   if ( !
$found ) {
      
/**
       * Seems there is no default template for this month yet. 
       * Let's create a default one.
       */
      
$M->region=$CONF['options']['region'];
      
$M->yearmonth $showyear.$monthno;
      
$M->template createMonthTemplate(strval($showyear),$monthnames[$i]);
      
$M->create();
   } else if ( empty(
$M->template) ) {
      
/**
       * Seems there is an empty default template. That can't be.
       * Let's create a default one.
       */
      
$M->template createMonthTemplate(strval($showyear),$monthnames[$i]);
      
$M->update($CONF['options']['region'],$showyear.$monthno);
   }
   
$yarray[$i]['tpl'] = $M->template;
}

/**
 * Build the page 
 */
require( "includes/header.html.inc.php" );
echo 
"<body>\r\n";
echo 
"<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>";
require( 
"includes/header.application.inc.php" );
require( 
"includes/menu.inc.php" );
?>

   <table width="100%" cellpadding="0" cellspacing="0" border="0">
      <tr>
         <td VALIGN="top">
            <table class="dlg" cellpadding="0" cellspacing="0" border="0">
               <tr>
                  <td class="dlg-header" colspan="2" style="border-bottom: 1px solid #000000;">
                     <?php printDialogTop($LANG['showyear_title_1']."&nbsp;".$showyear."&nbsp;".$LANG['showyear_title_2']."&nbsp;&nbsp;".$showuserfullname,"year_calendar_display.html","ico_calendar.png"); ?>
                  </td>
               </tr>
            </table>
         </td>
      </tr>
   </table>
   <br>   
   
   <table class="year" cellpadding="0" cellspacing="0" border="0">
      
      <!-- HEADER ROW -->
      <tr>
         <td class="year" colspan="2"><?=$showyear?></td>
         <?php
         
for ($i=1;$i<=37;$i++) {
            if ((
$j=$i%7)==0$j=7;
            
$class="yweekday";
            if (
$j>5$class="yweekday-wend";
            echo 
"<td class=\"".$class."\">".$LANG['weekdays'][$j]."</td>\n";
         }
         
?>
      </tr>
      
      <!-- MONTHS -->
      <?php
      
/**
       * Loop through each month
       */
      
for ($m=1$m<=12$m++) {
         
/**
          * Get month template
          */
         
$monthno sprintf("%02d",$m);
         
$M->findByName($CONF['options']['region'],$showyear.$monthno);
         
/**
          * Try to find this users template for this month
          */
         
$found $T->findTemplate($showuser,$showyear,$monthno);
         if (!
$found || !strlen($T->template)) {
            
/**
             * No template found for this user and month.
             * Create a default one.
             */
            
$T->username $showuser;
            
$T->year $showyear;
            
$T->month $monthno;
            
$T->template "";
            for (
$t=0$t<$yarray[$m]['nofdays']; $t++ ) {
               
$T->template .= $CONF['present'];
            }
            
$T->create();
         }
         
         
/**
          * Top row: Month name and Day numbers
          */
         
echo "<!-- ".strtoupper($monthnames[$m])." -->\n";
         echo 
"<!-- Top row: Month name and Day numbers -->\n";
         echo 
"<tr>\n";
         echo 
"<td class=\"ymonth\" rowspan=\"3\">".$LANG['monthnames'][$m]."</td>\n";
         
$buttoncell="<td class=\"ymonthb\" rowspan=\"3\">";
         if ( 
checkAuth("editMonth") ) {
            
$buttoncell.="<a href=\"javascript:openPopup('editmonth.php?lang=".$CONF['options']['lang']."&amp;Year=".$showyear."&amp;Month=".$monthnames[$m]."','shop','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=no,dependent=1,width=860,height=300');\"><img class=\"noprint\" src=\"themes/".$theme."/img/date.png\" width=\"16\" height=\"16\" border=\"0\" title=\"".$LANG['cal_img_alt_edit_month']."\" alt=\"".$LANG['cal_img_alt_edit_month']."\"></a>\n\r";
         }
         if ( 
checkAuth("editCalendar",$showuser) ) {
            
$buttoncell.="<br><a href=\"javascript:openPopup('editcalendar.php?lang=".$CONF['options']['lang']."&amp;Year=".$showyear."&amp;Month=".$monthnames[$m]."&amp;Member=".$showuser."','shop','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=no,dependent=1,width=880,height=520');\"><img class=\"noprint\" src=\"themes/".$theme."/img/btn_edit.gif\" width=\"16\" height=\"16\" border=\"0\" title=\"".$LANG['cal_img_alt_edit_cal']."\" alt=\"".$LANG['cal_img_alt_edit_cal']."\"></a>\n\r";
         }
         
$buttoncell.="</td>\n\r";
         echo 
$buttoncell;
         for (
$i=1;$i<=37;$i++) {
            if (
$i<$yarray[$m]['fwday']) {
               
/**
                * Not a day. Gray out this cell.
                */
               
$class="yndaytop";
               echo 
"<td class=\"".$class."\">&nbsp;</td>\n";
            }
            else if (
$i==$yarray[$m]['fwday']) {
               for (
$n=1;$n<=$yarray[$m]['nofdays'];$n++) {
                  
$class=" class=\"ydaytop\"";
                  
$title="";
                  
$addstyle="";
                  
$onmouseover="";
                  
$onmouseout="";
                  if ( 
$H->findBySymbol($M->template[$n-1]) ) {
                     if ( 
$H->cfgname=='busi' ) {
                        
/**
                         * Regular business day
                         */
                        
$title=" title=\"".$H->dspname."\"";
                     } else {
                        
/**
                         * Holiday or any other non-busi day
                         */
                        
$title=" title=\"".$H->dspname."\"";
                        
$addstyle.="background-color: #".$H->dspbgcolor.";";
                     }
                  }
                  
/**
                   * Get general Daynote into $title if one exists
                   */
                  
$dd sprintf("%02d",$n);
                  if ( 
$D->findByDay($showyear.$monthno.$dd,"all") ) {
                     
$tt_settings=str_replace("Information",$LANG['showyear_tt_day'],$CONF['ovl_tt_settings']);
                     
$onmouseover=" onmouseover=\"return overlib('".$D->daynote."',".$tt_settings.");\"";
                     
$onmouseout=" onmouseout=\"return nd();\"";
                     
$addstyle.=" background-image: url(themes/".$theme."/img/ovl_daynote.gif); background-repeat: no-repeat; background-position: top right;";
                     
$title="";
                  }
                  if ( 
$showyear==$curryear && $m==$currmonth && $n==$currday ) {
                     
$addstyle.=" border-left: 2px solid #".$C->readConfig("todayBorderColor")."; border-right: 2px solid #".$C->readConfig("todayBorderColor")."; border-top: 2px solid #".$C->readConfig("todayBorderColor").";";
                  }
                  if (
strlen($addstyle)) $addstyle " style=\"".$addstyle."\"";
                  echo 
"<td".$class.$addstyle.$title.$onmouseover.$onmouseout.">".$n."</td>\n";
                  
$i++;
               }
               
$i--;
            }
            else {
               
/**
                * Not a day. Gray out this cell.
                */
               
$class="yndaytop";
               echo 
"<td class=\"".$class."\">&nbsp;</td>\n";
            }
         }
         echo 
"</tr>\n";
         
/**
          * Middle row: Absences
          */
         
echo "<!-- Middle row: Absences -->\n";
         echo 
"<tr>\n";
         for (
$i=1;$i<=37;$i++) {
            if (
$i<$yarray[$m]['fwday']) {
               
/**
                * Not a day. Gray out this cell.
                */
               
$class="yndaymid";
               echo 
"<td class=\"".$class."\">&nbsp;</td>\n";
            }
            else if (
$i==$yarray[$m]['fwday']) {
               for (
$n=1;$n<=$yarray[$m]['nofdays'];$n++) {
                  
/**
                   * Set style and color background bases on holiday
                   */
                  
$class=" class=\"ydaymid\"";
                  
$title="";
                  
$addstyle="";
                  
$onmouseover="";
                  
$onmouseout="";
                  
$content="";
                  if ( 
$H->findBySymbol($M->template[$n-1]) ) {
                     if ( 
$H->cfgname!='busi' ) {
                        
// Holiday or any other non-busi day
                        
if ( substr_count($addstyle,"background-color: #") ) {
                           
$pos=strpos($addstyle,"background-color: #");
                           
$replace="background-color: #".$H->dspbgcolor.";";
                           
$addstyle=substr_replace($addstyle,$replace,$pos,26);
                        }
                        else 
                           
$addstyle.="background-color: #".$H->dspbgcolor.";";
                     }
                  }
                  
                  
/**
                   * Set birthday note if applicable
                   */
                  
$popup="";
                  
$birthday=false;
                  
$daynote=false;
                  if ( 
substr($showuserbday,4)==(sprintf("%02d",$m).sprintf("%02d",$n)) && ($UO->true($showuser,"showbirthday")) ) {
                     
/**
                      * Birthday
                      */
                     
if($UO->true($showuser,"ignoreage")) {
                        
$birthdate=date("d M",strtotime($showuserbday));
                        
$popup  "* ".$LANG['cal_birthday'].": ".$birthdate." * <br><br>";
                     } else {
                        
$birthdate=date("d M Y",strtotime($showuserbday));
                        
$dayofbirth=date("d M",strtotime($showuserbday));
                        
$age=intval($showyear)-intval(substr($showuserbday,0,4));
                        
$popup  "* ".$LANG['cal_birthday'].": ".$birthdate;
                        
$popup .= " (".$LANG['cal_age'].": ".$age.") * <br><br>";
                     }
                     
$birthday=true;
                  }
                  
                  
/**
                   * Set personal daynote if applicable
                   */
                  
if ( $D->findByDay($showyear.$monthno.sprintf("%02d",$n),$showuser) ) {
                     
$popup.=$D->daynote;
                     
$daynote=true;
                  }
                  
                  
/**
                   * Build the popup message from above findings
                   */
                  
if ( strlen($popup) ) {
                     
$tt_settings=str_replace("Information",$LANG['showyear_tt_user'],$CONF['ovl_tt_settings']);
                     
$onmouseover=" onmouseover=\"return overlib('".$popup."',".$tt_settings.");\"";
                     
$onmouseout=" onmouseout=\"return nd();\"";
                     if (
$birthday && !$daynote$marker="ovl_birthday.gif";
                     if (!
$birthday && $daynote$marker="ovl_daynote.gif";
                     if (
$birthday && $daynote$marker="ovl_bdaynote.gif";
                     
$addstyle.=" background-image: url(themes/".$theme."/img/".$marker."); background-repeat: no-repeat; background-position: top right;";
                  }
                  
                  
/**
                   * Set style and color background based on absence.
                   * This overwrites the holiday settings.
                   */
                  
$A->findBySymbol($T->template[$n-1]);
                  if (
$A->cfgsym != $CONF['present'] ) {
                     
$title=" title=\"".$A->dspname."\"";
                     if ( 
substr_count($addstyle,"background-color: #") ) {
                        
$pos=strpos($addstyle,"background-color: #");
                        
$replace="background-color: #".$A->dspbgcolor.";";
                        
$addstyle=substr_replace($addstyle,$replace,$pos,26);
                     }
                     else 
                        
$addstyle.=" background-color: #".$A->dspbgcolor.";";
                     
                     
$addstyle.=" color: #" $A->dspcolor.";";
                     if (
$A->iconfile) {
                        
$content="<img align=\"top\" alt=\"\" src=\"".$CONF['app_icon_dir'].$A->iconfile."\" width=\"16\" height=\"16\">";
                     }
                     else { 
                        
$content=$A->dspsym;
                     }
                  } 
                  else { 
                     
$content="&nbsp;";
                  }
                  
                  
/**
                   * Draw the cell
                   */
                  
if ( $showyear==$curryear && $m==$currmonth && $n==$currday ) {
                     
$addstyle.=" border-left: 2px solid #".$C->readConfig("todayBorderColor")."; border-right: 2px solid #".$C->readConfig("todayBorderColor").";";
                  }
                  if (
strlen($addstyle)) $addstyle " style=\"".$addstyle."\"";
                  if ( 
strlen($popup) ) $title="";
                  echo 
"<td".$class.$addstyle.$title.$onmouseover.$onmouseout.">".$content."</td>\n";
                  
$i++;
               }
               
$i--;
            }
            else {
               
/**
                * Not a day. Gray out this cell.
                */
               
$class="yndaymid";
               echo 
"<td class=\"".$class."\">&nbsp;</td>\n";
            }
         }
         echo 
"</tr>\n";
         
/**
          * Bottom row: Week numbers
          */
         
echo "<!-- Bottom row: Week numbers -->\n";
         echo 
"<tr>\n";
         for (
$i=1;$i<=37;$i++) {
            if (
$i<$yarray[$m]['fwday']) {
               
/**
                * Not a day. Gray out this cell.
                */
               
$class="yndaybot";
               echo 
"<td class=\"".$class."\">&nbsp;</td>\n";
            }
            else if (
$i==$yarray[$m]['fwday']) {
               for (
$n=1;$n<=$yarray[$m]['nofdays'];$n++) {
                  
$class=" class=\"ydaybot\"";
                  
$title="";
                  
$addstyle="";
                  
$onmouseover="";
                  
$onmouseout="";
                  if ( 
$H->findBySymbol($M->template[$n-1]) ) {
                     if ( 
$H->cfgname=='busi' ) {
                        
/**
                         * Regular business day
                         */
                        
$title=" title=\"".$H->dspname."\"";
                     } else {
                        
/**
                         * Holiday or any other non-busi day
                         */
                        
$addstyle.="background-color: #".$H->dspbgcolor.";";
                        
$title=" title=\"".$H->dspname."\"";
                     }
                  }
                  if ( 
$showyear==$curryear && $m==$currmonth && $n==$currday ) {
                     
$addstyle.=" border-left: 2px solid #".$C->readConfig("todayBorderColor")."; border-right: 2px solid #".$C->readConfig("todayBorderColor")."; border-bottom: 2px solid #".$C->readConfig("todayBorderColor").";";
                  }
                  if ((
$i%7)==1) {
                     
$w=sprintf("%d",date("W",mktime(0,0,0,$m,$n,$showyear)));
                     
$title=" title=\"".$LANG['showyear_weeknumber']." ".$w."\"";
                  }
                  else {
                     
$w="&nbsp;";   
                  }
                  if (
strlen($addstyle)) $addstyle " style=\"".$addstyle."\"";
                  echo 
"<td".$class.$addstyle.$title.$onmouseover.$onmouseout.">".$w."</td>\n";
                  
$i++;
               }
               
$i--;
            }
            else {
               
/**
                * Not a day. Gray out this cell.
                */
               
$class="yndaybot";
               echo 
"<td class=\"".$class."\">&nbsp;</td>\n";
            }
         }
         echo 
"</tr>\n";
      }
      
?>

   </table>

<?php
require( "includes/footer.html.inc.php" );
?>