Files
votianng/html/tools/station_request.php
2026-03-29 10:34:57 +02:00

1909 lines
117 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/*=======================================================================
*
* station_request.php
*
* Autor: Marc Vollmann
*
*
* The script identifies the paying debitor sent by header.
* Regarding the order time (especially the date) an existing order (jb)
* will be searched for the specified day. If found then the station will
* be added, otherwise a new job will be inserted with default pick up station
* (by the payer informations) and the station sent will be added to this
* new job.
*
=======================================================================*/
include_once ("../include/mcglobal.inc.php");
// include_once ("../include/caglobal.inc.php"); // For pricing and invoice-text only
// include_once ('../include/email/htmlMimeMail.php');
include_once ("../include/services_func.inc.php");
include_once ("../include/inc_parseXML.inc.php");
include_once ("../include/inc_mtf_func.inc.php");
include_once ("../include/inc_customer.inc.php");
include_once ("../include/inc_job.inc.php");
include_once ("../include/inc_vehicle.inc.php");
include_once ("../include/inc_disposition.inc.php");
// include_once ("../include/inc_disposition_DEV.inc.php");
// include_once ("../geo/geocode.inc.php");
// Write logdata into log file
$currentTime = getDateTime("0");
$currentDate = getDateTime("3");
$debug = false;
$debugOut = "";
// $orderReq = file_get_contents('php://input');
// Check HTTP-Parameters
getSecHttpVars("1",array("f_act", "orderReq", "selectedLanguage"));
if ($orderReq == "") :
if (isset($argv[1])) :
$orderReq = $argv[1];
endif;
endif;
function stationRequestLogFile ($msg, $logLevel = 0) {
XMLRequestLogFile($msg, $logLevel, $logFile = "stationReq.log");
}
$orderReq = urldecode($orderReq);
$orderReq = str_replace("'", "", $orderReq);
$orderReq = mcEncode($orderReq);
$orderReq = str_replace("'", "", $orderReq);
// echo $orderReq . "<br><br>";
stationRequestLogFile($currentTime);
stationRequestLogFile($orderReq);
if ($selectedLanguage == "" || !is_numeric($selectedLanguage)) : $selectedLanguage = "1"; endif; // Default in English
$languageSelected = $selectedLanguage;
getLanguage(__FILE__);
getCurrentScript(__FILE__);
$err = array();
$outResponse = "";
$acceptOrder = true;
// ---------------------------------------------------------------------------
// GLOBAL MODE OF USAGE
$globalParUseRelatedCustomer = getParameterValue("0", "GLOBAL_USE_RELATED_CUSTOMER", "0");
// *** Init ***
$maxNumOfStationsPerDay = 300;
$maxNumOfRunningStations = 500;
$hqId = "";
$usr_id = "";
$jbStatus = "9";
$jbType = "";
$jbTourname = "";
$fixprice = 0;
$cmpPostage = 0;
$csInvmode = "";
$jbService = 1;
$jbTimeUnits = 2;
$txId = "4";
$txValue = getFieldValueFromId("tax","tx_id",$txId,"tx_value");
$txSign = getFieldValueFromId("tax","tx_id",$txId,"tx_sign");
if ($globalParUseRelatedCustomer == "1") :
$txValue = $txId;
$txSign = "";
endif;
$trServicesArray = array(); // All station services and prices of all tour stations for calling price function
$trArticleArray = array(); // All articles (per station)
$trCalcFunctionsArray = array(); // All calculator functions (per station)
$trCalcFunctionsResultArray = array(); // All calculator function results (per station)
$gHqId = true; // Needed for calculator functions
// *** Parse request ***
$orderArray = xml2array($orderReq);
if ($debug) :
// print_r($orderArray); echo "<br><br><br>";
endif;
// *** Convert result array to usable parameters ***
// Authentication data
$csEid = convertSpecial($orderArray["xml"]["order"]["auth"]["customer"]);
$csId = getFieldValueFromId("customer","cs_eid",$csEid,"cs_id");
$usrAccount = convertSpecial($orderArray["xml"]["order"]["auth"]["account"]);
$usrPassword = convertSpecial($orderArray["xml"]["order"]["auth"]["password"]);
$sessionId = convertSpecial($orderArray["xml"]["order"]["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($orderArray["xml"]["order"]["auth"]["group_no"]);
$csGroupName = convertSpecial($orderArray["xml"]["order"]["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 . "<br>\n";
$debugOut .= "usrPassword: " . $usrPassword . "<br>\n";
$debugOut .= "sessionId: " . $sessionId . "<br>\n";
if (checkRequestAuthenticationData($usrAccount, $usrPassword, $sessionId, $csId)) :
$debugOut .= "Authentication okay!<br><br>\n";
// Data
$hqId = getFieldValueFromId("customer","cs_id",$csId,"hq_id");
$cscName = convertSpecial($orderArray["xml"]["order"]["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 current headquarters instance
// $parHqInstance = getParameterValue("0", "HQ_INSTANCE", $hqId);
// Check disposition mode related to the vehicle state. If enabled then "jb_status" will be set to "0" if vehicle is blocked for the vehicle for the day.
// $dispositionJbStatusMode = getParameterValue("0", "DISPOSITION_JB_STATUS_MODE", $hqId);
// if ($dispositionJbStatusMode == "") : $dispositionJbStatusMode = getParameterValue("0", "DISPOSITION_JB_STATUS_MODE", "0"); endif;
// if ($dispositionJbStatusMode == "") : $dispositionJbStatusMode = "0"; endif;
// Payer versus related
$cscIdPayer = $cscId;
$cscIdRelated = "0";
$csIdRelated = "0";
$jbRelevantCostcenterField = "csc_id_payer";
/*
if ($globalParUseRelatedCustomer == "1") :
$cscIdPayer = "0"; // Set below by inserting the new customer costcenter
$cscIdRelated = $cscId; // The authenticated customer will be the related customer and the end customer will be the payer (look below) !!!!
$csIdRelated = getFieldValueFromId("costcenter","csc_id",$cscIdRelated,"cs_id");
$jbRelevantCostcenterField = "csc_id_related";
endif;
*/
// Get (customer based) parameter for global error handling
$errHandlerDisabled = false;
$tmpErrHandlerDisabled = getParameterValue("0", "STATION_REQUEST_ERROR_HANDLER_DISABLED_" . $csId, "0");
if ($tmpErrHandlerDisabled == "") : $tmpErrHandlerDisabled = getParameterValue("0", "STATION_REQUEST_ERROR_HANDLER_DISABLED", $hqId); endif;
if ($tmpErrHandlerDisabled == "1") :
$errHandlerDisabled = true;
endif;
$operationMode = convertSpecial($orderArray["xml"]["order"]["operation"]); // "UPD" = UPDATE, "DEL" = DELETE, "INS" (or empty or any value) = INSERT
$debugOn = convertSpecial($orderArray["xml"]["order"]["debug_on"]);
$commissionNo = convertSpecial($orderArray["xml"]["order"]["no"]);
// Check commission number regarding existence
$checkExistenceCommissionNo = getParameterValue("0", "STATION_REQUEST_CHECK_EXISTENCE_COMMISSION_NO", $hqId);
if ($checkExistenceCommissionNo == "") : $checkExistenceCommissionNo = getParameterValue("0", "STATION_REQUEST_CHECK_EXISTENCE_COMMISSION_NO", "0"); endif;
if (!$debug && $debugOn == "ON" || $debugOn == "YES") :
$debug = true;
endif;
// Check existence of commission number
if ($checkExistenceCommissionNo == "1") :
// Get num of stations the commission number is associated to
$numOfRows = getCountOfTable("tour", "tr_commission_no = '" . $commissionNo . "'");
// If the sender does not know the order is an "INS" or "UPD" operation then always "UPD" will be sent.
// If the (unique) commission number check for existence is activated then the decision will be made here for the order to be an "UPD" or "INS"
$checkOperationForExistingCommissionNo = getParameterValue("0", "STATION_REQUEST_CHECK_OPERATION_EXISTENCE_COMMISSION_NO", $hqId);
if ($checkOperationForExistingCommissionNo == "") : $checkOperationForExistingCommissionNo = getParameterValue("0", "STATION_REQUEST_CHECK_OPERATION_EXISTENCE_COMMISSION_NO", "0"); endif;
if ($checkOperationForExistingCommissionNo == "1") :
// The commission number does exist, wrap "UPD" to "INS"
if ($operationMode == "UPD" || $operationMode == "UPDATE") :
if ($numOfRows == "0") :
$operationMode = "INS";
endif;
endif;
else :
// Standard check for existing commission number
if ($operationMode == "" || $operationMode == "INS" || $operationMode == "INSERT") :
if ($numOfRows != "" && $numOfRows > 0) :
$err[] = array("100", getLngt("Die eindeutige Kommissionsnummer existiert schon. Die neue Station kann nicht geschrieben werden."));
$acceptOrder = false;
endif;
endif;
endif;
endif;
$jbType = convertSpecial($orderArray["xml"]["order"]["type"]);
$hqMnemonic = convertSpecial($orderArray["xml"]["order"]["hq"]);
$hqId_XML = getFieldValueFromId("headquarters","hq_mnemonic",$hqMnemonic,"hq_id");
if ($hqMnemonic == "" && $hqId != "" && is_numeric($hqId) && $hqId > "0") :
$hqMnemonic = getFieldValueFromId("headquarters","hq_id",$hqId,"hq_mnemonic");
endif;
$vhtId = convertSpecial($orderArray["xml"]["order"]["vehicle"]["type_no"]);
$vhtType = convertSpecial($orderArray["xml"]["order"]["vehicle"]["type_name"]);
if ($vhtId != "" && is_numeric($vhtId)) :
$vhtType = getFieldValueFromClause("metatype","mt_value","mt_type = 'vehicletype' AND mt_sort = '" . $vhtId . "'");
elseif ($vhtType != "") :
$vhtId = getFieldValueFromClause("metatype","mt_sort","mt_type = 'vehicletype' AND mt_value = '" . $vhtType . "'");
endif;
$jbCrvhWeight = convertSpecial($orderArray["xml"]["order"]["vehicle"]["weight"],"intval");
$jbCrvhLength = convertSpecial($orderArray["xml"]["order"]["vehicle"]["length"],"intval");
$jbCrvhWidth = convertSpecial($orderArray["xml"]["order"]["vehicle"]["width"],"intval");
$jbCrvhHeight = convertSpecial($orderArray["xml"]["order"]["vehicle"]["height"],"intval");
$jbCrvhPosition = convertSpecial($orderArray["xml"]["order"]["vehicle"]["position"],"intval");
$jbOrdertime = convertSpecial($orderArray["xml"]["order"]["ordertime"]);
$jbOrdertimeUTC = convertSpecial($orderArray["xml"]["order"]["ordertimeUTC"]);
$jbWarningtime = convertSpecial($orderArray["xml"]["order"]["warningtime"]);
$jbWarningtimeUTC = convertSpecial($orderArray["xml"]["order"]["warningtimeUTC"]);
$jbAcquisitiontime = convertSpecial($orderArray["xml"]["order"]["acquisition_time"]);
$jbReserv = 0;
// Order time
if ($jbOrdertime == "" || $jbOrdertime == "0000-00-00 00:00:00") :
// Check for UTC
if ($jbOrdertimeUTC == "" || $jbOrdertimeUTC == "0000-00-00 00:00:00") :
$jbOrdertime = $currentTime;
else :
$gmtDT = substr($jbOrdertimeUTC, 0,19);
$checkGmtdatetimeIsValid = strtotime($gmtDT);
if ($checkGmtdatetimeIsValid != "" && is_int($checkGmtdatetimeIsValid)):
$jbOrdertime = date("Y-m-d H:i:s", gmmktime(substr($gmtDT,11,2), substr($gmtDT,14,2), substr($gmtDT,17,2), substr($gmtDT,5,2), substr($gmtDT,8,2), substr($gmtDT,0,4)));
else :
$err[] = array("112", getLngt("Das Datum wurde nicht erwartungsgemäß übergeben."));
$acceptOrder = false;
endif;
$jbReserv = 1;
endif;
else :
// $jbOrdertime = checkDateTimeFormat($jbOrdertime); // DISABLED BECAUSE OF PHP VERSION ONLY !!! ACTIVATE AFTER MIGRATION !!!
$checkGmtdatetimeIsValid = strtotime($jbOrdertime);
if ($checkGmtdatetimeIsValid != "" && is_int($checkGmtdatetimeIsValid)):
$jbReserv = 1;
else :
$err[] = array("113", getLngt("Die Auftragszeit wurde nicht erwartungsgemäß übergeben."));
$acceptOrder = false;
endif;
endif;
// Check ordertime being in the future
if ($operationMode != "DEL" && $operationMode != "DELETE" && $operationMode != "UPD" && $operationMode != "UPDATE") :
if ($executeOperationsBecauseNoEvent) :
$parCheckOrdertime = getObjectBasedParameterValue("STATION_REQUEST_CHECK_ORDERTIME", $csId, $hqId);
if ($parCheckOrdertime == "1") :
$errTime = $currentDate . " 00:00:00";
if ($jbOrdertime < $errTime) :
$err[] = array("116", getLngt("Die Auftragszeit liegt in der Vergangenheit."));
$acceptOrder = false;
endif;
endif;
endif;
endif;
// Warning time
if ($jbWarningtime == "" || $jbWarningtime == "0000-00-00 00:00:00") :
// Check for UTC
if ($jbWarningtimeUTC != "" && $jbWarningtimeUTC != "0000-00-00 00:00:00") :
$gmtDT = substr($jbWarningtimeUTC, 0,19);
$checkGmtdatetimeIsValid = strtotime($gmtDT);
if ($checkGmtdatetimeIsValid != "" && is_int($checkGmtdatetimeIsValid)):
$jbWarningtime = date("Y-m-d H:i:s", gmmktime(substr($gmtDT,11,2), substr($gmtDT,14,2), substr($gmtDT,17,2), substr($gmtDT,5,2), substr($gmtDT,8,2), substr($gmtDT,0,4)));
else :
$err[] = array("114", getLngt("Die späteste Erledigungszeit wurde nicht erwartungsgemäß übergeben."));
$acceptOrder = false;
endif;
endif;
else :
// $jbWarningtime = checkDateTimeFormat($jbWarningtime); // DISABLED BECAUSE OF PHP VERSION ONLY !!! ACTIVATE AFTER MIGRATION !!!
$checkGmtdatetimeIsValid = strtotime($jbWarningtime);
if ($checkGmtdatetimeIsValid == "" || !is_int($checkGmtdatetimeIsValid)):
$err[] = array("114", getLngt("Die späteste Erledigungszeit wurde nicht erwartungsgemäß übergeben."));
$acceptOrder = false;
endif;
endif;
$crSid = convertSpecial($orderArray["xml"]["order"]["courier"]);
$crIdOrder = "";
if ($crSid != "") :
$crIdOrder = getFieldValueFromId("couriervehicle","crvh_sid",$crSid,"cr_id");
if ($crIdOrder == "") : $crSid = ""; endif;
endif;
$jbCrFilter = convertSpecial($orderArray["xml"]["order"]["filter"]);
$jbRemark = convertSpecial($orderArray["xml"]["order"]["remark"]);
$parJbRemarkMode = getObjectBasedParameterValue("STATION_REQUEST_JB_REMARK_MODE", $csId, $hqId);
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if ($parJbRemarkMode == "1") :
// Overrule invoice text with customer date and daytime
$jbRemark = ""; // <= !!!!!!!!!!!! HERE !!!!!!!!!!!!!!!!!!!
endif;
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$jbCrRemark = convertSpecial($orderArray["xml"]["order"]["courier_remark"]);
// Check for existing job for the customer for the specified day in "ordertime"
$jbIdCurrent = "";
if ($acceptOrder) :
$jbIdCurrent = getOneStmt("SELECT jb.jb_id AS jb_id FROM job AS jb, costcenter AS csc, genericdatacontainer AS gdc WHERE LEFT(jb.jb_ordertime,10) = '" . substr($jbOrdertime,0,10) . "' AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' AND gdc.gdc_obj_id = jb.jb_id AND gdc.gdc_obj_type = 'jb' AND gdc.gdc_gen_fieldname = 'station_request'", "jb_id");
endif;
if ($operationMode == "UPD" || $operationMode == "UPDATE" || $operationMode == "DEL" || $operationMode == "DELETE") :
$checkOperationForJbStatus = true;
$tmpCheckJbStatus = getParameterValue("0", "STATION_REQUEST_CHECK_OPERATION_JOB_STATUS_DISABLED", $hqId);
if ($tmpCheckJbStatus == "1") :
$checkOperationForJbStatus = false;
endif;
if ($checkOperationForJbStatus) :
if ($jbIdCurrent != "") :
$jbStatusCurrent = getFieldValueFromId("job","jb_id",$jbIdCurrent,"jb_status");
if ($jbStatusCurrent != "0" && $jbStatusCurrent != "9") :
$err[] = array("118", getLngt("Die angeforderte Operation wird zurückgewiesen, weil sich der Auftrag in Bearbeitung befindet oder erledigt ist."));
$acceptOrder = false;
endif;
endif;
endif;
endif;
// Special informations inserted into GDC structure
$jbGdcArray = array();
$numOfGdcEntries = count($orderArray["xml"]["order"]["gdc"]["val"]);
if ($numOfGdcEntries > 0) :
for ($k = 0; $k < $numOfGdcEntries; $k++) :
if ($numOfGdcEntries == 1) :
$jbGdcArray[0] = convertSpecial($orderArray["xml"]["order"]["gdc"]["val"]);
else :
$jbGdcArray[$k] = convertSpecial($orderArray["xml"]["order"]["gdc"]["val"][$k]);
endif;
endfor;
endif;
// Init
$jbTourdata = "";
$jbTourdataZipcode = "";
$jbTourdataCity = "";
$jbTourdataCountry = "";
// "TOUR" data
$numOfStations = count($orderArray["xml"]["order"]["stations"]["station"]);
if ($debug) :
echo "numOfStations: " . $numOfStations . "<br><br>";
endif;
if ($numOfStations > 0) :
// Station arrays
$trWareFromTo = array(); $trCommissionNo = array(); $trCostcenter = array(); $trCompany = array(); $trCompany2 = array();
$trScanCodeMandatory = array(); $trDeliveryOutcomeMode = array(); $trDeliveryOutcomeStates = array();
$trStreet = array(); $trHouseno = array(); $trFloor = array(); $trZipcode = array(); $trCity = array(); $trAdId = array();
$trSpecialRemark = array(); $trPerson = array(); $trPhone = array(); $trEmail = array();
$trAdSupplement_1 = array(); $trAdSupplement_2 = array(); $trAdSupplement_3 = array(); $trAdSupplement_4 = array(); $trAdSupplement_5 = array();
$trInvCompany = array(); $trInvCompany2 = array();
$trInvStreet = array(); $trInvHouseno = array(); $trInvFloor = array(); $trInvZipcode = array(); $trInvCity = array(); $trInvAdId = array();
$trInvSpecialRemark = array(); $trInvPerson = array(); $trInvPhone = array(); $trInvEmail = array();
$trInvAdSupplement_1 = array(); $trInvAdSupplement_2 = array(); $trInvAdSupplement_3 = array(); $trInvAdSupplement_4 = array(); $trInvAdSupplement_5 = array();
$trInvPaymentMethod = array(); $trInvVoucher = array(); $trInvpartialPayment = array(); $trInvPriceMode = array();
$trGdcArray = array();
// Station services
$trServices = array(); $trTimeslots = array(); $trTimesunits = array(); $trShipmentMode = array(); $trOrderType = array();
$trDeliveryInfo = array(); $trFlagServiceDoc = array(); $trDocumentsURL = array();
// Arrays for summarized article fields OR maximum values
$trSumWeight = array(); $trSumPositions = array(); $trSumPieces = array(); $trSumPrices = array(); $trSumVolume = array();
$trMaxHeight = array(); $trMaxLength = array(); $trMaxWidth = array(); $trMaxDimension = array(); $trSumHoursEstimated = array();
// for ($i = 0; $i < $numOfStations; $i++) :
// First station has to be empty
for ($i = 1; $i < $numOfStations; $i++) :
$trSort = $i + 1;
$trWareFromTo[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["ware_from_to"]);
$trCommissionNo[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["commission_no"]);
$trCostcenter[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["costcenter"]);
$trCscId[$i] = "";
if ($trCostcenter[$i] != "") :
$trCscId[$i] = getFieldValueFromClause("costcenter","csc_id","cs_id = '" . $csId . "' AND csc_name = '" . $trCostcenter[$i] . "'");
endif;
$debugOut .= "trCostcenter[$i]: " . $trCostcenter[$i] . "<br>\n";
$debugOut .= "trCscId[$i]: " . $trCscId[$i] . "<br>\n";
$debugOut .= "<br>\n";
// Mandatory scan (bar)code
$trScanCodeMandatory[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["scan_code_mandatory"]);
// Delivery outcome
$trDeliveryOutcomeMode[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["delivery_outcome_mode"]);
$trDeliveryOutcomeStates[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["delivery_outcome_states"]);
// Invoice address
$trInvCompany[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["company"]);
$trInvCompany2[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["company2"]);
$trInvStreet[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["street"]);
$trInvHouseno[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["houseno"]);
$trInvZipcode[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["zipcode"]);
$trInvCity[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["city"]);
$trInvSpecialRemark[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["special_remark"]);
$trInvPerson[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["person"]);
$trInvPhone[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["phone"]);
$trInvEmail[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["email"]);
$trInvAdSupplement_1[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["ad_supplement_1"]);
$trInvAdSupplement_2[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["ad_supplement_2"]);
$trInvAdSupplement_3[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["ad_supplement_3"]);
$trInvAdSupplement_4[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["ad_supplement_4"]);
$trInvAdSupplement_5[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["ad_supplement_5"]);
$debugOut .= "INVOICE ADDRESS BY XML-TAGS<br>\n";
$debugOut .= "trInvCompany[$i]: " . $trInvCompany[$i] . "<br>\n";
$debugOut .= "trInvCompany2[$i]: " . $trInvCompany2[$i] . "<br>\n";
$debugOut .= "trInvAdId[$i]: " . $trInvAdId[$i] . "<br>\n";
$debugOut .= "trInvStreet[$i]: " . $trInvStreet[$i] . "<br>\n";
$debugOut .= "trInvHouseno[$i]: " . $trInvHouseno[$i] . "<br>\n";
$debugOut .= "trInvFloor[$i]: " . $trInvFloor[$i] . "<br>\n";
$debugOut .= "trInvZipcode[$i]: " . $trInvZipcode[$i] . "<br>\n";
$debugOut .= "trInvCity[$i]: " . $trInvCity[$i] . "<br>\n";
$debugOut .= "trInvSpecialRemark[$i]: " . $trInvSpecialRemark[$i] . "<br>\n";
$debugOut .= "trInvPerson[$i]: " . $trInvPerson[$i] . "<br>\n";
$debugOut .= "trInvPhone[$i]: " . $trInvPhone[$i] . "<br>\n";
$debugOut .= "trInvEmail[$i]: " . $trInvEmail[$i] . "<br>\n";
$debugOut .= "trInvAdSupplement_1[$i]: " . $trInvAdSupplement_1[$i] . "<br>\n";
$debugOut .= "trInvAdSupplement_2[$i]: " . $trInvAdSupplement_2[$i] . "<br>\n";
$debugOut .= "trInvAdSupplement_3[$i]: " . $trInvAdSupplement_3[$i] . "<br>\n";
$debugOut .= "trInvAdSupplement_4[$i]: " . $trInvAdSupplement_4[$i] . "<br>\n";
$debugOut .= "trInvAdSupplement_5[$i]: " . $trInvAdSupplement_5[$i] . "<br>\n";
$debugOut .= "<br>\n";
$trInvAdId[$i] = "";
if ($trInvStreet[$i] != "" && $trInvZipcode[$i] != "" && $trInvCity[$i] != "") :
$sqlStmt = "SELECT ad_id FROM address WHERE ad_street = '" . $trInvStreet[$i] . "' AND ad_zipcode = '" . $trInvZipcode[$i] . "' AND ad_city = '" . $trInvCity[$i] . "' AND ad_country = 'DE'";
$trInvAdId[$i] = $db->getOne($sqlStmt);
if (DB::isError($ad_id)) die ("$PHP_SELF: <br>$sqlStmt<br>" . $ad_id->getMessage());
if ($trInvAdId[$i] == ""):
insertStmt("address", array("ad_street", $trInvStreet[$i], "ad_zipcode", $trInvZipcode[$i], "ad_city", $trInvCity[$i], "ad_country", "DE"));
$trInvAdId[$i] = getLastInsertID();
endif;
// $tmpArray = insertAddress($trInvStreet[$i], $trInvZipcode[$i], $trInvCity[$i], "", "DE", true);
// $trAdId[$i] = $tmpArray[0];
endif;
if ($trCscId[$i] != "" && $trCscId[$i] != "0") :
$debugOut .= "trCostcenter[$i] does exist: YES<br><br>\n";
// Delivery address
$trCompany[$i] = getFieldValueFromClause("costcenteraddress","cscad_comp","adt_id = '4' AND csc_id = '" . $trCscId[$i] . "'");
$trCompany2[$i] = getFieldValueFromClause("costcenteraddress","cscad_comp2","adt_id = '4' AND csc_id = '" . $trCscId[$i] . "'");
$trAdId[$i] = getFieldValueFromClause("costcenteraddress","ad_id","adt_id = '4' AND csc_id = '" . $trCscId[$i] . "'");
$trStreet[$i] = getFieldValueFromId("address","ad_id",$trAdId[$i],"ad_street");
$trHouseno[$i] = getFieldValueFromClause("costcenteraddress","cscad_hsno","adt_id = '4' AND csc_id = '" . $trCscId[$i] . "'");
$trFloor[$i] = getFieldValueFromClause("costcenteraddress","cscad_floor","adt_id = '4' AND csc_id = '" . $trCscId[$i] . "'");
$trZipcode[$i] = getFieldValueFromId("address","ad_id",$trAdId[$i],"ad_zipcode");
$trCity[$i] = getFieldValueFromId("address","ad_id",$trAdId[$i],"ad_city");
$trSpecialRemark[$i] = getFieldValueFromClause("costcenteraddress","cscad_remark","adt_id = '4' AND csc_id = '" . $trCscId[$i] . "'");
$trPerson[$i] = getFieldValueFromClause("costcenteraddress","cscad_person","adt_id = '4' AND csc_id = '" . $trCscId[$i] . "'");
$trPhone[$i] = getFieldValueFromClause("costcenteraddress","cscad_phone","adt_id = '4' AND csc_id = '" . $trCscId[$i] . "'");
$trEmail[$i] = getFieldValueFromClause("costcenteraddress","cscad_email","adt_id = '4' AND csc_id = '" . $trCscId[$i] . "'");
$tmpAddressSupplement = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = 'csc' AND gdc_gen_fieldname = 'ad_supplement' AND gdc_context = '" . $trSort . "' AND gdc_obj_id = '" . $trCscId[$i] . "'");
$tmpAddressSupplement = str_replace("|", "-,-", $tmpAddressSupplement);
$tmpAddressSupplementArray = spliti("-,-",$tmpAddressSupplement);
$trAdSupplement_1[$i] = $tmpAddressSupplementArray[0];
$trAdSupplement_2[$i] = $tmpAddressSupplementArray[1];
$trAdSupplement_3[$i] = $tmpAddressSupplementArray[2];
$trAdSupplement_4[$i] = $tmpAddressSupplementArray[3];
$trAdSupplement_5[$i] = $tmpAddressSupplementArray[4];
$debugOut .= "PICKUP/DELIVERY ADDRESS BY EXISTING COSTCENTER<br>\n";
$debugOut .= "trCompany[$i]: " . $trCompany[$i] . "<br>\n";
$debugOut .= "trCompany2[$i]: " . $trCompany2[$i] . "<br>\n";
$debugOut .= "trAdId[$i]: " . $trAdId[$i] . "<br>\n";
$debugOut .= "trStreet[$i]: " . $trStreet[$i] . "<br>\n";
$debugOut .= "trHouseno[$i]: " . $trHouseno[$i] . "<br>\n";
$debugOut .= "trFloor[$i]: " . $trFloor[$i] . "<br>\n";
$debugOut .= "trZipcode[$i]: " . $trZipcode[$i] . "<br>\n";
$debugOut .= "trCity[$i]: " . $trCity[$i] . "<br>\n";
$debugOut .= "trSpecialRemark[$i]: " . $trSpecialRemark[$i] . "<br>\n";
$debugOut .= "trPerson[$i]: " . $trPerson[$i] . "<br>\n";
$debugOut .= "trPhone[$i]: " . $trPhone[$i] . "<br>\n";
$debugOut .= "trEmail[$i]: " . $trEmail[$i] . "<br>\n";
$debugOut .= "trAdSupplement_1[$i]: " . $trAdSupplement_1[$i] . "<br>\n";
$debugOut .= "trAdSupplement_2[$i]: " . $trAdSupplement_2[$i] . "<br>\n";
$debugOut .= "trAdSupplement_3[$i]: " . $trAdSupplement_3[$i] . "<br>\n";
$debugOut .= "trAdSupplement_4[$i]: " . $trAdSupplement_4[$i] . "<br>\n";
$debugOut .= "trAdSupplement_5[$i]: " . $trAdSupplement_5[$i] . "<br>\n";
$debugOut .= "<br>\n";
// Invoice address
if ($trInvAdId[$i] == "") :
$trInvCompany[$i] = getFieldValueFromClause("costcenteraddress","cscad_comp","adt_id = '2' AND csc_id = '" . $trCscId[$i] . "'");
$trInvCompany2[$i] = getFieldValueFromClause("costcenteraddress","cscad_comp2","adt_id = '2' AND csc_id = '" . $trCscId[$i] . "'");
$trInvAdId[$i] = getFieldValueFromClause("costcenteraddress","ad_id","adt_id = '2' AND csc_id = '" . $trCscId[$i] . "'");
$trInvStreet[$i] = getFieldValueFromId("address","ad_id",$trInvAdId[$i],"ad_street");
$trInvHouseno[$i] = getFieldValueFromClause("costcenteraddress","cscad_hsno","adt_id = '2' AND csc_id = '" . $trCscId[$i] . "'");
$trInvFloor[$i] = getFieldValueFromClause("costcenteraddress","cscad_floor","adt_id = '2' AND csc_id = '" . $trCscId[$i] . "'");
$trInvZipcode[$i] = getFieldValueFromId("address","ad_id",$trInvAdId[$i],"ad_zipcode");
$trInvCity[$i] = getFieldValueFromId("address","ad_id",$trInvAdId[$i],"ad_city");
$trInvSpecialRemark[$i] = getFieldValueFromClause("costcenteraddress","cscad_remark","adt_id = '2' AND csc_id = '" . $trCscId[$i] . "'");
$trInvPerson[$i] = getFieldValueFromClause("costcenteraddress","cscad_person","adt_id = '2' AND csc_id = '" . $trCscId[$i] . "'");
$trInvPhone[$i] = getFieldValueFromClause("costcenteraddress","cscad_phone","adt_id = '2' AND csc_id = '" . $trCscId[$i] . "'");
$trInvEmail[$i] = getFieldValueFromClause("costcenteraddress","cscad_email","adt_id = '2' AND csc_id = '" . $trCscId[$i] . "'");
$tmpInvAddressSupplement = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = 'csc' AND gdc_gen_fieldname = 'ad_inv_supplement' AND gdc_context = '" . $trSort . "' AND gdc_obj_id = '" . $trCscId[$i] . "'");
$tmpInvAddressSupplement = str_replace("|", "-,-", $tmpInvAddressSupplement);
$tmpInvAddressSupplementArray = spliti("-,-",$tmpInvAddressSupplement);
$trInvAdSupplement_1[$i] = $tmpInvAddressSupplementArray[0];
$trInvAdSupplement_2[$i] = $tmpInvAddressSupplementArray[1];
$trInvAdSupplement_3[$i] = $tmpInvAddressSupplementArray[2];
$trInvAdSupplement_4[$i] = $tmpInvAddressSupplementArray[3];
$trInvAdSupplement_5[$i] = $tmpInvAddressSupplementArray[4];
$debugOut .= "INVOICE ADDRESS BY EXISTING COSTCENTER<br>\n";
$debugOut .= "trInvCompany[$i]: " . $trInvCompany[$i] . "<br>\n";
$debugOut .= "trInvCompany2[$i]: " . $trInvCompany2[$i] . "<br>\n";
$debugOut .= "trInvAdId[$i]: " . $trInvAdId[$i] . "<br>\n";
$debugOut .= "trInvStreet[$i]: " . $trInvStreet[$i] . "<br>\n";
$debugOut .= "trInvHouseno[$i]: " . $trInvHouseno[$i] . "<br>\n";
$debugOut .= "trInvFloor[$i]: " . $trInvFloor[$i] . "<br>\n";
$debugOut .= "trInvZipcode[$i]: " . $trInvZipcode[$i] . "<br>\n";
$debugOut .= "trInvCity[$i]: " . $trInvCity[$i] . "<br>\n";
$debugOut .= "trInvSpecialRemark[$i]: " . $trInvSpecialRemark[$i] . "<br>\n";
$debugOut .= "trInvPerson[$i]: " . $trInvPerson[$i] . "<br>\n";
$debugOut .= "trInvPhone[$i]: " . $trInvPhone[$i] . "<br>\n";
$debugOut .= "trInvEmail[$i]: " . $trInvEmail[$i] . "<br>\n";
$debugOut .= "trInvAdSupplement_1[$i]: " . $trInvAdSupplement_1[$i] . "<br>\n";
$debugOut .= "trInvAdSupplement_2[$i]: " . $trInvAdSupplement_2[$i] . "<br>\n";
$debugOut .= "trInvAdSupplement_3[$i]: " . $trInvAdSupplement_3[$i] . "<br>\n";
$debugOut .= "trInvAdSupplement_4[$i]: " . $trInvAdSupplement_4[$i] . "<br>\n";
$debugOut .= "trInvAdSupplement_5[$i]: " . $trInvAdSupplement_5[$i] . "<br>\n";
$debugOut .= "<br>\n";
endif;
else :
$debugOut .= "trCostcenter[$i] does exist: NO<br><br>\n";
// Delivery address
$trCompany[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["company"]);
$trCompany2[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["company2"]);
$trStreet[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["street"]);
$trHouseno[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["houseno"]);
$trFloor[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["floorno"]);
$trZipcode[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["zipcode"]);
$trCity[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["city"]);
$trSpecialRemark[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["special_remark"]);
$trPerson[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["person"]);
$trPhone[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["phone"]);
$trEmail[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["email"]);
$trAdSupplement_1[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["ad_supplement_1"]);
$trAdSupplement_2[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["ad_supplement_2"]);
$trAdSupplement_3[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["ad_supplement_3"]);
$trAdSupplement_4[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["ad_supplement_4"]);
$trAdSupplement_5[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["ad_supplement_5"]);
$trAdId[$i] = "";
if ($trStreet[$i] != "" && $trZipcode[$i] != "" && $trCity[$i] != "") :
$sqlStmt = "SELECT ad_id FROM address WHERE ad_street = '" . $trStreet[$i] . "' AND ad_zipcode = '" . $trZipcode[$i] . "' AND ad_city = '" . $trCity[$i] . "' AND ad_country = 'DE'";
$trAdId[$i] = $db->getOne($sqlStmt);
if (DB::isError($ad_id)) die ("$PHP_SELF: <br>$sqlStmt<br>" . $ad_id->getMessage());
if ($trAdId[$i] == ""):
insertStmt("address", array("ad_street", $trStreet[$i], "ad_zipcode", $trZipcode[$i], "ad_city", $trCity[$i], "ad_country", "DE"));
$trAdId[$i] = getLastInsertID();
endif;
// $tmpArray = insertAddress($trStreet[$i], $trZipcode[$i], $trCity[$i], "", "DE", true);
// $trAdId[$i] = $tmpArray[0];
endif;
// Get "EXTERN" costcenter of the current headquarters
if ($globalParUseRelatedCustomer != "1") :
$trCscId[$i] = getParameterValue("0", "CSC_ID_PAYER_EXTERN", $hqId);
endif;
$debugOut .= "PICKUP/DELIVERY ADDRESS BY XML-TAGS<br>\n";
$debugOut .= "trCompany[$i]: " . $trCompany[$i] . "<br>\n";
$debugOut .= "trCompany2[$i]: " . $trCompany2[$i] . "<br>\n";
$debugOut .= "trAdId[$i]: " . $trAdId[$i] . "<br>\n";
$debugOut .= "trStreet[$i]: " . $trStreet[$i] . "<br>\n";
$debugOut .= "trHouseno[$i]: " . $trHouseno[$i] . "<br>\n";
$debugOut .= "trFloor[$i]: " . $trFloor[$i] . "<br>\n";
$debugOut .= "trZipcode[$i]: " . $trZipcode[$i] . "<br>\n";
$debugOut .= "trCity[$i]: " . $trCity[$i] . "<br>\n";
$debugOut .= "trSpecialRemark[$i]: " . $trSpecialRemark[$i] . "<br>\n";
$debugOut .= "trPerson[$i]: " . $trPerson[$i] . "<br>\n";
$debugOut .= "trPhone[$i]: " . $trPhone[$i] . "<br>\n";
$debugOut .= "trEmail[$i]: " . $trEmail[$i] . "<br>\n";
$debugOut .= "trAdSupplement_1[$i]: " . $trAdSupplement_1[$i] . "<br>\n";
$debugOut .= "trAdSupplement_2[$i]: " . $trAdSupplement_2[$i] . "<br>\n";
$debugOut .= "trAdSupplement_3[$i]: " . $trAdSupplement_3[$i] . "<br>\n";
$debugOut .= "trAdSupplement_4[$i]: " . $trAdSupplement_4[$i] . "<br>\n";
$debugOut .= "trAdSupplement_5[$i]: " . $trAdSupplement_5[$i] . "<br>\n";
$debugOut .= "<br>\n";
endif;
// Invoice data
// Presently store data into "tr_remark" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/*
$trInvPaymentMethod[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["payment_method"]); // Payment method
if ($trSpecialRemark[$i] != "") : $trSpecialRemark[$i] .= "<br>" . "------------------------"; endif;
if ($trInvPaymentMethod[$i] != "") : $trSpecialRemark[$i] .= "<br>" . getLngt("Bezahlart") . ":" . $trInvPaymentMethod[$i]; endif;
$trInvPriceMode[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["price_mode"]); // Price mode (e.g. "family card")
if ($trInvPriceMode[$i] != "") : $trSpecialRemark[$i] .= "<br>" . getLngt("Spezialpreis") . ":" . $trInvPriceMode[$i]; endif;
$trInvPartialPayment[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["partial_payment"]); // Partial payment
if ($trInvPartialPayment[$i] != "") : $trSpecialRemark[$i] .= "<br>" . getLngt("Bereits bezahlt") . ":" . $trInvPartialPayment[$i]; endif;
$trInvVoucher[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["voucher_no"]); // Voucher
if ($trInvVoucher[$i] != "") : $trSpecialRemark[$i] .= "<br>" . getLngt("Voucher") . ":" . $trInvVoucher[$i]; endif;
// if ($trInvAdId[$i] == "") : $trInvAdId[$i] = $trAdId[$i]; endif; // No invoice address specified => take delivery address
if ($trInvAdId[$i] != "") :
$trSpecialRemark[$i] .= "<br>" . "------------------------";
if ($trInvCompany[$i] != "") : $trSpecialRemark[$i] .= "<br>" . $trInvCompany[$i] . "<br>" . $trInvCompany2[$i]; endif;
$trSpecialRemark[$i] .= "<br>" . $trInvCompany[$i] . "<br>" . $trInvCompany2[$i];
$trSpecialRemark[$i] .= "<br>" . getLngt("Adresse") . ":" . "<br>" . $trInvStreet[$i] . " " . $trInvHouseno[$i] . "<br>" . $trInvZipcode[$i] . " " . $trInvCity[$i];
endif;
if ($trInvPerson[$i] != "") : $trSpecialRemark[$i] .= "<br>" . $trInvPerson[$i]; endif;
if ($trInvPhone[$i] != "") : $trSpecialRemark[$i] .= "<br>" . $trInvPhone[$i]; endif;
if ($trInvEmail[$i] != "") : $trSpecialRemark[$i] .= "<br>" . $trInvEmail[$i]; endif;
if ($trInvSpecialRemark[$i] != "") : $trSpecialRemark[$i] .= "<br>" . $trInvSpecialRemark[$i]; endif;
*/
// Articles
$numOfArticles = 0;
if ($orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["article"]["no"] != "" || $orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["article"]["description"] != "") :
$numOfArticles = 1;
else :
$numOfArticles = count($orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["article"]);
endif;
// Mode of tour article service to be handled per station
$tratModeArray = array(); // Init
$tratModeTratSortArray = array(); // Init
if ($numOfArticles > 0) :
for ($j = 0; $j < $numOfArticles; $j++) :
if ($numOfArticles == 1) :
$trArticleArray[$i][0] = $orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["article"];
else :
$trArticleArray[$i][$j] = $orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["article"][$j];
endif;
// if ($trSpecialRemark[$i] != "") : $trSpecialRemark[$i] .= "\n" . "------------------------"; endif;
$trArticleArray[$i][$j]["mode"] = convertSpecial($trArticleArray[$i][$j]["mode"]);
// $csAddedServiceReverseInfosArray1[$tmpValArray[$languageSelected]] = $csAddSrvKeysArray[$l]; // $csAddedServiceReverseInfosArray1["ADDITIONAL_INSTALL_SERVICE"] = 100;
// $csAddedServiceReverseInfosArray2[$tmpValArray[$languageSelected]] = $tmpValArray[0]; // $csAddedServiceReverseInfosArray2["ADDITIONAL_INSTALL_SERVICE"] = "Montage aller Art/Montagezusatzkosten";
$tmpTratModeArray = spliti(",", $trArticleArray[$i][$j]["mode"]); // E.g. "FURNITURE_ASSEMBLY,ADDITIONAL_INSTALL_SERVICE,...." => array("FURNITURE_ASSEMBLY","ADDITIONAL_INSTALL_SERVICE",....)
$tmpTratModeArrayLen = count($tmpTratModeArray);
for ($t = 0; $t < $tmpTratModeArrayLen; $t++) :
// if ($csAddedServiceReverseInfosArray1[$trArticleArray[$i][$j]["mode"]] != "") :
if ($csAddedServiceReverseInfosArray1[$tmpTratModeArray[$t]] != "") :
// array_push($tratModeArray, $csAddedServiceReverseInfosArray1[$trArticleArray[$i][$j]["mode"]]);
array_push($tratModeArray, $csAddedServiceReverseInfosArray1[$tmpTratModeArray[$t]]);
array_push($tratModeTratSortArray, ($j + 1)); // ($j + 1) equals content later stored in "trat_sort". Used to write string of corresponding "trat_id"s in GDC.gdc_contxt
endif;
endfor;
/*
if ($trArticleArray[$i][$j]["mode"] == "1") :
$trSpecialRemark[$i] .= "\n" . getLngt("WARE RETOURE");
elseif ($trArticleArray[$i][$j]["mode"] == "2") :
$trSpecialRemark[$i] .= "\n" . getLngt("WARE MONTIEREN");
elseif ($trArticleArray[$i][$j]["mode"] == "3") :
$trSpecialRemark[$i] .= "\n" . getLngt("WARE DEMONTIEREN");
elseif ($trArticleArray[$i][$j]["mode"] == "4") :
$trSpecialRemark[$i] .= "\n" . getLngt("WARE ENTSORGEN");
else :
$trSpecialRemark[$i] .= "\n" . getLngt("WARE AUSLIEFERN");
endif;
*/
$trArticleArray[$i][$j]["no"] = convertSpecial($trArticleArray[$i][$j]["no"]);
$trArticleArray[$i][$j]["serialno"] = convertSpecial($trArticleArray[$i][$j]["serialno"]);
$trArticleArray[$i][$j]["description"] = convertSpecial($trArticleArray[$i][$j]["description"]);
$trArticleArray[$i][$j]["quantity"] = convertSpecial($trArticleArray[$i][$j]["quantity"]);
if ($trArticleArray[$i][$j]["quantity"] == "" || !is_numeric($trArticleArray[$i][$j]["quantity"])) :
// Default quantity "= 1"
$trArticleArray[$i][$j]["quantity"] = 1;
endif;
$trArticleArray[$i][$j]["price"] = convertNumSpecial($trArticleArray[$i][$j]["price"]);
$trArticleArray[$i][$j]["articlegroup_no"] = convertSpecial($trArticleArray[$i][$j]["articlegroup_no"]);
$trArticleArray[$i][$j]["weight"] = convertNumSpecial($trArticleArray[$i][$j]["weight"]);
$trArticleArray[$i][$j]["positions"] = convertNumSpecial($trArticleArray[$i][$j]["positions"]);
$trArticleArray[$i][$j]["pieces"] = convertNumSpecial($trArticleArray[$i][$j]["pieces"]);
if ($trArticleArray[$i][$j]["pieces"] == "" || !is_numeric($trArticleArray[$i][$j]["pieces"])) :
// Default number of pieces "= 1"
$trArticleArray[$i][$j]["pieces"] = 1;
$trArticleArray[$i][$j]["pieces"] = "1";
endif;
$trArticleArray[$i][$j]["length"] = convertNumSpecial($trArticleArray[$i][$j]["length"]);
$trArticleArray[$i][$j]["width"] = convertNumSpecial($trArticleArray[$i][$j]["width"]);
$$trArticleArray[$i][$j]["height"] = convertNumSpecial($trArticleArray[$i][$j]["height"]);
if ($trArticleArray[$i][$j]["length"] != "" || $trArticleArray[$i][$j]["width"] != "" || $$trArticleArray[$i][$j]["height"] != "") :
$trSpecialRemark[$i] .= "\n" . getLngt("LxBxH") . ": " . $trArticleArray[$i][$j]["length"] . "x" . $trArticleArray[$i][$j]["width"] . "x" . $$trArticleArray[$i][$j]["height"];
endif;
$trArticleArray[$i][$j]["volume"] = convertNumSpecial($trArticleArray[$i][$j]["volume"]);
// Try to get an existing article ID from table "article"
$tmpAtId = getFieldValueFromId("article", "at_name", $trArticleArray[$i][$j]["no"], "at_id");
// Store data into "tr_remark"
/*
if ($trArticleArray[$i][$j]["no"] != "") : $trSpecialRemark[$i] .= "\n" . getLngt("NR.") . ": " . $trArticleArray[$i][$j]["no"]; endif;
if ($trArticleArray[$i][$j]["serialno"] != "") : $trSpecialRemark[$i] .= "\n" . getLngt("SN") . ": " . $trArticleArray[$i][$j]["serialno"]; endif;
if ($trArticleArray[$i][$j]["description"] != "") : $trSpecialRemark[$i] .= "\n" . $trArticleArray[$i][$j]["description"]; endif;
if ($trArticleArray[$i][$j]["quantity"] != "") : $trSpecialRemark[$i] .= "\n" . getLngt("STK.") . ": " . $trArticleArray[$i][$j]["quantity"]; endif;
if ($trArticleArray[$i][$j]["price"] != "") : $trSpecialRemark[$i] .= "\n" . getLngt("PREIS") . ": " . $trArticleArray[$i][$j]["price"]; endif;
if ($trArticleArray[$i][$j]["articlegroup_no"] != "") : $trSpecialRemark[$i] .= "\n" . getLngt("WGRP") . ": " . $trArticleArray[$i][$j]["articlegroup_no"]; endif;
if ($trArticleArray[$i][$j]["weight"] != "") : $trSpecialRemark[$i] .= "\n" . getLngt("GEWICHT") . ": " . $trArticleArray[$i][$j]["weight"]; endif;
if ($trArticleArray[$i][$j]["positions"] != "") : $trSpecialRemark[$i] .= "\n" . getLngt("STELLPL.") . ": " . $trArticleArray[$i][$j]["positions"]; endif;
if ($trArticleArray[$i][$j]["pieces"] != "") : $trSpecialRemark[$i] .= "\n" . getLngt("PACKSTK.") . ": " . $trArticleArray[$i][$j]["pieces"]; endif;
if ($trArticleArray[$i][$j]["volume"] != "") : $trSpecialRemark[$i] .= "\n" . getLngt("VOLUMEN") . ": " . $trArticleArray[$i][$j]["volume"]; endif;
*/
// * Cumulated fields *
// Weight
if ($trSumWeight[$i] == "") : $trSumWeight[$i] = 0; endif;
if ($trArticleArray[$i][$j]["weight"] != "" && is_numeric($trArticleArray[$i][$j]["weight"])) :
$trSumWeight[$i] += ($trArticleArray[$i][$j]["quantity"] * $trArticleArray[$i][$j]["weight"]);
endif;
// Positions
if ($trSumPositions[$i] == "") : $trSumPositions[$i] = 0; endif;
if ($trArticleArray[$i][$j]["positions"] != "" && is_numeric($trArticleArray[$i][$j]["positions"])) :
$trSumPositions[$i] += $trArticleArray[$i][$j]["positions"];
endif;
// Pieces
if ($trSumPieces[$i] == "") : $trSumPieces[$i] = 0; endif;
if ($trArticleArray[$i][$j]["pieces"] != "" && is_numeric($trArticleArray[$i][$j]["pieces"])) :
$trSumPieces[$i] += $trArticleArray[$i][$j]["pieces"];
endif;
// Volume
if ($trSumVolume[$i] == "") : $trSumVolume[$i] = 0; endif;
if ($trArticleArray[$i][$j]["volume"] != "" && is_numeric($trArticleArray[$i][$j]["volume"])) :
$trSumVolume[$i] += $trArticleArray[$i][$j]["volume"];
endif;
// Total price
if ($trSumPrices[$i] == "") : $trSumPrices[$i] = 0; endif;
if ($tmpAtId != "" && ($trArticleArray[$i][$j]["price"] == "" || !is_numeric($trArticleArray[$i][$j]["price"]))) :
// Try to get price from "articleprice" for this article
// Check for special customer price ($trInvPriceMode[$i] <=> "mt_sort" ("disposition_mode"))
$trArticleArray[$i][$j]["price"] = getArticleServiceValues($tmpAtId, $currentTime, "", $csId, $trInvPriceMode[$i], 0); // Check for article SPECIAL price of the SPECIAL customer
if ($trArticleArray[$i][$j]["price"] == "" && $csGroupId == "" && $csGroupName == "") :
$trArticleArray[$i][$j]["price"] = getArticleServiceValues($tmpAtId, $currentTime, $csGroupId, "", $trInvPriceMode[$i], 0); // Check for article SPECIAL group price
endif;
if ($trArticleArray[$i][$j]["price"] == "") :
$trArticleArray[$i][$j]["price"] = getArticleServiceValues($tmpAtId, $currentTime, "", $csId, "", 0); // Check for article STANDARD price of the SPECIAL customer
endif;
if ($trArticleArray[$i][$j]["price"] == "" && $csGroupId == "" && $csGroupName == "") :
$trArticleArray[$i][$j]["price"] = getArticleServiceValues($tmpAtId, $currentTime, $csGroupId, "", $csId, "", 0); // Check for article STANDARD group price
endif;
endif;
if ($trArticleArray[$i][$j]["price"] != "" && is_numeric($trArticleArray[$i][$j]["price"])) :
$trSumPrices[$i] += ($trArticleArray[$i][$j]["quantity"] * $trArticleArray[$i][$j]["price"]);
endif;
// Maximum of height
if ($trMaxHeight[$i] == "") : $trMaxHeight[$i] = 0; endif;
if ($$trArticleArray[$i][$j]["height"] != "" && is_numeric($$trArticleArray[$i][$j]["height"])) :
$trMaxHeight[$i] = max($trMaxHeight[$i], $$trArticleArray[$i][$j]["height"]);
endif;
// Maximum of length
if ($trMaxLength[$i] == "") : $trMaxLength[$i] = 0; endif;
if ($trArticleArray[$i][$j]["length"] != "" && is_numeric($trArticleArray[$i][$j]["length"])) :
$trMaxLength[$i] = max($trMaxLength[$i], $trArticleArray[$i][$j]["length"]);
endif;
// Maximum of width
if ($trMaxWidth[$i] == "") : $trMaxWidth[$i] = 0; endif;
if ($trArticleArray[$i][$j]["width"] != "" && is_numeric($trArticleArray[$i][$j]["width"])) :
$trMaxWidth[$i] = max($trMaxWidth[$i], $trArticleArray[$i][$j]["width"]);
endif;
// Maximum of any dimension
if ($trMaxDimension[$i] == "") : $trMaxDimension[$i] = 0; endif;
$trMaxDimension[$i] = max($trMaxHeight[$i], $trMaxLength[$i], $trMaxWidth[$i]);
// Hours estimated
if ($trSumHoursEstimated[$i] == "") : $trSumHoursEstimated[$i] = 0; endif;
if ($trArticleArray[$i][$j]["hours_estimated"] != "" && is_numeric($trArticleArray[$i][$j]["hours_estimated"])) :
$trSumHoursEstimated[$i] += $trArticleArray[$i][$j]["hours_estimated"];
endif;
endfor;
endif;
// If ARTICLE TOTAL VALUES are sent within the request overwrite existing conputed values
$tmpTotalWeight = convertNumSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["total_weight"]);
if ($tmpTotalWeight != "" && is_numeric($tmpTotalWeight) && $tmpTotalWeight > 0) :
$trSumWeight = $tmpTotalWeight;
endif;
$tmpTotalPieces = convertNumSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["total_pieces"]);
if ($tmpTotalPieces != "" && is_numeric($tmpTotalPieces) && $tmpTotalPieces > 0) :
$trSumPieces = $tmpTotalPieces;
endif;
$tmpTotalVolume = convertNumSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["total_volume"]);
if ($tmpTotalVolume != "" && is_numeric($tmpTotalVolume) && $tmpTotalVolume > 0) :
$trSumVolume = $tmpTotalVolume;
endif;
$tmpTotalMeters = convertNumSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["total_meter"]);
// if ($tmpTotalMeters != "" && is_numeric($tmpTotalMeters) && $tmpTotalMeters > 0) :
$trSumMeters = $tmpTotalMeters;
// endif;
$tmpTotalMetersDeassembly = convertNumSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["total_meter_deassembly"]);
// if ($tmpTotalMetersDeassembly != "" && is_numeric($tmpTotalMetersDeassembly) && $tmpTotalMetersDeassembly > 0) :
$trSumMetersDeassembly = $tmpTotalMetersDeassembly;
// endif;
$tmpTotalHoursEstimated = convertNumSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["articles"]["total_hours_estimated"]);
if ($tmpTotalHoursEstimated != "" && is_numeric($tmpTotalHoursEstimated) && $tmpTotalHoursEstimated > 0) :
$trSumHoursEstimated[$i] = $tmpTotalHoursEstimated;
endif;
// Station services
$trServices[$i] = $orderArray["xml"]["order"]["stations"]["station"][$i]["services"];
$trTimeslots[$i] = $trServices[$i]["timeslots"];
$trTimesunits[$i] = $trServices[$i]["timeunits"];
$trShipmentMode[$i] = $trServices[$i]["shipment_mode"];
$trOrderType[$i] = $trServices[$i]["order_type"];
$trDeliveryInfo[$i] = $trServices[$i]["delivery_info"];
$trFlagServiceDoc[$i] = $trServices[$i]["flag_service_doc"];
$trDocumentsURL[$i] = $trServices[$i]["documents_URL"];
// Write some service infos into "tr_remark"
// if ($trTimeslots[$i] != "") : $trSpecialRemark[$i] .= "\nTageszeit: " . $trTimeslots[$i] . "\n----------"; endif;
if ($trOrderType[$i] != "") : $trSpecialRemark[$i] .= "\nOrder-Typ: " . $trOrderType[$i] . "\n----------"; endif;
if ($trDeliveryInfo[$i] != "") : $trSpecialRemark[$i] .= "\nAuslieferinformationen: " . $trDeliveryInfo[$i] . "\n----------"; endif;
if ($trFlagServiceDoc[$i] == "1") : $trSpecialRemark[$i] .= "\nINSTRUKTIONEN EXISTIEREN! " . "\n----------"; endif;
if ($trDocumentsURL[$i] != "") : $trSpecialRemark[$i] .= "\nOrder-Typ: " . $trDocumentsURL[$i] . "\n----------"; endif;
$debugOut .= "STATION SERVICES<br>\n";
$debugOut .= "trTimeslots[$i]: " . $trTimeslots[$i] . "<br>\n";
$debugOut .= "trTimesunits[$i]: " . $trTimesunits[$i] . "<br>\n";
$debugOut .= "trShipmentMode[$i]: " . $trShipmentMode[$i] . "<br>\n";
$debugOut .= "trOrderType[$i]: " . $trOrderType[$i] . "<br>\n";
$debugOut .= "trDeliveryInfo[$i]: " . $trDeliveryInfo[$i] . "<br>\n";
$debugOut .= "trFlagServiceDoc[$i]: " . $trFlagServiceDoc[$i] . "<br>\n";
$debugOut .= "trDocumentsURL[$i]: " . $trDocumentsURL[$i] . "<br>\n";
$debugOut .= "<br>\n";
// Calculator prices per functions
$numOfCalcFunctions = count($orderArray["xml"]["order"]["stations"]["station"][$i]["services"]["calculator"]["func_item"]);
if ($numOfCalcFunctions > 0) :
for ($j = 0; $j < $numOfCalcFunctions; $j++) :
$trCalcFunctionsArray[$i][$j] = $orderArray["xml"]["order"]["stations"]["station"][$i]["services"]["calculator"]["func_item"][$j];
$trCalcFunctionsResultArray[$i][$j] = 0;
$tmpFuncNo = $orderArray["xml"]["order"]["stations"]["station"][$i]["services"]["calculator"]["func_item"][$j]["no"];
if ($tmpFuncNo != "" && is_numeric($tmpFuncNo)) :
if (substr($tmpFuncNo, 0, 1) == "2") :
$tmpFuncNo = "ident_" . substr($tmpFuncNo, 1);
else :
$tmpFuncNo = substr($tmpFuncNo, 1);
endif;
$tmpPar1 = $orderArray["xml"]["order"]["stations"]["station"][$i]["services"]["calculator"]["func_item"][$j]["par_1"];
$tmpPar2 = $orderArray["xml"]["order"]["stations"]["station"][$i]["services"]["calculator"]["func_item"][$j]["par_2"];
$tmpPar3 = $orderArray["xml"]["order"]["stations"]["station"][$i]["services"]["calculator"]["func_item"][$j]["par_3"];
$tmpPar4 = $orderArray["xml"]["order"]["stations"]["station"][$i]["services"]["calculator"]["func_item"][$j]["par_4"];
$tmpPar5 = $orderArray["xml"]["order"]["stations"]["station"][$i]["services"]["calculator"]["func_item"][$j]["par_5"];
$tmpQuantity = $orderArray["xml"]["order"]["stations"]["station"][$i]["services"]["calculator"]["func_item"][$j]["quantity"];
if ($tmpQuantity == "" || !is_numeric($tmpQuantity)) : $tmpQuantity = 1; endif;
$trCalcFunctionsResultArray[$i][$j] = getMtfFunctionResult($hqId, $csId, "20", $tmpFuncNo, $tmpPar1, $tmpPar2, $tmpPar3, $tmpPar4, $tmpPar5);
if ($trCalcFunctionsResultArray[$i][$j] == "" || !is_numeric($trCalcFunctionsResultArray[$i][$j])) : $trCalcFunctionsResultArray[$i][$j] = 0; endif;
$trCalcFunctionsResultArray[$i][$j] = $tmpQuantity * $trCalcFunctionsResultArray[$i][$j];
// Totalprice of the job
$fixprice += $trCalcFunctionsResultArray[$i][$j];
endif;
endfor;
endif;
// Special informations inserted into GDC structure
$numOfGdcEntries = count($orderArray["xml"]["order"]["stations"]["station"][$i]["gdc"]["val"]);
if ($numOfGdcEntries > 0) :
for ($k = 0; $k < $numOfGdcEntries; $k++) :
if ($numOfGdcEntries == 1) :
$trGdcArray[$i][$k] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["gdc"]["val"]);
else :
$trGdcArray[$i][$k] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["gdc"]["val"][$k]);
endif;
endfor;
endif;
// Generation parts of the field "jb_tourdata" (e.g.: "04109;04316|Leipzig;Leipzig/Mölkau|DE;DE")
/*
if ($i > 0) :
$jbTourdataZipcode .= ";";
$jbTourdataCity .= ";";
$jbTourdataCountry .= ";";
endif;
$jbTourdataZipcode .= $trZipcode[$i];
$jbTourdataCity .= $trCity[$i];
$jbTourdataCountry .= "DE";
*/
// Error handling
/*
if ($jbRemark == "" && $parJbRemarkMode == "") :
if (!$errHandlerDisabled) :
$err[] = array("117", getLngt("Es wurde kein Rechnungstext übergeben."));
$acceptOrder = false;
endif;
endif;
*/
if ($trAdId[$i] == "") :
if ($operationMode != "DEL" && $operationMode != "DELETE") :
$err[] = array("110", getLngt("Die Adressdaten sind nicht vollständig."));
$acceptOrder = false;
endif;
endif;
endfor;
// Generation of the field "jb_tourdata" (e.g.: "04109;04316|Leipzig;Leipzig/Mölkau|DE;DE")
// $jbTourdata = $jbTourdataZipcode . "|" . $jbTourdataCity . "|" . $jbTourdataCountry;
else :
if ($operationMode != "DEL" && $operationMode != "DELETE") :
$err[] = array("111", getLngt("Es konnten keine Stationen generiert werden."));
$acceptOrder = false;
endif;
endif;
// Store into the database
if ($debug) :
echo "jbIdCurrent:" . $jbIdCurrent . "<br>";
echo "csEid:" . $csEid . "<br>";
echo "csId:" . $csId . "<br>";
echo "usrAccount:" . $usrAccount . "<br>";
echo "usrPassword:" . $usrPassword . "<br>";
echo "cscName:" . $cscName . "<br>";
echo "cscId:" . $cscId . "<br>";
echo "hqMnemonic:" . $hqMnemonic . "<br>";
echo "hqId:" . $hqId . "<br>";
echo "hqId_XML:" . $hqId_XML . "<br>";
echo "vhtId:" . $vhtId . "<br>";
echo "vhtType:" . $vhtType . "<br>";
echo "jbCrvhWeight:" . $jbCrvhWeight . "<br>";
echo "jbCrvhLength:" . $jbCrvhLength . "<br>";
echo "jbCrvhWidth:" . $jbCrvhWidth . "<br>";
echo "jbCrvhHeight:" . $jbCrvhHeight . "<br>";
echo "jbCrvhPosition:" . $jbCrvhPosition . "<br>";
echo "jbOrdertime:" . $jbOrdertime . "<br>";
echo "jbOrdertimeUTC:" . $jbOrdertimeUTC . "<br>";
echo "jbWarningtime:" . $jbWarningtime . "<br>";
echo "jbWarningtimeUTC:" . $jbWarningtimeUTC . "<br>";
echo "crSid:" . $crSid . "<br>";
echo "crIdOrder:" . $crIdOrder . "<br>";
echo "jbCrFilter:" . $jbCrFilter . "<br>";
echo "jbCrRemark:" . $jbCrRemark . "<br>";
echo "jbTourdata:" . $jbTourdata . "<br>";
echo "numOfStations:" . $numOfStations . "<br>";
for ($i = 0; $i < $numOfStations; $i++) :
echo "<br>";
echo "* STATION " . $i . " * : <br>";
echo "DELIVERY:" . "<br>";
echo $trWareFromTo[$i] . "<br>";
echo $trCostcenter[$i] . "<br>";
echo $trCscId[$i] . "<br>";
echo $trCompany[$i] . "<br>";
echo $trCompany2[$i] . "<br>";
echo $trAdId[$i] . "<br>";
echo $trStreet[$i] . "<br>";
echo $trHouseno[$i] . "<br>";
echo $trFloor[$i] . "<br>";
echo $trZipcode[$i] . "<br>";
echo $trCity[$i] . "<br>";
echo $trSpecialRemark[$i] . "<br>";
echo $trPerson[$i] . "<br>";
echo $trPhone[$i] . "<br>";
echo $trEmail[$i] . "<br>";
echo "INVOICE:" . "<br>";
echo $trInvCompany[$i] . "<br>";
echo $trInvCompany2[$i] . "<br>";
echo $trInvAdId[$i] . "<br>";
echo $trInvStreet[$i] . "<br>";
echo $trInvHouseno[$i] . "<br>";
echo $trInvZipcode[$i] . "<br>";
echo $trInvCity[$i] . "<br>";
echo $trInvSpecialRemark[$i]. "<br>";
echo $trInvPerson[$i] . "<br>";
echo $trInvPhone[$i] . "<br>";
echo $trInvEmail[$i] . "<br>";
print_r($trServices[$i]); echo "<br>";
echo "trInvVoucher:" . $trInvVoucher[$i] . "<br>";
echo "trInvPaymentMethod:" . $trInvPaymentMethod[$i] . "<br>";
echo "trArticleArray:"; print_r($trArticleArray[$i]); echo "<br>";
print_r($trCalcFunctionsArray[$i]); echo "<br>";
print_r($trCalcFunctionsResultArray[$i]); echo "<br>";
endfor;
echo "<br><br>ERR: "; print_r($err); echo "<br>";
echo "acceptOrder: " . $acceptOrder . "<br>";
endif;
if (!$errHandlerDisabled) :
$cscIdList = array();
if ($csId != "" && $csId > "0") :
$sqlquery = "SELECT csc.csc_id FROM costcenter AS csc WHERE csc.cs_id = '" . $csId . "'";
$result = $db->query($sqlquery);
if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage());
while ($row = $result->fetch_assoc()):
$cscIdList[] = $row["csc_id"];
endwhile;
$result->free();
endif;
if (count($cscIdList) > 0) :
// Check for maximum number of jobs per day
$numOfOrdersOfTheCurrentDay = getCountOfTable("job", "jb_modify >= '" . $currentDate . " 00:00:00' AND csc_id_payer IN (" . implode(",", $cscIdList) . ")");
if ($numOfOrdersOfTheCurrentDay == "" || (is_numeric($numOfOrdersOfTheCurrentDay) && $numOfOrdersOfTheCurrentDay > $maxNumOfStationsPerDay)) :
$acceptOrder = false;
$err[] = array("102", getLngt("Das Limit der Stationen pro Tag wurde überschritten. Derzeit sind dies") . " " . $maxNumOfStationsPerDay . " " . getLngt("Stationen"));
endif;
// Check for maximum number of running jobs
$numOfRunningOrders = getCountOfTable("job", "jb_status != '2' AND csc_id_payer IN (" . implode(",", $cscIdList) . ")");
if ($numOfRunningOrders > $maxNumOfRunningStations) :
$acceptOrder = false;
$err[] = array("103", getLngt("Das Limit insgesamt laufender Stationen wurde überschritten. Derzeit sind dies") . " " . $maxNumOfRunningStations . " " . getLngt("Stationen"));
endif;
endif;
endif;
// Check existence of at least one error
$errLen = count($err);
if ($errLen == 0 && $acceptOrder) :
// For UPDATE and DELETE identify station by specified commission no (of the specified day!)
// $jbIdCurrent has to exist because an existing station has to belong to en existing order (no "tr" without "jb")
$trIdCurrent = "";
if ($jbIdCurrent != "" && $commissionNo != "") :
$trIdCurrent = getOneStmt("SELECT tr.tr_id AS tr_id FROM tour AS tr WHERE tr.tr_commission_no = '" . $commissionNo . "' AND tr.jb_id = '" . $jbIdCurrent . "'", "tr_id");
endif;
// **********
// * UPDATE *
// **********
if ($operationMode == "UPD" || $operationMode == "UPDATE") :
if ($trIdCurrent != "" && is_numeric($trIdCurrent) && $trIdCurrent > "0") :
// Update the identified station
// ...................................................
else :
$acceptOrder = false;
$err[] = array("105", getLngt("Es wurde keine Station für ein Update gefunden! Bitte Kommissionsnummer überprüfen!"));
endif;
endif;
// **********
// * DELETE *
// **********
$opCancellationExecuted = false;
if ($operationMode == "DEL" || $operationMode == "DELETE" || $updateMode == "1") :
if ($trIdCurrent != "" && is_numeric($trIdCurrent) && $trIdCurrent > "0") :
// Delete the identified station
// ...................................................
else :
$acceptOrder = false;
$err[] = array("107", getLngt("Der Stornovorgang konnte nicht abgeschlossen werden, weil die Station nicht gefunden wurde!"));
endif;
endif;
// **********
// * INSERT *
// **********
if ($operationMode == "" || $operationMode == "INS" || $operationMode == "INSERT") :
// Order
TA("B");
// Init
$jbIdNew = $jbIdCurrent;
$trIdNewArray = array();
if ($jbIdNew == "") :
insertStmt("job", array("hq_id", $hqId, "csc_id", $cscIdPayer, "vht_id", $vhtId, "csc_id_payer", $cscIdPayer, "csc_id_related", $cscIdRelated, "jb_payment", "0",
"jb_ordertime", $jbOrdertime, "jb_reserv", $jbReserv, "cr_id", "", "cr_sid", $crSid, "cr_id_order", $crIdOrder,
"jb_cr_filter", $jbCrFilter, "jb_cr_filter_opt", "", "jb_waitstorno", "0",
"jb_taketime", "", "jb_status", $jbStatus, "jb_autoranking", "0", "jb_type", $jbType,
"jb_incomplete", "0", "jb_globaljob", "0", "jb_tourname", $jbTourname,
"jb_finishtime", "", "jb_warningtime", $jbWarningtime, "emp_id", $usr_id, "jb_fixprice", $fixprice, "jb_totalprice", $fixprice,
"jb_postage", $cmpPostage, "jb_invmode", $csInvmode, "jb_freetext_1", $jbRemark,
"jb_weight", $jbCrvhWeight, "jb_crvh_length", $jbCrvhLength, "jb_crvh_width", $jbCrvhWidth,
"jb_crvh_height", $jbCrvhHeight, "jb_crvh_position", $jbCrvhPosition,
"jb_tourdata", $jbTourdata, "jb_lockuser", "0", "jb_id_parent", $jbIdParent, "jb_dispoinfo", "",
"jb_sales_tax_rate", $txValue, "jb_sales_tax_rate_sign", $txSign, "jb_createtime", $currentTime,
"jb_timeunits", $jbTimeUnits, "jb_service", $jbService, "jb_booktime", ""));
$jbIdNew = getLastInsertId();
if ($jbIdNew != "" && is_numeric($jbIdNew)) :
$csAddress = getAddress($csId, "costcenteraddress");
$trStatusFrom = "0";
$trFinishtimeFrom = "";
// Insert pick up station during first iteration
insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $csAddress["id"], "tr_sort", "1", "tr_comp", $csAddress["comp"], "tr_comp2", "",
"tr_hsno", $csAddress["hsno"], "tr_floor", "", "csc_id", $cscIdPayer, "tr_status", $trStatusFrom, "tr_finishtime", $trFinishtimeFrom,
"tr_commission_no", "", "tr_ware_from_to", "", "tr_person", "", "tr_phone", "", "tr_remark", ""));
$trIdPickUpNew = getLastInsertID();
// Special informations inserted into GDC structure
$numOfGdcEntries = count($jbGdcArray);
if ($numOfGdcEntries > 0) :
for ($k = 0; $k < $numOfGdcEntries; $k++) :
if ($jbGdcArray[$k] != "") :
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "info_" . $k, "gdc_content", $jbGdcArray[$k], "gdc_context", ""));
// Add ALL gdc_gen_fieldname = 'info_<n>' to station remark
if ($globalParUseRelatedCustomer == 1) :
if ($trSpecialRemark[$tmpStation] != "") : $trSpecialRemark[$tmpStation] .= "\n" . "------------------------"; endif;
$trSpecialRemark[$tmpStation] .= "\n" . $jbGdcArray[$k];
endif;
endif;
endfor;
endif;
// Write predicate for the job
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "station_request", "gdc_content", "1", "gdc_context", $csId));
$trSort = 1;
else :
$acceptOrder = false;
$err[] = array("199", getLngt("Der Station konnte nicht eingefügt werden, weil die Anlage des Basisauftrags fehlschlug!"));
endif;
else :
// Get last existing station no ("tr_sort")
$trSort = getMaxOfField("tour", "tr_sort", "jb_id = '" . $jbIdNew . "'");
endif;
// Stations
if ($acceptOrder) :
// for ($i = 0; $i < $numOfStations; $i++) :
// First station has to be empty
for ($i = 1; $i < $numOfStations; $i++) :
$trSort++;
// $trServicesArray[] = $trServices[$i]; // Services and prices for calling price function
// Insert tour data for station
insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $trAdId[$i], "tr_sort", $trSort, "tr_comp", $trCompany[$i], "tr_comp2", $trCompany2[$i],
"tr_hsno", $trHouseno[$i], "tr_floor", $trFloor[$i], "csc_id", $trCscId[$i], "tr_status", "0",
"tr_commission_no", $commissionNo, "tr_ware_from_to", $trWareFromTo[$i],
"tr_person", $trPerson[$i], "tr_phone", $trPhone[$i], "tr_remark", $trSpecialRemark[$i]));
$trIdNewArray[] = getLastInsertId();
// Insert tourservice data
/* INSERTED BY FUNCTION mk_price()
insertStmt("tourservice", array("jb_id", $jbIdNew, "csc_id", $trCscId[$i], "tr_sort", "0",
"srv_id", "0", "trs_srv_name", "Fixpreis", "srvt_id", "0", "trs_srvt_name", ""));
*/
/*
if ($globalParUseRelatedCustomer != 1) :
$commissionNo = ""; // Reset commission number because associated to the first station only
endif;
*/
// Special informations inserted into GDC structure
$numOfGdcEntries = count($trGdcArray[$i]);
if ($numOfGdcEntries > 0) :
for ($k = 0; $k < $numOfGdcEntries; $k++) :
if ($trGdcArray[$i][$k] != "") :
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "info_" . $k, "gdc_content", $trGdcArray[$i][$k], "gdc_context", $jbIdNew . "," . $trSort));
endif;
endfor;
endif;
// Mandatory scan (bar)code
if ($trScanCodeMandatory[$i] != "") :
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "scan_code_mandatory", "gdc_content", $trScanCodeMandatory[$i], "gdc_context", ""));
endif;
// Delivery outcome (mode and states)
if ($trDeliveryOutcomeMode[$i] != "" && $trDeliveryOutcomeStates[$i] != "") :
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "delivery_outcome", "gdc_content", $trDeliveryOutcomeStates[$i], "gdc_context", $trDeliveryOutcomeMode[$i]));
endif;
// Insert the station based order type into the GDC
if ($trOrderType[$i] != "") :
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "order_type", "gdc_content", $trOrderType[$i], "gdc_context", $jbIdNew));
endif;
// Insert (or update existing) (invoice) address supplement entries in GDC
$tmpAddressSupplement = $trAdSupplement_1[$i] . "|" . $trAdSupplement_2[$i] . "|" . $trAdSupplement_3[$i] . "|" . $trAdSupplement_4[$i] . "|" . $trAdSupplement_5[$i];
if ($tmpAddressSupplement != "||||") :
if (existsEntry("genericdatacontainer",array("gdc_obj_type","jb","gdc_gen_fieldname","ad_supplement","gdc_obj_id",$jbIdNew,"gdc_context",$trSort))) :
updateStmt("genericdatacontainer","gdc_obj_type","jb",array("gdc_content", $tmpAddressSupplement),"gdc_obj_id = '" . $jbIdNew . "' AND gdc_gen_fieldname = 'ad_supplement' AND gdc_context = '" . $trSort . "'");
else :
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "ad_supplement", "gdc_content", $tmpAddressSupplement, "gdc_context", $trSort));
endif;
endif;
$tmpInvAddressSupplement = $trInvAdSupplement_1[$i] . "|" . $trInvAdSupplement_2[$i] . "|" . $trInvAdSupplement_3[$i] . "|" . $trInvAdSupplement_4[$i] . "|" . $trInvAdSupplement_5[$i];
if ($tmpInvAddressSupplement != "||||") :
if (existsEntry("genericdatacontainer",array("gdc_obj_type","jb","gdc_gen_fieldname","ad_inv_supplement","gdc_obj_id",$jbIdNew,"gdc_context",$trSort))) :
updateStmt("genericdatacontainer","gdc_obj_type","jb",array("gdc_content", $tmpInvAddressSupplement),"gdc_obj_id = '" . $jbIdNew . "' AND gdc_gen_fieldname = 'ad_inv_supplement' AND gdc_context = '" . $trSort . "'");
else :
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "ad_inv_supplement", "gdc_content", $tmpInvAddressSupplement, "gdc_context", $trSort));
endif;
endif;
// Insert tourarticle data
$numOfArticles = count($trArticleArray[$i]);
if ($numOfArticles > 0) :
for ($j = 0; $j < $numOfArticles; $j++) :
$tratSort = $j + 1;
insertStmt("tourarticle", array("jb_id", $jbIdNew, "tr_sort", $trSort, "trat_sort", $tratSort, "at_id", "", "trat_name", $trArticleArray[$i][$j]["no"],
"trat_quantity", $trArticleArray[$i][$j]["quantity"],
"trat_weight", ($trArticleArray[$i][$j]["weight"] * $trArticleArray[$i][$j]["quantity"]), "trat_price", $trArticleArray[$i][$j]["price"],
"trat_packingpieces", $trArticleArray[$i][$j]["pieces"], "trat_serialno", $trArticleArray[$i][$j]["serialno"],
"trat_remark", $trArticleArray[$i][$j]["description"], "trat_createtime", $currentTime));
endfor;
// If total sum of tourarticle weight had been sent and overruled the computed sum value then store it in the GDC
if ($trSumWeight != "" && is_numeric($trSumWeight) && $trSumWeight > 0 && $tmpTotalWeight != "" && is_numeric($tmpTotalWeight) && $tmpTotalWeight > 0) :
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "trat_sum_weight", "gdc_content", $trSumWeight, "gdc_context", $trSort));
endif;
// If total sum of tourarticle weight had been sent and overruled the computed sum value then store it in the GDC
if ($trSumPieces != "" && is_numeric($trSumPieces) && $trSumPieces > 0 && $tmpTotalPieces != "" && is_numeric($tmpTotalPieces) && $tmpTotalPieces > 0) :
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "trat_sum_pieces", "gdc_content", $trSumPieces, "gdc_context", $trSort));
endif;
// If total sum of tourarticle weight had been sent and overruled the computed sum value then store it in the GDC
if ($trSumVolume != "" && is_numeric($trSumVolume) && $trSumVolume > 0 && $tmpTotalVolume != "" && is_numeric($tmpTotalVolume) && $tmpTotalVolume > 0) :
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "trat_sum_volume", "gdc_content", $trSumVolume, "gdc_context", $trSort));
endif;
// If total sum of meters had been sent and overruled the computed sum value then store it in the GDC
if ($trSumMeters != "" && is_numeric($trSumMeters) && $trSumMeters > 0 && $tmpTotalMeters != "" && is_numeric($tmpTotalMeters) && $tmpTotalMeters > 0) :
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "trat_sum_meters", "gdc_content", $trSumMeters, "gdc_context", $trSort));
endif;
// If total sum of deinstallation meters had been sent and overruled the computed sum value then store it in the GDC
if ($trSumMetersDeassembly != "" && is_numeric($trSumMetersDeassembly) && $trSumMetersDeassembly > 0 && $tmpTotalMetersDeassembly != "" && is_numeric($tmpTotalMetersDeassembly) && $tmpTotalMetersDeassembly > 0) :
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "trat_sum_meters_deassembly", "gdc_content", $trSumMetersDeassembly, "gdc_context", $trSort));
endif;
// If total sum of estimated hours had been sent and overruled the computed sum value then store it in the GDC
if ($trSumHoursEstimated[$i] != "" && is_numeric($trSumHoursEstimated[$i]) && $trSumHoursEstimated[$i] > 0) :
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "trat_sum_hours_estimated", "gdc_content", $trSumHoursEstimated[$i], "gdc_context", $trSort));
$jbTotalHoursEstimated += $trSumHoursEstimated[$i];
endif;
endif;
endfor;
// Write tour article services for the job
if (count($tratModeArray) > 0) :
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "jb_add_service_info", "gdc_content", implode(",",$tratModeArray), "gdc_context", ""));
// Update gdc_context with corresponding "trat_id"s
$tratModeTratSortArrayLen = count($tratModeTratSortArray);
$tmpTratIdString = "";
for ($t = 0; $t < $tratModeTratSortArrayLen; $t++) :
if ($tmpTratIdString != "") : $tmpTratIdString .= ","; endif;
$tmpTratIdString .= getFieldValueFromClause("tourarticle","trat_id","jb_id = '" . $jbIdNew . "' AND trat_sort = '" . $tratModeTratSortArray[$t] . "'");
endfor;
updateStmt("genericdatacontainer","gdc_obj_type","jb",array("gdc_context", $tmpTratIdString),"gdc_obj_type = 'jb' AND gdc_obj_id = '" . $jbIdNew . "' AND gdc_gen_fieldname = 'jb_add_service_info'");
endif;
// Write EVENT "PLANNED" (presently for installation only)
if (((int)$jbService & 2) == 2) :
if ($trIdPickup != "" && $trIdPickup > 0) :
insertStmt("phoenix_log.b2b_objects", array("bo_ver", "0", "bo_type", "300", "bo_state", "1", "bo_ext_id0", $jbIdNew, "bo_ext_id1", $trIdPickup, "bo_ext_id2", $usr_id, "bo_obj_data", $commissionNo . "|501", "bo_createtime", $currentTime));
endif;
endif;
// Write relation to new job after cancellation
if ($opCancellationExecuted && $jbIdCancellation != "") :
// Reference to cancelled job by update
// if ($executeCancellationByEvent) : // Write reference to old copied job in jb_storno although previous job is NOT cancelled !!!!
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "jb_storno", "gdc_content", $jbIdCancellation, "gdc_context", ""));
// endif;
if ($updateMode == "1") :
// Reference to new job after update
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdCancellation, "gdc_gen_fieldname", "jb_update", "gdc_content", $jbIdNew, "gdc_context", ""));
endif;
endif;
// Write estimated hours for the whole job
if ($jbTotalHoursEstimated != "" && is_numeric($jbTotalHoursEstimated)) :
if (existsEntry("genericdatacontainer",array("gdc_obj_type","jb","gdc_gen_fieldname","addmont","gdc_obj_id",$jbIdNew))) :
updateStmt("genericdatacontainer","gdc_obj_type","jb",array("gdc_context", $jbTotalHoursEstimated),"gdc_obj_id = '" . $jbIdNew . "' AND gdc_gen_fieldname = 'addmont'");
else :
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "addmont", "gdc_content", "", "gdc_context", $jbTotalHoursEstimated));
endif;
endif;
// SET jb_freetext_1
// Get daytimes of the customer associated to the current vehicle
$dayTimeSlots = metatypeGetMappedValues("day_time", "", $csId, "cs", "1");
$dayTimeSlotsLen = count($dayTimeSlots);
$csDaytimeStart = substr($dayTimeSlots[0][0],0,5);
$csDaytimeEnd = substr($dayTimeSlots[($dayTimeSlotsLen - 1)][1],0,5);
// Endcustomer time window
$tmpJbFreetext1 = substr($jbOrdertime,8,2) . "." . substr($jbOrdertime,5,2) . "." . substr($jbOrdertime,0,4) . " ";
$tmpDaytime = "ganztägig";
if ($csDaytimeStart != "" && $csDaytimeEnd != "" && ($csDaytimeStart != substr($jbOrdertime,11,5) || $csDaytimeEnd != substr($jbWarningtime,11,5))) :
$tmpDaytime = substr($jbOrdertime,11,5) . " - " . substr($jbWarningtime,11,5);
endif;
$tmpJbFreetext1 .= $tmpDaytime;
updateStmt("job","jb_id",$jbIdNew,array("jb_freetext_1", $tmpJbFreetext1));
// Finish transaction here because all order data have been written
TA("C");
TA("E");
// --------------------------------------------------------
// Call specific job function. All data transactions heve to be finished here !!!!
// Preparation...
$hq_id = $hqId;
// Generate prices
/*
$makePrice = true;
$parOrderRequestJobNoPrice = getParameterValue("0", "STATION_REQUEST_NO_PRICE_CS_" . $csId, "0");
if ($parOrderRequestJobNoPrice == "1") :
$makePrice = false;
endif;
if ($makePrice) :
mk_jb_price($jbIdNew);
endif;
*/
// Generate invoice text
if ($globalParUseRelatedCustomer == "1") :
// .............
else :
// mk_jb_invtext($jbIdNew, false);
endif;
// ****
// Special patch because of "bug" in function "mk_jb_invtext()"
if ($jbIdNew != "" && is_numeric($jbIdNew)) :
updateStmt("job","jb_id",$jbIdNew,array("jb_tourdata",$jbTourdata));
endif;
// ****
writeToLogDB("102",$hq_id,$jbIdNew,$usr_id,"","",$csId,"B2B_IMPORT=1|MODE=STATION"); // Success!
else :
TA("R");
TA("E");
endif; // ($acceptOrder == true)
endif; // Operation mode
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);
// echo "errLen: " . $errLen . "<br>";
// Output
$outResponse .= "<xml>";
if ($errLen > 0) :
stationRequestLogFile("ERRORS", 1);
$outResponse .= "<state>NOT OK</state>";
$outResponse .= "<errors>";
for ($i = 0; $i < $errLen; $i++) :
$outResponse .= "<error>";
$outResponse .= "<err_no>" . $err[$i][0] . "</err_no>";
$outResponse .= "<err_desc><![CDATA[" . mcEncode($err[$i][1]) . "]]></err_desc>";
$outResponse .= "</error>";
if ($debug) :
$outResponse .= "<debug>" . $debugOut . "</debug>";
endif;
stationRequestLogFile($err[$i][0] . " : " . mcEncode($err[$i][1]), 1);
endfor;
$outResponse .= "</errors>";
else :
$trIdNewArrayLen = count($trIdNewArray);
$xmlStations = "";
if ($trIdNewArrayLen > 0) :
$xmlStations .= "<stations>";
for ($i = 0; $i < $trIdNewArrayLen; $i++) :
$xmlStations .= "<station_no>" . $trIdNewArray[$i] . "</station_no>";
endfor;
$xmlStations .= "</stations>";
endif;
$outResponse .= "<state>OK</state><carrier><orderno>" . $jbIdNew . "</orderno>" . $xmlStations . "</carrier>";
if ($debug) :
$outResponse .= "<debug>" . $debugOut . "</debug>";
endif;
endif;
$outResponse .= "</xml>";
// Log entries
stationRequestLogFile($outResponse); // Write response into log
stationRequestLogFile("___________________________________________________________________________________");
// Return output
echo $outResponse;
/*
// ERROR CODES
100 : Commission number does still exit. Insert of new order not possible.
101 : Authentication Data not correct.
102 : Maximum limit of orders per day reached. Presently xxxx orders.
103 : Maximum limit of orders in progress reached. Presently xxxx orders.
104 : Customer data could not be inserted.
105 : No order number for update!
106 : No order number for cancellation or order number not found!
107 : Cancellation failed because order is canceled or is in progress!
108 : Zipcode did not match zone
109 : Zone error.
110 : Address data are not complete.
111 : Generation of stations failed.
112 : Datetime format not correct.
113 : Start time of the order is not correct.
114 : Latest finish time of the order is not correct.
115 : No vehicle available
116 : Start time has to be in the future
117 : No invoice text
118 : Order is in progress or finished
// FELDER UND IHRE BEDEUTUNG
<xml>
<order> // Fuhrauftrag
<auth> // Identifikation des Kunden
<customer>...</customer> // Kundennummer (EID) {"STBxxxxxx", ...} => csc_id_payer
<account>...</account> // Eingetragener Benutzer für den Kunden => cs.cs_admin => emp.emp_id => emp.usr_id => usr.usr_id => usr.usr_account
<password>...</password> // Passwort für den Benutzer => usr.usr_password
<session_id>...</session_id> // Zusätzliche Session-ID, die mit dem Kunden ausgehandelt wurde [mandatory]
<costcenter_name>...</costcenter_name> // Kostenstellenname {"abcd", "efgh", ...} => Mapping csc_id [optional]
<group_no>...</group_no> // Nummer der Kundengruppe (Bei einer automatischen Preisfindung muss entweder <group_no> oder <group_name> gesetzt sein)
<group_name>...</group_name> // Name der Kundengruppe (Bei einer automatischen Preisfindung muss entweder <group_name> oder <group_no> gesetzt sein)
</auth>
<operation>...</operation> // Operation (INS, UPD, DEL)
<debug_on>...</debug_on> // Activates debug output ("ON" or "YES")
<event> // Manuelle EVENTS
<val>[optional]</val>
<val>[optional]</val>
<val>[optional]</val>
...
</event>
<no>...</no> // Order no of the customer => tr_commission_no
<type>...</type> // Type of the job => jb_type
<hq>...</hq> // {HB, HH, ...} => hq_mnemonic => hq_id
<vehicle> // Angefordertes Fahrzeug
<type_no>...</type_no> // {1,2,3...} => Mapping "metatype" => vht_id (entweder <type_no> oder <type_name> ist mandatory)
<type_name>...</type_name> // {"bus", ...} => Mapping "metatype" => vht_id (entweder <type_no> oder <type_name> ist mandatory)
<weight>...</weight> // Gewicht des Transportguts
<length>...</length> // Angeforderte Mindestlänge des Fahrzeugs
<width>...</width> // Angeforderte Mindestbreite des Fahrzeugs
<height>...</height> // Angeforderte Mindesthöhe des Fahrzeugs
<position>...</position> // Angeforderte Mindestanzahl an Stellplätzen im Fahrzeug
</vehicle>
<ordertime>...</ordertime> // Startzeit des Auftrags (wenn leer, dann "adhoc"-Auftrag mit aktuellem Zeitstempel) => jb_ordertime und jb_reserv
<ordertimeUTC>...</ordertimeUTC> // Startzeit des Auftrags in UTC (erst wird nach der Inhalt in <ordertime> geschaut, dann ich <ordertimeUTC>)
<warningtime>...</warningtime> // Späteste Erledigungszeit des Auftrags (Bsp: 2014-10-22 09:00:00)
<warningtimeUTC></warningtimeUTC> // Späteste Erledigungszeit des Auftrags in UTC (erst wird nach der Inhalt in <warningtime> geschaut, dann ich <warningtimeUTC>)
<acquisition_time>...</acquisition_time> // Erfassungszeit des Auftrags bei asynchroner Übertragung
<courier>...</courier> // {HH1000, HH1420, ...} Wunschfahrer => jb.cr_sid => Abgleich mit cr.cr_sid => cr.cr_id => jb.cr_id_order [optional]
<filter>CK,DE,EN</filter> // Fahrzeug-Filter zur Einschränkung der Fahrzeugvermittlung (Aufstellung siehe Anhang)
<remark>...</remark> // Bemerkung zum Auftrag
<courier_remark>...</courier_remark> // Bemerkung zum Auftrag für den Fahrer
<gdc> // Zusätzliche Informationen pro Auftrag, die gesondert behandelt und bei Rückgaben herangezogen werden können
<val>[optional]</val>
<val>[optional]</val>
<val>[optional]</val>
...
</gdc>
<stations> // Stationen
<station> // Station 1 (Abholung)
<ware_from_to>...</ware_from_to> // Abholung [optional] {leer, 0 = weder Abholung noch Anlieferung, 1 = nur Abholung, 2 = nur Anlieferung, 3 = beides}
<costcenter>...</costcenter> // Kostenstellenname {"abcd", "efgh", ...} => Mapping csc_id [optional, wenn gesetzt, dann weitere Felder leer]
<company>...</company> // Firmenbezeichnung
<company2>...</company2> // Firmenzusatz
<street>...</street> // Straße
<houseno>...</houseno> // Hausnummer
<zipcode>...</zipcode> // PLZ
<city>...</city> // Ort
<special_remark>...</special_remark> // Bemerkung zur Station
<person>...</person> // Abgabe der Sendung bei ..., Ansprechpartner [optional]
<phone>...</phone> // Telefonnummer [optional]
<email>...</email> // Email [optional]
<invoice> // Rechnungsangaben (des belieferten Endkunden)
<costcenter>...</costcenter> // Kostenstellenname {"abcd", "efgh", ...} => Mapping csc_id [optional, wenn gesetzt, dann weitere Felder leer]
<company>...</company> // Firmenbezeichnung
<company2>...</company2> // Firmenzusatz
<street>...</street> // Straße
<houseno>...</houseno> // Hausnummer
<floorno>...</floorno> // Etage, Flur
<zipcode>...</zipcode> // PLZ
<city>...</city> // Ort
<special_remark>...</special_remark> // Bemerkung zur Station
<person>...</person> // Abgabe der Sendung bei ..., Ansprechpartner [optional]
<phone>...</phone> // Telefonnummer [optional]
<email>...</email> // Email [optional]
<voucher_no>...</voucher_no> // Belegnummer des Endkunden (Rechnungsnummer, Kassenbon)
<payment_method>...</payment_method> // Zahlungsart (leer oder 0 = Bar, 1 = ECPin, 2 = ECLastschrift, etc.)
<price_mode>...</price_mode> // Art des rabattierten Preises ("" = Standardpreis, 0 = Aktionpreis_1 (z.B. "family card"), 1 = Aktionspreis_2)
<partial_payment>...</partial_payment> // Bereits geleisteter Betrag (leer = 0 = keine Anzahlung/Bezahlung)
</invoice>
<articles>
<article>
<mode>...</mode> // Modus (leer oder 0 = Auslieferung, 1 = Retoure, 2 = Montage, 3 = Demontage, 4 = Entsorgung (bei 2 und 3 mindestens Felder "description" und "quantity" gesetzt))
<no>...</no> // Artikelnummer
<serialno>...</serialno> // Seriennummer (<quantity>1</quantity>)
<description>...</description> // Beschreibung
<quantity>...</quantity> // Menge
<price>...</price> // Stückpreis
<weight>...</weight> // Einzelgewicht eines Artikels
<length>...</length> // Länge eines Artikels
<width>...</width> // Breite eines Artikels
<height>...</height> // Höhe eines Artikels
<pieces>...</pieces> // Anzahl Packstücke (leer oder 0 = z.B. keine Lieferung und nur Montage, ansonsten Anzahl)
<positions>...</positions> // Stellplätze, Kolli
<articlegroup_no>...</articlegroup_no> // Warengruppe
</article>
...
</articles>
<services> // Preisestruktur(en) [optional]
<timeslots>...</timeslots> // Zeitintervalle für Belieferung bzw. Anfahrt (leer = keine Einschränkung, "0" = vormittags, "1" = nachmittags, "2" = abends, "1,2" = vormittags und abends, ..., "1,2,3 = ganztägig")
<timeunits>...</timeunits> // Anzahl Zeiteinheiten für Erfüllung des Auftrags (1 Zeiteinheit = 10 Minuten)
<shipment_mode>...</shipment_mode> // Versandart (bit-string)
// 0 => 2^0 = 1 Lieferung (Delivery)
// 1 => 2^1 = 2 Montage (Installation)
// 2 => 2^2 = 4 Neumöbelmontage (Installation furniture) ("Installation" [2^1] also has to be set)
// 3 => 2^3 = 8 Besichtigung (Viewing)
// 4 => 2^4 = 16 Kücheninstallation (Installation kitchen) ("Installation" [2^1] also has to be set)
// 5 => 2^5 = 32 Nachlieferung (Delivery supplementary)
// 6 => 2^6 = 64 Reklamation (Complaint)
// 7 => 2^7 = 128 Abholung (Return shipment, Retoure))
// 8 => 2^8 = 256 Austausch (Replacement)
// 9 => 2^9 = 512 Aufmaß (Measurement)
// (E.g.: Delivery = 1, Installation furniture = 6 (including "Installation"),
// Installation kitchen = 18 (including "Installation"),
// Retoure = 128, Delivery and Retoure = 129, Replacement = 256
// Delivery and Replacement = 257, ...)
<order_type>...</order_type> // Auftragsart(en) (Sameday = 0, Nextday = 1, Kurier = 2)
<calculator> // Calculatorpreise [optional]
<calc_item> // Spezielle Zelle der Preis-/Leistungsmatrix
<servicetype>...</servicetype> // Leistungstyp
<pricetype>...</pricetype> // Preistyp
<price>...</price> // Preis [optional] => überschreibt den in der zelle eingetragenen Preis
<quantity>...</quantity> // Menge
</calc_item>
...
<func_item> // Calculatorpreisfunktionen [optional]
<no>...</no> // Nummer der Funktion (Erläuterung siehe bitte unten)
<par_1>...</par_1> // Wert für Parameter Nr. 1 der Funktion
<par_2>...</par_2> // Wert für Parameter Nr. 2 der Funktion
<par_3>...</par_3> // Wert für Parameter Nr. 3 der Funktion
<par_4>...</par_4> // Wert für Parameter Nr. 4 der Funktion
<par_5>...</par_5> // Wert für Parameter Nr. 5 der Funktion
<quantity>...</quantity> // Menge (leer = 1 = default, ansonsten angegebene Anzahl)
</func_item>
...
</calculator>
</services>
<gdc> // Zusätzliche Informationen pro Station, die gesondert behandelt und bei Rückgaben herangezogen werden können
<1>[optional]</1>
<2>[optional]</2>
<3>[optional]</3>
<4>[optional]</4>
<5>[optional]</5>
</gdc>
</station>
<station> // Station 2
<ware_from_to>...<ware_from_to> // Abholung, Anlieferung, beides [optional]
...
</station>
... // Weitere Stationen
</stations>
</order>
</xml>
Calculatorpreisfunktionen:
<func_item>...</func_item>
Nr. : Kontext
Parameter (außer der Menge, die bei jeder Funktion optional übergeben werden kann)
Menge (leer = 1 = default, ansonsten angegebene Anzahl)
10002 : Gestaffelter warenwertabhängiger Grundpreis für den Transport
<func_item>
<no>10002</no>
<par_1>490</par_1> // Warenwert (Bsp. 490,- €)
<quantity></quantity>
</func_item>
10003 : Tagessatz für Lagerungskosten ab dem n. Tag
<func_item>
<no>10003</no>
<par_1>14</par_1> // Anzahl Tage (bei 0 => keine Berechnung => keine Kosten für Endkunde)
<quantity>1</quantity>
</func_item>
10004 : Montagebetrag auf Basis des Prozentsatzes p% vom Warenwert
<func_item>
<no>10004</no>
<par_1>288</par_1> // Warenwert
<quantity></quantity>
</func_item>
10010 : Preis pro Meter Küchenmontage
<func_item>
<no>10010</no>
<par_1>5</par_1> // Angabe lfd. Meter
<quantity></quantity>
</func_item>
20005 : Elektroanschluss bei Küchenmontage
<func_item>
<no>20005</no>
<quantity>1</quantity>
</func_item>
20006 : Wasseranschluss bei Küchenmontage
<func_item>
<no>20006</no>
<quantity>1</quantity>
</func_item>
10005 : Expresslieferung nach Zonen
<func_item>
<no>10005</no>
<par_1>22525</par_1> // PLZ
<quantity></quantity>
</func_item>
20001 : Zusätzliche Montagestunde
<func_item>
<no>20001</no>
<quantity>2.25</quantity>
</func_item>
20002 : Pauschale Nachmontage
<func_item>
<no>20002</no>
<quantity>1.5</quantity>
</func_item>
20003 : Monteurstunde bei Nachmontage
<func_item>
<no>20003</no>
<quantity>3</quantity>
</func_item>
10007 : Prozentsatzes p% des Lieferpreises beim Abholauftrag
<func_item>
<no>10007</no>
<par_1>197</par_1> // Preis des Abholauftrags
<quantity>1</quantity>
</func_item>
10009 : Warengruppenabhängiger Preis für die Montage
<func_item>
<no>10009</no>
<par_1>10</par_1> // Warengruppe
<quantity>1</quantity>
</func_item>
10006 : Warengruppenabhängiger Preis für die Altmöbelrücknahme
<func_item>
<no>10006</no>
<par_1>15</par_1> // Warengruppe
<quantity>1</quantity>
</func_item>
10008 : Preis für Liefergewicht pro x kg höher als das Freigewicht
<func_item>
<no>10008</no>
<par_1>350</par_1> // Gewicht in kg
<quantity>1</quantity>
</func_item>
20004 : Endkundenpreis für Einkaufsservice
<func_item>
<no>20004</no>
<quantity>1</quantity>
</func_item>
10011 : Verrechnungssatz pro Artikel in Prozent p% vom Verkaufspreis bei Verlust und Schäden
<func_item>
<no>10011</no>
<par_1>350</par_1> // Warenwert
<quantity>1</quantity>
</func_item>
20007 : Hantierungshilfsmittel: Verrechnungssatz Euro-Palette
<func_item>
<no>20007</no>
<quantity>3</quantity>
</func_item>
20008 : Hantierungshilfsmittel: Verrechnungssatz IKEA-Palette
<func_item>
<no>20008</no>
<quantity>3</quantity>
</func_item>
1xxxx : Kosten für Transportverpackung(en) z.B. bei Kleinteilen
<func_item>
<no>1xxxx</no>
<quantity>1</quantity>
</func_item>
// PFLICHTFELDER UND OPTIONALE FELDER
<xml>
<order> // Fuhrauftrag
<auth> // Identifikation des Kunden
<customer>[mandatory]</customer> // Kundennummer (EID) {"STBxxxxxx", ...}
<account>[mandatory]</account> // Eingetragener Benutzer für den Kunden
<password>[mandatory]</password> // Passwort für den Benutzer
<session_id>[mandatory]</session_id> // Zusätzliche ausgehandelte Session-ID
<costcenter_name>[optional]</costcenter_name> // Bekannte Kostenstelle
<group_no>[optional]</group_no> // Nummer der Kundengruppe (Bei einer automatischen Preisfindung muss entweder <group_no> oder <group_name> gesetzt sein)
<group_name>[optional]</group_name> // Name der Kundengruppe (Bei einer automatischen Preisfindung muss entweder <group_name> oder <group_no> gesetzt sein)
</auth>
<operation>[optional]</operation> // Operation (INS, UPD, DEL)
<debug_on>[optional]</debug_on> // Activates debug output ("ON" or "YES")
<event> // Manuelle EVENTS
<val>[optional]</val>
<val>[optional]</val>
<val>[optional]</val>
...
</event>
<no>[optional]</no> // Eigene Auftragsnummer z.B. aus Lotus
<type>[optional]</type> // Auftragstype (z.B. 1,2,3,...) (Mapping z.B. auf "G", "K", ...)
<hq>[mandatory]</hq> // HH (HB, B, DD), Städtekürzel
<vehicle> // Angefordertes Fahrzeug
<type_no>[mandatory]</type_no> // {2=PKW, 3=Kombi, 4=Kastenwagen, 5=Bus, 6=Großer Bus, 7=LKW}
<type_name>[optional]</type_name> // {PKW, ...}
<weight>[optional]</weight> // Gewicht des Transportguts
<length>[optional]</length> // Angeforderte Mindestlänge des Fahrzeugs
<width>[optional]</width> // Angeforderte Mindestbreite des Fahrzeugs
<height>[optional]</height> // Angeforderte Mindesthöhe des Fahrzeugs
<position>[optional]</position> // Angeforderte Mindestanzahl an Stellplätzen im Fahrzeug
</vehicle>
<ordertime>[optional]</ordertime> // Startzeit des Auftrags (wenn leer, dann "adhoc"-Auftrag mit aktuellem Zeitstempel) (Bsp: 2012-02-17 09:30:00)
<ordertimeUTC>[optional]</ordertimeUTC> // Startzeit des Auftrags in UTC (erst wird nach der Inhalt in <ordertime> geschaut, dann ich <ordertimeUTC>)
<warningtime>[optional]</warningtime> // Späteste Erledigungszeit des Auftrags (Bsp: 2014-10-22 09:00:00)
<warningtimeUTC>[optional]</warningtimeUTC> // Späteste Erledigungszeit des Auftrags in UTC (erst wird nach der Inhalt in <warningtime> geschaut, dann ich <warningtimeUTC>)
<acquisition_time>[optional]</acquisition_time> // Erfassungszeit des Auftrags bei asynchroner Übertragung
<courier>[optional]</courier> // {HH1000, HH1420, ...} Wunschfahrer
<filter>[optional]</filter> // Fahrzeug-Filter zur Einschränkung der Fahrzeugvermittlung (Aufstellung siehe Anhang) (Bsp.: EN=Englisch, HW=Hubwagen, ...)
<remark>[mandatory]</remark> // Rechnungstext und Bemerkung zum Auftrag
<courier_remark>[optional]</courier_remark> // Bemerkung zum Auftrag für den Fahrer
<gdc> // Zusätzliche Informationen pro Auftrag, die gesondert behandelt und bei Rückgaben herangezogen werden können
<val>[optional]</val>
<val>[optional]</val>
<val>[optional]</val>
...
</gdc>
<stations> // Stationen
<station> // Station 1 (Abholung)
<ware_from_to>[optional]</ware_from_to> // Abholung, Anlieferung, beides {leer, 0, 1, 2, 3}
<costcenter>[optional]</costcenter> // Kostenstellenname {"abcd", "efgh", ...}
<company>[mandatory]</company> // Firmenbezeichnung ODER Person
<company2>[optional]</company2> // Firmenzusatz
<street>[mandatory]</street> // Straße
<houseno>[mandatory]</houseno> // Hausnummer
<floorno>[optional]</floorno> // Etage, Flur
<zipcode>[mandatory]</zipcode> // PLZ
<city>[mandatory]</city> // Ort
<special_remark>[optional]</special_remark> // Bemerkung zur Station
<person>[optional]</person> // Abgabe der Sendung bei ..., Ansprechpartner
<phone>[optional]</phone> // Telefonnummer
<email>[optional]</email> // Email
<invoice> // Rechnungsangaben (des belieferten Endkunden)
<costcenter>[optional]</costcenter> // Kostenstellenname {"abcd", "efgh", ...} => Mapping csc_id [optional, wenn gesetzt, dann weitere Felder leer]
<company>[optional]</company> // Firmenbezeichnung
<company2>[optional]</company2> // Firmenzusatz
<street>[optional]</street> // Straße
<houseno>[optional]</houseno> // Hausnummer
<zipcode>[optional]</zipcode> // PLZ
<city>[optional]</city> // Ort
<special_remark>[optional]</special_remark> // Bemerkung zur Station
<person>[optional]</person> // Abgabe der Sendung bei ..., Ansprechpartner [optional]
<phone>[optional]</phone> // Telefonnummer [optional]
<email>[optional]</email> // Email [optional]
<voucher_no>[optional]</voucher_no> // Belegnummer des Endkunden (Rechnungsnummer, Kassenbon)
<payment_method>[optional]</payment_method> // Zahlungsart (leer oder 0 = Bar, 1 = ECPin, 2 = ECLastschrift, 20 = Familycard, 21 = Businesscard)
<price_mode>[optional]</price_mode> // Art des rabattierten Preises ("" = Standardpreis, 0 = Aktionpreis_1 (z.B. "family card"), 1 = Aktionspreis_2)
<partial_payment>[optional]</partial_payment> // Bereits geleisteter Betrag (leer = 0 = keine Anzahlung/Bezahlung)
</invoice>
<articles>
<article>
<mode>[optional]</mode> // Modus (leer oder 0 = Auslieferung, 1 = Retoure, 2 = Montage, 3 = Demontage, 4 = Entsorgung (bei 2 und 3 mindestens Felder "description" und "quantity" gesetzt))
<no>[optional]</no> // Artikelnummer
<serialno>[optional]</serialno> // Seriennummer (<quantity>1</quantity>)
<description>[optional]</description> // Beschreibung
<quantity>[optional]</quantity> // Menge
<price>[optional]</price> // Stückpreis
<weight>[optional]</weight> // Einzelgewicht eines Artikels
<length>[optional]</length> // Länge eines Artikels
<width>[optional]</width> // Breite eines Artikels
<height>[optional]</height> // Höhe eines Artikels
<pieces>[optional]</pieces> // Anzahl Packstücke (leer oder 0 = z.B. keine Lieferung und nur Montage, ansonsten Anzahl)
<positions>[optional]</positions> // Stellplätze, Kolli
<articlegroup_no>[optional]</articlegroup_no> // Warengruppe
</article>
...
</articles>
<services> // Preisestruktur(en) [optional]
<timeslots>[optional]</timeslots> // Zeitintervalle für Belieferung bzw. Anfahrt (leer = keine Einschränkung, "0" = vormittags, "1" = nachmittags, "2" = abends, "1,2" = vormittags und abends, ..., "1,2,3" = ganztägig")
<timeunits>[mandatory]</timeunits> // Anzahl Zeiteinheiten für Erfüllung des Auftrags (1 Zeiteinheit = 10 Minuten)
<shipment_mode>[optional]</shipment_mode> // Versandart (bit-string)
// 0 => 2^0 = 1 Lieferung (Delivery)
// 1 => 2^1 = 2 Montage (Installation)
// 2 => 2^2 = 4 Neumöbelmontage (Installation furniture) ("Installation" [2^1] also has to be set)
// 3 => 2^3 = 8 Besichtigung (Viewing)
// 4 => 2^4 = 16 Kücheninstallation (Installation kitchen) ("Installation" [2^1] also has to be set)
// 5 => 2^5 = 32 Nachlieferung (Delivery supplementary)
// 6 => 2^6 = 64 Reklamation (Complaint)
// 7 => 2^7 = 128 Abholung (Return shipment, Retoure))
// 8 => 2^8 = 256 Austausch (Replacement)
// 9 => 2^9 = 512 Aufmaß (Measurement)
// (E.g.: Delivery = 1, Installation furniture = 6 (including "Installation"),
// Installation kitchen = 18 (including "Installation"),
// Retoure = 128, Delivery and Retoure = 129, Replacement = 256
// Delivery and Replacement = 257, ...)
<order_type>[optional]</order_type> // Auftragsart(en) (Sameday = 0, Nextday = 1, Kurier = 2)
<calculator> // Calculatorpreise [optional]
<calc_item> // Spezielle Zelle der Preis-/Leistungsmatrix
<servicetype>[mandatory]</servicetype> // Leistungstyp
<pricetype>[mandatory]</pricetype> // Preistyp
<price>[optional]</price> // Preis [optional] => überschreibt den in der zelle eingetragenen Preis
<quantity>[mandatory]</quantity> // Menge
</calc_item>
...
<func_item> // Calculatorpreisfunktionen [optional]
<no>[mandatory]</no> // Nummer der Funktion (Erläuterung siehe bitte unten)
<par_1>[optional]</par_1> // Wert für Parameter Nr. 1 der Funktion
<par_2>[optional]</par_2> // Wert für Parameter Nr. 2 der Funktion
<par_3>[optional]</par_3> // Wert für Parameter Nr. 3 der Funktion
<par_4>[optional]</par_4> // Wert für Parameter Nr. 4 der Funktion
<par_5>[optional]</par_5> // Wert für Parameter Nr. 5 der Funktion
<quantity>[optional]</quantity> // Menge (leer = 1 = default, ansonsten angegebene Anzahl)
</func_item>
...
</calculator>
</services>
<gdc> // Zusätzliche Informationen pro Station, die gesondert behandelt und bei Rückgaben herangezogen werden können
<1>[optional]</1>
<2>[optional]</2>
<3>[optional]</3>
<4>[optional]</4>
<5>[optional]</5>
</gdc>
</station>
<station> // Station 2
<ware_from_to>[optional]<ware_from_to> // Abholung, Anlieferung, beides [optional]
...
</station>
... // Weitere Stationen
</stations>
</order>
</xml>
*/
?>