C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\heimam\tcpro\holidays.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
<?php
/**
 * holidays.php
 * 
 * Displays the groups administration 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/tcabsence.class.php" );
require_once( 
"includes/tcallowance.class.php" );
require_once( 
"includes/tcconfig.class.php" );
require_once( 
"includes/tcholiday.class.php" );
require_once( 
"includes/tclog.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;
$B = new tcAllowance;
$C = new tcConfig;
$H = new tcHoliday
$L = new tcLogin
$LOG = new tcLog;
$M = new tcMonth
$T  = new tcTemplate;
$U  = new tcUser;
$UG = new tcUserGroup;
$UO = new tcUserOption;

$error false;

$monthnames $CONF['monthnames'];
$today getdate();
$curryear $today['year']; // numeric value, 4 digits
$currmonth $today['mon']; // numeric value
$themearray getThemes();

/**
 * Check if allowed 
 */
if (!checkAuth("admin")) {
   
// Not authorized. Get outta here
   
jsReload("index.php");
}

/**
 * Add Holiday 
 */
if ( isset($_POST['btn_hol_add']) ) {
     
   if ( 
strlen($_POST['hol_nameadd']) && strlen($_POST['hol_coloradd']) && strlen($_POST['hol_bgcoloradd']) ) {
      
/**
       * The user needs not to be bothered with the symbol that is used
       * to identify this day type internally since it is never displayed
       * to him. So we have to chose one ourselves. 0 is business day and
       * 1 is weekend. So we have 34 more (should be sufficient).
       */
      
$symbols "23456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
      
// Get next available symbol
      
$query  "SELECT * FROM `".$H->table."` ORDER BY `cfgsym`;";
      
$result=$H->db->db_query($query);
      for ( 
$i=0$i<strlen($symbols); $i++ ) {
         
$taken=false;
         while (
$row $H->db->db_fetch_array($result,MYSQL_ASSOC)) {
            if ( 
$row['cfgsym']==$symbols[$i] ) {
               
$taken=true;
               break;
            }
         }
         if (!
$taken) break;
      }
      if ( !
$taken ) {
         
$hol_symadd $symbols[$i];
         
$H->cfgsym=strtoupper(trim($hol_symadd));
         
$H->cfgname="d".strval(rand(1000,9999));
         
$H->dspsym=strtoupper(trim($hol_symadd));
         
$H->dspname=trim($_POST['hol_nameadd']);
         
$H->dspcolor=strtoupper(trim($_POST['hol_coloradd']));
         
$H->dspbgcolor=strtoupper(trim($_POST['hol_bgcoloradd']));
         if (
$_POST['chkBusinessDay']) $H->setOptions($CONF['H_BUSINESSDAY']);
         
$H->create();
         
         
/**
          * Create the theme css files so it includes this absence type
          */
         
foreach ($themearray as $theme) { 
            
createCSS($theme["name"]);
         }
         
         
/**
          * Log this event
          */
         
$LOG->log("logHoliday",$L->checkLogin(),"Holiday created: ".$H->dspname." ".$H->dspcolor." ".$H->dspbgcolor);
         
sendNotification("holidayadd",trim($_POST['hol_nameadd']),"");
      } else {
         
$error true;
         
$errmsg  $LANG['err_input_caption'];
         
$errmsg .= $LANG['err_input_max_daytype'];
      }
   } else {
      
$error true;
      
$errmsg  $LANG['err_input_caption'];
      
$errmsg .= $LANG['err_input_hol_add'];
   }
     
/**
 * Update Holiday 
 */
} else if ( isset($_POST['btn_hol_update']) ) {
     
   
$H->findBySymbol($_POST['hol_symbolhidden']);
   
$H->dspname=trim($_POST['hol_dspname']);
   
$H->dspcolor=strtoupper(trim($_POST['hol_color']));
   
$H->dspbgcolor=strtoupper(trim($_POST['hol_bgcolor']));
   
$H->clearOptions($CONF['H_BUSINESSDAY']);
   if (
$_POST['chkBusinessDay']) $H->setOptions($CONF['H_BUSINESSDAY']);
   
$H->update($_POST['hol_symbolhidden']);
   
   
/**
    * Create the theme css files so it includes this absence type
    */
   
foreach ($themearray as $theme) { 
      
createCSS($theme["name"]);
   }
   
   
/**
    * Log this event
    */
   
$LOG->log("logHoliday",$L->checkLogin(),"Holiday updated: ".$H->dspname." ".$H->dspcolor." ".$H->dspbgcolor);
   
sendNotification("holidaychange",trim($_POST['hol_dspname']),"");
     
/**
 * Delete Holiday 
 */
} else if ( isset($_POST['btn_hol_delete']) ) {
     
   
$delsym strtoupper(trim($_POST['hol_symbolhidden']));
   
$H->findBySymbol($delsym);
   
$delname $H->dspname;
   
$H->deleteBySymbol($delsym);
   
/**
    * Remove holiday from all month templates
    */
   
$M->removeHoliday($CONF['options']['region'],$delsym);
   
   
/**
    * Create the theme css files so it includes this absence type
    */
   
foreach ($themearray as $theme) { 
      
createCSS($theme["name"]);
   }
   
   
/**
    * Log this event
    */
   
$LOG->log("logHoliday",$L->checkLogin(),"Holiday deleted: ".$delname);
   
sendNotification("holidaydelete",$delname,"");
}


/**
 * Show HTML header
 * Use this file to adjust your meta tags and such
 */
require("includes/header.html.inc.php");

echo 
"<body>\r\n";
echo 
"<div id=\"overDiv\" style=\"position:absolute; visibility:hidden; z-index:1000;\"></div>\r\n";

/**
 * Show application header
 * This is the file to change in order to put different images at the top
 * of the main page.
 */
require("includes/header.application.inc.php");

/**
 * Show menu header
 * This is the file containing the TeamCal menu
 */
require("includes/menu.inc.php");

/**
 * Show error message
 * If any error occurred so far, show it now.
 */
if ($error)
   echo (
"<script type=\"text/javascript\">alert(\"" $errmsg "\")</script>");
?>
   <table width="100%">
      <tr>
         <td valign="top" style="background-color: inherit;">
            
            <!--  HOLIDAY TYPES ==================================================== -->
            <table class="dlg" cellpadding="0" cellspacing="0">
               <tr>
                  <td class="dlg-header" colspan="4">
                     <?php printDialogTop($LANG['admin_holiday_title'],"manage_holiday_types.html","ico_holidays.png"); ?>
                  </td>
               </tr>
            </table>
            <table class="dlg" cellpadding="0" cellspacing="0">
               <tr>
                  <td>
                     <form class="form" name="form-hol-add" method="POST" action="<?=$_SERVER['PHP_SELF']."?lang=".$CONF['options']['lang']?>">
                     <table border="0" cellpadding="0" cellspacing="0" width="100%">
                        <tr>
                           <td class="dlg-bodyffb" width="5%">&nbsp;</td>
                           <td class="dlg-bodyffb" width="30%">[<?=$LANG['ed_column_name']?>]</td>
                           <td class="dlg-bodyffb" width="15%">[<?=$LANG['ed_column_color']?>]</td>
                           <td class="dlg-bodyffb" width="15%">[<?=$LANG['ed_column_bgcolor']?>]</td>
                           <td class="dlg-bodyffb" width="10%">[<?=$LANG['ed_column_businessday']?>]</td>
                           <td class="dlg-bodyffb" width="25%">[<?=$LANG['ed_column_action']?>]</td>
                        </tr>
                        <tr>
                           <td class="dlg-row1" style="vertical-align: middle;"><img src="themes/<?=$theme?>/img/ico_add.png" alt=""></td>
                           <td class="dlg-row1"><input name="hol_nameadd" size="28" type="text" class="text" value=""></td>
                           <td class="dlg-row1"><input name="hol_coloradd" size="6" maxlength="6" type="text" class="text" style="text-align: center;" value=""><a href="javascript:TCP.popup(document.forms['form-hol-add'].elements['hol_coloradd'])"><img align="top" border="0" alt="<?=$LANG['color_picker']?>" src="themes/<?=$theme?>/img/colorpicker.png" style="padding-left: 2px;" onmouseover="return overlib('<?=$LANG['color_picker_tt']?>',<?=$CONF['ovl_tt_settings']?>);" onmouseout="return nd();"></a></td>
                           <td class="dlg-row1"><input name="hol_bgcoloradd" size="6" maxlength="6" type="text" class="text" style="text-align: center;" value=""><a href="javascript:TCP.popup(document.forms['form-hol-add'].elements['hol_bgcoloradd'])"><img align="top" border="0" alt="<?=$LANG['color_picker']?>" src="themes/<?=$theme?>/img/colorpicker.png" style="padding-left: 2px;" onmouseover="return overlib('<?=$LANG['color_picker_tt']?>',<?=$CONF['ovl_tt_settings']?>);" onmouseout="return nd();"></a></td>
                           <td class="dlg-row1"><input name="chkBusinessDay" type="checkbox" value="chkBusinessDay"></td>
                           <td class="dlg-row1"><input name="btn_hol_add" type="submit" class="button" value="<?=$LANG['btn_add']?>" onmouseover="this.className='button-over';" onmouseout="this.className='button';"></td>
                        </tr>
                     </table>
                     </form>
                  </td>
               </tr>
               <?php
               $query  
"SELECT `cfgsym` FROM `".$H->table."` ORDER BY `dspname`;";
               
$result $H->db->db_query($query);
               
$i=1;
               
$printrow=1;
               while ( 
$row $H->db->db_fetch_array($result,MYSQL_ASSOC) ){
                  
$H->findBySymbol($row['cfgsym']);
                  if (
$printrow==1$printrow=2; else $printrow=1;
                  echo 
"
                  <!-- "
.$H->dspname." -->
                  <tr>
                     <td>
                        <form class=\"form\" name=\"form-hol-"
.$i."\" method=\"POST\" action=\"".$_SERVER['PHP_SELF']."?lang=".$CONF['options']['lang']."\">
                        <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">
                           <tr>
                              <td class=\"dlg-row"
.$printrow."\" width=\"5%\">
                                 <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">
                                    <tr><td class=\"daynum-"
.$H->cfgname."\" width=20 height=20>15</td></tr>
                                 </table>
                              </td>
                              <td class=\"dlg-row"
.$printrow."\" width=\"30%\">
                                 <input name=\"hol_symbolhidden\" type=\"hidden\" class=\"text\" value=\""
.$H->cfgsym."\">
                                 <input name=\"hol_dspname\" size=\"28\" type=\"text\" class=\"text\" value=\""
.$H->dspname."\">
                              </td>
                              <td class=\"dlg-row"
.$printrow."\" width=\"15%\"><input name=\"hol_color\" size=\"6\" maxlength=\"6\" type=\"text\" class=\"text\" style=\"text-align: center;\" value=\"".$H->dspcolor."\"><a href=\"javascript:TCP.popup(document.forms['form-hol-".$i."'].elements['hol_color'])\"><img align=\"top\" border=\"0\" alt=\"".$LANG['color_picker']."\" src=\"themes/".$theme."/img/colorpicker.png\" style=\"padding-left: 2px;\" onmouseover=\"return overlib('".$LANG['color_picker_tt']."',".$CONF['ovl_tt_settings'].");\" onmouseout=\"return nd();\"></a></td>
                              <td class=\"dlg-row"
.$printrow."\" width=\"15%\"><input name=\"hol_bgcolor\" size=\"6\" maxlength=\"6\" type=\"text\" class=\"text\" style=\"text-align: center;\" value=\"".$H->dspbgcolor."\"><a href=\"javascript:TCP.popup(document.forms['form-hol-".$i."'].elements['hol_bgcolor'])\"><img align=\"top\" border=\"0\" alt=\"".$LANG['color_picker']."\" src=\"themes/".$theme."/img/colorpicker.png\" style=\"padding-left: 2px;\" onmouseover=\"return overlib('".$LANG['color_picker_tt']."',".$CONF['ovl_tt_settings'].");\" onmouseout=\"return nd();\"></a></td>
                              <td class=\"dlg-row"
.$printrow."\" width=\"10%\"><input name=\"chkBusinessDay\" type=\"checkbox\" value=\"chkBusinessDay\" ".($H->checkOptions($CONF['H_BUSINESSDAY'])?'CHECKED':'')."></td>
                              <td class=\"dlg-row"
.$printrow."\" width=\"25%\">
                                 <input name=\"btn_hol_update\" type=\"submit\" class=\"button\" value=\""
.$LANG['btn_update']."\" onmouseover=\"this.className='button-over';\" onmouseout=\"this.className='button';\">&nbsp;";
                                 if ( 
$H->cfgsym!='0' && $H->cfgsym!='1' ) { // Business Day and Weekend Day cannot be deleted
                                   
echo "<input name=\"btn_hol_delete\" type=\"submit\" class=\"button\" value=\"".$LANG['btn_delete']."\" onmouseover=\"this.className='button-over';\" onmouseout=\"this.className='button';\" onclick=\"return confirmSubmit('".$LANG['ed_delete_confirm']."')\">";
                                 }
                                 echo 
"
                              </td>
                           </tr>
                        </table>
                        </form>
                     </td>
                  </tr>
                  "
;
                  
$i+=1;
               } 
               
?>
            </table>
            <br>
         </td>
      </tr>
   </table>
    
<?php
require("includes/footer.html.inc.php");
?>