"; orderDataRequestLogFile($currentTime); orderDataRequestLogFile($orderDataReq); if ($selectedLanguage == "" || !is_numeric($selectedLanguage)) : $selectedLanguage = "1"; endif; // Default in English $languageSelected = $selectedLanguage; getLanguage(__FILE__); getCurrentScript(__FILE__); $err = array(); $orderDataResponse = ""; $xmlOrderData = ""; // --------------------------------------------------------------------------- // GLOBAL MODE OF USAGE $globalParUseRelatedCustomer = getParameterValue("0", "GLOBAL_USE_RELATED_CUSTOMER", "0"); // *** Parse request *** $orderDataArray = xml2array($orderDataReq); if ($debug) : echo "Order data:

\n\n"; print_r($orderDataArray); echo "


"; endif; // *** Convert result array to usable parameters *** // * Authentication data * // Generic fields for multiple types $authType = strtolower(convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["auth_type"])); if ($authType == "") : $authType = "cs"; endif; $authId = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["auth_id"]); $authEid = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["auth_eid"]); if ($authEid == "" && $authId != "") : if ($authType == "cr") : $authEid = getFieldValueFromId("courier","cr_id",$authId,"cr_eid"); else : $authEid = getFieldValueFromId("customer","cs_id",$authId,"cs_eid"); endif; endif; // Classic fields for customer only because of compatibility $csEid = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["customer"]); if ($csEid == "") : $csEid = $authEid; endif; $csId = getFieldValueFromId("customer","cs_eid",$csEid,"cs_id"); if ($authId == "") : if ($authType == "cr") : $authId = getFieldValueFromId("courier","cr_eid",$authEid,"cr_id"); else : $authId = $csId; endif; endif; $usrAccount = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["account"]); $usrPassword = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["password"]); $sessionId = convertSpecial($orderDataArray["xml"]["order_data"]["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($orderDataArray["xml"]["order_data"]["auth"]["group_no"]); $csGroupName = convertSpecial($orderDataArray["xml"]["order_data"]["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"; $doContinue = true; if ($csId == "" || !is_numeric($csId)) : $err[] = array("119", getLngt("Der Authentifikations-Header ist nicht vollständig!")); $doContinue = false; endif; if ($doContinue && checkRequestAuthenticationData($usrAccount, $usrPassword, $sessionId, $authId, $authType)) : $debugOut .= "Authentication okay!

\n"; // Data $hqId = getFieldValueFromId("customer","cs_id",$csId,"hq_id"); $cscName = convertSpecial($orderDataArray["xml"]["order_data"]["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 costcenter data $operation = convertSpecial($orderDataArray["xml"]["order_data"]["operation"]); $debugOn = convertSpecial($orderDataArray["xml"]["order_data"]["debug_on"]); $debugOut .= "operation: " . $operation . "
\n"; $debugOut .= "address_type: " . $address_type . "
\n"; if (!$debug && $debugOn == "ON" || $debugOn == "YES") : $debug = true; echo "csId: " . $csId . "
"; echo "csEid: " . $csEid . "

"; endif; // Get requested orders $orderNumbers = convertSpecial($orderDataArray["xml"]["order_data"]["order_numbers"]); $orderNumberArray = explode("|", $orderNumbers); $orderNumberArrayLen = count($orderNumberArray); $isOperationalOrder = convertSpecial($orderDataArray["xml"]["order_data"]["is_operative"]); $isOperationalOrderArray = array(); if ($isOperationalOrder != "") : $isOperationalOrderArray = explode("|", $isOperationalOrder); endif; $isOperationalOrderArrayLen = 0; if (is_array($isOperationalOrderArray)) : $isOperationalOrderArrayLen = count($isOperationalOrderArray); endif; $debugOut .= "isOperationalOrder: " . $isOperationalOrder . "
\n"; $debugOut .= "isOperationalOrderArrayLen: " . $isOperationalOrderArrayLen . "
\n"; if ($operation == "SET") : // Get requested order states to be changed in $orderStateFields = convertSpecial($orderDataArray["xml"]["order_data"]["list_jb_status"]); $orderStateFieldArray = explode("|", $orderStateFields); $orderStateFieldArrayLen = count($orderStateFieldArray); // Get courier to be associated $crIdFields = convertSpecial($orderDataArray["xml"]["order_data"]["list_cr_id"]); $crIdFieldsArray = explode("|", $crIdFields); // Get couriervehicle to be associated $crvhIdFields = convertSpecial($orderDataArray["xml"]["order_data"]["list_crvh_id"]); $crvhIdFieldsArray = explode("|", $crvhIdFields); // Get invoice numbers to be associated (regarding new state equals "3" <=> "exported") $invNoFields = convertSpecial($orderDataArray["xml"]["order_data"]["list_inv_no"]); $invNoFieldsArray = explode("|", $invNoFields); $invNoFieldsArrayLen = count($invNoFieldsArray); // ATTENTION: This following structures regard the FIRST job number in $orderNumbers ONLY! // Only ONE order has to be sent for special job and/or station updates (!!!!) // Get data for selective update of job data fields (table "job") $jbDataArray = $orderDataArray["xml"]["order_data"]["job"]; // Get data for selective update of station data fields (table "tour") $jbTourdata = ""; $jbTourdataZipcode = ""; $jbTourdataCity = ""; $jbTourdataCountry = ""; $numOfStations = 0; if ($orderDataArray["xml"]["order_data"]["stations"]["station"]["tr_sort"] != "" && is_numeric($orderDataArray["xml"]["order_data"]["stations"]["station"]["tr_sort"])) : $numOfStations = 1; else : $numOfStations = count($orderDataArray["xml"]["order_data"]["stations"]["station"]); endif; if ($debug) : echo "orderNumberArrayLen: " . $orderNumberArrayLen . "
"; print_r($orderNumberArray); echo "\n\n

"; echo "isOperationalOrderArrayLen: " . $isOperationalOrderArrayLen . "
"; print_r($isOperationalOrderArray); echo "\n\n

"; echo "orderStateFieldArrayLen: " . $orderStateFieldArrayLen . "
"; print_r($orderStateFieldArray); echo "\n\n

"; echo "invNoFieldsArray: " . $invNoFieldsArrayLen . "
"; print_r($invNoFieldsArray); echo "\n\n

"; echo "numOfStations: " . $numOfStations . "
"; endif; // Iterate array $xmlOrderData .= ""; for ($i = 0; $i < $orderNumberArrayLen; $i++) : $xmlOrderData .= ""; $jbIdOrg = $orderNumberArray[$i]; $xmlOrderData .= "" . $jbIdOrg . ""; // First check valid association between authenticated customer and requested job(s) !!!! // $cscIdPayer = $dbData["job"]["csc_id_payer"]; $cscIdPayer = getFieldValueFromId("job","jb_id",$jbIdOrg,"csc_id_payer"); $csIdPayer = getFieldValueFromId("costcenter","csc_id",$cscIdPayer,"cs_id"); // Get operational job of requested job (!!!!) $jbIsOperational = false; if ($isOperationalOrderArrayLen > 0 && ($isOperationalOrderArray[$i] == "" || $isOperationalOrderArray[$i] == "0")) : // Search for operational job by FDS job $tmpValue = getFieldValueFromClause("phoenix.genericdatacontainer","gdc_content","gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'is_operative' AND gdc_obj_id = '" . $jbIdOrg . "'"); $tmpArray = explode("|", $tmpValue); $jbId = $tmpArray[0]; $jbIsOperational = true; else : // Take operational job (classic mode) $jbId = $jbIdOrg; endif; $xmlOrderData .= "" . $jbId . ""; if ($debug) : echo "jbId: " . $jbId . "
"; endif; if ($jbId != "" && is_numeric($jbId)) : if ($csId == $csIdPayer) : if ($debug) : echo "csId == csIdPayer: YES

"; endif; /* getDBData("job", $jbId); if ($debug) : print_r($dbData); echo "\n\n

"; endif; */ $tmpOpCode = "0"; // Init // [1] CHECK FOR SETTING CARRIER $tmpCrId = $crIdFieldsArray[$i]; $tmpCrvhId = $crvhIdFieldsArray[$i]; if ($tmpCrId != "" && is_numeric($tmpCrId) && $tmpCrvhId != "" && is_numeric($tmpCrvhId)) : // Check association between courier and couriervehicle $tmpCrvhCrId = getFieldValueFromId("couriervehicle","crvh_id",$tmpCrvhId,"cr_id"); if ($tmpCrvhCrId == $tmpCrId) : $tmpCrEid = getFieldValueFromId("courier","cr_id",$tmpCrId,"cr_eid"); $tmpCrvhSid = getFieldValueFromId("couriervehicle","crvh_id",$tmpCrvhId,"crvh_sid"); if ($tmpCrEid != "" && $tmpCrvhSid != "") : // Get potential current courier $tmpJbHqId = getFieldValueFromId("job","jb_id",$jbId,"hq_id"); // $tmpJbCrIdCurr = getFieldValueFromId("job","jb_id",$jbId,"cr_id"); // $tmpJbCrIdOrderCurr = getFieldValueFromId("job","jb_id",$jbId,"cr_id_order"); TA("B"); $res = updateStmt("job", "jb_id", $jbId, array("cr_id", $tmpCrId, "cr_id_order", $tmpCrId, "cr_sid", $tmpCrvhSid), ""); if ($db->affected_rows > 0) : // Write logdata into log database $currentSessionUsrId = "0"; $arLooseRanking = "0"; writeToLogDB("7",$tmpJbHqId,$jbId,$currentSessionUsrId,$tmpCrId,$tmpCrvhSid,"","LOST_RANKING=" . ($arLooseRanking == "1" ? "YES" : "NO")); // Survey // checkJobForSurvey($jbId); endif; TA("C"); TA("E"); else : $tmpOpCode = "113"; $tmpOpMsg = "Der spezifizierte Transporteur oder das spezifizierte Fahrzeug scheinen nicht zu existieren!"; endif; else : $tmpOpCode = "112"; $tmpOpMsg = "Das angegebene Fahrzeug scheint dem Transporteur nicht zugeordnet!"; endif; endif; // [2] CHECK FOR CHANGING STATE // Check for changing state if ($tmpOpCode == "0" && $orderStateFieldArrayLen > 0) : $newState = $orderStateFieldArray[$i]; if ($debug) : echo "newState == " . $newState . "

"; endif; if ($newState != "" && is_numeric($newState)) : // [Order states: 0 = open | 1 = taken | 2 = finished | 9 = to be reassigned manually | 8 = automatic assignment] $jbStatusCurr = getFieldValueFromId("job","jb_id",$jbId,"jb_status"); $tmpOpCode = "0"; $tmpOpMsg = "OK"; if ($newState == "0") : // State "Open" $tmpOpCode = "199"; $tmpOpMsg = "Statusübernahme für OPEN z.Z. nicht implementiert!"; elseif ($newState == "1") : // State "Taken" if ($jbStatusCurr != "2") : // Get potential current courier $tmpJbHqId = getFieldValueFromId("job","jb_id",$jbId,"hq_id"); $tmpJbCrIdCurr = getFieldValueFromId("job","jb_id",$jbId,"cr_id"); $tmpJbCrIdOrderCurr = getFieldValueFromId("job","jb_id",$jbId,"cr_id_order"); if ($tmpJbCrIdCurr != "" && $tmpJbCrIdOrderCurr != "") : TA("B"); $res = updateStmt("job", "jb_id", $jbId, array("jb_status", $newState, "jb_globaljob", "0", "jb_autoranking", "0"), ""); if ($db->affected_rows > 0) : // Set current assigning time for revoking a job if not taken by the courier /* if (existsEntry("autoranking",array("jb_id",$f_jb_id,"cr_id",$cr_id))) : updateStmt("autoranking", "jb_id", $f_jb_id, array("ar_challenge", "0", "ar_lastassigntime", $currentTime, "ar_looseranking", $arLooseRanking, "ar_locating", "0"),"cr_id = '" . $cr_id . "'"); else : insertStmt("autoranking", array("jb_id", $f_jb_id, "cr_id", $cr_id, "ar_challenge", "0", "ar_lastassigntime", $currentTime, "ar_looseranking", $arLooseRanking, "ar_locating", "0")); endif; */ // Insert PDA command to remove job (take cr_id/cr_id_order before changing) /* $currentTimePDA = getDateTime("datetime_plus_offset", array(0,0,30,0,0,0), $formatStr = "Y-m-d H:i:s"); if ($tmpJbCrIdCurr != "" && $tmpJbCrIdCurr != "0") : insertPDACommand($tmpJbHqId, $tmpJbCrIdCurr, "4", "1", $jbId, $currentTimePDA, ""); endif; if ($tmpJbCrIdOrderCurr != "" && $tmpJbCrIdOrderCurr != "0" && $tmpJbCrIdOrderCurr != $tmpJbCrIdCurr) : insertPDACommand($tmpJbHqId, $tmpJbCrIdOrderCurr, "4", "1", $jbId, $currentTimePDA, ""); endif; // Reset availabletime of the OLD courier if requested by the disposition manually if ($f_cr_availabletime_reset == "1") : updateStmt("courier", "cr_id", $tmpJbCrIdCurr, array("cr_availabletime", $currentTime)); endif; */ // Write logdata into log database $currentSessionUsrId = "0"; $arLooseRanking = "0"; writeToLogDB("7",$tmpJbHqId,$jbId,$currentSessionUsrId,$tmpCrId,$tmpCrvhSid,"","LOST_RANKING=" . ($arLooseRanking == "1" ? "YES" : "NO")); // Survey // checkJobForSurvey($jbId); endif; TA("C"); TA("E"); else : $tmpOpCode = "111"; $tmpOpMsg = "Es wurde kein Transporteur oder kein Fahrzeug spezifiziert!"; endif; else : $tmpOpCode = "105"; $tmpOpMsg = "Der neue Status darf nicht gesetzt werden!"; endif; elseif ($newState == "2") : // State "Finished" if ($jbStatusCurr != "2") : TA("B"); $res = updateStmt("job", "jb_id", $jbId, array("jb_status", $newState, "jb_finishtime", $currentTime), ""); if ($db->affected_rows > 0) : // Write logdata into log database $currentSessionUsrId = "0"; $tmpJbHqId = getFieldValueFromId("job","jb_id",$jbId,"hq_id"); writeToLogDB("5",$tmpJbHqId,$jbId,$currentSessionUsrId,$tmpCrId,$tmpCrvhSid,"",""); // Survey // checkJobForSurvey($jbId); endif; TA("C"); TA("E"); else : $tmpOpCode = "105"; $tmpOpMsg = "Der neue Status darf nicht gesetzt werden!"; endif; elseif ($newState == "3") : // State "Exported" if ($jbStatusCurr == "2") : // Check for cancellation $tmpJbStorno = getFieldValueFromId("job","jb_id",$jbId,"jb_storno"); if ($tmpJbStorno == "" || $tmpJbStorno == "0") : // Check for being exported in the past $tmpJbExportTime = getFieldValueFromId("job","jb_id",$jbId,"jb_export_time"); if ($tmpJbExportTime == "" || $tmpJbExportTime == "0000-00-00 00:00:00" || $tmpJbExportTime == "9999-12-31 23:59:59") : // Check for existence of the invoice number $jbInvNo = trim($invNoFieldsArray[$i]); if ($jbInvNo != "") : TA("B"); $res = updateStmt("job", "jb_id", $jbId, array("jb_export_time", $currentTime), ""); if ($db->affected_rows > 0) : // Write into invoice table if (existsEntry("invoice",array("jb_id",$jbId))) : updateStmt("invoice", "jb_id", $jbId, array("inv_no", $jbInvNo, "inv_datetime", $currentTime),""); else : insertStmt("invoice", array("jb_id", $jbId, "inv_no", $jbInvNo, "inv_datetime", $currentTime)); endif; endif; TA("C"); TA("E"); else : $tmpOpCode = "109"; $tmpOpMsg = "Dem zu exportierenden Auftrag wurde keine Rechnungsnummer mitgegeben! Der Export-Status konnte nicht gesetzt werden!"; endif; else : $tmpOpCode = "108"; $tmpOpMsg = "Der Auftrag wurde erhielt bereits in der Vergangenheit den Export-Status!"; endif; else : $tmpOpCode = "107"; $tmpOpMsg = "Der Auftrag wurde storniert und darf keinen Export-Status erhalten!"; endif; else : $tmpOpCode = "106"; $tmpOpMsg = "Der Auftrag ist noch nicht beendet und darf keinen Export-Status erhalten!"; endif; elseif ($newState == "8") : // State "Automatic assignment" $tmpOpCode = "199"; $tmpOpMsg = "Statusübernahme für AUTOMATIC ASSIGNMENT z.Z. nicht implementiert!"; elseif ($newState == "9") : // State "To be reassigned manually" $tmpOpCode = "199"; $tmpOpMsg = "Statusübernahme für REASSIGNED MANUALLY z.Z. nicht implementiert!"; else : $tmpOpCode = "104"; $tmpOpMsg = "Kein gültiger Status für eine Übernahme spezifiziert!"; endif; $xmlOrderData .= "" . $tmpOpCode . ""; $xmlOrderData .= "" . getLngt($tmpOpMsg) . ""; else : $xmlOrderData .= "" . "103" . ""; $xmlOrderData .= "" . getLngt("Es wurde für den Auftrag kein neuer Status angefragt!") . ""; endif; else : $xmlOrderData .= "" . $tmpOpCode . ""; $xmlOrderData .= "" . getLngt("Das Fahrzeug passt nicht zum Auftragnehmer oder es wurde kein Status für den Auftrag gesetzt!") . ""; endif; // [3][A] Get data for selective update of "job" data $doUpdate = true; $defaultFieldArray = array(); $setJobPrice = false; $jobPrice = "0.0000"; TA("B"); $jbDataFieldsArray = array_keys($jbDataArray); $jbDataFieldsArrayLen = count($jbDataFieldsArray); if ($doUpdate && $jbDataFieldsArrayLen > 0) : for ($j = 0; $j < $jbDataFieldsArrayLen; $j++) : if ($jbDataFieldsArray[$j] == "jb_tourname" || $jbDataFieldsArray[$j] == "jb_weight" || $jbDataFieldsArray[$j] == "jb_crvh_length" || $jbDataFieldsArray[$j] == "jb_crvh_width" || $jbDataFieldsArray[$j] == "jb_crvh_height" || $jbDataFieldsArray[$j] == "jb_crvh_position" || $jbDataFieldsArray[$j] == "jb_cr_filter" || $jbDataFieldsArray[$j] == "jb_freetext_1" || $jbDataFieldsArray[$j] == "jb_cr_remark") : if ($jbDataArray[$jbDataFieldsArray[$j]] == "--DEL--") : array_push($defaultFieldArray, $jbDataFieldsArray[$j], ""); else : array_push($defaultFieldArray, $jbDataFieldsArray[$j], $jbDataArray[$jbDataFieldsArray[$j]]); endif; elseif ($jbDataFieldsArray[$j] == "jb_ordertime" || $jbDataFieldsArray[$j] == "jb_warningtime") : if ($jbDataArray[$jbDataFieldsArray[$j]] == "--DEL--") : array_push($defaultFieldArray, $jbDataFieldsArray[$j], ""); else : $jbDatetimeField = $jbDataArray[$jbDataFieldsArray[$j]]; if ($jbDatetimeField != "" && $jbDatetimeField != "0000-00-00 00:00:00") : // $jbDatetimeField = checkDateTimeFormat($jbDatetimeField); // DISABLED BECAUSE OF PHP VERSION ONLY !!! ACTIVATE AFTER MIGRATION !!! $checkGmtdatetimeIsValid = strtotime($jbDatetimeField); if ($checkGmtdatetimeIsValid != "" && is_int($checkGmtdatetimeIsValid)): $jbReserv = 1; else : $xmlOrderData .= "" . "120" . ""; $xmlOrderData .= "" . getLngt("Die Datumsangabe ist nicht korrekt!") . ""; $doUpdate = false; break; endif; endif; array_push($defaultFieldArray, $jbDataFieldsArray[$j], $jbDataArray[$jbDataFieldsArray[$j]]); endif; elseif ($jbDataFieldsArray[$j] == "jb_totalprice") : if ($jbDataArray[$jbDataFieldsArray[$j]] == "--DEL--") : $jobPrice = "0.0000"; else : $jobPrice = $jbDataArray[$jbDataFieldsArray[$j]]; $jobPrice = str_replace (",", ".", $jobPrice); endif; if (!is_numeric($jobPrice)) : $xmlOrderData .= "" . "121" . ""; $xmlOrderData .= "" . getLngt("Die Preisangabe ist nicht numerisch!") . ""; $doUpdate = false; break; endif; array_push($defaultFieldArray, $jbDataFieldsArray[$j], $jobPrice); $setJobPrice = true; endif; endfor; if ($debug) : echo "JOB.defaultFieldArray:
"; print_r($defaultFieldArray); echo "\n\n

"; endif; // Update if ($doUpdate && count($defaultFieldArray) > 0): // Update data in "job" updateStmt("job", "jb_id", $jbId, $defaultFieldArray, ""); // Update price data in "tourservice" if requested. The entry has to exist after order request if ($setJobPrice) : updateStmt("tourservice", "jb_id", $jbId, array("trs_price", $jobPrice, "trs_discount", "0.0000"), "trs_srv_name = 'Grundpreis'"); endif; endif; endif; // [3][B] Get data for selective update of "tour" data if ($doUpdate && $numOfStations > 0) : for ($j = 0; $j < $numOfStations; $j++) : $defaultFieldArray = array(); $trSort = $j + 1; if ($numOfStations == 1) : $stationArray = $orderDataArray["xml"]["order_data"]["stations"]["station"]; else : $stationArray = $orderDataArray["xml"]["order_data"]["stations"]["station"][$j]; endif; $stationFieldArray = array_keys($stationArray); $stationFieldArrayLen = count($stationFieldArray); // * Handle standard DB fields * for ($k = 0; $k < $stationFieldArrayLen; $k++) : if ($stationFieldArray[$k] != "ad_street" && $stationFieldArray[$k] != "ad_zipcode" && $stationFieldArray[$k] != "ad_city" && $stationFieldArray[$k] != "tr_id" && $stationFieldArray[$k] != "ad_id" && $stationFieldArray[$k] != "csc_id" && $stationFieldArray[$k] != "tr_status" && $stationFieldArray[$k] != "tr_sign" && $stationFieldArray[$k] != "tr_signame" && $stationFieldArray[$k] != "tr_modify") : if ($stationArray[$stationFieldArray[$k]] == "--DEL--") : array_push($defaultFieldArray, $stationFieldArray[$k], ""); else : array_push($defaultFieldArray, $stationFieldArray[$k], $stationArray[$stationFieldArray[$k]]); endif; endif; endfor; if ($debug) : echo "stationFieldArrayLen: " . $stationFieldArrayLen . "
"; print_r($stationFieldArray); echo "\n\n

"; endif; // * Handle excluded DB fields like these for the address, etc. * // Check for address fields either all empty or none of them empty $tmpAdStr = $stationArray["ad_street"] . $stationArray["ad_zipcode"] . $stationArray["ad_city"]; if ($tmpAdStr != "" && ($stationArray["ad_street"] == "" || $stationArray["ad_zipcode"] == "" || $stationArray["ad_city"] == "")) : $xmlOrderData .= "" . "130" . ""; $xmlOrderData .= "" . getLngt("Mindestens eine der Stationsadressen ist nicht vollständig!") . ""; $doUpdate = false; break; endif; // ADD HERE "GPS" // .... (!!!!) ........................................ // ADD HERE "ADDRESS SUPPLEMENT" // .... (!!!!) ........................................ $trAdId = ""; $trStreet = $stationArray["ad_street"]; $trZipcode = $stationArray["ad_zipcode"]; $trCity = $stationArray["ad_city"]; $trCountry = $stationArray["ad_country"]; if ($trCountry == "") : $trCountry = "DE"; endif; if ($trStreet != "" && $trZipcode != "" && $trCity != "") : $sqlStmt = "SELECT ad_id FROM address WHERE ad_street = '" . $trStreet . "' AND ad_zipcode = '" . $trZipcode . "' AND ad_city = '" . $trCity . "' AND ad_country = '" . $trCountry . "'"; $trAdId = $db->getOne($sqlStmt); if (DB::isError($ad_id)) die ("$PHP_SELF:
$sqlStmt
" . $ad_id->getMessage()); if ($trAdId == ""): insertStmt("address", array("ad_street", $trStreet, "ad_zipcode", $trZipcode, "ad_city", $trCity, "ad_country", "DE")); $trAdId = getLastInsertID(); endif; // $tmpArray = insertAddress($trStreet, $trZipcode, $trCity, "", "DE", true); // $trAdId = $tmpArray[0]; array_push($defaultFieldArray, "ad_id", $trAdId); endif; // Get "EXTERN" costcenter of the current headquarters if ($globalParUseRelatedCustomer != "1") : $trCscId = getParameterValue("0", "CSC_ID_PAYER_EXTERN", $hqId); array_push($defaultFieldArray, "csc_id", $trCscId); endif; // ADD HERE "tourarticle" // .... (!!!!) ........................................ // Station services $trServices = $stationArray["services"]; $trTimeslots = $trServices["timeslots"]; $trTimesunits = $trServices["timeunits"]; $trShipmentMode = $trServices["shipment_mode"]; $trOrderType = $trServices["order_type"]; $trDeliveryInfo = $trServices["delivery_info"]; $trFlagServiceDoc = $trServices["flag_service_doc"]; $trDocumentsURL = $trServices["documents_URL"]; // Write some service infos into "tr_remark" // if ($trTimeslots != "") : $trSpecialRemark .= "\nTageszeit: " . $trTimeslots . "\n----------"; endif; if ($trOrderType != "") : $trSpecialRemark .= "\nOrder-Typ: " . $trOrderType . "\n----------"; endif; if ($trDeliveryInfo != "") : $trSpecialRemark .= "\nAuslieferinformationen: " . $trDeliveryInfo . "\n----------"; endif; if ($trFlagServiceDoc == "1") : $trSpecialRemark .= "\nINSTRUKTIONEN EXISTIEREN! " . "\n----------"; endif; if ($trDocumentsURL != "") : $trSpecialRemark .= "\nOrder-Typ: " . $trDocumentsURL . "\n----------"; endif; $debugOut .= "STATION SERVICES
\n"; $debugOut .= "trTimeslots: " . $trTimeslots . "
\n"; $debugOut .= "trTimesunits: " . $trTimesunits . "
\n"; $debugOut .= "trShipmentMode: " . $trShipmentMode . "
\n"; $debugOut .= "trOrderType: " . $trOrderType . "
\n"; $debugOut .= "trDeliveryInfo: " . $trDeliveryInfo . "
\n"; $debugOut .= "trFlagServiceDoc: " . $trFlagServiceDoc . "
\n"; $debugOut .= "trDocumentsURL: " . $trDocumentsURL . "
\n"; // ADD HERE "jobcalculator" // .... (!!!!) ........................................ // ADD HERE "genericdatacontainer" // .... (!!!!) ........................................ // Generation parts of the field "jb_tourdata" (e.g.: "04109;04316|Leipzig;Leipzig/Mölkau|DE;DE") if ($j > 0) : $jbTourdataZipcode .= ";"; $jbTourdataCity .= ";"; $jbTourdataCountry .= ";"; endif; $jbTourdataZipcode .= $trZipcode; $jbTourdataCity .= $trCity; $jbTourdataCountry .= $trCountry; if ($debug) : echo "TOUR.defaultFieldArray:
"; print_r($defaultFieldArray); echo "\n\n

"; endif; // Update if ($doUpdate && count($defaultFieldArray) > 0): // Update data in "tour" updateStmt("tour", "jb_id", $jbId, $defaultFieldArray, "tr_sort = '" . $trSort . "'"); endif; endfor; endif; // Update job tour data string if ($doUpdate) : // Generation of the field "jb_tourdata" (e.g.: "04109;04316|Leipzig;Leipzig/Mölkau|DE;DE") $jbTourdata = $jbTourdataZipcode . "|" . $jbTourdataCity . "|" . $jbTourdataCountry; updateStmt("job", "jb_id", $jbId, array("jb_tourdata",$jbTourdata)); endif; if ($doUpdate) : TA("C"); else : TA("R"); endif; TA("E"); if ($doUpdate) : // Generate prices $makePrice = true; if ($makePrice) : // mk_jb_price($jbIdNew); endif; // Generate invoice text if ($globalParUseRelatedCustomer == "1") : // ............. else : // mk_jb_invtext($jbId, false); // updateStmt("job", "jb_id", $jbId, array("jb_tourdata",$jbTourdata)); // Again because of anomalie endif; endif; else : $xmlOrderData .= "" . "102" . ""; $xmlOrderData .= "" . getLngt("Der Auftrag passt nicht zu den Authentifizierungsdaten!") . ""; endif; else : $xmlOrderData .= "" . "101" . ""; $xmlOrderData .= "" . getLngt("Der " . ($jbIsOperational ? "operative " : "") . "Auftrag ist nicht existent!") . ""; endif; $xmlOrderData .= "
"; endfor; $xmlOrderData .= "
"; else : $dataFields = convertSpecial($orderDataArray["xml"]["order_data"]["data_fields"]); $dataFieldArray = explode("|", $dataFields); $dataFieldArrayLen = count($dataFieldArray); $gotTourData = false; // Get data from table "tour" if needed $gotTourarticleData = false; // Get data from table "tourarticle" if needed if ($debug) : print_r($orderNumberArray); echo "\n\n

"; echo $orderNumberArrayLen . "

"; print_r($dataFieldArray); echo "\n\n

"; echo $dataFieldArrayLen . "

"; endif; // Iterate array $xmlOrderData .= ""; for ($i = 0; $i < $orderNumberArrayLen; $i++) : $xmlOrderData .= ""; $jbIdOrg = $orderNumberArray[$i]; $xmlOrderData .= "" . $jbIdOrg . ""; // First check valid association between authenticated customer and requested job(s) !!!! // $cscIdPayer = $dbData["job"]["csc_id_payer"]; $cscIdPayer = getFieldValueFromId("job","jb_id",$jbIdOrg,"csc_id_payer"); $csIdPayer = getFieldValueFromId("costcenter","csc_id",$cscIdPayer,"cs_id"); // Get operational job of requested job (!!!!) if ($isOperationalOrderArrayLen > 0 && ($isOperationalOrderArray[$i] == "" || $isOperationalOrderArray[$i] == "0")) : // Search for operational job by FDS job $tmpValue = getFieldValueFromClause("phoenix.genericdatacontainer","gdc_content","gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'is_operative' AND gdc_obj_id = '" . $jbIdOrg . "'"); $tmpArray = explode("|", $tmpValue); $jbId = $tmpArray[0]; else : // Take operational job (classic mode) $jbId = $jbIdOrg; endif; $xmlOrderData .= "" . $jbId . ""; if ($jbId != "" && is_numeric($jbId)) : getDBData("job", $jbId); if ($debug) : print_r($dbData); echo "\n\n

"; endif; $xmlOrderData .= ""; if ($csIdPayer == $csId) : for ($j = 0; $j < $dataFieldArrayLen; $j++) : $fieldName = $dataFieldArray[$j]; // Get data from table "tour" if needed if (!$gotTourData && substr($fieldName,0,3) == "tr_") : getDBData("tour", $jbId); $gotTourData = true; if ($debug) : print_r($dbData); echo "\n\n

"; endif; endif; // Get data from table "tourarticle" if needed if (!$gotTourarticleData && substr($fieldName,0,5) == "trat_") : getDBData("tourarticle", $jbId); $gotTourData = true; if ($debug) : print_r($dbData); echo "\n\n

"; endif; endif; if (substr($fieldName,0,3) == "tr_") : // "TOUR" $dbDataTourLen = count($dbData["tour"]); $xmlOrderData .= ""; $xmlOrderData .= ""; for ($k = 1; $k <= $dbDataTourLen; $k++) : $fieldVal = $dbData["tour"][$k][$dataFieldArray[$j]]; $xmlOrderData .= ""; $xmlOrderData .= "" . $k . ""; $xmlOrderData .= ""; $xmlOrderData .= ""; endfor; $xmlOrderData .= ""; elseif (substr($fieldName,0,5) == "trat_") : // "TOURARTICLE" else : // "JOB" (default) $fieldVal = $dbData["job"][$dataFieldArray[$j]]; if ($fieldName == "vht_id" || $fieldName == "vht_id_real") : $fieldVal = getFieldValueFromClause("phoenix.metatype","mt_value","mt_type = 'vehicletype' AND mt_sort = '" . $fieldVal . "'"); endif; if ($fieldName == "search_contractors") : $adId = getFieldValueFromClause("phoenix.tour","ad_id","jb_id = '" . $jbId . "' AND tr_sort = '1'"); if ($adId != "" && is_numeric($adId) && $adId > 0) : $adZipcode = getFieldValueFromId("phoenix.address","ad_id",$adId,"ad_zipcode"); $currentAreaCourierArray = getCourierByRanking($adZipcode, "0101000000", $jbId, "", $hqId); // $fieldVal = // $fieldVal .= endif; endif; $xmlOrderData .= ""; $xmlOrderData .= ""; $xmlOrderData .= ""; $xmlOrderData .= ""; endif; endfor; else : $xmlOrderData .= ""; $xmlOrderData .= ""; $xmlOrderData .= ""; $xmlOrderData .= ""; endif; $xmlOrderData .= "
"; else : $xmlOrderData .= ""; $xmlOrderData .= ""; $xmlOrderData .= ""; $xmlOrderData .= ""; $xmlOrderData .= ""; $xmlOrderData .= ""; endif; $xmlOrderData .= "
"; endfor; $xmlOrderData .= "
"; if ($debug) : echo "RESPONSE:
" . $xmlOrderData . "

"; 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 $orderDataResponse .= ""; if ($errLen > 0) : orderDataRequestLogFile("ERRORS", 1); $orderDataResponse .= "NOT OK"; $orderDataResponse .= ""; for ($i = 0; $i < $errLen; $i++) : $orderDataResponse .= ""; $orderDataResponse .= "" . $err[$i][0] . ""; $orderDataResponse .= ""; $orderDataResponse .= ""; if ($debug) : $orderDataResponse .= "" . $debugOut . ""; endif; orderDataRequestLogFile($err[$i][0] . " : " . mcEncode($err[$i][1]), 1); endfor; $orderDataResponse .= ""; else : $orderDataResponse .= "OK" . $xmlOrderData; if ($debug) : $orderDataResponse .= "" . $debugOut . ""; endif; endif; $orderDataResponse .= ""; // Log entries orderDataRequestLogFile($orderDataResponse); // Write response into log orderDataRequestLogFile("___________________________________________________________________________________"); // Return output echo $orderDataResponse; /* // REQUEST // Request for all orderData of the customer // Object (e.g. customer [default]) to be authenticated ... // Object type ("cs" [or "empty"] = customer, "cr" = contractor, etc.). ... // Object ID (internal ID) regarding the type ... // Object EID (unique) regarding the type ... // 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 costcenter(s), default is "GET" if emty tag) // List of votian order numbers "17310234|17310296|17310242|...." // List of flags "0|0|1|...." being an operational order, corresponding with order number in TAG // List of data fields like "vh_id_real|jb_finishtime|...." // List of order states "0|0|1|...." of each order, corresponding with order number in TAG // [Order states: 0 = open | 1 = taken | 2 = finished | 9 = to be reassigned manually | 8 = automatic assignment] ... // List of courier IDs of each order, corresponding with order number in TAG ... // List of vehicle IDs of each order, corresponding with order number in TAG ... // List of invoice numbers of each order, corresponding with order number in TAG // "job" equals "order" ;-) // Optional tour name // Restriction for weight regarding the vehicle types to be disposed // Restriction for length.... // Restriction for width.... // Restriction for height.... // Restriction for positions.... // (New) order time of the job // (New) warning time the job has to be finished // Optional filter (regarding restrictions for [automatic] disposition) // Price of the job [needed for statistic requests] // Freetext field containing the job remark of the order request // Freetext for courier remark .... // Company name // Company name // Street // Zipcode // City // Country (wenn leer, dann "DE") // House number // Floor // Station remark // Person for special contact // Station phone number .... // MORE FIELDS PRESENTLY NOT RELEVANT .... .... // RESPONSE for GET OK // Single order .... // votian (requested) order number .... // votian operational order number with real vehicle id .... // (Requested) field name .... // Field value .... // Next single order .... // RESPONSE for SET OK // Single order .... // votian (requested) order number .... // votian operational order number with real vehicle id // In case of request for changing state .... // Empty or "0" or "ok" <=> Ok, state has been changed | >"0" <=> state has NOT been changed // Message: In case of success empty or "OK" | In case of failure specified message // Next single order .... */ ?>