This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /************************************************************************ |
||
| 3 | * OVIDENTIA http://www.ovidentia.org * |
||
| 4 | ************************************************************************ |
||
| 5 | * Copyright (c) 2003 by CANTICO ( http://www.cantico.fr ) * |
||
| 6 | * * |
||
| 7 | * This file is part of Ovidentia. * |
||
| 8 | * * |
||
| 9 | * Ovidentia is free software; you can redistribute it and/or modify * |
||
| 10 | * it under the terms of the GNU General Public License as published by * |
||
| 11 | * the Free Software Foundation; either version 2, or (at your option) * |
||
| 12 | * any later version. * |
||
| 13 | * * |
||
| 14 | * This program is distributed in the hope that it will be useful, but * |
||
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of * |
||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * |
||
| 17 | * See the GNU General Public License for more details. * |
||
| 18 | * * |
||
| 19 | * You should have received a copy of the GNU General Public License * |
||
| 20 | * along with this program; if not, write to the Free Software * |
||
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,* |
||
| 22 | * USA. * |
||
| 23 | ************************************************************************/ |
||
| 24 | |||
| 25 | include_once $babInstallPath."utilit/afincl.php"; |
||
| 26 | include_once dirname(__FILE__).'/utilit/vacincl.php'; |
||
| 27 | include_once dirname(__FILE__).'/functions.php'; |
||
| 28 | include_once dirname(__FILE__).'/utilit/agent.class.php'; |
||
| 29 | include_once dirname(__FILE__).'/utilit/entry.class.php'; |
||
| 30 | |||
| 31 | |||
| 32 | function absences_listVacationRequestsb() |
||
| 33 | { |
||
| 34 | global $babBody; |
||
| 35 | |||
| 36 | class temp extends absences_Paginate |
||
| 37 | { |
||
| 38 | var $nametxt; |
||
| 39 | var $urlname; |
||
| 40 | var $url; |
||
| 41 | var $editurl; |
||
| 42 | var $begindatetxt; |
||
| 43 | var $enddatetxt; |
||
| 44 | var $quantitytxt; |
||
| 45 | var $statustxt; |
||
| 46 | var $begindate; |
||
| 47 | var $enddate; |
||
| 48 | var $quantity; |
||
| 49 | var $status; |
||
| 50 | |||
| 51 | var $arr = array(); |
||
| 52 | var $count; |
||
| 53 | var $res; |
||
| 54 | |||
| 55 | var $statarr; |
||
| 56 | var $total; |
||
| 57 | var $checkall; |
||
| 58 | var $uncheckall; |
||
| 59 | |||
| 60 | var $usersbrowurl; |
||
| 61 | var $datetxt; |
||
| 62 | var $filteron; |
||
| 63 | var $usertxt; |
||
| 64 | var $begintxt; |
||
| 65 | var $endtxt; |
||
| 66 | var $userval; |
||
| 67 | var $userid; |
||
| 68 | var $dateb; |
||
| 69 | var $datee; |
||
| 70 | var $dateburl; |
||
| 71 | var $dateeurl; |
||
| 72 | var $topurl; |
||
| 73 | var $bottomurl; |
||
| 74 | var $nexturl; |
||
| 75 | var $prevurl; |
||
| 76 | var $topname; |
||
| 77 | var $bottomname; |
||
| 78 | var $nextname; |
||
| 79 | var $prevname; |
||
| 80 | var $pos; |
||
| 81 | |||
| 82 | var $resettxt; |
||
| 83 | |||
| 84 | var $entryid; |
||
| 85 | var $alttxt; |
||
| 86 | var $altbg = true; |
||
| 87 | |||
| 88 | function temp() |
||
| 89 | { |
||
| 90 | |||
| 91 | |||
| 92 | $idstatus = $this->param('idstatus'); |
||
| 93 | $userid = (int) $this->param('userid'); |
||
| 94 | $organization = (int) $this->param('organization'); |
||
| 95 | $dateb = $this->param('dateb'); |
||
| 96 | $datee = $this->param('datee'); |
||
| 97 | $vpos = (int) $this->param('vpos', 0); |
||
|
0 ignored issues
–
show
|
|||
| 98 | $pos = (int) $this->param('pos', 0); |
||
| 99 | $archived = (int) bab_rp('archived', 0); |
||
| 100 | |||
| 101 | include_once $GLOBALS['babInstallPath']."utilit/urlincl.php"; |
||
| 102 | |||
| 103 | global $babDB, $babBody; |
||
| 104 | |||
| 105 | if ($archived) |
||
| 106 | { |
||
| 107 | $babBody->setTitle(absences_translate("Archived vacations requests list")); |
||
| 108 | } else { |
||
| 109 | $babBody->setTitle(absences_translate("Vacations requests list")); |
||
| 110 | } |
||
| 111 | |||
| 112 | |||
| 113 | |||
| 114 | $this->uncheckall = absences_translate("Uncheck all"); |
||
| 115 | $this->checkall = absences_translate("Check all"); |
||
| 116 | $this->nametxt = absences_translate("Fullname"); |
||
| 117 | $this->begindatetxt = absences_translate("Begin date"); |
||
| 118 | $this->enddatetxt = absences_translate("End date"); |
||
| 119 | $this->quantitytxt = absences_translate("Quantity"); |
||
| 120 | $this->statustxt = absences_translate("Status"); |
||
| 121 | $this->datetxt = absences_translate("Date")." ( ".absences_translate("dd-mm-yyyy")." )"; |
||
| 122 | $this->filteron = absences_translate("Filter on"); |
||
| 123 | $this->usertxt = absences_translate("User"); |
||
| 124 | $this->begintxt = absences_translate("Begin"); |
||
| 125 | $this->endtxt = absences_translate("End"); |
||
| 126 | $this->resettxt = absences_translate("Reset"); |
||
| 127 | $this->alttxt = absences_translate("Modify"); |
||
| 128 | $this->t_edit = absences_translate("Modification"); |
||
| 129 | $this->t_delete = absences_translate("Delete"); |
||
| 130 | |||
| 131 | $this->t_first_page = absences_translate("First page"); |
||
| 132 | $this->t_previous_page = absences_translate("Previous page"); |
||
| 133 | $this->t_next_page = absences_translate("Next page"); |
||
| 134 | $this->t_last_page = absences_translate("Last page"); |
||
| 135 | |||
| 136 | $this->topurl = ""; |
||
| 137 | $this->bottomurl = ""; |
||
| 138 | $this->nexturl = ""; |
||
| 139 | $this->prevurl = ""; |
||
| 140 | |||
| 141 | $this->t_position = ''; |
||
| 142 | |||
| 143 | |||
| 144 | $this->statarr = array(absences_translate("Waiting"), absences_translate("Accepted"), absences_translate("Refused"), absences_translate('Previsional')); |
||
| 145 | $this->dateb = $dateb; |
||
| 146 | $this->datee = $datee; |
||
| 147 | $this->idstatus = $idstatus; |
||
| 148 | $this->userid = $userid; |
||
| 149 | $this->pos = $pos; |
||
| 150 | $this->userval = $userid != "" ? bab_toHtml(bab_getUserName($userid)) : ""; |
||
| 151 | $aaareq = array(); |
||
| 152 | |||
| 153 | $req = 'absences_entries e, |
||
| 154 | bab_users u LEFT JOIN absences_personnel p ON p.id_user=u.id WHERE '; |
||
| 155 | |||
| 156 | $aaareq[] = 'u.id=e.id_user'; |
||
| 157 | $aaareq[] = 'e.archived='.$babDB->quote($archived); |
||
| 158 | |||
| 159 | if( $idstatus != "" || $userid > 0 || $organization > 0 || $dateb != "" || $datee != "") |
||
| 160 | { |
||
| 161 | |||
| 162 | if( $idstatus != "") |
||
| 163 | { |
||
| 164 | switch($idstatus) |
||
| 165 | { |
||
| 166 | case 0: |
||
| 167 | $aaareq[] = "e.status=''"; break; |
||
| 168 | case 1: |
||
| 169 | $aaareq[] = "e.status='Y'"; break; |
||
| 170 | case 2: |
||
| 171 | $aaareq[] = "e.status='N'"; break; |
||
| 172 | case 3: |
||
| 173 | $aaareq[] = "e.status='P'"; break; |
||
| 174 | } |
||
| 175 | } |
||
| 176 | |||
| 177 | if( $userid > 0) |
||
| 178 | { |
||
| 179 | $aaareq[] = "e.id_user='".$babDB->db_escape_string($userid)."'"; |
||
| 180 | } |
||
| 181 | |||
| 182 | if ($organization > 0) { |
||
| 183 | |||
| 184 | $aaareq[] = "p.id_organization='".$babDB->db_escape_string($organization)."'"; |
||
| 185 | } |
||
| 186 | |||
| 187 | View Code Duplication | if( $dateb != "" ) |
|
| 188 | { |
||
| 189 | $ar = explode("-", $dateb); |
||
| 190 | $dateb = $ar[2]."-".$ar[1]."-".$ar[0]; |
||
| 191 | } |
||
| 192 | |||
| 193 | View Code Duplication | if( $datee != "" ) |
|
| 194 | { |
||
| 195 | $ar = explode("-", $datee); |
||
| 196 | $datee = $ar[2]."-".$ar[1]."-".$ar[0]; |
||
| 197 | } |
||
| 198 | |||
| 199 | if( $datee != "" ) |
||
| 200 | { |
||
| 201 | $aaareq[] = "e.date_begin <= DATE_ADD('".$babDB->db_escape_string($datee)."', INTERVAL 1 DAY)"; |
||
| 202 | } |
||
| 203 | if( $dateb != "" ) |
||
| 204 | { |
||
| 205 | $aaareq[] = "e.date_end >= '".$babDB->db_escape_string($dateb)."'"; |
||
| 206 | } |
||
| 207 | } |
||
| 208 | |||
| 209 | View Code Duplication | if( sizeof($aaareq) > 0 ) |
|
| 210 | { |
||
| 211 | if( sizeof($aaareq) > 1 ) |
||
| 212 | $req .= implode(' AND ', $aaareq); |
||
| 213 | else |
||
| 214 | $req .= $aaareq[0]; |
||
| 215 | } |
||
| 216 | |||
| 217 | |||
| 218 | $orderby = bab_rp('orderby', 'begin'); |
||
| 219 | |||
| 220 | $url = bab_url::request('tg', 'idx', 'idstatus', 'userid', 'dateb', 'datee', 'vpos', 'orderby', 'archived'); |
||
| 221 | |||
| 222 | $this->orderby = bab_toHtml($orderby); |
||
| 223 | |||
| 224 | |||
| 225 | switch($orderby) { |
||
| 226 | |||
| 227 | case 'begin.asc': |
||
| 228 | $this->orderbyname = bab_url::mod($url, 'orderby', 'name'); |
||
| 229 | $this->orderbybegin = bab_url::mod($url, 'orderby', 'begin.desc'); |
||
| 230 | $req .= " ORDER BY e.date_begin ASC, u.lastname, u.firstname"; |
||
| 231 | break; |
||
| 232 | |||
| 233 | case 'begin.desc': |
||
| 234 | View Code Duplication | case 'begin': |
|
| 235 | $this->orderbyname = bab_url::mod($url, 'orderby', 'name'); |
||
| 236 | $this->orderbybegin = bab_url::mod($url, 'orderby', 'begin.asc'); |
||
| 237 | $req .= " ORDER BY e.date_begin desc, u.lastname, u.firstname"; |
||
| 238 | break; |
||
| 239 | |||
| 240 | View Code Duplication | case 'name.desc': |
|
| 241 | $this->orderbyname = bab_url::mod($url, 'orderby', 'name.asc'); |
||
| 242 | $this->orderbybegin = bab_url::mod($url, 'orderby', 'begin'); |
||
| 243 | $req .= " ORDER BY u.lastname DESC, u.firstname DESC, e.date desc"; |
||
| 244 | break; |
||
| 245 | |||
| 246 | case 'name.asc': |
||
| 247 | View Code Duplication | case 'name': |
|
| 248 | $this->orderbyname = bab_url::mod($url, 'orderby', 'name.desc'); |
||
| 249 | $this->orderbybegin = bab_url::mod($url, 'orderby', 'begin'); |
||
| 250 | $req .= " ORDER BY u.lastname ASC, u.firstname ASC, e.date desc"; |
||
| 251 | break; |
||
| 252 | } |
||
| 253 | |||
| 254 | |||
| 255 | list($total) = $babDB->db_fetch_row($babDB->db_query("select count(*) as total from ".$req)); |
||
| 256 | $this->paginate($total, ABSENCES_MAX_REQUESTS_LIST); |
||
| 257 | |||
| 258 | |||
| 259 | if( $total > ABSENCES_MAX_REQUESTS_LIST) |
||
| 260 | { |
||
| 261 | $req .= " limit ".$pos.",".ABSENCES_MAX_REQUESTS_LIST; |
||
| 262 | } |
||
| 263 | |||
| 264 | |||
| 265 | bab_debug("select e.*, u.lastname, u.firstname from ".$req); |
||
| 266 | |||
| 267 | $this->res = $babDB->db_query("select e.*, u.lastname, u.firstname from ".$req); |
||
| 268 | $this->count = $babDB->db_num_rows($this->res); |
||
| 269 | |||
| 270 | |||
| 271 | $this->searchform = $this->getSearchForm(); |
||
| 272 | } |
||
| 273 | |||
| 274 | /** |
||
| 275 | * @return string |
||
| 276 | */ |
||
| 277 | private function getSearchForm() |
||
| 278 | { |
||
| 279 | $f = new absences_getRequestSearchForm(); |
||
| 280 | return $f->getHtmlForm($this->statarr); |
||
| 281 | } |
||
| 282 | |||
| 283 | |||
| 284 | View Code Duplication | private function param($name, $default = '') |
|
| 285 | { |
||
| 286 | if (isset($_REQUEST[$name])) |
||
| 287 | { |
||
| 288 | $_SESSION['babVacation'][$name] = $_REQUEST[$name]; |
||
| 289 | return $_REQUEST[$name]; |
||
| 290 | } |
||
| 291 | |||
| 292 | if (isset($_SESSION['babVacation'][$name])) |
||
| 293 | { |
||
| 294 | return $_SESSION['babVacation'][$name]; |
||
| 295 | } |
||
| 296 | |||
| 297 | return $default; |
||
| 298 | } |
||
| 299 | |||
| 300 | public function getnext() |
||
| 301 | { |
||
| 302 | global $babDB; |
||
| 303 | static $i = 0; |
||
| 304 | if( $i < $this->count) |
||
| 305 | { |
||
| 306 | $this->altbg = !$this->altbg; |
||
| 307 | $arr = $babDB->db_fetch_array($this->res); |
||
| 308 | |||
| 309 | $entry = new absences_Entry(); |
||
| 310 | $entry->setRow($arr); |
||
| 311 | |||
| 312 | $this->urlname = bab_toHtml($arr['lastname'].' '.$arr['firstname']); |
||
| 313 | $this->url = bab_toHtml(absences_addon()->getUrl()."vacadmb&idx=morvw&id=".$arr['id']); |
||
| 314 | $this->editconfirmed = false; |
||
| 315 | if ($entry->firstconfirm && '' === $entry->status) { |
||
| 316 | $this->editconfirmed = absences_translate('Modification of an allready confirmed request'); |
||
| 317 | } |
||
| 318 | |||
| 319 | $this->todelete = false; |
||
| 320 | if ($entry->todelete) { |
||
| 321 | $this->todelete = absences_translate('Deletion request'); |
||
| 322 | } |
||
| 323 | |||
| 324 | $this->editurl = bab_toHtml($entry->getEditUrl(1)); |
||
| 325 | $url = absences_addon()->getUrl()."vacadmb&idx=lreq"; |
||
| 326 | $this->urldelete = bab_toHtml(absences_addon()->getUrl()."vacadmb&idx=delete&id_entry=".$arr['id']."&from=".urlencode($url)); |
||
| 327 | $this->quantity = bab_toHtml(absences_vacEntryQuantity($arr['id'])); |
||
| 328 | |||
| 329 | $this->begindate = bab_toHtml(absences_shortDate(bab_mktime($arr['date_begin']))); |
||
| 330 | $this->enddate = bab_toHtml(absences_shortDate(bab_mktime($arr['date_end']))); |
||
| 331 | |||
| 332 | $this->status = $entry->getStatusStr(); |
||
| 333 | |||
| 334 | $i++; |
||
| 335 | return true; |
||
| 336 | } |
||
| 337 | else |
||
| 338 | return false; |
||
| 339 | |||
| 340 | } |
||
| 341 | |||
| 342 | View Code Duplication | function getnextstatus() |
|
| 343 | { |
||
| 344 | static $i = 0; |
||
| 345 | if( $i < count($this->statarr)) |
||
| 346 | { |
||
| 347 | $this->statusid = $i; |
||
| 348 | $this->statusname = bab_toHtml($this->statarr[$i]); |
||
| 349 | if( $this->idstatus != "" && $i == $this->idstatus ) |
||
| 350 | $this->selected = "selected"; |
||
| 351 | else |
||
| 352 | $this->selected = ""; |
||
| 353 | $i++; |
||
| 354 | return true; |
||
| 355 | } |
||
| 356 | else |
||
| 357 | return false; |
||
| 358 | } |
||
| 359 | } |
||
| 360 | |||
| 361 | $temp = new temp(); |
||
| 362 | |||
| 363 | /*@var $babBody babBody */ |
||
| 364 | |||
| 365 | |||
| 366 | absences_addSpoofButton('entry', absences_translate('Add a vacation request')); |
||
| 367 | |||
| 368 | $babBody->addStyleSheet(absences_addon()->getStylePath().'vacation.css'); |
||
| 369 | $babBody->addJavascriptFile($GLOBALS['babInstallPath'].'scripts/bab_dialog.js'); |
||
| 370 | $babBody->babecho( bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadmb.html", "vrequestslist")); |
||
| 371 | return $temp->count; |
||
| 372 | } |
||
| 373 | |||
| 374 | function editVacationRequest($vrid) |
||
| 375 | { |
||
| 376 | global $babBody; |
||
| 377 | class temp |
||
| 378 | { |
||
| 379 | var $datebegin; |
||
| 380 | var $dateend; |
||
| 381 | var $vactype; |
||
| 382 | var $addvac; |
||
| 383 | |||
| 384 | var $daybeginid; |
||
| 385 | var $monthbeginid; |
||
| 386 | var $nbdaystxt; |
||
| 387 | |||
| 388 | var $remark; |
||
| 389 | |||
| 390 | var $res; |
||
| 391 | var $count; |
||
| 392 | |||
| 393 | var $daybegin; |
||
| 394 | var $monthbegin; |
||
| 395 | var $yearbegin; |
||
| 396 | var $dayend; |
||
| 397 | var $monthend; |
||
| 398 | var $yearend; |
||
| 399 | var $halfdaybegin; |
||
| 400 | var $halfdayend; |
||
| 401 | var $nbdays; |
||
| 402 | var $remarks; |
||
| 403 | |||
| 404 | var $daysel; |
||
| 405 | var $monthsel; |
||
| 406 | var $yearsel; |
||
| 407 | var $halfdaysel; |
||
| 408 | var $totaltxt; |
||
| 409 | var $totalval; |
||
| 410 | |||
| 411 | var $invaliddate; |
||
| 412 | var $invaliddate2; |
||
| 413 | var $invalidentry; |
||
| 414 | var $invalidentry1; |
||
| 415 | var $invalidentry2; |
||
| 416 | var $iduser; |
||
| 417 | var $deletetxt; |
||
| 418 | |||
| 419 | function temp($id) |
||
| 420 | { |
||
| 421 | global $babBody, $babDB; |
||
| 422 | $this->vrid = $id; |
||
| 423 | $this->datebegintxt = absences_translate("Begin date"); |
||
| 424 | $this->dateendtxt = absences_translate("End date"); |
||
| 425 | $this->vactype = absences_translate("Vacation type"); |
||
| 426 | $this->addvac = absences_translate("Update"); |
||
| 427 | $this->remark = absences_translate("Remarks"); |
||
| 428 | $this->nbdaystxt = absences_translate("Quantity"); |
||
| 429 | $this->invaliddate = absences_translate("ERROR: End date must be older"); |
||
| 430 | $this->invaliddate = str_replace("'", "\'", $this->invaliddate); |
||
| 431 | $this->invaliddate = str_replace('"', "'+String.fromCharCode(34)+'",$this->invaliddate); |
||
| 432 | $this->invaliddate2 = absences_translate("Total days does'nt fit between dates"); |
||
| 433 | $this->invaliddate2 = str_replace("'", "\'", $this->invaliddate2); |
||
| 434 | $this->invaliddate2 = str_replace('"', "'+String.fromCharCode(34)+'",$this->invaliddate2); |
||
| 435 | $this->invalidentry = absences_translate("Invalid entry! Only numbers are accepted or . !"); |
||
| 436 | $this->invalidentry = str_replace("'", "\'", $this->invalidentry); |
||
| 437 | $this->invalidentry = str_replace('"', "'+String.fromCharCode(34)+'",$this->invalidentry); |
||
| 438 | $this->totaltxt = absences_translate("Total"); |
||
| 439 | $this->invalidentry1 = absences_translate("Invalid entry"); |
||
| 440 | $this->invalidentry2 = absences_translate("Days must be multiple of 0.5"); |
||
| 441 | $this->balancetxt = absences_translate("Balance"); |
||
| 442 | |||
| 443 | $arr = $babDB->db_fetch_array($babDB->db_query("select * from ".ABSENCES_ENTRIES_TBL." where id='".$babDB->db_escape_string($id)."'")); |
||
| 444 | $this->iduser = $arr['id_user']; |
||
| 445 | |||
| 446 | |||
| 447 | include_once $GLOBALS['babInstallPath']."utilit/dateTime.php"; |
||
| 448 | |||
| 449 | |||
| 450 | $date_begin = BAB_DateTime::fromIsoDateTime($arr['date_begin']); |
||
| 451 | $date_end = BAB_DateTime::fromIsoDateTime($arr['date_end']); |
||
| 452 | |||
| 453 | |||
| 454 | $this->daybegin = $date_begin->getDayOfMonth(); |
||
| 455 | $this->daysel = $this->daybegin; |
||
| 456 | |||
| 457 | |||
| 458 | |||
| 459 | $this->monthbegin = $date_begin->getMonth(); |
||
| 460 | $this->monthsel = $this->monthbegin; |
||
| 461 | |||
| 462 | $this->yearbegin = $date_begin->getYear(); |
||
| 463 | $this->yearsel = $this->yearbegin; |
||
| 464 | $this->timestampbegin = $date_begin->getTimeStamp(); |
||
| 465 | $this->timestampsel = $this->timestampbegin; |
||
| 466 | |||
| 467 | |||
| 468 | $this->dayend = $date_end->getDayOfMonth(); |
||
| 469 | |||
| 470 | $this->monthend = $date_end->getMonth(); |
||
| 471 | |||
| 472 | $this->yearend = $date_end->getYear(); |
||
| 473 | $this->yearendsel = $this->yearend; |
||
| 474 | $this->timestampend = $date_end->getTimeStamp(); |
||
| 475 | |||
| 476 | |||
| 477 | $this->hourbegin = date('H:i:s', $date_begin->getTimeStamp()); |
||
| 478 | $this->hoursel = $this->hourbegin; |
||
| 479 | $this->hourend = date('H:i:s', $date_end->getTimeStamp()); |
||
| 480 | |||
| 481 | |||
| 482 | $this->remarks = $arr['comment']; |
||
| 483 | |||
| 484 | $this->startyear = $this->yearbegin - 5; |
||
| 485 | |||
| 486 | $this->res = $babDB->db_query(" |
||
| 487 | select |
||
| 488 | e.id_right, |
||
| 489 | e.quantity, |
||
| 490 | e.id, |
||
| 491 | r.description, |
||
| 492 | r.quantity right_quantity, |
||
| 493 | r.quantity_unit |
||
| 494 | |||
| 495 | FROM ".ABSENCES_ENTRIES_ELEM_TBL." e, |
||
| 496 | absences_rights r |
||
| 497 | where |
||
| 498 | e.id_entry=".$babDB->quote($id)." |
||
| 499 | AND r.id = e.id_right |
||
| 500 | "); |
||
| 501 | $this->count = $babDB->db_num_rows($this->res); |
||
| 502 | $this->totalval = 0; |
||
| 503 | |||
| 504 | $this->dayType = array(absences_translate("Morning"), absences_translate("Afternoon")); |
||
| 505 | |||
| 506 | $babBody->addJavascriptFile($GLOBALS['babInstallPath'].'scripts/bab_dialog.js'); |
||
| 507 | |||
| 508 | $this->hours = absences_hoursList($GLOBALS['BAB_SESS_USERID']); |
||
| 509 | } |
||
| 510 | |||
| 511 | |||
| 512 | function getnexttype() |
||
| 513 | { |
||
| 514 | static $i = 0; |
||
| 515 | global $babDB; |
||
| 516 | if( $i < $this->count) |
||
| 517 | { |
||
| 518 | $arr = $babDB->db_fetch_array($this->res); |
||
| 519 | |||
| 520 | $this->typename = bab_toHtml($arr['description']); |
||
| 521 | $this->id_entry_elem = bab_toHtml($arr['id']); |
||
| 522 | $this->nbdays = $arr['quantity']; |
||
| 523 | $this->totalval += $this->nbdays; |
||
| 524 | |||
| 525 | $row2 = $babDB->db_fetch_array($babDB->db_query("select sum(quantity) as total from ".ABSENCES_ENTRIES_ELEM_TBL." ee |
||
| 526 | join ".ABSENCES_ENTRIES_TBL." e |
||
| 527 | where e.id_user='".$babDB->db_escape_string($this->iduser)."' |
||
| 528 | and e.status!='N' |
||
| 529 | and ee.id_right='".$babDB->db_escape_string($arr['id_right'])."' |
||
| 530 | and ee.id_entry=e.id")); |
||
| 531 | |||
| 532 | $qdp = isset($row2['total'])? $row2['total'] : 0; |
||
| 533 | |||
| 534 | list($quant) = $babDB->db_fetch_row($babDB->db_query("select quantity from ".ABSENCES_USERS_RIGHTS_TBL." where id_right='".$babDB->db_escape_string($arr['id_right'])."' and id_user='".$babDB->db_escape_string($this->iduser)."'")); |
||
| 535 | if( $quant == '' ) |
||
| 536 | $quant = $arr['right_quantity']; |
||
| 537 | |||
| 538 | View Code Duplication | switch($arr['quantity_unit']) |
|
| 539 | { |
||
| 540 | case 'D': |
||
| 541 | $this->unit = absences_translate('day(s)'); |
||
| 542 | break; |
||
| 543 | case 'H': |
||
| 544 | $this->unit = absences_translate('hour(s)'); |
||
| 545 | break; |
||
| 546 | } |
||
| 547 | |||
| 548 | $this->quantity_available = $quant - $qdp; |
||
| 549 | $i++; |
||
| 550 | return true; |
||
| 551 | } |
||
| 552 | else |
||
| 553 | { |
||
| 554 | $this->daysel = $this->dayend; |
||
| 555 | $i = 1; |
||
| 556 | return false; |
||
| 557 | } |
||
| 558 | |||
| 559 | } |
||
| 560 | |||
| 561 | |||
| 562 | function getnextday() |
||
| 563 | { |
||
| 564 | static $i = 1; |
||
| 565 | |||
| 566 | if( $i <= date('t', $this->timestampsel)) |
||
| 567 | { |
||
| 568 | $this->dayid = $i; |
||
| 569 | if( $this->daysel == $i) |
||
| 570 | { |
||
| 571 | $this->selected = "selected"; |
||
| 572 | } |
||
| 573 | else |
||
| 574 | $this->selected = ""; |
||
| 575 | |||
| 576 | $i++; |
||
| 577 | return true; |
||
| 578 | } |
||
| 579 | else |
||
| 580 | { |
||
| 581 | $this->daysel = $this->dayend; |
||
| 582 | $this->timestampsel = $this->timestampend; |
||
| 583 | $i = 1; |
||
| 584 | return false; |
||
| 585 | } |
||
| 586 | |||
| 587 | } |
||
| 588 | |||
| 589 | function getnextmonth() |
||
| 590 | { |
||
| 591 | static $i = 1; |
||
| 592 | |||
| 593 | if( $i < 13) |
||
| 594 | { |
||
| 595 | $this->monthid = $i; |
||
| 596 | $this->monthname = bab_DateStrings::getMonth($i); |
||
| 597 | if( $this->monthsel == $i) |
||
| 598 | { |
||
| 599 | $this->selected = "selected"; |
||
| 600 | } |
||
| 601 | else |
||
| 602 | $this->selected = ""; |
||
| 603 | |||
| 604 | $i++; |
||
| 605 | return true; |
||
| 606 | } |
||
| 607 | else |
||
| 608 | { |
||
| 609 | $this->monthsel = $this->monthend; |
||
| 610 | $i = 1; |
||
| 611 | return false; |
||
| 612 | } |
||
| 613 | |||
| 614 | } |
||
| 615 | function getnextyear() |
||
| 616 | { |
||
| 617 | static $i = 0; |
||
| 618 | if( $i < 20) |
||
| 619 | { |
||
| 620 | $this->yearidval = $this->startyear + $i; |
||
| 621 | if( $this->yearsel == $this->yearidval ) |
||
| 622 | { |
||
| 623 | $this->selected = "selected"; |
||
| 624 | } |
||
| 625 | else |
||
| 626 | $this->selected = ""; |
||
| 627 | $i++; |
||
| 628 | return true; |
||
| 629 | } |
||
| 630 | else |
||
| 631 | { |
||
| 632 | $this->yearsel = $this->yearendsel; |
||
| 633 | $i = 0; |
||
| 634 | return false; |
||
| 635 | } |
||
| 636 | |||
| 637 | } |
||
| 638 | function getnexthour() |
||
| 639 | { |
||
| 640 | if (list($key, $value) = each($this->hours)) |
||
| 641 | { |
||
| 642 | $this->value = bab_toHtml($key); |
||
| 643 | $this->option = bab_toHtml($value); |
||
| 644 | if ($this->hoursel === $this->value) |
||
| 645 | { |
||
| 646 | $this->selected = "selected"; |
||
| 647 | } else { |
||
| 648 | $this->selected = ""; |
||
| 649 | } |
||
| 650 | return true; |
||
| 651 | } |
||
| 652 | |||
| 653 | $this->hoursel = $this->hourend; |
||
| 654 | reset($this->hours); |
||
| 655 | return false; |
||
| 656 | } |
||
| 657 | |||
| 658 | } |
||
| 659 | |||
| 660 | $temp = new temp($vrid); |
||
| 661 | $babBody->babecho( bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadmb.html", "editvacrequest")); |
||
| 662 | } |
||
| 663 | |||
| 664 | |||
| 665 | |||
| 666 | function deleteVacationRequests($dateb, $userid) |
||
| 667 | { |
||
| 668 | global $babBody, $babDB; |
||
| 669 | class tempa |
||
| 670 | { |
||
| 671 | var $datetxt; |
||
| 672 | var $dateformattxt; |
||
| 673 | var $delete; |
||
| 674 | var $usertext; |
||
| 675 | var $usersbrowurl; |
||
| 676 | var $dateburl; |
||
| 677 | |||
| 678 | function tempa($dateb, $userid) |
||
| 679 | { |
||
| 680 | global $babDB; |
||
| 681 | $this->datetxt = absences_translate("End date"); |
||
| 682 | $this->dateformattxt = "( ".absences_translate("dd-mm-yyyy")." )"; |
||
| 683 | $this->delete = absences_translate("Delete"); |
||
| 684 | $this->usertext = absences_translate("User"); |
||
| 685 | $this->usersbrowurl = absences_addon()->getUrl()."vacadm&idx=browu&cb="; |
||
| 686 | $this->dateburl = $GLOBALS['babUrlScript']."?tg=month&callback=dateBegin&ymin=10&ymax=0"; |
||
| 687 | if( $dateb != "" ) |
||
| 688 | $this->datebval = $dateb; |
||
| 689 | else |
||
| 690 | $this->datebval = ""; |
||
| 691 | if( $userid != "" ) |
||
| 692 | { |
||
| 693 | $this->userval = bab_getUserName($userid); |
||
| 694 | $this->userid =$userid; |
||
| 695 | } |
||
| 696 | else |
||
| 697 | { |
||
| 698 | $this->userval =""; |
||
| 699 | $this->userid =""; |
||
| 700 | } |
||
| 701 | } |
||
| 702 | } |
||
| 703 | |||
| 704 | $temp = new tempa($dateb, $userid); |
||
| 705 | $babBody->babecho(bab_printTemplate($temp, absences_addon()->getRelativePath()."vacadmb.html", "reqdelete")); |
||
| 706 | } |
||
| 707 | |||
| 708 | function deleteInfoVacationRequests($dateb, $userid) |
||
| 709 | { |
||
| 710 | global $babBody; |
||
| 711 | |||
| 712 | class temp |
||
| 713 | { |
||
| 714 | var $warning; |
||
| 715 | var $message; |
||
| 716 | var $title; |
||
| 717 | var $urlyes; |
||
| 718 | var $urlno; |
||
| 719 | var $yes; |
||
| 720 | var $no; |
||
| 721 | |||
| 722 | function temp($dateb, $userid) |
||
| 723 | { |
||
| 724 | $this->message = absences_translate("Are you sure you want to remove the requests which finish before the following date ").$dateb; |
||
| 725 | if( $userid == "" ) |
||
| 726 | $this->title = bab_getUserName("All users"); |
||
| 727 | else |
||
| 728 | $this->title = bab_getUserName($userid); |
||
| 729 | $this->warning = absences_translate("WARNING: This operation will delete vacations requests"). "!"; |
||
| 730 | $this->urlyes = absences_addon()->getUrl()."vacadmb&idx=lreq&date=".$dateb."&userid=".$userid."&action=Yes"; |
||
| 731 | $this->yes = absences_translate("Yes"); |
||
| 732 | $this->urlno = absences_addon()->getUrl()."vacadmb&idx=lreq"; |
||
| 733 | $this->no = absences_translate("No"); |
||
| 734 | } |
||
| 735 | } |
||
| 736 | |||
| 737 | $ret = true; |
||
| 738 | if( $dateb == "" ) |
||
| 739 | { |
||
| 740 | $ret = false; |
||
| 741 | } |
||
| 742 | |||
| 743 | $ar = explode("-", $dateb); |
||
| 744 | if( count($ar) != 3 || !is_numeric($ar[0]) || !is_numeric($ar[1]) || !is_numeric($ar[2])) |
||
| 745 | { |
||
| 746 | $ret = false; |
||
| 747 | } |
||
| 748 | |||
| 749 | if( $ar[0] <= 0 || $ar[1] <= 0 || $ar[2] <= 0) |
||
| 750 | { |
||
| 751 | $ret = false; |
||
| 752 | } |
||
| 753 | |||
| 754 | if( !$ret ) |
||
| 755 | { |
||
| 756 | $babBody->msgerror = absences_translate("You must provide a correct date"); |
||
| 757 | return false; |
||
| 758 | } |
||
| 759 | |||
| 760 | $temp = new temp($dateb, $userid); |
||
| 761 | $babBody->babecho( bab_printTemplate($temp, absences_addon()->getRelativePath()."warning.html", "warningyesno")); |
||
| 762 | return true; |
||
| 763 | } |
||
| 764 | |||
| 765 | |||
| 766 | |||
| 767 | function updateVacationRequest($daybegin, $monthbegin, $yearbegin,$dayend, $monthend, $yearend, $hourbegin, $hourend, $remarks, $vrid, $quantity) |
||
| 768 | { |
||
| 769 | global $babBody, $babDB; |
||
| 770 | $nbdays = array(); |
||
| 771 | |||
| 772 | $res = $babDB->db_query("select * from ".ABSENCES_ENTRIES_ELEM_TBL." where id_entry='".$babDB->db_escape_string($vrid)."'"); |
||
| 773 | |||
| 774 | $ntotal = 0; |
||
| 775 | while( $arr = $babDB->db_fetch_array($res)) |
||
| 776 | { |
||
| 777 | if( isset($quantity[$arr['id']])) |
||
| 778 | { |
||
| 779 | $nbd = $quantity[$arr['id']]; |
||
| 780 | if( !is_numeric($nbd) || $nbd < 0 ) |
||
| 781 | { |
||
| 782 | $babBody->msgerror = absences_translate("You must specify a correct number days") ." !"; |
||
| 783 | return false; |
||
| 784 | } |
||
| 785 | |||
| 786 | if( $nbd >= 0 ) |
||
| 787 | { |
||
| 788 | $nbdays['id'][] = $arr['id']; |
||
| 789 | $nbdays['val'][] = $nbd; |
||
| 790 | $ntotal += $nbd; |
||
| 791 | } |
||
| 792 | } |
||
| 793 | } |
||
| 794 | |||
| 795 | $begin = bab_mktime("$yearbegin-$monthbegin-$daybegin $hourbegin"); |
||
| 796 | $end = bab_mktime("$yearend-$monthend-$dayend $hourend"); |
||
| 797 | |||
| 798 | if( $begin >= $end) { |
||
| 799 | $babBody->msgerror = absences_translate("ERROR: End date must be older")." !"; |
||
| 800 | return false; |
||
| 801 | } |
||
| 802 | |||
| 803 | $res = $babDB->db_query(" |
||
| 804 | SELECT |
||
| 805 | date_begin, |
||
| 806 | date_end, |
||
| 807 | id_user |
||
| 808 | FROM ".ABSENCES_ENTRIES_TBL." |
||
| 809 | WHERE |
||
| 810 | id='".$babDB->db_escape_string($vrid)."' |
||
| 811 | "); |
||
| 812 | |||
| 813 | $old = $babDB->db_fetch_assoc($res); |
||
| 814 | |||
| 815 | $old_begin = bab_mktime($old['date_begin']); |
||
| 816 | $old_end = bab_mktime($old['date_end']); |
||
| 817 | |||
| 818 | |||
| 819 | $b = date('Y-m-d H:i:s', $begin); |
||
| 820 | $e = date('Y-m-d H:i:s', $end); |
||
| 821 | |||
| 822 | |||
| 823 | |||
| 824 | |||
| 825 | |||
| 826 | |||
| 827 | $babDB->db_query(" |
||
| 828 | update ".ABSENCES_ENTRIES_TBL." SET |
||
| 829 | date_begin = '".$babDB->db_escape_string($b)."', |
||
| 830 | date_end = '".$babDB->db_escape_string($e)."', |
||
| 831 | comment = '".$babDB->db_escape_string($remarks)."' |
||
| 832 | where |
||
| 833 | id='".$babDB->db_escape_string($vrid)."' |
||
| 834 | "); |
||
| 835 | |||
| 836 | for( $i = 0; $i < count($nbdays['id']); $i++) |
||
| 837 | { |
||
| 838 | if( $nbdays['val'][$i] > 0 ) { |
||
| 839 | $babDB->db_query("update ".ABSENCES_ENTRIES_ELEM_TBL." set quantity='".$babDB->db_escape_string($nbdays['val'][$i])."' where id='".$babDB->db_escape_string($nbdays['id'][$i])."'"); |
||
| 840 | } |
||
| 841 | else { |
||
| 842 | $babDB->db_query("delete from ".ABSENCES_ENTRIES_ELEM_TBL." where id='".$babDB->db_escape_string($nbdays['id'][$i])."'"); |
||
| 843 | } |
||
| 844 | } |
||
| 845 | |||
| 846 | |||
| 847 | require_once $GLOBALS['babInstallPath'].'utilit/dateTime.php'; |
||
| 848 | absences_updatePeriod($vrid, BAB_DateTime::fromIsoDateTime($b), BAB_DateTime::fromIsoDateTime($e)); |
||
| 849 | |||
| 850 | |||
| 851 | $period_begin = $old_begin < $begin ? $old_begin : $begin; |
||
| 852 | $period_end = $old_end > $end ? $old_end : $end; |
||
| 853 | |||
| 854 | |||
| 855 | include_once $GLOBALS['babInstallPath']."utilit/eventperiod.php"; |
||
| 856 | $event = new bab_eventPeriodModified($period_begin, $period_end, $old['id_user']); |
||
| 857 | $event->types = BAB_PERIOD_VACATION; |
||
| 858 | bab_fireEvent($event); |
||
| 859 | |||
| 860 | return true; |
||
| 861 | } |
||
| 862 | |||
| 863 | |||
| 864 | function doDeleteVacationRequests($date, $userid) |
||
| 865 | { |
||
| 866 | global $babDB; |
||
| 867 | |||
| 868 | $ar = explode("-", $date); |
||
| 869 | $dateb = sprintf("%04d-%02d-%02d", $ar[2], $ar[1], $ar[0]); |
||
| 870 | |||
| 871 | $req = "SELECT id FROM ".ABSENCES_ENTRIES_TBL." WHERE date_end <= ".$babDB->quote($dateb); |
||
| 872 | if( $userid != "" ) |
||
| 873 | $req .= " and id_user=".$babDB->quote($userid); |
||
| 874 | |||
| 875 | $res = $babDB->db_query($req); |
||
| 876 | while( $arr = $babDB->db_fetch_array($res)) |
||
| 877 | { |
||
| 878 | absences_delete_request($arr['id']); |
||
| 879 | } |
||
| 880 | } |
||
| 881 | |||
| 882 | |||
| 883 | |||
| 884 | /* main */ |
||
| 885 | bab_requireCredential(); |
||
| 886 | $agent = absences_Agent::getCurrentUser(); |
||
| 887 | if( !$agent->isManager()) |
||
| 888 | { |
||
| 889 | $babBody->msgerror = absences_translate("Access denied"); |
||
| 890 | return; |
||
| 891 | } |
||
| 892 | |||
| 893 | |||
| 894 | $idx = bab_rp('idx', "lreq"); |
||
| 895 | $Submit = bab_pp('Submit', null); |
||
| 896 | |||
| 897 | if( bab_rp('add') == "modvr") |
||
| 898 | { |
||
| 899 | if( isset($Submit)) |
||
| 900 | { |
||
| 901 | if(!updateVacationRequest(bab_pp('daybegin'), bab_pp('monthbegin'), bab_pp('yearbegin'),bab_pp('dayend'), bab_pp('monthend'), bab_pp('yearend'), bab_pp('hourbegin'), bab_pp('hourend'), bab_pp('remarks'), bab_pp('vrid'), bab_pp('quantity'))) |
||
| 902 | $idx = "vunew"; |
||
| 903 | } |
||
| 904 | else if( isset($bdelete)) |
||
| 905 | { |
||
| 906 | $idx = "delur"; |
||
| 907 | } |
||
| 908 | } |
||
| 909 | else if( bab_rp('action') == "Yes") |
||
| 910 | { |
||
| 911 | doDeleteVacationRequests(bab_rp('date'), bab_rp('userid')); |
||
| 912 | } |
||
| 913 | |||
| 914 | if ($agent->isInPersonnel()) |
||
| 915 | { |
||
| 916 | $babBody->addItemMenu("vacuser", absences_translate("Vacations"), absences_addon()->getUrl()."vacuser"); |
||
| 917 | } |
||
| 918 | |||
| 919 | $babBody->addItemMenu("menu", absences_translate("Management"), absences_addon()->getUrl()."vacadm&idx=menu"); |
||
| 920 | |||
| 921 | |||
| 922 | |||
| 923 | |||
| 924 | |||
| 925 | /** |
||
| 926 | * Manually update the calendar for one absence entry |
||
| 927 | * @param int $id |
||
| 928 | */ |
||
| 929 | function absences_updateEntryCalendar($id) { |
||
| 930 | $entry = absences_Entry::getById($id); |
||
| 931 | $entry->updateCalendar(); |
||
| 932 | } |
||
| 933 | |||
| 934 | |||
| 935 | |||
| 936 | |||
| 937 | $pos = bab_rp('pos'); |
||
| 938 | $idcol = bab_rp('idcol'); |
||
| 939 | $idsa = bab_rp('idsa'); |
||
| 940 | |||
| 941 | switch($idx) |
||
| 942 | { |
||
| 943 | View Code Duplication | case "morvw": |
|
| 944 | require_once dirname(__FILE__).'/utilit/request.ui.php'; |
||
| 945 | $babBody->addItemMenu("lreq", absences_translate("Requests"), absences_addon()->getUrl()."vacadmb&idx=lreq"); |
||
| 946 | $babBody->addItemMenu("morvw", absences_translate("View"), absences_addon()->getUrl()."vacadmb&idx=morvw&id=".bab_rp('id')); |
||
| 947 | absences_viewVacationRequestDetail(bab_rp('id'), true); |
||
| 948 | break; |
||
| 949 | |||
| 950 | case 'updcal': |
||
| 951 | if (bab_isUserAdministrator()) { |
||
| 952 | absences_updateEntryCalendar(bab_rp('id')); |
||
| 953 | } |
||
| 954 | break; |
||
| 955 | |||
| 956 | |||
| 957 | case 'crecal': |
||
| 958 | if (bab_isUserAdministrator()) { |
||
| 959 | // warning, this can create duplicates |
||
| 960 | absences_createPeriod(bab_rp('id')); |
||
| 961 | } |
||
| 962 | break; |
||
| 963 | |||
| 964 | |||
| 965 | View Code Duplication | case "edvr": |
|
| 966 | $babBody->title = absences_translate("Edit request vacation"); |
||
| 967 | editVacationRequest(bab_rp('id')); |
||
| 968 | $babBody->addItemMenu("lreq", absences_translate("Requests"), absences_addon()->getUrl()."vacadmb&idx=lreq"); |
||
| 969 | $babBody->addItemMenu("edvr", absences_translate("Modify"), absences_addon()->getUrl()."vacadmb&idx=edvr"); |
||
| 970 | break; |
||
| 971 | |||
| 972 | |||
| 973 | |||
| 974 | View Code Duplication | case "ddreq": |
|
| 975 | $babBody->title = absences_translate("Delete vacations requests"); |
||
| 976 | if(!empty($_POST)) { |
||
| 977 | deleteInfoVacationRequests(bab_rp('dateb'), bab_rp('userid')); |
||
| 978 | } else { |
||
| 979 | deleteVacationRequests(bab_rp('dateb'), bab_rp('userid')); |
||
| 980 | } |
||
| 981 | |||
| 982 | $babBody->addItemMenu("lreq", absences_translate("Requests"), absences_addon()->getUrl()."vacadmb&idx=lreq"); |
||
| 983 | $babBody->addItemMenu("ddreq", absences_translate("Delete"), absences_addon()->getUrl()."vacadmb&idx=ddreq"); |
||
| 984 | break; |
||
| 985 | |||
| 986 | View Code Duplication | case 'delete': |
|
| 987 | $babBody->title = absences_translate("Delete vacation request"); |
||
| 988 | absences_deleteVacationRequest(bab_rp('id_entry'), true); |
||
| 989 | $babBody->addItemMenu("lreq", absences_translate("Requests"), absences_addon()->getUrl()."vacadmb&idx=lreq"); |
||
| 990 | $babBody->addItemMenu("delete", absences_translate("Delete"), absences_addon()->getUrl()."vacadmb&idx=delete"); |
||
| 991 | break; |
||
| 992 | |||
| 993 | |||
| 994 | case 'archives'; |
||
| 995 | case "lreq": |
||
| 996 | View Code Duplication | default: |
|
| 997 | |||
| 998 | absences_listVacationRequestsb(); |
||
| 999 | $babBody->addItemMenu("lreq", absences_translate("Requests"), absences_addon()->getUrl()."vacadmb&idx=lreq"); |
||
| 1000 | $babBody->addItemMenu("archives", absences_translate("Archives"), absences_addon()->getUrl()."vacadmb&idx=archives&archived=1"); |
||
| 1001 | $babBody->addItemMenu("ddreq", absences_translate("Delete"), absences_addon()->getUrl()."vacadmb&idx=ddreq"); |
||
| 1002 | break; |
||
| 1003 | } |
||
| 1004 | $babBody->setCurrentItemMenu($idx); |
||
| 1005 | bab_siteMap::setPosition('absences','User'); |
||
| 1006 | |||
| 1007 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.