"; appointmentRequestLogFile($currentTime); appointmentRequestLogFile($appointmentReq); if ($selectedLanguage == "" || !is_numeric($selectedLanguage)) : $selectedLanguage = "1"; endif; // Default in English $languageSelected = $selectedLanguage; getLanguage(__FILE__); getCurrentScript(__FILE__); $err = array(); $appointmentResponse = ""; $xmlVehiclesAvailable = ""; // --------------------------------------------------------------------------- // GLOBAL MODE OF USAGE $globalParUseRelatedCustomer = getParameterValue("0", "GLOBAL_USE_RELATED_CUSTOMER", "0"); // *** Parse request *** $appointmentArray = xml2array($appointmentReq); if ($debug) : print_r($appointmentArray); echo "


"; endif; // *** Convert result array to usable parameters *** // Authentication data $csEid = convertSpecial($appointmentArray["xml"]["appointment"]["auth"]["customer"]); $csId = getFieldValueFromId("customer","cs_eid",$csEid,"cs_id"); $usrAccount = convertSpecial($appointmentArray["xml"]["appointment"]["auth"]["account"]); $usrPassword = convertSpecial($appointmentArray["xml"]["appointment"]["auth"]["password"]); $sessionId = convertSpecial($appointmentArray["xml"]["appointment"]["auth"]["session_id"]); // Optional customer group data (needed to find e.g. an article price automatically). Has to be set explicitly, because a customer could belong to more groups !!!! $csGroupId = convertSpecial($appointmentArray["xml"]["appointment"]["auth"]["group_no"]); $csGroupName = convertSpecial($appointmentArray["xml"]["appointment"]["auth"]["group_name"]); if ($csGroupId != "" && is_numeric($csGroupId)) : $csGroupName = getFieldValueFromId("groups","grp_id",$csGroupId,"grp_name"); elseif ($csGroupName != "") : $csGroupId = getFieldValueFromId("groups","grp_name",$csGroupName,"grp_id"); endif; // Reset customer group data if it could not be identified if ($csGroupId == "" || $csGroupName == "") : $csGroupId = ""; $csGroupName = ""; endif; $debugOut .= "usrAccount: " . $usrAccount . "
\n"; $debugOut .= "usrPassword: " . $usrPassword . "
\n"; $debugOut .= "sessionId: " . $sessionId . "
\n"; if (checkRequestAuthenticationData($usrAccount, $usrPassword, $sessionId, $csId)) : $debugOut .= "Authentication okay!

\n"; // Data $hqId = getFieldValueFromId("customer","cs_id",$csId,"hq_id"); $cscName = convertSpecial($appointmentArray["xml"]["appointment"]["auth"]["costcenter_name"]); $cscId = ""; if ($cscName != "") : $cscId = getFieldValueFromClause("costcenter","csc_id","cs_id = '" . $csId . "' AND csc_name = '" . $cscName . "'"); endif; if ($cscId == "" || !is_numeric($cscId)) : $cscId = getFieldValueFromClause("costcenter","csc_id","cs_id = '" . $csId . "' AND isnull(csc_pre_id)"); // Root costcenter endif; // Get job or appointment data $operation = convertSpecial($appointmentArray["xml"]["appointment"]["operation"]); $debugOn = convertSpecial($appointmentArray["xml"]["appointment"]["debug_on"]); $jbId = convertSpecial($appointmentArray["xml"]["appointment"]["order_id"]); $ecoZipcode = convertSpecial($appointmentArray["xml"]["appointment"]["eco_zipcode"]); $ecoNeededTimeUnits = convertSpecial($appointmentArray["xml"]["appointment"]["eco_needed_time_units"]); $sortSequence = convertSpecial($appointmentArray["xml"]["appointment"]["sort_sequence"]); $ecoServices = convertSpecial($appointmentArray["xml"]["appointment"]["eco_services"]); $ecoWeight = convertSpecial($appointmentArray["xml"]["appointment"]["eco_weight"]); $ecoPositions = convertSpecial($appointmentArray["xml"]["appointment"]["eco_positions"]); $maxLimitOfRows = convertSpecial($appointmentArray["xml"]["appointment"]["max_limit_of_rows"]); $deliveryTimeValue = convertSpecial($appointmentArray["xml"]["appointment"]["delivery_time_value"]); $day_from = convertSpecial($appointmentArray["xml"]["appointment"]["day_from"]); $month_from = convertSpecial($appointmentArray["xml"]["appointment"]["month_from"]); $year_from = convertSpecial($appointmentArray["xml"]["appointment"]["year_from"]); $day_to = convertSpecial($appointmentArray["xml"]["appointment"]["day_to"]); $month_to = convertSpecial($appointmentArray["xml"]["appointment"]["month_to"]); $year_to = convertSpecial($appointmentArray["xml"]["appointment"]["year_to"]); $jbTimedFilter = convertSpecial($appointmentArray["xml"]["appointment"]["jb_timed_filter"]); $dateSelectionByCalendar = convertSpecial($appointmentArray["xml"]["appointment"]["date_selection_by_calendar"]); $futureDaysOffset = convertSpecial($appointmentArray["xml"]["appointment"]["future_days_offset"]); $debugOut .= "operation: " . $operation . "
\n"; $debugOut .= "jbId: " . $jbId . "
\n"; $debugOut .= "ecoZipcode: " . $ecoZipcode . "
\n"; $debugOut .= "ecoNeededTimeUnits: " . $ecoNeededTimeUnits . "
\n"; $debugOut .= "sortSequence: " . $sortSequence . "
\n"; $debugOut .= "ecoServices: " . $ecoServices . "
\n"; $debugOut .= "ecoWeight: " . $ecoWeight . "
\n"; $debugOut .= "ecoPositions: " . $ecoPositions . "
\n"; $debugOut .= "maxLimitOfRows: " . $maxLimitOfRows . "
\n"; $debugOut .= "deliveryTimeValue: " . $deliveryTimeValue . "
\n"; $debugOut .= "day_from: " . $day_from . "
\n"; $debugOut .= "month_from: " . $month_from . "
\n"; $debugOut .= "year_from: " . $year_from . "
\n"; $debugOut .= "day_to: " . $day_to . "
\n"; $debugOut .= "month_to: " . $month_to . "
\n"; $debugOut .= "year_to: " . $year_to . "
\n"; $debugOut .= "jbTimedFilter: " . $jbTimedFilter . "
\n"; $debugOut .= "dateSelectionByCalendar: " . $dateSelectionByCalendar . "
\n"; $debugOut .= "futureDaysOffset: " . $futureDaysOffset . "
\n"; // Daytimes $ecoDayTimeArray = array(); $tmpEcoDayTimes = count($appointmentArray["xml"]["appointment"]["eco_day_time"]["val"]); if ($tmpEcoDayTimes > 0) : if ($tmpEcoDayTimes == 1) : $ecoDayTimeArray[0] = convertSpecial($appointmentArray["xml"]["appointment"]["eco_day_time"]["val"]); else : for ($k = 0; $k < $tmpEcoDayTimes; $k++) : $tmpVal = convertSpecial($appointmentArray["xml"]["appointment"]["eco_day_time"]["val"][$k]); $tmpVal = trim($tmpVal); if ($tmpVal != "") : $ecoDayTimeArray[] = $tmpVal; endif; endfor; endif; endif; // $debugOut .= "ecoDayTimeArray: " . print_r($ecoDayTimeArray) . "

\n"; // Weekdays $ecoWeekdayArray = array(); $tmpEcoWeekday = count($appointmentArray["xml"]["appointment"]["eco_weekday"]["val"]); if ($tmpEcoWeekday > 0) : if ($tmpEcoWeekday == 1) : $ecoWeekdayArray[0] = convertSpecial($appointmentArray["xml"]["appointment"]["eco_weekday"]["val"]); else : for ($k = 0; $k < $tmpEcoWeekday; $k++) : $tmpVal = convertSpecial($appointmentArray["xml"]["appointment"]["eco_weekday"]["val"][$k]); $tmpVal = trim($tmpVal); if ($tmpVal != "") : $ecoWeekdayArray[] = $tmpVal; endif; endfor; endif; endif; // $debugOut .= "ecoWeekdayArray: " . print_r($ecoWeekdayArray) . "

\n"; // Init $currentTimestamp = getDateTime("0"); $currentDay = getDateTime("3"); // "Y-m-d" $currentTime = getDateTime("4"); // Current time ("H:i:s") $currYear = getDateTime("year"); // Current year $combinedJob = false; if (!$debug && $debugOn == "ON" || $debugOn == "YES") : $debug = true; endif; if ($operation == "SET") : // TO BE DONE! else : // Get available vehicle data $globalParArray = array($jbId, $csId, $ecoDayTimeArray, $ecoWeekdayArray, $ecoZipcode, $ecoNeededTimeUnits, $sortSequence, $ecoServices, $ecoWeight, $ecoPositions, $maxLimitOfRows, $deliveryTimeValue, $deactivateMenu, $day_from, $month_from, $year_from, $day_to, $month_to, $year_to, $jbTimedFilter, $dateSelectionByCalendar, $futureDaysOffset); // $debugOut .= "globalParArray: " . print_r($globalParArray) . "

\n"; // echo "

\n"; print_r($globalParArray); $retArray = getDispositionAppointments("0", $globalParArray); // $debugOut .= "
RESPONSE DATA:

retArray: " . print_r($retArray) . "

\n"; // echo "

\n"; print_r($retArray); // Check for ERRORS if (is_array($retArray)) : // Vehicles found => Generate output $retArrayLen = count($retArray); $xmlVehiclesAvailable .= ""; for ($k = 0; $k < $retArrayLen; $k++) : $xmlVehiclesAvailable .= ""; $xmlVehiclesAvailable .= "" . $retArray[$k][0] . ""; // vha_day $xmlVehiclesAvailable .= "" . $retArray[$k][4] . ""; // vhat_starttimeunit => converted to clock time (e.g. 14:30) $xmlVehiclesAvailable .= "" . $retArray[$k][3] . ""; // vhat_timeunits (available time units [1 time unit equals 10 minutes]) $xmlVehiclesAvailable .= "" . $retArray[$k][7] . ""; // crvh_id $xmlVehiclesAvailable .= "" . $retArray[$k][1] . ""; // crvh_sid $xmlVehiclesAvailable .= "" . $retArray[$k][6] . ""; // vhat_daytime ("0" = 1st defined daytime for the customer, "1" = 2nd daytime, "2" = ....) $xmlVehiclesAvailable .= "" . $retArray[$k][2] . ""; // vhat_daytime (e.g. "Vormittag", "Nachmittag", "Abend") $xmlVehiclesAvailable .= "" . $retArray[$k][10] . ""; // vhat_daytime (e.g. "07:00 - 12:00", "12:00 - 16:00", "16:00 - 21:00") $xmlVehiclesAvailable .= "" . $retArray[$k][5] . ""; // jb_service = ("1" => "LI" = Lieferung, "2" => "MO" = Montage,....) $xmlVehiclesAvailable .= ""; endfor; $xmlVehiclesAvailable .= ""; else : if (!(strpos($retArray, "ERR:ZIPCODE_NOT_IN_ANY_ZONE") === FALSE)) : $err[] = array("102", getLngt("Die PLZ ist keiner Zone zugeordnet!") . " [" . $ecoZipcode . "]"); else : $err[] = array("103", getLngt("Bereichsfehler!")); endif; endif; $debugOut .= "

xmlVehiclesAvailable: " . $xmlVehiclesAvailable . "
\n"; // Write logdata into log database for calling reservation page /* if ($jbId != "") : $parLogCallingReservationPage = getParameterValue("0", "DISPOSITION_LOG_PAGE_CALL_ENABLED", $hqId); if ($parLogCallingReservationPage == "1") : // ZIP = Zipcode, CJ = Combined Job, WD = Whole day request writeToLogDB("130",$hqId,$jbId,"","","",$csId,"ZIP=" . $ecoZipcode . "|ZONE=" . $ecoSrvzId . "|CJ=" . ($combinedJob ? "Y" : "N") . "|WD=" . ($ecoHasWholeDayRequest ? "Y" : "N"),"","",""); endif; endif; */ endif; else : // Authentication data not ok $err[] = array("101", getLngt("Die Authentifizierungsdaten sind nicht in Ordnung.")); endif; // print_r($err); // Check existence of at least one error $errLen = count($err); // Output $appointmentResponse .= ""; if ($errLen > 0) : appointmentRequestLogFile("ERRORS", 1); $appointmentResponse .= "NOT OK"; $appointmentResponse .= ""; for ($i = 0; $i < $errLen; $i++) : $appointmentResponse .= ""; $appointmentResponse .= "" . $err[$i][0] . ""; $appointmentResponse .= ""; $appointmentResponse .= ""; if ($debug) : $appointmentResponse .= "" . $debugOut . ""; endif; appointmentRequestLogFile($err[$i][0] . " : " . mcEncode($err[$i][1]), 1); endfor; $appointmentResponse .= ""; else : $appointmentResponse .= "OK" . $xmlVehiclesAvailable; if ($debug) : $appointmentResponse .= "" . $debugOut . ""; endif; endif; $appointmentResponse .= ""; // Log entries $currentTimeResponse = getDateTime("0"); appointmentRequestLogFile($appointmentResponse); // Write response into log appointmentRequestLogFile($currentTimeResponse . " :: " . $csEid); appointmentRequestLogFile("___________________________________________________________________________________"); // Return output echo $appointmentResponse; /* // REQUEST // Terminanfrage // Identifikation des Kunden ... // Kundennummer (EID) {"STBxxxxxx", ...} => csc_id_payer ... // Eingetragener Benutzer für den Kunden => cs.cs_admin => emp.emp_id => emp.usr_id => usr.usr_id => usr.usr_account ... // Passwort für den Benutzer => usr.usr_password ... // Zusätzliche Session-ID, die mit dem Kunden ausgehandelt wurde [mandatory] ... // Kostenstellenname {"abcd", "efgh", ...} => Mapping csc_id [optional] ... // Nummer der Kundengruppe (Bei einer automatischen Preisfindung muss entweder oder gesetzt sein) ... // Name der Kundengruppe (Bei einer automatischen Preisfindung muss entweder oder gesetzt sein) ... // Activates debug output ("ON" or "YES") GET|SET // Operation (GET or SET appointment(s), default is "GET" if emty tag) ... // Existing order ID ... // ... // ... // ... // ... // ... // ... // ... // ... // ... // ... // ... // ... // ... // ... // ... // ... // // Tageszeiten [optional] [optional] [optional] ... // Wochentage [optional] [optional] [optional] ... // RESPONSE for GET OK .... // Tag, an dem das Fahrzeug verfügbar ist. Wenn nur ein Tag im Request definiert, dann wird dieser auch nur hier in der Antwort zurückgeliefert .... // Uhrzeit, ab wann das Fahrzeug zur Verfügung steht .... // Anzahl Zeiteinheiten, die ab der Startzeit verfügbar sind .... // (Interne) ID des Fahrzeugs .... // Fahrzeugnummer (für Kunden nicht zwingend sichtbar) .... // Tageszeit der Verfügbarkeit ("0" = 1. definierte Tageszeit für den Kunden, "1" = 2. Tageszeit, "2" = 3. Tageszeit,....) .... // Tageszeit der Verfügbarkeit (Text z.B. "Vormittag", "Nachmittag", "Abend") .... // Tageszeit der Verfügbarkeit (Zeitintervall, z.B. "07:00 - 12:00", "12:00 - 16:00", "16:00 - 21:00") .... // Service = ("1" => "LI" = Lieferung, "2" => "MO" = Montage,....) // Weiteres Fahrzeug .... */ ?>