1. Import
This commit is contained in:
97
html/tools/updateFDSVehicleAvailability_HHA.php
Normal file
97
html/tools/updateFDSVehicleAvailability_HHA.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/*=======================================================================
|
||||
*
|
||||
* updateFDSVehicleAvailability_HHA.php
|
||||
*
|
||||
* Autor: Marc Vollmann
|
||||
*
|
||||
=======================================================================*/
|
||||
|
||||
include_once ("../include/mcglobal.inc.php");
|
||||
// include_once ("../include/auth.inc.php");
|
||||
include_once ("../include/inc_filters.inc.php");
|
||||
include_once ("../include/inc_vehicle.inc.php");
|
||||
|
||||
|
||||
// Check for authentication access and granted rights
|
||||
// $usrAccessArray["hq"] = "1";
|
||||
// authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
|
||||
// authCheckEmployeeRights($emp_id, "1", "1");
|
||||
|
||||
|
||||
// Execution-Time for script
|
||||
set_time_limit(0);
|
||||
|
||||
// Activate buffering
|
||||
ob_start();
|
||||
|
||||
// Current day
|
||||
$numOfDays = 120;
|
||||
$selDay = getDateTime("day");
|
||||
$selMonth = getDateTime("month");
|
||||
$selYear = getDateTime("year");
|
||||
|
||||
// Hours per day
|
||||
/*
|
||||
$hours = getParameterValue("0", "DISPOSITION_HOURS", "0");
|
||||
if ($hours == "" || !is_numeric($hours)) :
|
||||
$hours = 23;
|
||||
endif;
|
||||
*/
|
||||
|
||||
// Time units of a hour (e.g. 12 units per 5 minutes <=> 6 units per 10 minutes <=> one hour)
|
||||
$hourTimeUnits = getParameterValue("0", "DISPOSITION_HOUR_TIME_UNITS", "0");
|
||||
if ($hourTimeUnits == "" || !is_numeric($hourTimeUnits)) :
|
||||
$hourTimeUnits = 6;
|
||||
endif;
|
||||
|
||||
|
||||
// Generate date array
|
||||
$dateArray = array();
|
||||
for ($k = 0; $k < $numOfDays; $k++) :
|
||||
$dateArray[] = getDateTime("format", array(0,0,0,$selMonth,$selDay + $k,$selYear), "Y-m-d");
|
||||
endfor;
|
||||
|
||||
$csIdArray = array("829067");
|
||||
$csIdArrayLen = count($csIdArray);
|
||||
|
||||
// Iterate all customers
|
||||
for ($i = 0; $i < $csIdArrayLen; $i++) :
|
||||
|
||||
$csId = $csIdArray[$i];
|
||||
|
||||
// Get array of day times of the current customer
|
||||
$dayTimes = getColVectorFromDB2ArrayByClause("metatype", "mt_sort", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $csId . "'", "", "mt_sort", "");
|
||||
$dayTimeNames = getColVectorFromDB2ArrayByClause("metatype", "mt_value", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $csId . "'", "", "mt_sort", "");
|
||||
$dayTimeMappedValues = getColVectorFromDB2ArrayByClause("metatype", "mt_mapped_value", "mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $csId . "'", "", "mt_sort", "");
|
||||
$dayTimesLen = count($dayTimes);
|
||||
|
||||
// Get the vehicles for the current customer
|
||||
$crvhList = array();
|
||||
$sqlquery = getStmtCustomerVehicleRelation("", $csId);
|
||||
$result = $db->query($sqlquery);
|
||||
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
|
||||
while ($row = $result->fetch_assoc()):
|
||||
$crvhList[] = $row["crvh_id"];
|
||||
endwhile;
|
||||
$result->free();
|
||||
$crvhListLen = count($crvhList);
|
||||
|
||||
// Check for each vehicle displayed the existence of entries in "vehicledisposition", "vehicleavailability" and "vehicleavailabilitytimeunits".
|
||||
// If it does not exist then generate it to handle the drag and dropping the jobs etc.
|
||||
for ($v = 0; $v < $crvhListLen; $v++) :
|
||||
$crvhId = $crvhList[$v];
|
||||
|
||||
// Iterate the next x days
|
||||
for ($k = 0; $k < $numOfDays; $k++) :
|
||||
$retVal = updateVehicleAvailability ($crvhId, $csId, $dateArray[$k]);
|
||||
echo "CS = " . $csId . " | " . "CRVH = " . $crvhId . " | " . "DAY = " . $dateArray[$k] . " | " . " RET = [" . $retVal . "]";
|
||||
echo "<br>";
|
||||
ob_flush(); flush();
|
||||
endfor;
|
||||
endfor;
|
||||
endfor;
|
||||
|
||||
// Deactivate buffering and flush data
|
||||
ob_end_flush();
|
||||
?>
|
||||
Reference in New Issue
Block a user