90 lines
3.0 KiB
PHP
90 lines
3.0 KiB
PHP
<?php
|
|
/*=======================================================================
|
|
*
|
|
* inc_check_publicholiday.inc.php
|
|
*
|
|
* Autor: Marc Vollmann
|
|
*
|
|
=======================================================================*/
|
|
|
|
include_once ("../include/global.inc.php");
|
|
//include_once ("../include/auth.inc.php");
|
|
|
|
|
|
// Gets the public holiday of the specified year and the next one
|
|
function getPublicHolidays($year = "", $withNextYear = "", $mode = "", $specialWhereClause = "") {
|
|
global $db, $hq_id;
|
|
|
|
$retArray = array();
|
|
if ($year == "" || !is_numeric($year)) : $year = getDateTime("year"); endif;
|
|
|
|
// $whereClause = "hq_id = $hq_id AND ph.ph_year = '" . $year . "'";
|
|
// if ($withNextYear != "") :
|
|
// $whereClause = "(" . $whereClause;
|
|
// $whereClause .= " OR ph.ph_year = '" . ($year + 1) . "') ";
|
|
// endif;
|
|
$whereClause = "hq_id = $hq_id AND (ph.ph_year = '" . $year . "'";
|
|
if ($withNextYear != "") :
|
|
$whereClause .= " OR ph.ph_year = '" . ($year + 1) . "'";
|
|
endif;
|
|
$whereClause .= ")";
|
|
if ($specialWhereClause != "") :
|
|
$whereClause .= " AND " . $specialWhereClause;
|
|
endif;
|
|
if (TRUE) :
|
|
$sqlquery = "SELECT ph.ph_id, ph.ph_year, ph.ph_month, ph.ph_day, ph.ph_time_from, ph.ph_time_to, ph.ph_name"
|
|
. " FROM publicholiday AS ph"
|
|
. " WHERE " . $whereClause
|
|
. " ORDER BY ph.ph_year, ph.ph_month, ph.ph_day, ph.ph_time_from";
|
|
|
|
$result = $db->query($sqlquery);
|
|
if (DB::isError($result)) die ("$PHP_SELF: '$sqlquery'" . $result->getMessage());
|
|
|
|
$count = 0;
|
|
while ($row = $result->fetch_assoc()):
|
|
$retArray[$count][0] = $row["ph_year"];
|
|
$retArray[$count][1] = $row["ph_month"];
|
|
$retArray[$count][2] = $row["ph_day"];
|
|
$retArray[$count][3] = $row["ph_time_from"];
|
|
$retArray[$count][4] = $row["ph_time_to"];
|
|
$count++;
|
|
endwhile;
|
|
$result->free();
|
|
endif;
|
|
|
|
// Special javascript output as string ...
|
|
if ($mode == "1") :
|
|
$retString = "var ph = new Array();\n";
|
|
|
|
for ($i = 0; $i < $count; $i++) :
|
|
$retString .= "ph[" . $i . "] = new Array();\n";
|
|
$retString .= "ph[" . $i . "][0] = \"" . $retArray[$i][0] . "\";\n";
|
|
$retString .= "ph[" . $i . "][1] = \"" . $retArray[$i][1] . "\";\n";
|
|
$retString .= "ph[" . $i . "][2] = \"" . $retArray[$i][2] . "\";\n";
|
|
$retString .= "ph[" . $i . "][3] = \"" . $retArray[$i][3] . "\";\n";
|
|
$retString .= "ph[" . $i . "][4] = \"" . $retArray[$i][4] . "\";\n";
|
|
endfor;
|
|
|
|
return $retString;
|
|
endif;
|
|
|
|
// If no special $mode specified the 2-D-Array will be returned !!!
|
|
return $retArray;
|
|
}
|
|
|
|
|
|
// Gets the public holiday of the specified year and the next one
|
|
function convertPublicHolidayArrayToDateArray($phArray, $mode = "") {
|
|
|
|
$retArray = array();
|
|
if (is_array($phArray)) :
|
|
|
|
$phArrayLen = count($phArray);
|
|
for ($i = 0; $i < $phArrayLen; $i++) :
|
|
$retArray[] = $phArray[$i][0] . "-" . pad($phArray[$i][1],2) . "-" . pad($phArray[$i][2],2);
|
|
endfor;
|
|
endif;
|
|
|
|
return $retArray;
|
|
}
|
|
?>
|