";
orderRequestLogFile($currentTime);
orderRequestLogFile($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 ***
$maxNumOfOrdersPerDay = 300;
$maxNumOfRunningOrders = 1000;
$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 "
";
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 . "
\n";
$debugOut .= "usrPassword: " . $usrPassword . "
\n";
$debugOut .= "sessionId: " . $sessionId . "
\n";
if (checkRequestAuthenticationData($usrAccount, $usrPassword, $sessionId, $csId)) :
$debugOut .= "Authentication okay!
\n";
// Data
$hqId = getFieldValueFromId("customer","cs_id",$csId,"hq_id");
$cscName = convertSpecial($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", "ORDER_REQUEST_ERROR_HANDLER_DISABLED_" . $csId, "0");
if ($tmpErrHandlerDisabled == "") : $tmpErrHandlerDisabled = getParameterValue("0", "ORDER_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"]);
$commNoRelated = convertSpecial($orderArray["xml"]["order"]["no_related"]);
$commNoMerged = convertSpecial($orderArray["xml"]["order"]["no_merged"]);
$commNoService = convertSpecial($orderArray["xml"]["order"]["no_service"]);
// Check commission number regarding existence
$checkExistenceCommissionNo = getParameterValue("0", "ORDER_REQUEST_CHECK_EXISTENCE_COMMISSION_NO", $hqId);
if ($checkExistenceCommissionNo == "") : $checkExistenceCommissionNo = getParameterValue("0", "ORDER_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", "ORDER_REQUEST_CHECK_OPERATION_EXISTENCE_COMMISSION_NO", $hqId);
if ($checkOperationForExistingCommissionNo == "") : $checkOperationForExistingCommissionNo = getParameterValue("0", "ORDER_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. Der neue Auftrag kann nicht geschrieben werden."));
$acceptOrder = false;
endif;
endif;
endif;
endif;
// EVENTS
$executeOperationsBecauseNoEvent = true; // Init (Set parameter for potential disabling the current job status check!)
$jbEventArray = array();
$executeCancellationByEvent = true; // Init (Set parameter for cancellation)
$numOfOrderEvents = count($orderArray["xml"]["order"]["event"]["val"]);
if ($numOfOrderEvents > 0) :
if ($numOfOrderEvents == 1) :
$jbEventArray[0] = convertSpecial($orderArray["xml"]["order"]["event"]["val"]);
else :
for ($k = 0; $k < $numOfOrderEvents; $k++) :
$jbEventArray[$k] = convertSpecial($orderArray["xml"]["order"]["event"]["val"][$k]);
endfor;
endif;
endif;
$jbEventArrayLen = count($jbEventArray);
if ($jbEventArrayLen > 0) :
$executeOperationsBecauseNoEvent = false; // At least one event does exist
// Get customized event infos if parameter activated
$parEventMappingActivated = getParameterValue("0", "ORDER_REQUEST_CUSTOMIZED_EVENT_MAPPING_ACTIVATED_" . $csId, "0");
if ($parEventMappingActivated == "1") :
// Structure: key_01=val_01|key_02=val_02|key_03=val_03|key_04=val_04|....
// (E.g.: 100=Change customer request|101=Failed delivery TSP|102=Return/Cancel to Store, order at TSP|103=Payment change|104=Failed Delivery IKEA|105=Return/Cancel, order at Store|....)
$csEvents = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = 'cs' AND gdc_gen_fieldname = 'events' AND gdc_obj_id = '" . $csId . "'");
$csEventsArray = getKeyValueArrayFromString($csEvents);
$csEventsArrayLen = count($csEventsArray);
// Generate reverse array:
// $arr["The manual events that will be sent are the following if I have the right information."] = "101", ....;
$csEventsReverseArray = array_flip($csEventsArray);
$csEventsReverseArrayLen = count($csEventsReverseArray);
else :
// Get events for current related customer to prevent cancellation of the current order (because of payment) by UPD
$parEventsPreventsCancellation = getParameterValue("0", "ORDER_REQUEST_EVENTS_PREVENT_CANCELLATION_" . $csId, "0");
if ($parEventsPreventsCancellation != "") :
$parEventsPreventsCancellation = str_replace("|", "-,-", $parEventsPreventsCancellation);
$tmpEventsPreventsCancellationArray = spliti("-,-",$parEventsPreventsCancellation);
$tmpEventsPreventsCancellationArrayLen = count($tmpEventsPreventsCancellationArray);
for ($k = 0; $k < $jbEventArrayLen; $k++) :
for ($l = 0; $l < $tmpEventsPreventsCancellationArrayLen; $l++) :
if (!(strpos($jbEventArray[$k], $tmpEventsPreventsCancellationArray[$l]) === FALSE)) :
$executeCancellationByEvent = false;
break 2;
endif;
endfor;
endfor;
endif;
endif;
endif;
// Check jb_status by operations UPD and DEL. jb_status has to be in (0,9), because taken or finished jobs cannot be changed
$jbIdCurrent = "";
if ($commissionNo != "") :
$jbIdCurrent = getOneStmt("SELECT jb.jb_id AS jb_id FROM tour AS tr, job AS jb, costcenter AS csc WHERE tr.tr_commission_no = '" . $commissionNo . "' AND tr.jb_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
// Check special parameter for event cancellation mode. If enabled (= "1") then check PREDECESSOR JOB still having the event preventing the cancellation.
// If it has it execute cancellation process of the CURRENT job!
if ($jbIdCurrent != "" && !$executeCancellationByEvent) :
$parEventsStorageMode = getParameterValue("0", "ORDER_REQUEST_EVENT_STORAGE_MODE_CS_" . $csId, "0");
if ($parEventsStorageMode == "1") :
// Get predecessor job
$jbPredecessor = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'jb_storno' AND gdc_obj_id = '" . $jbIdCurrent . "'");
if ($jbPredecessor != "" && is_numeric($jbPredecessor)) :
$jbCurrentEvents = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'jb_events' AND gdc_obj_id = '" . $jbPredecessor . "'");
if ($jbCurrentEvents != "") :
if ($parEventsPreventsCancellation == "") : // Defined above
$parEventsPreventsCancellation = getParameterValue("0", "ORDER_REQUEST_EVENTS_PREVENT_CANCELLATION_" . $csId, "0");
$parEventsPreventsCancellation = str_replace("|", "-,-", $parEventsPreventsCancellation);
$tmpEventsPreventsCancellationArray = spliti("-,-",$parEventsPreventsCancellation);
$tmpEventsPreventsCancellationArrayLen = count($tmpEventsPreventsCancellationArray);
endif;
if ($parEventsPreventsCancellation != "") :
for ($l = 0; $l < $tmpEventsPreventsCancellationArrayLen; $l++) :
if (!(strpos($jbCurrentEvents, $tmpEventsPreventsCancellationArray[$l]) === FALSE)) :
$executeCancellationByEvent = true;
endif;
endfor;
endif;
endif;
endif;
endif;
endif;
endif;
if ($debug) :
echo "---- REQUEST EVENTS ---------------------------------------------------------------------
\n";
echo "numOfOrderEvents: " . $numOfOrderEvents . "
\n";
echo "jbEventArray:
";
print_r($jbEventArray);
echo "----------------------------------------------------------------------------------------
\n";
echo "---- CUSTOMER EVENTS -------------------------------------------------------------------
\n";
echo "parEventMappingActivated: " . $parEventMappingActivated . "
\n";
echo "parEventsPreventsCancellation: " . $parEventsPreventsCancellation . "
\n";
echo "EXECUTE DELETE: " . ($executeCancellationByEvent ? "YES" : "NO") . "
\n";
echo "BASE VALUES IN csEvents: " . $csEvents . "
\n";
echo "csEventsArray:
\n";
print_r($csEventsArray); echo "
\n";
echo "tmpEventsPreventsCancellationArray:
\n";
print_r($tmpEventsPreventsCancellationArray); echo "
\n";
echo "----------------------------------------------------------------------------------------
\n";
echo "---- CUSTOMER EVENTS REVERSE ------------------------------------------------------------
\n";
echo "csEventsReverseArray:
\n";
print_r($csEventsReverseArray);
echo "----------------------------------------------------------------------------------------
\n";
endif;
if ($operationMode == "UPD" || $operationMode == "UPDATE" || $operationMode == "DEL" || $operationMode == "DELETE") :
// Check for event
if ($executeOperationsBecauseNoEvent) :
$checkOperationForJbStatus = true;
$tmpCheckJbStatus = getParameterValue("0", "ORDER_REQUEST_CHECK_OPERATION_JOB_STATUS_DISABLED", $hqId);
if ($tmpCheckJbStatus == "1") :
$checkOperationForJbStatus = false;
endif;
if ($checkOperationForJbStatus) :
// $jbIdCurrent = getOneStmt("SELECT jb.jb_id AS jb_id FROM tour AS tr, job AS jb, costcenter AS csc WHERE tr.tr_commission_no = '" . $commissionNo . "' AND tr.jb_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
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;
endif;
// Get related (parent/delivery) job ID by order number
$jbIdParent = "";
if ($commNoRelated != "") :
// Look for SERVICE MODE of the job to decide searching for PARENT JOB
$parNoRelatedByService = getObjectBasedParameterValue("ORDER_REQUEST_NO_RELATED_BY_SERVICE", $csId, $hqId);
if ($parNoRelatedByService == "1") :
/*
if ($commissionNo == $commNoRelated) :
$jbIdParent = getOneStmt("SELECT jb.jb_id AS jb_id FROM genericdatacontainer AS gdc, job AS jb, costcenter AS csc WHERE gdc.gdc_obj_type = 'jb' AND gdc.gdc_gen_fieldname = 'info_0' AND gdc.gdc_content = '" . $commNoRelated . "' AND gdc.gdc_obj_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
else :
$jbIdParent = getOneStmt("SELECT jb.jb_id AS jb_id FROM tour AS tr, job AS jb, costcenter AS csc WHERE tr.tr_commission_no = '" . $commNoRelated . "' AND tr.jb_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
endif;
if ($jbIdParent == "" || $jbIdParent == "0") :
$jbIdParent = getOneStmt("SELECT jb.jb_id AS jb_id FROM tour AS tr, job AS jb, costcenter AS csc WHERE tr.tr_commission_no = '" . $commNoRelated . "' AND tr.jb_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
if ($jbIdParent == "" || $jbIdParent == "0") :
// Check reference in gdc.info_0
$jbIdParent = getOneStmt("SELECT jb.jb_id AS jb_id FROM genericdatacontainer AS gdc, job AS jb, costcenter AS csc WHERE gdc.gdc_obj_type = 'jb' AND gdc.gdc_gen_fieldname = 'info_0' AND gdc.gdc_content = '" . $commNoRelated . "' AND gdc.gdc_obj_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
endif;
endif;
*/
else :
$parNoRelated = getObjectBasedParameterValue("ORDER_REQUEST_NO_RELATED_MODE", $csId, $hqId);
if ($parNoRelated == "1") :
// Overrule with related order number from GDC field "info_0" because (<=> $commissionNo) contains the shipment NO
$jbIdParent = getOneStmt("SELECT jb.jb_id AS jb_id FROM genericdatacontainer AS gdc, job AS jb, costcenter AS csc WHERE gdc.gdc_obj_type = 'jb' AND gdc.gdc_gen_fieldname = 'info_0' AND gdc.gdc_content = '" . $commNoRelated . "' AND gdc.gdc_obj_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
elseif ($parNoRelated == "2") :
$jbIdParent = $commNoRelated;
else :
// DEFAULT: Remote order number equals commission number
$jbIdParent = getOneStmt("SELECT jb.jb_id AS jb_id FROM tour AS tr, job AS jb, costcenter AS csc WHERE tr.tr_commission_no = '" . $commNoRelated . "' AND tr.jb_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
endif;
endif;
endif;
// Get merged job ID by merged order number
$jbIdMerged = "";
if ($commNoMerged != "") :
$parNoMerged = getObjectBasedParameterValue("ORDER_REQUEST_NO_MERGED_MODE", $csId, $hqId);
if ($parNoMerged == "1") :
$jbIdMerged = getOneStmt("SELECT jb.jb_id AS jb_id FROM genericdatacontainer AS gdc, job AS jb, costcenter AS csc WHERE gdc.gdc_obj_type = 'jb' AND gdc.gdc_gen_fieldname = 'info_0' AND gdc.gdc_content = '" . $commNoMerged . "' AND gdc.gdc_obj_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
elseif ($parNoMerged == "2") :
$jbIdMerged = $commNoMerged;
else :
$jbIdMerged = getOneStmt("SELECT jb.jb_id AS jb_id FROM tour AS tr, job AS jb, costcenter AS csc WHERE tr.tr_commission_no = '" . $commNoMerged . "' AND tr.jb_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
endif;
endif;
// Get job ID to be UPDATED by order number
$jbIdUpdate = "";
$parNoUpdate = getObjectBasedParameterValue("ORDER_REQUEST_NO_UPDATE", $csId, $hqId);
if ($operationMode == "UPD" || $operationMode == "UPDATE") :
if ($parNoUpdate == "1") :
$jbIdUpdate = getOneStmt("SELECT jb.jb_id AS jb_id FROM genericdatacontainer AS gdc, job AS jb, costcenter AS csc WHERE gdc.gdc_obj_type = 'jb' AND gdc.gdc_gen_fieldname = 'info_0' AND gdc.gdc_content = '" . $commissionNo . "' AND gdc.gdc_obj_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
elseif ($parNoUpdate == "2") :
$jbIdUpdate = $commissionNo;
else :
// DEFAULT: Remote order number equals commission number
$jbIdUpdate = getOneStmt("SELECT jb.jb_id AS jb_id FROM tour AS tr, job AS jb, costcenter AS csc WHERE tr.tr_commission_no = '" . $commissionNo . "' AND tr.jb_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
endif;
endif;
// Get job ID to be CANCELLED by order number
$jbIdCancellation = "";
$jbIdArrayWithParentOfCancellation = array(); // If a job will be cancelled then move "jb_parent" of all jobs refering to the cancelled job to the new job [Here init only]
$parNoCancellation = getObjectBasedParameterValue("ORDER_REQUEST_NO_CANCELLATION", $csId, $hqId);
if ($operationMode == "DEL" || $operationMode == "DELETE") :
if ($parNoCancellation == "1") :
$jbIdCancellation = getOneStmt("SELECT jb.jb_id AS jb_id FROM genericdatacontainer AS gdc, job AS jb, costcenter AS csc WHERE gdc.gdc_obj_type = 'jb' AND gdc.gdc_gen_fieldname = 'info_0' AND gdc.gdc_content = '" . $commissionNo . "' AND gdc.gdc_obj_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
elseif ($parNoCancellation == "2") :
$jbIdCancellation = $commissionNo;
else :
// DEFAULT: Remote order number equals commission number
$jbIdCancellation = getOneStmt("SELECT jb.jb_id AS jb_id FROM tour AS tr, job AS jb, costcenter AS csc WHERE tr.tr_commission_no = '" . $commissionNo . "' AND tr.jb_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
endif;
endif;
$debugOut .= "---- OP ---------
\n";
$debugOut .= "operationMode: " . $operationMode . "
\n";
$debugOut .= "jbIdParent: " . $jbIdParent . "
\n";
$debugOut .= "jbIdMerged: " . $jbIdMerged . "
\n";
$debugOut .= "jbIdUpdate: " . $jbIdUpdate . "
\n";
$debugOut .= "jbIdCancellation: " . $jbIdCancellation . "
\n";
$debugOut .= "---- OP ---------
\n";
$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("ORDER_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("ORDER_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"]);
// Special informations inserted into GDC structure
$jbGdcArray = array();
/*
$numOfGdcEntries = count($orderArray["xml"]["order"]["gdc"]["val"]);
for ($k = 0; $k < $numOfGdcEntries; $k++) :
$jbGdcArray[$k] = convertSpecial($orderArray["xml"]["order"]["gdc"]["val"][$k]);
endfor;
*/
$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;
// Get customized ("tourarticle") added service infos (for invoicing etc.)
// Structure: key_01=val_01_german,val_01_english,....|key_02=val_02_german,val_02_english,....|key_03=val_03_german,val_03_english,....|key_04=val_04_german,val_04_english,....|....
// (E.g.: 100=Montage aller Art/Montagezusatzkosten,ADDITIONAL_INSTALL_SERVICE|101=Möbelmontage,FURNITURE_ASSEMBLY|102=Polstermöbelmontage,LEGS_FURNITURE_ASSEMBLY|103=Möbelmontage/Monteur vor Ort,FURNITURE_ASSEMBLY_EXPRESS|104=KuSe Möbelnachmontage,AFTER_SALES_FURNITURE_ASSEMBLY|....)
$csAddedServiceInfos = getFieldValueFromClause("genericdatacontainer", "gdc_content", "gdc_obj_type = 'cs' AND gdc_gen_fieldname = 'add_service_info' AND gdc_obj_id = '" . $csId . "'");
$csAddedServiceInfosArray = getKeyValueArrayFromString($csAddedServiceInfos);
$csAddedServiceInfosArrayLen = count($csAddedServiceInfosArray);
// Generate both reverse arrays depending on the language selected:
// 1. $arr[100] = "ADDITIONAL_INSTALL_SERVICE", ....
// 2. $arr["ADDITIONAL_INSTALL_SERVICE"] = "Montage aller Art/Montagezusatzkosten";
$csAddedServiceReverseInfosArray1 = array();
$csAddedServiceReverseInfosArray2 = array();
$csAddSrvKeysArray = array_keys($csAddedServiceInfosArray);
$csAddSrvKeysArrayLen = count($csAddSrvKeysArray);
for ($l = 0; $l < $csAddSrvKeysArrayLen; $l++) :
$tmpValArray = spliti(",", $csAddedServiceInfosArray[$csAddSrvKeysArray[$l]]); // "Montage aller Art/Montagezusatzkosten,ADDITIONAL_INSTALL_SERVICE" => array("ADDITIONAL_INSTALL_SERVICE","Montage aller Art/Montagezusatzkosten")
$csAddedServiceReverseInfosArray1[$tmpValArray[$languageSelected]] = $csAddSrvKeysArray[$l]; // $csAddedServiceReverseInfosArray1["ADDITIONAL_INSTALL_SERVICE"] = 100;
$csAddedServiceReverseInfosArray2[$tmpValArray[$languageSelected]] = $tmpValArray[0]; // $csAddedServiceReverseInfosArray2["ADDITIONAL_INSTALL_SERVICE"] = "Montage aller Art/Montagezusatzkosten";
endfor;
$csAddedServiceReverseInfosArray1Len = count($csAddedServiceReverseInfosArray1);
$csAddedServiceReverseInfosArray2Len = count($csAddedServiceReverseInfosArray2);
if ($debug) :
echo "---- ADDED SERVICE INFOS ---------------------------------------------------------------
";
echo "BASE VALUES IN csAddedServiceInfos: " . $csAddedServiceInfos . "
";
echo "csAddedServiceInfosArray:
";
print_r($csAddedServiceInfosArray);
echo "----------------------------------------------------------------------------------------
";
echo "---- ADDED SERVICE INFOS REVERSE --------------------------------------------------------
";
echo "csAddedServiceReverseInfosArray1:
";
print_r($csAddedServiceReverseInfosArray1);
echo "csAddedServiceReverseInfosArray2:
";
print_r($csAddedServiceReverseInfosArray2);
echo "----------------------------------------------------------------------------------------
";
endif;
// Init
$jbTourdata = "";
$jbTourdataZipcode = "";
$jbTourdataCity = "";
$jbTourdataCountry = "";
// "TOUR" data
$numOfStations = count($orderArray["xml"]["order"]["stations"]["station"]);
if ($debug) :
echo "numOfStations: " . $numOfStations . "
";
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++) :
$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] . "
\n";
$debugOut .= "trCscId[$i]: " . $trCscId[$i] . "
\n";
$debugOut .= "
\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
\n";
$debugOut .= "trInvCompany[$i]: " . $trInvCompany[$i] . "
\n";
$debugOut .= "trInvCompany2[$i]: " . $trInvCompany2[$i] . "
\n";
$debugOut .= "trInvAdId[$i]: " . $trInvAdId[$i] . "
\n";
$debugOut .= "trInvStreet[$i]: " . $trInvStreet[$i] . "
\n";
$debugOut .= "trInvHouseno[$i]: " . $trInvHouseno[$i] . "
\n";
$debugOut .= "trInvFloor[$i]: " . $trInvFloor[$i] . "
\n";
$debugOut .= "trInvZipcode[$i]: " . $trInvZipcode[$i] . "
\n";
$debugOut .= "trInvCity[$i]: " . $trInvCity[$i] . "
\n";
$debugOut .= "trInvSpecialRemark[$i]: " . $trInvSpecialRemark[$i] . "
\n";
$debugOut .= "trInvPerson[$i]: " . $trInvPerson[$i] . "
\n";
$debugOut .= "trInvPhone[$i]: " . $trInvPhone[$i] . "
\n";
$debugOut .= "trInvEmail[$i]: " . $trInvEmail[$i] . "
\n";
$debugOut .= "trInvAdSupplement_1[$i]: " . $trInvAdSupplement_1[$i] . "
\n";
$debugOut .= "trInvAdSupplement_2[$i]: " . $trInvAdSupplement_2[$i] . "
\n";
$debugOut .= "trInvAdSupplement_3[$i]: " . $trInvAdSupplement_3[$i] . "
\n";
$debugOut .= "trInvAdSupplement_4[$i]: " . $trInvAdSupplement_4[$i] . "
\n";
$debugOut .= "trInvAdSupplement_5[$i]: " . $trInvAdSupplement_5[$i] . "
\n";
$debugOut .= "
\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:
$sqlStmt
" . $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
\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
\n";
$debugOut .= "trCompany[$i]: " . $trCompany[$i] . "
\n";
$debugOut .= "trCompany2[$i]: " . $trCompany2[$i] . "
\n";
$debugOut .= "trAdId[$i]: " . $trAdId[$i] . "
\n";
$debugOut .= "trStreet[$i]: " . $trStreet[$i] . "
\n";
$debugOut .= "trHouseno[$i]: " . $trHouseno[$i] . "
\n";
$debugOut .= "trFloor[$i]: " . $trFloor[$i] . "
\n";
$debugOut .= "trZipcode[$i]: " . $trZipcode[$i] . "
\n";
$debugOut .= "trCity[$i]: " . $trCity[$i] . "
\n";
$debugOut .= "trSpecialRemark[$i]: " . $trSpecialRemark[$i] . "
\n";
$debugOut .= "trPerson[$i]: " . $trPerson[$i] . "
\n";
$debugOut .= "trPhone[$i]: " . $trPhone[$i] . "
\n";
$debugOut .= "trEmail[$i]: " . $trEmail[$i] . "
\n";
$debugOut .= "trAdSupplement_1[$i]: " . $trAdSupplement_1[$i] . "
\n";
$debugOut .= "trAdSupplement_2[$i]: " . $trAdSupplement_2[$i] . "
\n";
$debugOut .= "trAdSupplement_3[$i]: " . $trAdSupplement_3[$i] . "
\n";
$debugOut .= "trAdSupplement_4[$i]: " . $trAdSupplement_4[$i] . "
\n";
$debugOut .= "trAdSupplement_5[$i]: " . $trAdSupplement_5[$i] . "
\n";
$debugOut .= "
\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
\n";
$debugOut .= "trInvCompany[$i]: " . $trInvCompany[$i] . "
\n";
$debugOut .= "trInvCompany2[$i]: " . $trInvCompany2[$i] . "
\n";
$debugOut .= "trInvAdId[$i]: " . $trInvAdId[$i] . "
\n";
$debugOut .= "trInvStreet[$i]: " . $trInvStreet[$i] . "
\n";
$debugOut .= "trInvHouseno[$i]: " . $trInvHouseno[$i] . "
\n";
$debugOut .= "trInvFloor[$i]: " . $trInvFloor[$i] . "
\n";
$debugOut .= "trInvZipcode[$i]: " . $trInvZipcode[$i] . "
\n";
$debugOut .= "trInvCity[$i]: " . $trInvCity[$i] . "
\n";
$debugOut .= "trInvSpecialRemark[$i]: " . $trInvSpecialRemark[$i] . "
\n";
$debugOut .= "trInvPerson[$i]: " . $trInvPerson[$i] . "
\n";
$debugOut .= "trInvPhone[$i]: " . $trInvPhone[$i] . "
\n";
$debugOut .= "trInvEmail[$i]: " . $trInvEmail[$i] . "
\n";
$debugOut .= "trInvAdSupplement_1[$i]: " . $trInvAdSupplement_1[$i] . "
\n";
$debugOut .= "trInvAdSupplement_2[$i]: " . $trInvAdSupplement_2[$i] . "
\n";
$debugOut .= "trInvAdSupplement_3[$i]: " . $trInvAdSupplement_3[$i] . "
\n";
$debugOut .= "trInvAdSupplement_4[$i]: " . $trInvAdSupplement_4[$i] . "
\n";
$debugOut .= "trInvAdSupplement_5[$i]: " . $trInvAdSupplement_5[$i] . "
\n";
$debugOut .= "
\n";
endif;
else :
$debugOut .= "trCostcenter[$i] does exist: NO
\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:
$sqlStmt
" . $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
\n";
$debugOut .= "trCompany[$i]: " . $trCompany[$i] . "
\n";
$debugOut .= "trCompany2[$i]: " . $trCompany2[$i] . "
\n";
$debugOut .= "trAdId[$i]: " . $trAdId[$i] . "
\n";
$debugOut .= "trStreet[$i]: " . $trStreet[$i] . "
\n";
$debugOut .= "trHouseno[$i]: " . $trHouseno[$i] . "
\n";
$debugOut .= "trFloor[$i]: " . $trFloor[$i] . "
\n";
$debugOut .= "trZipcode[$i]: " . $trZipcode[$i] . "
\n";
$debugOut .= "trCity[$i]: " . $trCity[$i] . "
\n";
$debugOut .= "trSpecialRemark[$i]: " . $trSpecialRemark[$i] . "
\n";
$debugOut .= "trPerson[$i]: " . $trPerson[$i] . "
\n";
$debugOut .= "trPhone[$i]: " . $trPhone[$i] . "
\n";
$debugOut .= "trEmail[$i]: " . $trEmail[$i] . "
\n";
$debugOut .= "trAdSupplement_1[$i]: " . $trAdSupplement_1[$i] . "
\n";
$debugOut .= "trAdSupplement_2[$i]: " . $trAdSupplement_2[$i] . "
\n";
$debugOut .= "trAdSupplement_3[$i]: " . $trAdSupplement_3[$i] . "
\n";
$debugOut .= "trAdSupplement_4[$i]: " . $trAdSupplement_4[$i] . "
\n";
$debugOut .= "trAdSupplement_5[$i]: " . $trAdSupplement_5[$i] . "
\n";
$debugOut .= "
\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] .= "
" . "------------------------"; endif;
if ($trInvPaymentMethod[$i] != "") : $trSpecialRemark[$i] .= "
" . 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] .= "
" . getLngt("Spezialpreis") . ":" . $trInvPriceMode[$i]; endif;
$trInvPartialPayment[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["partial_payment"]); // Partial payment
if ($trInvPartialPayment[$i] != "") : $trSpecialRemark[$i] .= "
" . getLngt("Bereits bezahlt") . ":" . $trInvPartialPayment[$i]; endif;
$trInvVoucher[$i] = convertSpecial($orderArray["xml"]["order"]["stations"]["station"][$i]["invoice"]["voucher_no"]); // Voucher
if ($trInvVoucher[$i] != "") : $trSpecialRemark[$i] .= "
" . 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] .= "
" . "------------------------";
if ($trInvCompany[$i] != "") : $trSpecialRemark[$i] .= "
" . $trInvCompany[$i] . "
" . $trInvCompany2[$i]; endif;
$trSpecialRemark[$i] .= "
" . $trInvCompany[$i] . "
" . $trInvCompany2[$i];
$trSpecialRemark[$i] .= "
" . getLngt("Adresse") . ":" . "
" . $trInvStreet[$i] . " " . $trInvHouseno[$i] . "
" . $trInvZipcode[$i] . " " . $trInvCity[$i];
endif;
if ($trInvPerson[$i] != "") : $trSpecialRemark[$i] .= "
" . $trInvPerson[$i]; endif;
if ($trInvPhone[$i] != "") : $trSpecialRemark[$i] .= "
" . $trInvPhone[$i]; endif;
if ($trInvEmail[$i] != "") : $trSpecialRemark[$i] .= "
" . $trInvEmail[$i]; endif;
if ($trInvSpecialRemark[$i] != "") : $trSpecialRemark[$i] .= "
" . $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
\n";
$debugOut .= "trTimeslots[$i]: " . $trTimeslots[$i] . "
\n";
$debugOut .= "trTimesunits[$i]: " . $trTimesunits[$i] . "
\n";
$debugOut .= "trShipmentMode[$i]: " . $trShipmentMode[$i] . "
\n";
$debugOut .= "trOrderType[$i]: " . $trOrderType[$i] . "
\n";
$debugOut .= "trDeliveryInfo[$i]: " . $trDeliveryInfo[$i] . "
\n";
$debugOut .= "trFlagServiceDoc[$i]: " . $trFlagServiceDoc[$i] . "
\n";
$debugOut .= "trDocumentsURL[$i]: " . $trDocumentsURL[$i] . "
\n";
$debugOut .= "
\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 . "
";
echo "csEid:" . $csEid . "
";
echo "csId:" . $csId . "
";
echo "usrAccount:" . $usrAccount . "
";
echo "usrPassword:" . $usrPassword . "
";
echo "cscName:" . $cscName . "
";
echo "cscId:" . $cscId . "
";
echo "hqMnemonic:" . $hqMnemonic . "
";
echo "hqId:" . $hqId . "
";
echo "hqId_XML:" . $hqId_XML . "
";
echo "vhtId:" . $vhtId . "
";
echo "vhtType:" . $vhtType . "
";
echo "jbCrvhWeight:" . $jbCrvhWeight . "
";
echo "jbCrvhLength:" . $jbCrvhLength . "
";
echo "jbCrvhWidth:" . $jbCrvhWidth . "
";
echo "jbCrvhHeight:" . $jbCrvhHeight . "
";
echo "jbCrvhPosition:" . $jbCrvhPosition . "
";
echo "jbOrdertime:" . $jbOrdertime . "
";
echo "jbOrdertimeUTC:" . $jbOrdertimeUTC . "
";
echo "jbWarningtime:" . $jbWarningtime . "
";
echo "jbWarningtimeUTC:" . $jbWarningtimeUTC . "
";
echo "crSid:" . $crSid . "
";
echo "crIdOrder:" . $crIdOrder . "
";
echo "jbCrFilter:" . $jbCrFilter . "
";
echo "jbCrRemark:" . $jbCrRemark . "
";
echo "jbTourdata:" . $jbTourdata . "
";
echo "numOfStations:" . $numOfStations . "
";
for ($i = 0; $i < $numOfStations; $i++) :
echo "
";
echo "* STATION " . $i . " * :
";
echo "DELIVERY:" . "
";
echo $trWareFromTo[$i] . "
";
echo $trCostcenter[$i] . "
";
echo $trCscId[$i] . "
";
echo $trCompany[$i] . "
";
echo $trCompany2[$i] . "
";
echo $trAdId[$i] . "
";
echo $trStreet[$i] . "
";
echo $trHouseno[$i] . "
";
echo $trFloor[$i] . "
";
echo $trZipcode[$i] . "
";
echo $trCity[$i] . "
";
echo $trSpecialRemark[$i] . "
";
echo $trPerson[$i] . "
";
echo $trPhone[$i] . "
";
echo $trEmail[$i] . "
";
echo "INVOICE:" . "
";
echo $trInvCompany[$i] . "
";
echo $trInvCompany2[$i] . "
";
echo $trInvAdId[$i] . "
";
echo $trInvStreet[$i] . "
";
echo $trInvHouseno[$i] . "
";
echo $trInvZipcode[$i] . "
";
echo $trInvCity[$i] . "
";
echo $trInvSpecialRemark[$i]. "
";
echo $trInvPerson[$i] . "
";
echo $trInvPhone[$i] . "
";
echo $trInvEmail[$i] . "
";
print_r($trServices[$i]); echo "
";
echo "trInvVoucher:" . $trInvVoucher[$i] . "
";
echo "trInvPaymentMethod:" . $trInvPaymentMethod[$i] . "
";
echo "trArticleArray:"; print_r($trArticleArray[$i]); echo "
";
print_r($trCalcFunctionsArray[$i]); echo "
";
print_r($trCalcFunctionsResultArray[$i]); echo "
";
endfor;
echo "
ERR: "; print_r($err); echo "
";
echo "acceptOrder: " . $acceptOrder . "
";
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 > $maxNumOfOrdersPerDay)) :
$acceptOrder = false;
$err[] = array("102", getLngt("Das Limit der Aufträge pro Tag wurde überschritten. Derzeit sind dies") . " " . $maxNumOfOrdersPerDay . " " . getLngt("Aufträge"));
endif;
// Check for maximum number of running jobs
$numOfRunningOrders = getCountOfTable("job", "jb_status != '2' AND csc_id_payer IN (" . implode(",", $cscIdList) . ")");
if ($numOfRunningOrders > $maxNumOfRunningOrders) :
$acceptOrder = false;
$err[] = array("103", getLngt("Das Limit insgesamt laufender Aufträge wurde überschritten. Derzeit sind dies") . " " . $maxNumOfRunningOrders . " " . getLngt("Aufträge"));
endif;
endif;
endif;
// Check existence of at least one error
$errLen = count($err);
if ($errLen == 0 && $acceptOrder) :
// Execute operation in FDS
$fdsDoExecute = true;
// **********
// * UPDATE *
// **********
if ($operationMode == "UPD" || $operationMode == "UPDATE") :
// There are two options for updates:
// [1.] All order data will be updated => Cancellation of the existing job and insert a new one
// [2.] Partial update => All atomic tags being not be empty have to be updated
$updateMode = "1"; // Option [1.]
if ($jbIdUpdate != "" && is_numeric($jbIdUpdate) && $jbIdUpdate > "0") :
if ($updateMode == "1") :
$jbIdCancellation = $jbIdUpdate; // Important for cancellation
// Get ALL job IDs having $jbIdCancellation in "jb_parent_id"
// $jbIdWithParentOfCancellation = getFieldValueFromId("job", "jb_id_parent", $jbIdCancellation, "jb_id"); // ONE JOB ONLY
$jbIdArrayWithParentOfCancellation = getColVectorFromDB2ArrayByClause("job", "jb_id", "jb_id_parent = '" . $jbIdCancellation . "'", "", "", "");
else :
// Delta update
// ............
endif;
else :
$acceptOrder = false;
$err[] = array("105", getLngt("Es wurde keine Auftragsnummer für ein Update übergeben!"));
endif;
endif;
// **********
// * DELETE *
// **********
$opCancellationExecuted = false;
if ($operationMode == "DEL" || $operationMode == "DELETE" || $updateMode == "1") :
//$debugOut .= "\njbIdCancellation = $jbIdCancellation\n";
if ($jbIdCancellation != "" && is_numeric($jbIdCancellation) && $jbIdCancellation > "0") :
// Update job data
$doCancellation = true;
if ($executeCancellationByEvent) :
$res = updateStmt("job", "jb_id", $jbIdCancellation, array("jb_storno", "2", "jb_status", "2", "jb_finishtime", $currentTime, "cr_sid", "", "jb_autoranking", "1"), "(jb_status = '8' OR jb_status = '9' OR jb_status = '0' OR jb_status = '1' OR jb_status = '2') AND (isnull(jb_storno) OR jb_storno = '0')");
$affectedRows = $db->affected_rows;
//$debugOut .= "\n[STORNO AND FINISHED]affectedRows = $affectedRows\n";
if ($affectedRows > 0) :
// In case of REAL cancellation (jb_storno = 1|2) only the commission number will be set to empty value !!!!
updateStmt("tour", "jb_id", $jbIdCancellation, array("tr_commission_no", ""), "tr_commission_no = '" . $commissionNo . "'");
updateStmt("genericdatacontainer", "gdc_obj_id", $jbIdCancellation, array("gdc_content", "XX" . $commissionNo . "XX"), "gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'info_0' AND gdc_content = '" . $commissionNo . "'");
else :
$doCancellation = false;
endif;
else :
// Set job to state finished only (without storno)
$res = updateStmt("job", "jb_id", $jbIdCancellation, array("jb_status", "2", "jb_finishtime", $currentTime), "(jb_status = '8' OR jb_status = '9' OR jb_status = '0' OR jb_status = '1' OR jb_status = '2') AND (isnull(jb_storno) OR jb_storno = '0')");
$affectedRows = $db->affected_rows;
//$debugOut .= "\n[NO STORNO, FINISHED ONLY] affectedRows = $affectedRows\n";
if ($affectedRows == 0) :
$doCancellation = false;
endif;
endif;
//$debugOut .= "\ndoCancellation = $doCancellation\n";
// Write EVENT for the current job in every case but for "DELETE" (or "DEL") only (!!!!)
if ($operationMode == "DEL" || $operationMode == "DELETE") :
if ($jbEventArrayLen > 0 && $jbIdCurrent != "" && is_numeric($jbIdCurrent)) :
for ($e = 0; $e < $jbEventArrayLen; $e++) :
if ($parEventMappingActivated == "1") :
$tmpEventVal = $csEventsReverseArray[$jbEventArray[$e]];
if ($tmpEventVal != "") :
$tmpExistingEvents = getFieldValueFromClause("genericdatacontainer","gdc_content","gdc_obj_type = 'jb' AND gdc_obj_id = '" . $jbIdCurrent . "' AND gdc_gen_fieldname = 'jb_events'");
if ($tmpExistingEvents != "") :
$tmpExistingEvents .= "," . $tmpEventVal;
updateStmt("genericdatacontainer","gdc_obj_type","jb",array("gdc_content", $tmpExistingEvents),"gdc_obj_id = '" . $jbIdCurrent . "' AND gdc_gen_fieldname = 'jb_events'");
else :
$tmpExistingEvents = $tmpEventVal;
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdCurrent, "gdc_gen_fieldname", "jb_events", "gdc_content", $tmpExistingEvents, "gdc_context", ""));
endif;
endif;
else :
// Simply store NOT MAPPED value(s) in GDC
$tmpExistingEvents = getFieldValueFromClause("genericdatacontainer","gdc_content","gdc_obj_type = 'jb' AND gdc_obj_id = '" . $jbIdCurrent . "' AND gdc_gen_fieldname = 'jb_events'");
if ($tmpExistingEvents != "") :
$tmpExistingEvents .= "," . $jbEventArray[$e];
updateStmt("genericdatacontainer","gdc_obj_type","jb",array("gdc_content", $tmpExistingEvents),"gdc_obj_id = '" . $jbIdCurrent . "' AND gdc_gen_fieldname = 'jb_events'");
else :
$tmpExistingEvents = $jbEventArray[$e];
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdCurrent, "gdc_gen_fieldname", "jb_events", "gdc_content", $tmpExistingEvents, "gdc_context", ""));
endif;
endif;
endfor;
endif;
endif;
if ($doCancellation) :
// Remove existing commission number not to be found again in the future
/*
if ($parNoCancellation == "1") :
// Remove related order number from GDC (field "info_0")
updateStmt("genericdatacontainer", "gdc_obj_id", $jbIdCancellation, array("gdc_content", "XX" . $commissionNo . "XX"), "gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'info_0' AND gdc_content = '" . $commissionNo . "'");
elseif ($parNoCancellation == "2") :
// Do nothing because $jbIdCancellation =!= $commissionNo;
else :
// DEFAULT: Remote order number equals commission number
updateStmt("tour", "jb_id", $jbIdCancellation, array("tr_commission_no", ""), "tr_commission_no = '" . $commissionNo . "'");
endif;
*/
/*
// Had been moved regarding event handling
updateStmt("tour", "jb_id", $jbIdCancellation, array("tr_commission_no", ""), "tr_commission_no = '" . $commissionNo . "'");
updateStmt("genericdatacontainer", "gdc_obj_id", $jbIdCancellation, array("gdc_content", "XX" . $commissionNo . "XX"), "gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'info_0' AND gdc_content = '" . $commissionNo . "'");
*/
$opCancellationExecuted = true;
// Remove job from FDS
// In case of DELETE by requested UPDATE the ordertimes have to be checked. If they are equal the FDS entry has NOT to be removed but updated
if ($updateMode == "1") :
$jbOrdertimeCancellation = getFieldValueFromId("job","jb_id",$jbIdCancellation,"jb_ordertime");
if ($jbOrdertimeCancellation != "" && $jbOrdertime != "" && $jbOrdertimeCancellation == $jbOrdertime) :
$fdsDoExecute = false;
endif;
endif;
if ($fdsDoExecute || !$executeCancellationByEvent) :
removeAssocCrvhJb($jbIdCancellation, $csId);
endif;
else :
if (!$errHandlerDisabled) :
$acceptOrder = false;
$err[] = array("107", getLngt("Der Stornovorgang konnte nicht abgeschlossen werden, weil entweder der Auftrag schon storniert wurde oder sich in der Ausführung befindet!"));
endif;
endif;
else :
/*
if ($updateMode != "1") :
$acceptOrder = false;
$err[] = array("106", getLngt("Es wurde keine Auftragsnummer für ein Storno übergeben oder der Auftrag wurde nicht gefunden!"));
endif;
*/
endif;
endif;
// **********
// * INSERT *
// **********
if ($operationMode == "" || $operationMode == "INS" || $operationMode == "INSERT" || ($updateMode == "1" && $opCancellationExecuted)) :
TA("B");
if ($globalParUseRelatedCustomer == "1") :
// **** INSERT CUSTOMER DATA ****
$tmpStation = "1"; // End customer data in second station by delivery and installation
$orderIsRetour = false;
$orderIsExchange = false;
// Check for "Retoure" <=> customer data in the first station
if (((int)$trShipmentMode[0] & 128) == 128 || ((int)$trShipmentMode[1] & 128) == 128) :
$orderIsRetour = true;
$tmpStation = "0";
endif;
// Check for "Exchange" <=> Normal order with added station with retour state
if (((int)$trShipmentMode[0] & 256) == 256 || ((int)$trShipmentMode[1] & 256) == 256) :
$orderIsExchange = true;
endif;
// SPECIAL WRAPPER TO CHANGE PLACES OF FIRST STATION AND SECOND STATION BECAUSE OF CURRENT APP
// WRAPPER START
if (true && $orderIsRetour) :
$tmpStation = "1"; // End customer data in second station by delivery and installation IN EVERY CASE !!!!
$tmpVal = $trCscId[1]; $trCscId[1] = $trCscId[0]; $trCscId[0] = $tmpVal;
$tmpVal = $trWareFromTo[1]; $trWareFromTo[1] = $trWareFromTo[0]; $trWareFromTo[0] = $tmpVal;
$tmpVal = $trCommissionNo[1]; $trCommissionNo[1] = $trCommissionNo[0]; $trCommissionNo[0] = $tmpVal;
$tmpVal = $trCostcenter[1]; $trCostcenter[1] = $trCostcenter[0]; $trCostcenter[0] = $tmpVal;
$tmpVal = $trCompany[1]; $trCompany[1] = $trCompany[0]; $trCompany[0] = $tmpVal;
$tmpVal = $trCompany2[1]; $trCompany2[1] = $trCompany2[0]; $trCompany2[0] = $tmpVal;
$tmpVal = $trScanCodeMandatory[1]; $trScanCodeMandatory[1] = $trScanCodeMandatory[0]; $trScanCodeMandatory[0] = $tmpVal;
$tmpVal = $trDeliveryOutcomeMode[1]; $trDeliveryOutcomeMode[1] = $trDeliveryOutcomeMode[0]; $trDeliveryOutcomeMode[0] = $tmpVal;
$tmpVal = $trDeliveryOutcomeStates[1]; $trDeliveryOutcomeStates[1] = $trDeliveryOutcomeStates[0]; $trDeliveryOutcomeStates[0] = $tmpVal;
$tmpVal = $trStreet[1]; $trStreet[1] = $trStreet[0]; $trStreet[0] = $tmpVal;
$tmpVal = $trHouseno[1]; $trHouseno[1] = $trHouseno[0]; $trHouseno[0] = $tmpVal;
$tmpVal = $trFloor[1]; $trFloor[1] = $trFloor[0]; $trFloor[0] = $tmpVal;
$tmpVal = $trZipcode[1]; $trZipcode[1] = $trZipcode[0]; $trZipcode[0] = $tmpVal;
$tmpVal = $trCity[1]; $trCity[1] = $trCity[0]; $trCity[0] = $tmpVal;
$tmpVal = $trAdId[1]; $trAdId[1] = $trAdId[0]; $trAdId[0] = $tmpVal;
$tmpVal = $trSpecialRemark[1]; $trSpecialRemark[1] = $trSpecialRemark[0]; $trSpecialRemark[0] = $tmpVal;
$tmpVal = $trPerson[1]; $trPerson[1] = $trPerson[0]; $trPerson[0] = $tmpVal;
$tmpVal = $trPhone[1]; $trPhone[1] = $trPhone[0]; $trPhone[0] = $tmpVal;
$tmpVal = $trEmail[1]; $trEmail[1] = $trEmail[0]; $trEmail[0] = $tmpVal;
$tmpVal = $trAdSupplement_1[1]; $trAdSupplement_1[1] = $trAdSupplement_1[0]; $trAdSupplement_1[0] = $tmpVal;
$tmpVal = $trAdSupplement_2[1]; $trAdSupplement_2[1] = $trAdSupplement_2[0]; $trAdSupplement_2[0] = $tmpVal;
$tmpVal = $trAdSupplement_3[1]; $trAdSupplement_3[1] = $trAdSupplement_3[0]; $trAdSupplement_3[0] = $tmpVal;
$tmpVal = $trAdSupplement_4[1]; $trAdSupplement_4[1] = $trAdSupplement_4[0]; $trAdSupplement_4[0] = $tmpVal;
$tmpVal = $trAdSupplement_5[1]; $trAdSupplement_5[1] = $trAdSupplement_5[0]; $trAdSupplement_5[0] = $tmpVal;
$tmpVal = $trInvCompany[1]; $trInvCompany[1] = $trInvCompany[0]; $trInvCompany[0] = $tmpVal;
$tmpVal = $trInvCompany2[1]; $trInvCompany2[1] = $trInvCompany2[0]; $trInvCompany2[0] = $tmpVal;
$tmpVal = $trInvStreet[1]; $trInvStreet[1] = $trInvStreet[0]; $trInvStreet[0] = $tmpVal;
$tmpVal = $trInvHouseno[1]; $trInvHouseno[1] = $trInvHouseno[0]; $trInvHouseno[0] = $tmpVal;
$tmpVal = $trInvFloor[1]; $trInvFloor[1] = $trInvFloor[0]; $trInvFloor[0] = $tmpVal;
$tmpVal = $trInvZipcode[1]; $trInvZipcode[1] = $trInvZipcode[0]; $trInvZipcode[0] = $tmpVal;
$tmpVal = $trInvCity[1]; $trInvCity[1] = $trInvCity[0]; $trInvCity[0] = $tmpVal;
$tmpVal = $trInvAdId[1]; $trInvAdId[1] = $trInvAdId[0]; $trInvAdId[0] = $tmpVal;
$tmpVal = $trInvSpecialRemark[1]; $trInvSpecialRemark[1] = $trInvSpecialRemark[0]; $trInvSpecialRemark[0] = $tmpVal;
$tmpVal = $trInvPerson[1]; $trInvPerson[1] = $trInvPerson[0]; $trInvPerson[0] = $tmpVal;
$tmpVal = $trInvPhone[1]; $trInvPhone[1] = $trInvPhone[0]; $trInvPhone[0] = $tmpVal;
$tmpVal = $trInvEmail[1]; $trInvEmail[1] = $trInvEmail[0]; $trInvEmail[0] = $tmpVal;
$tmpVal = $trInvAdSupplement_1[1]; $trInvAdSupplement_1[1] = $trInvAdSupplement_1[0]; $trInvAdSupplement_1[0] = $tmpVal;
$tmpVal = $trInvAdSupplement_2[1]; $trInvAdSupplement_2[1] = $trInvAdSupplement_2[0]; $trInvAdSupplement_2[0] = $tmpVal;
$tmpVal = $trInvAdSupplement_3[1]; $trInvAdSupplement_3[1] = $trInvAdSupplement_3[0]; $trInvAdSupplement_3[0] = $tmpVal;
$tmpVal = $trInvAdSupplement_4[1]; $trInvAdSupplement_4[1] = $trInvAdSupplement_4[0]; $trInvAdSupplement_4[0] = $tmpVal;
$tmpVal = $trInvAdSupplement_5[1]; $trInvAdSupplement_5[1] = $trInvAdSupplement_5[0]; $trInvAdSupplement_5[0] = $tmpVal;
$tmpVal = $trInvPaymentMethod[1]; $trInvPaymentMethod[1] = $trInvPaymentMethod[0]; $trInvPaymentMethod[0] = $tmpVal;
$tmpVal = $trInvVoucher[1]; $trInvVoucher[1] = $trInvVoucher[0]; $trInvVoucher[0] = $tmpVal;
$tmpVal = $trInvpartialPayment[1]; $trInvpartialPayment[1] = $trInvpartialPayment[0]; $trInvpartialPayment[0] = $tmpVal;
$tmpVal = $trInvPriceMode[1]; $trInvPriceMode[1] = $trInvPriceMode[0]; $trInvPriceMode[0] = $tmpVal;
$tmpVal = $trGdcArray[1]; $trGdcArray[1] = $trGdcArray[0]; $trGdcArray[0] = $tmpVal;
// Station services
$tmpVal = $trServices[1]; $trServices[1] = $trServices[0]; $trServices[0] = $tmpVal;
$tmpVal = $trTimeslots[1]; $trTimeslots[1] = $trTimeslots[0]; $trTimeslots[0] = $tmpVal;
$tmpVal = $trTimesunits[1]; $trTimesunits[1] = $trTimesunits[0]; $trTimesunits[0] = $tmpVal;
$tmpVal = $trShipmentMode[1]; $trShipmentMode[1] = $trShipmentMode[0]; $trShipmentMode[0] = $tmpVal;
$tmpVal = $trOrderType[1]; $trOrderType[1] = $trOrderType[0]; $trOrderType[0] = $tmpVal;
$tmpVal = $trDeliveryInfo[1]; $trDeliveryInfo[1] = $trDeliveryInfo[0]; $trDeliveryInfo[0] = $tmpVal;
$tmpVal = $trFlagServiceDoc[1]; $trFlagServiceDoc[1] = $trFlagServiceDoc[0]; $trFlagServiceDoc[0] = $tmpVal;
$tmpVal = $trDocumentsURL[1]; $trDocumentsURL[1] = $trDocumentsURL[0]; $trDocumentsURL[0] = $tmpVal;
// Arrays for summarized article fields OR maximum values
$tmpVal = $trSumWeight[1]; $trSumWeight[1] = $trSumWeight[0]; $trSumWeight[0] = $tmpVal;
$tmpVal = $trSumPositions[1]; $trSumPositions[1] = $trSumPositions[0]; $trSumPositions[0] = $tmpVal;
$tmpVal = $trSumPieces[1]; $trSumPieces[1] = $trSumPieces[0]; $trSumPieces[0] = $tmpVal;
$tmpVal = $trSumVolume[1]; $trSumVolume[1] = $trSumVolume[0]; $trSumVolume[0] = $tmpVal;
$tmpVal = $trSumPrices[1]; $trSumPrices[1] = $trSumPrices[0]; $trSumPrices[0] = $tmpVal;
$tmpVal = $trMaxHeight[1]; $trMaxHeight[1] = $trMaxHeight[0]; $trMaxHeight[0] = $tmpVal;
$tmpVal = $trMaxLength[1]; $trMaxLength[1] = $trMaxLength[0]; $trMaxLength[0] = $tmpVal;
$tmpVal = $trMaxWidth[1]; $trMaxWidth[1] = $trMaxWidth[0]; $trMaxWidth[0] = $tmpVal;
$tmpVal = $trMaxDimension[1]; $trMaxDimension[1] = $trMaxDimension[0]; $trMaxDimension[0] = $tmpVal;
$tmpVal = $trSumHoursEstimated[1]; $trSumHoursEstimated[1] = $trSumHoursEstimated[0]; $trSumHoursEstimated[0] = $tmpVal;
$tmpVal = $trArticleArray[1]; $trArticleArray[1] = $trArticleArray[0]; $trArticleArray[0] = $tmpVal;
endif;
// WRAPPER END
// Set service state for the job
$jbService = $trShipmentMode[$tmpStation];
if ($jbService == "" || !is_numeric($jbService) || $jbService == 0) : $jbService = 1; endif;
// if (((int)$jbService & 128) == 128 && ((int)$jbService & 1) == 0 && ((int)$jbService & 2) == 0) : $jbService = ($jbService | 1); endif; // Add delivery to retour if neither delivery nor installation
if ($jbService == 129) : $jbService = 128; endif;
if ($jbService == 256) : $jbService = 257; endif;
if (((int)$jbService & 4) == 4 && ((int)$jbService & 2) == 0) : $jbService = ($jbService | 2); endif; // Add "standard installation bit" to special installation
if (((int)$jbService & 16) == 16 && ((int)$jbService & 2) == 0) : $jbService = ($jbService | 2); endif; // Add "standard installation bit" to special installation
if ($orderIsExchange) :
// Fallback for exchange
if ($jbService == 385) : $jbService = 384; endif;
endif;
// Set time units for the job
$jbTimeUnits = $trTimesunits[$tmpStation];
if ($jbTimeUnits == "" || !is_numeric($jbTimeUnits) || $jbTimeUnits < "2") :
$jbTimeUnits = "2";
endif;
$debugOut .= "trShipmentMode[0]: " . $trShipmentMode[0] . " (1 = Delivery, 0 = Retoure)
\n";
$debugOut .= "trShipmentMode[1]: " . $trShipmentMode[1] . " (1 = Delivery, 0 = Retoure)
\n";
$debugOut .= "(trShipmentMode[0] & 128): " . ((int)$trShipmentMode[0] & 128) . "
\n";
$debugOut .= "(trShipmentMode[1] & 128): " . ((int)$trShipmentMode[1] & 128) . "
\n";
$debugOut .= "tmpStation: " . $tmpStation . " (1 = Delivery, 0 = Retoure)
\n";
$debugOut .= "orderIsExchange: " . ($orderIsExchange ? "YES" : "NO") . "
\n";
$debugOut .= "jbService: " . $jbService . "
\n";
// The authenticated customer will be the related customer and the end customer will be the payer (look below) !!!!
$cscNameNew = $trCompany[$tmpStation];
$cscInvNameNew = $trInvCompany[$tmpStation];
if ($cscInvNameNew == "") : $cscInvNameNew = $cscNameNew; endif;
$cscadHsnoNew = $trHouseno[$tmpStation];
$cscadInvHsnoNew = $trInvHouseno[$tmpStation];
if ($cscadInvHsnoNew == "") : $cscadInvHsnoNew = $cscadHsnoNew; endif;
$adIdNew = $trAdId[$tmpStation];
$adIdInvNew = $trInvAdId[$tmpStation];
if ($adIdInvNew == "") : $adIdInvNew = $adIdNew; endif;
$cscadRemark = ""; // $trSpecialRemark[$tmpStation];
$cscadInvRemark = ""; // $trInvSpecialRemark[$tmpStation];
// if ($cscadInvRemark == "") : $cscadInvRemark = $cscadRemark; endif;
$cscadPerson = $trPerson[$tmpStation];
$cscadInvPerson = $trInvPerson[$tmpStation];
// if ($cscadInvPerson == "") : $cscadInvPerson = $cscadPerson; endif;
$cscadPhone = $trPhone[$tmpStation];
$cscadInvPhone = $trInvPhone[$tmpStation];
// if ($cscadInvPhone == "") : $cscadInvPhone = $cscadPhone; endif;
$cscadEmail = $trEmail[$tmpStation];
$cscadInvEmail = $trInvEmail[$tmpStation];
// if ($cscadInvEmail == "") : $cscadInvEmail = $cscadEmail; endif;
$cscadFloor = $trFloor[$tmpStation];
$cscadInvFloor = $trInvFloor[$tmpStation];
// if ($cscadInvFloor == "") : $cscadInvFloor = $cscadFloor; endif;
$cscadZipcode = $trZipcode[$tmpStation];
// Handling of commission number(s)
if ($commissionNo != "") :
$trCommissionNo[$tmpStation] = $commissionNo; // Overwrite if exist
endif;
$debugOut .= "cscNameNew: " . $cscNameNew . "
\n";
$debugOut .= "cscadHsnoNew: " . $cscadHsnoNew . "
\n";
$debugOut .= "adIdNew: " . $adIdNew . "
\n";
$debugOut .= "adIdInvNew: " . $adIdInvNew . "
\n";
$debugOut .= "cscadRemark: " . $cscadRemark . "
\n";
$debugOut .= "cscadInvRemark: " . $cscadInvRemark . "
\n";
$debugOut .= "cscadPerson: " . $cscadPerson . "
\n";
$debugOut .= "cscadInvPerson: " . $cscadInvPerson . "
\n";
$debugOut .= "cscadPhone: " . $cscadPhone . "
\n";
$debugOut .= "cscadInvPhone: " . $cscadInvPhone . "
\n";
$debugOut .= "cscadEmail: " . $cscadEmail . "
\n";
$debugOut .= "cscadInvEmail: " . $cscadInvEmail . "
\n";
$debugOut .= "cscadFloor: " . $cscadFloor . "
\n";
$debugOut .= "cscadInvFloor: " . $cscadInvFloor . "
\n";
$debugOut .= "cscadZipcode: " . $cscadZipcode . "
\n";
$debugOut .= "
\n";
if ($cscNameNew != "") :
// Insert costcenter
insertStmt("costcenter", array("csc_name", $cscNameNew, "csc_is_extern", 1, "csc_visible", 1));
$cscIdNew = getLastInsertId();
// Get tour.csc_id for the NEW end customer in csc.csc_id
if ($trCscId[$tmpStation] == "") :
$trCscId[$tmpStation] = $cscIdNew;
$cscIdPayer = $cscIdNew;
endif;
$debugOut .= "trCscId[$tmpStation]: " . $trCscId[$tmpStation] . "
\n";
$debugOut .= "cscIdPayer: " . $cscIdPayer . "
\n";
$debugOut .= "cscIdRelated: " . $cscIdRelated . "
\n";
$debugOut .= "
\n";
// Insert company
insertStmt("company", array("cmp_comp", $cscInvNameNew, "ad_id", $adIdInvNew,"cmp_hsno", $cscadInvHsnoNew, "cmp_authenticated", "1", "cmp_visible", "1", "cmp_modify_status", "0"));
$cmpIdNew = getLastInsertId();
$csEidNew = $parHqInstance . ($db->getOne("SELECT RIGHT(MAX(cs_eid),5) FROM customer WHERE LEFT(cs_eid, " . strlen($parHqInstance) . ") = '" . $parHqInstance . "'") + 1);
// Insert customer
insertStmt("customer", array("cmp_id", $cmpIdNew, "hq_id", $hqId, "csc_id", $cscIdNew, "cs_eid", $csEidNew, "cs_invmode", 2, "cs_id_related", $csIdRelated));
$csIdNew = getLastInsertId();
// Update new costcenter with new customer
updateStmt("costcenter", "csc_id", $cscIdNew, array("cs_id", $csIdNew));
// Update the costcenteraddresses
insertStmt("costcenteraddress", array("csc_id", $cscIdNew, "cscad_comp", $cscNameNew, "ad_id", $adIdNew, "adt_id", 1, "cscad_hsno", $cscadHsnoNew, "cscad_remark", $cscadRemark, "cscad_person", $cscadPerson, "cscad_phone", $cscadPhone, "cscad_email", $cscadEmail, "cscad_floor", $cscadFloor));
insertStmt("costcenteraddress", array("csc_id", $cscIdNew, "cscad_comp", $cscNameNew, "ad_id", $adIdInvNew, "adt_id", 2, "cscad_hsno", $cscadHsnoNew, "cscad_remark", $cscadInvRemark, "cscad_person", $cscadInvPerson, "cscad_phone", $cscadInvPhone, "cscad_email", $cscadInvEmail, "cscad_floor", $cscadInvFloor));
insertStmt("costcenteraddress", array("csc_id", $cscIdNew, "cscad_comp", $cscNameNew, "ad_id", $adIdInvNew, "adt_id", 3, "cscad_hsno", $cscadHsnoNew, "cscad_remark", $cscadInvRemark, "cscad_person", $cscadInvPerson, "cscad_phone", $cscadInvPhone, "cscad_email", $cscadInvEmail, "cscad_floor", $cscadInvFloor));
insertStmt("costcenteraddress", array("csc_id", $cscIdNew, "cscad_comp", $cscNameNew, "ad_id", $adIdNew, "adt_id", 4, "cscad_hsno", $cscadHsnoNew, "cscad_remark", $cscadRemark, "cscad_person", $cscadPerson, "cscad_phone", $cscadPhone, "cscad_email", $cscadEmail, "cscad_floor", $cscadFloor));
else :
$acceptOrder = false;
$err[] = array("104", getLngt("Der Endkundendatensatz konnte nicht angelegt werden."));
endif;
endif;
// Order
if ($acceptOrder) :
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_timeunits", $jbTimeUnits, "jb_service", $jbService, "jb_booktime", ""));
$jbIdNew = getLastInsertId();
// Change existing "jb_id_parent" of ALL jobs refering the deleted reference to the new one
if (count($jbIdArrayWithParentOfCancellation) > 0 && ($updateMode == "1" && $opCancellationExecuted)) :
updateStmt("job","","",array("jb_id_parent", $jbIdNew),"jb_id IN (" . implode(",",$jbIdArrayWithParentOfCancellation) . ")");
endif;
// 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_' to station remark
if ($globalParUseRelatedCustomer == 1) :
if ($trSpecialRemark[$tmpStation] != "") : $trSpecialRemark[$tmpStation] .= "\n" . "------------------------"; endif;
$trSpecialRemark[$tmpStation] .= "\n" . $jbGdcArray[$k];
endif;
endif;
endfor;
endif;
// Insert merged job in GDC
if ($commNoMerged != "") :
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "no_merged", "gdc_content", $commNoMerged, "gdc_context", ""));
endif;
if ($jbIdMerged != "") :
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "jb_merged", "gdc_content", $jbIdMerged, "gdc_context", ""));
endif;
// Acquisition time, e.g. departure date from compound shipment. (It is NOT the create time of the job)
if ($jbAcquisitiontime != "") :
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "acquisitiontime", "gdc_content", $jbAcquisitiontime, "gdc_context", ""));
endif;
// Insert special service number of the job in GDC
if ($commNoService != "") :
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdNew, "gdc_gen_fieldname", "jb_service_job", "gdc_content", "1", "gdc_context", $commNoService));
endif;
// Write EVENTS for the job
if ($jbEventArrayLen > 0 && $jbIdCurrent != "" && is_numeric($jbIdCurrent)) :
for ($e = 0; $e < $jbEventArrayLen; $e++) :
if ($parEventMappingActivated == "1") :
$tmpEventVal = $csEventsReverseArray[$jbEventArray[$e]];
if ($tmpEventVal != "") :
$tmpExistingEvents = getFieldValueFromClause("genericdatacontainer","gdc_content","gdc_obj_type = 'jb' AND gdc_obj_id = '" . $jbIdCurrent . "' AND gdc_gen_fieldname = 'jb_events'");
if ($tmpExistingEvents != "") :
$tmpExistingEvents .= "," . $tmpEventVal;
updateStmt("genericdatacontainer","gdc_obj_type","jb",array("gdc_content", $tmpExistingEvents),"gdc_obj_id = '" . $jbIdCurrent . "' AND gdc_gen_fieldname = 'jb_events'");
else :
$tmpExistingEvents = $tmpEventVal;
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdCurrent, "gdc_gen_fieldname", "jb_events", "gdc_content", $tmpExistingEvents, "gdc_context", ""));
endif;
endif;
else :
// Simply store NOT MAPPED value(s) in GDC
$tmpExistingEvents = getFieldValueFromClause("genericdatacontainer","gdc_content","gdc_obj_type = 'jb' AND gdc_obj_id = '" . $jbIdCurrent . "' AND gdc_gen_fieldname = 'jb_events'");
if ($tmpExistingEvents != "") :
$tmpExistingEvents .= "," . $jbEventArray[$e];
updateStmt("genericdatacontainer","gdc_obj_type","jb",array("gdc_content", $tmpExistingEvents),"gdc_obj_id = '" . $jbIdCurrent . "' AND gdc_gen_fieldname = 'jb_events'");
else :
$tmpExistingEvents = $jbEventArray[$e];
insertStmt("genericdatacontainer", array("gdc_obj_type", "jb", "gdc_obj_id", $jbIdCurrent, "gdc_gen_fieldname", "jb_events", "gdc_content", $tmpExistingEvents, "gdc_context", ""));
endif;
endif;
endfor;
endif;
// Stations
$trIdPickup = 0; // Init for writing EVENT "PLANNED"
$jbTotalHoursEstimated = 0; // Init estimated hours added for the whole job
for ($i = 0; $i < $numOfStations; $i++) :
$trServicesArray[] = $trServices[$i]; // Services and prices for calling price function
$trSort = $i + 1;
$trCommissionNoNew = "";
if ($globalParUseRelatedCustomer == 1) :
if ($i == $tmpStation) :
$trCommissionNoNew = $trCommissionNo[$i];
endif;
else :
$trCommissionNoNew = $commissionNo;
endif;
// 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", $trCommissionNoNew, "tr_ware_from_to", $trWareFromTo[$i],
"tr_person", $trPerson[$i], "tr_phone", $trPhone[$i], "tr_remark", $trSpecialRemark[$i]));
$trIdNew = getLastInsertId();
// Remember unique tr_id of pick-up station for EVENT "PLANNED"
if ($i == 0) :
$trIdPickup = $trIdNew;
endif;
// 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;
// CHECK AND SET PARENT_ID after commission no etc. are written into the database for the NEW job (!!!!)
// Look for SERVICE MODE of the job to decide "normal" or "reverse" PARENT ID
$parNoRelatedReverse = ""; // Init
if ($commNoRelated != "") :
// $parNoRelatedByService = getObjectBasedParameterValue("ORDER_REQUEST_NO_RELATED_BY_SERVICE", $csId, $hqId);
$debugOut .= "parNoRelatedByService: " . $parNoRelatedByService . "
\n";
if ($parNoRelatedByService == "1") :
if ($commissionNo == $commNoRelated) :
$jbIdParent = getOneStmt("SELECT jb.jb_id AS jb_id FROM genericdatacontainer AS gdc, job AS jb, costcenter AS csc WHERE gdc.gdc_obj_type = 'jb' AND gdc.gdc_gen_fieldname = 'info_0' AND gdc.gdc_content = '" . $commNoRelated . "' AND gdc.gdc_obj_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
else :
$jbIdParent = getOneStmt("SELECT jb.jb_id AS jb_id FROM tour AS tr, job AS jb, costcenter AS csc WHERE tr.tr_commission_no = '" . $commNoRelated . "' AND tr.jb_id = jb.jb_id AND jb." . $jbRelevantCostcenterField . " = csc.csc_id AND csc.cs_id = '" . $csId . "' ORDER BY jb.jb_id DESC", "jb_id");
endif;
if ($jbIdParent != "") :
// Service of current job
$debugOut .= "currentJob.jbService: " . $jbService . "
\n";
$currentJobIsInstallation = false;
if (((int)$jbService & 2) == 2) : $currentJobIsInstallation = true; endif;
$debugOut .= "currentJobIsInstallation: " . $currentJobIsInstallation . "
\n";
// Service of parent job.
$jbServiceOfParent = getFieldValueFromId("job","jb_id",$jbIdParent,"jb_service");
$debugOut .= "jbServiceOfParent: " . $jbServiceOfParent . "
\n";
$parentJobIsInstallation = false;
if (((int)$jbServiceOfParent & 2) == 2) : $parentJobIsInstallation = true; endif;
$debugOut .= "parentJobIsInstallation: " . $parentJobIsInstallation . "
\n";
// Both should not have the same basic service mode (both delivery or both installation) !!!!
if (($currentJobIsInstallation && $parentJobIsInstallation) || (!$currentJobIsInstallation && !$parentJobIsInstallation)) :
// Remove inserted standard relation
$jbIdParent = "";
updateStmt("job","jb_id",$jbIdNew,array("jb_id_parent", ""));
$debugOut .= "BOTH HAVE SAME SERVICE! REMOVE PARENT!
\n";
else :
if (!$currentJobIsInstallation) :
$parNoRelatedReverse = "1"; // Current job is "delivery". The older "installation" job does still exist in system
updateStmt("job","jb_id",$jbIdParent,array("jb_id_parent", $jbIdNew));
$debugOut .= "CURRENT JOB IS DELIVERY!
\n";
else :
updateStmt("job","jb_id",$jbIdNew,array("jb_id_parent", $jbIdParent));
endif;
endif;
endif;
else :
// Look for REVERSE mode of parent relation BY (STATIC) PARAMETER
// Standard mode: "jb_id_parent" of the current job will be set with value of identified ID in $jbIdParent
// Reverse mode : "jb_id_parent" of the identified job in $jbIdParent will have the value $jbIdNew
// (E.g. the installation job is older than the delivery job, but "jb_id_parent" of installation job has to be filled with the reference to the delivery job)
if ($jbIdParent != "") :
$parNoRelatedReverse = getObjectBasedParameterValue("ORDER_REQUEST_NO_RELATED_REVERSE_MODE", $csId, $hqId);
$debugOut .= "PARAMETER ORDER_REQUEST_NO_RELATED_REVERSE_MODE requested! BAD for service mode!
\n";
endif;
endif;
$debugOut .= "parNoRelatedReverse: " . $parNoRelatedReverse . "
\n";
$debugOut .= "jbIdParent: " . $jbIdParent . "
\n";
if ($jbIdParent != "" && $parNoRelatedReverse == "1") :
// Reverse mode activated
// [1.] Remove inserted standard relation
updateStmt("job","jb_id",$jbIdNew,array("jb_id_parent", ""));
// [2.] Update "jb_id_parent" of existing older job with current job in $jbIdNew
updateStmt("job","jb_id",$jbIdParent,array("jb_id_parent", $jbIdNew));
$debugOut .= "UPDATED current job and parent job!
\n";
endif;
endif;
// 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", "ORDER_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;
// ****
// Call price function
// mk_jb_tourprices($jbIdNew, $trServicesArray);
// print_r($trServicesArray); echo "
";
writeToLogDB("102",$hq_id,$jbIdNew,$usr_id,"","",$csId,"B2B_IMPORT=1"); // Success!
// --------------------------------------------------------
$debugOut .= "START DISPOSITION
\n";
if ($globalParUseRelatedCustomer == "1") :
if ($fdsDoExecute == false) :
// In case of successful DELETE by requested UPDATE (!) the job IDs has to be changed only if the order times of the jobs are equal
if ($updateMode == "1" && $opCancellationExecuted && $jbIdCancellation != "" && $jbIdNew != "" && is_numeric($jbIdCancellation) && is_numeric($jbIdNew) && $jbIdCancellation > 0 && $jbIdNew > 0) :
updateStmt("vehicledisposition", "jb_id", $jbIdCancellation, array("jb_id", $jbIdNew), "jb_id = '" . $jbIdCancellation . "'");
endif;
else :
// **** Get available vehicle data ****
// Get time units for the current job if changed by called job functions
$jbTimeUnits = getFieldValueFromId("job","jb_id",$jbIdNew,"jb_timeunits");
// Filter
$jbTimedFilter = "";
if (substr($jbOrdertime,0,10) == $currentDate) :
$jbTimedFilter = getDateTime("1") . "=TG";
endif;
if (!isset($hourTimeUnits) || $hourTimeUnits == "") : $hourTimeUnits = 6; endif;
$ecoDayTimeArray = array(); // Init for whole day
$ecoWeekdayArray = array(); // Wochentage irrelevant !!!!!!!!!!!!!!!!!!!!!!!!!!
// Check day time of the order regarding the day times of the (related) customer
if ($csId != "") :
$hourStart = substr($jbOrdertime,11); // E.g. 07:00:00
$hourEnd = substr($jbWarningtime,11); // E.g. 21:00:00
$clockTimeArray = metatypeGetMappedValues("day_time", "", $csId, "cs", "1");
$clockTimeArrayLen = count($clockTimeArray);
if ($clockTimeArrayLen > 0) :
for ($d = 0; $d < $clockTimeArrayLen; $d++) :
if ($clockTimeArray[$d][0] == $hourStart || $clockTimeArray[$d][1] == $hourEnd) :
array_push($ecoDayTimeArray, $d);
endif;
endfor;
endif;
// Reset to whole day if count("day_times_of_the_customer") == count($ecoDayTimeArray)
if (count($clockTimeArray) == count($ecoDayTimeArray)) :
$ecoDayTimeArray = array();
endif;
endif;
$dayTimesLen = count($dayTimes);
if ($debug) :
echo "---- TAGESZEITBESCHRÄNKUNG -------------------------------------------------------------
";
echo "ecoDayTimeArray:
";
print_r($ecoDayTimeArray);
echo "----------------------------------------------------------------------------------------
";
endif;
$iterWhile = true;
$iterCount = 0;
while ($iterWhile) :
$sortSequence = "";
$ecoWeight = "";
$ecoPositions = "";
$maxLimitOfRows = ""; // Vielleicht begrenzen ????? !!!!!!!!!!!!!!!!!!!!!
$deliveryTimeValue = "";
$dateSelectionByCalendar = ""; // LEER!
$deactivateMenu = "1"; // MUSS gesetzt sein
$hq_id = $hqId; // "$hq_id" needed in "in_disposition.inc.php"
$globalArrayIsDefined = false; // In case of merged or related jobs the global array to get appointments has to set another way
$specialCrvhId = ""; // In case of merged or related jobs the CURRENT job has to bet set on the same vehicle like the MERGED/RELATED job
// Try to find an appointment for the current job in FDS near by the existing merged job
if ($jbIdParent != "") :
// [1.] Get day of the parent job
$sqlStmt = getStmtVehicledispositionData($jbIdParent,"","","vhd.vhd_timeslot LIMIT 0,1");
$vhdTimeslot = getOneStmt($sqlStmt, "vhd_timeslot");
$specialCrvhId = getOneStmt($sqlStmt, "crvh_id");
$jbIdParentOrdertime = getFieldValueFromId("job","jb_id",$jbIdParent,"jb_ordertime"); // LEFT($jbIdMergedOrdertime,10) =!= LEFT($vhdTimeslot,10)
$jbIdParentTimeunits = getFieldValueFromId("job","jb_id",$jbIdParent,"jb_timeunits");
// Remove existing job (ID in $jbIdParent) from FDS to make a combined reservation with the new job.
// Check for same day to make a combined job (!!!!)
$totalTimeUnitsNeeded = $jbTimeUnits;
if ($jbIdParentOrdertime != "" && substr($jbIdParentOrdertime,0,10) == substr($jbOrdertime,0,10)) :
removeAssocCrvhJb($jbIdParent, $csId);
$totalTimeUnitsNeeded += $jbIdParentTimeunits;
if (substr($jbIdParentOrdertime,0,10) == substr($vhdTimeslot,0,10)) :
// The (merged) PARENT job is currently associated to a special vehicle on the present day. Try to associate the CURRENT job to this parent job
$globalParArray = array($jbIdNew, $csId, $ecoDayTimeArray, $ecoWeekdayArray, $cscadZipcode, $totalTimeUnitsNeeded, $sortSequence, $jbService, $ecoWeight, $ecoPositions,
$maxLimitOfRows, $deliveryTimeValue, $deactivateMenu, substr($jbIdParentOrdertime,8,2), substr($jbIdParentOrdertime,5,2), substr($jbIdParentOrdertime,0,4),
substr($jbIdParentOrdertime,8,2), substr($jbIdParentOrdertime,5,2), substr($jbIdParentOrdertime,0,4), $jbTimedFilter, $dateSelectionByCalendar, 0);
$globalArrayIsDefined = true;
endif;
endif;
endif;
// Try to find an appointment for the current job in FDS near by the existing merged job
if ($jbIdMerged != "") :
// [1.] Get day of the job to be merged
$sqlStmt = getStmtVehicledispositionData($jbIdMerged,"","","vhd.vhd_timeslot LIMIT 0,1");
$vhdTimeslot = getOneStmt($sqlStmt, "vhd_timeslot");
$specialCrvhId = getOneStmt($sqlStmt, "crvh_id");
$jbIdMergedOrdertime = getFieldValueFromId("job","jb_id",$jbIdMerged,"jb_ordertime"); // LEFT($jbIdMergedOrdertime,10) =!= LEFT($vhdTimeslot,10)
$jbIdMergedTimeunits = getFieldValueFromId("job","jb_id",$jbIdMerged,"jb_timeunits");
if (substr($jbIdMergedOrdertime,0,10) == substr($vhdTimeslot,0,10)) :
// The MERGED job is currently associated to a special vehicle on the present day. Try to associate the CURRENT job to this merged job
$globalParArray = array($jbIdNew, $csId, $ecoDayTimeArray, $ecoWeekdayArray, $cscadZipcode, $jbTimeUnits, $sortSequence, $jbService, $ecoWeight, $ecoPositions,
$maxLimitOfRows, $deliveryTimeValue, $deactivateMenu, substr($jbIdMergedOrdertime,8,2), substr($jbIdMergedOrdertime,5,2), substr($jbIdMergedOrdertime,0,4),
substr($jbIdMergedOrdertime,8,2), substr($jbIdMergedOrdertime,5,2), substr($jbIdMergedOrdertime,0,4), $jbTimedFilter, $dateSelectionByCalendar, 0);
$globalArrayIsDefined = true;
endif;
endif;
if (!$globalArrayIsDefined) :
$globalParArray = array($jbIdNew, $csId, $ecoDayTimeArray, $ecoWeekdayArray, $cscadZipcode, $jbTimeUnits, $sortSequence, $jbService, $ecoWeight, $ecoPositions,
$maxLimitOfRows, $deliveryTimeValue, $deactivateMenu, substr($jbOrdertime,8,2), substr($jbOrdertime,5,2), substr($jbOrdertime,0,4),
substr($jbOrdertime,8,2), substr($jbOrdertime,5,2), substr($jbOrdertime,0,4), $jbTimedFilter, $dateSelectionByCalendar, 0);
endif;
// Get vehicle list
$retArray = getDispositionAppointments("3", $globalParArray);
$globalParArray = $retArray[0]; // Global parameters
$tmpArray = $retArray[1]; // Available vehicle data as array OR error string
list($xJbId, $xCsId, $xEcoDayTimeArray, $xEcoWeekdayArray, $xEcoZipcode, $xEcoNeededTimeUnits, $xSortSequence, $xEcoServices, $xEcoWeight, $xEcoPositions,
$xMaxLimitOfRows, $xDeliveryTimeValue, $xDeactivateMenu, $x_day_from, $x_month_from, $x_year_from, $x_day_to, $x_month_to, $x_year_to, $xJbTimedFilter,
$xDateSelectionByCalendar, $xCurrentTimestamp, $xCurrentDay, $xCurrentTime, $xCurrYear, $xCombinedJob, $xHourTimeUnits, $xEcoDayClockTimes,
$xJbOrdertime, $xEcoCapacityMax, $xEcoSummatedNeededTimeUnits,$xEcoHasWholeDayRequest, $srvpId, $srvzId, $xWeekDayNames, $xCheckTotalweight,
$xDispositionJbStatusMode, $xEcoChildrenServices, $xMaskDisplayWholeDayAvoidingSingleDaytimes, $xEcoIsInstallationJob, $xEcoIsSpecialServiceJob,
$xDispositionAllocationMode, $xEcoChildrenTimeunitsArray, $xJbIdChildren, $xJbIdChildrenLen, $xDaytimeReadonlyArray) = $globalParArray;
// Check for ERRORS
if (!is_array($tmpArray)) :
if (!$errHandlerDisabled) :
$acceptOrder = false;
if (!(strpos($tmpArray, "ERR:ZIPCODE_NOT_IN_ANY_ZONE") === FALSE)) :
$err[] = array("108", getLngt("Die PLZ ist keiner Zone zugeordnet.") . " [" . $ecoZipcode . "]");
else :
$err[] = array("109", getLngt("Bereichsfehler."));
endif;
endif;
endif;
$errMsgArrayLen = count($errMsgArray);
if ($acceptOrder && is_array($tmpArray)) :
$tmpArrayLen = count($tmpArray);
if ($tmpArrayLen > 0) :
if ($debug) :
echo "---- VERFÜGBARE FAHRZEUGE --------------------------------------------------------------
";
print_r($tmpArray);
echo "----------------------------------------------------------------------------------------
";
endif;
$iterWhile2 = true;
$iterCount2 = 0;
while ($iterWhile2) :
// Take vehicle, start with the first
for ($v = 0; $v < $tmpArrayLen; $v++) :
// array(vhaDay, crvhSid, daytimeValues, vhatTimeunits, starttime, service, vhatDaytime, crvhId, substr(vhat_starttimeunit,0,2), substr(vhat_starttimeunit,3,2), $daytimeMappedValues, crvhService)
$vhtArray = $tmpArray[$v];
// Associate job to FDS
if ($specialCrvhId == "" || $specialCrvhId == $vhtArray[7]) :
// COMBINED JOB
// In case of existence of a parent job try to get slots for both serial without space between them
$jbId_1 = $jbIdNew;
$jbTimeUnits_1 = $jbTimeUnits;
$jbId_2 = "";
$jbTimeUnits_2 = "";
if ($jbIdParent != "") :
// Check for same day to make a combined job (!!!!)
if ($jbIdParentOrdertime != "" && substr($jbIdParentOrdertime,0,10) == substr($jbOrdertime,0,10)) :
// New job should be placed BEHIND existing job
$jbId_1 = $jbIdParent;
$jbTimeUnits_1 = $jbIdParentTimeunits;
$jbId_2 = $jbIdNew;
$jbTimeUnits_2 = $jbTimeUnits;
// Remove existing job (ID in $jbIdParent) from FDS to make a combined reservation with the new job
// removeAssocCrvhJb($jbIdParent, $csId);
if ($parNoRelatedReverse == "1") :
// New job should be placed BEFORE existing job
$jbId_1 = $jbIdNew;
$jbTimeUnits_1 = $jbTimeUnits;
$jbId_2 = $jbIdParent;
$jbTimeUnits_2 = $jbIdParentTimeunits;
endif;
endif;
endif;
if ($debug) :
echo "jbId_1.timeunits: " . $jbTimeUnits_1 . "
";
echo "jbId_2.timeunits: " . $jbTimeUnits_2 . "
";
endif;
if ($jbId_1 != "") :
$retBool_1 = setAssocCrvhJb($jbId_1, $vhtArray[7], $csId, $vhtArray[0], $vhtArray[8], $vhtArray[9], $jbTimeUnits_1);
$retBool_2 = true; // Init with true because $jbId_2 can be empty (no parent does exist)
if ($debug) :
echo "jbId_1.start_timeslot: " . $vhtArray[0] . " " . $vhtArray[8] . "_" . $vhtArray[9] . "
";
endif;
endif;
if ($jbId_2 != "") :
// Get first timeslot and last timeslot (interval)
$startTimeslotToBeChecked = $vhtArray[0] . '_' . pad($hour, 2) . '_' . pad($hourUnit, 2);
$tmpHour = $vhtArray[8];
$tmpHourUnit = $vhtArray[9];
$timeslots = $jbTimeUnits_1;
for ($t = 0; $t < $timeslots; $t++) :
$tmpHourUnit++;
if ($tmpHourUnit == $hourTimeUnits) :
$tmpHour++;
$tmpHourUnit = 0;
endif;
endfor;
$endTimeslotToBeChecked = $vhtArray[0] . '_' . pad($tmpHour, 2) . '_' . pad($tmpHourUnit, 2);
$retBool_2 = setAssocCrvhJb($jbId_2, $vhtArray[7], $csId, $vhtArray[0], $tmpHour, $tmpHourUnit, $jbTimeUnits_2);
if ($debug) :
echo "jbId_1.end_timeslot: " . $vhtArray[0] . " " . $tmpHour . "_" . $vhtArray[9] . "
";
endif;
endif;
if ($retBool_1 && $retBool_2) :
// Set order time
if ($debug) :
echo "jbId_1.ordertime: " . $vhtArray[0] . " " . $vhtArray[4] . ":00" . "
";
endif;
updateStmt("job","jb_id",$jbId_1,array("jb_ordertime",$vhtArray[0] . " " . $vhtArray[4] . ":00"));
if ($jbId_2 != "") :
if ($debug) :
echo "jbId_2.ordertime: " . $vhtArray[0] . " " . pad($tmpHour, 2) . ":" . pad(strval(floor(intval(substr($endTimeslotToBeChecked,14,2)) * (60 / $hourTimeUnits))),2) . ":00" . "
";
endif;
updateStmt("job","jb_id",$jbId_2,array("jb_ordertime",$vhtArray[0] . " " . pad($tmpHour, 2) . ":" . pad(strval(floor(intval(substr($endTimeslotToBeChecked,14,2)) * (60 / $hourTimeUnits))),2) . ":00"));
endif;
if ($dispositionJbStatusMode == "1") :
$retIsBlocked = crvhIsBlocked($vhtArray[7], $vhtArray[0], 1);
if ($retIsBlocked) :
// Update jb_status for disposition by courier
updateStmt("job","jb_id",$jbId_1,array("jb_status","0"));
if ($jbId_2 != "") :
updateStmt("job","jb_id",$jbId_2,array("jb_status","0"));
endif;
// Get courier ID of the current vehicle ("jb.cr_id_order" has to be set regarding the current vehicle)
$crvhSid = getFieldValueFromId("couriervehicle","crvh_id",$vhtArray[7],"crvh_sid"); // Get SID, needed for "fake" courier for the vehicle !!!!
$crId = getFieldValueFromId("courier","cr_sid",$crvhSid,"cr_id"); // Get "fake" courier ID
$res = updateStmt("job", "jb_id", $jbIdNew, array("cr_sid", $crvhSid, "cr_id_order", $crId));
endif;
endif;
$iterWhile = false; // Terminate outer loop
$iterWhile2 = false; // Terminate inner loop
break;
else :
// Remove job(s) from FDS (probably not needed)
removeAssocCrvhJb($jbId_1, $csId);
if ($jbId_2 != "") :
removeAssocCrvhJb($jbId_2, $csId);
endif;
endif;
endif;
endfor;
if ($iterWhile2) :
$specialCrvhId = ""; // Second iteration without special vehicle
if ($iterCount2 > 1) :
$iterWhile2 = false;
endif;
$iterCount2++;
endif;
endwhile;
// Write zone information and "dispo callback"
if ($globalParUseRelatedCustomer == "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;
// Get name of the zone
$srvzName = "";
if ($srvzId != "" && is_numeric($srvzId)) :
$srvzName = getFieldValueFromId("servicezone","srvz_id",$srvzId,"srvz_name");
else :
$srvzId = "";
if (!$errHandlerDisabled) :
$acceptOrder = false;
$err[] = array("108", getLngt("Die PLZ ist keiner Zone zugeordnet."));
endif;
endif;
if ($acceptOrder) :
updateStmt("job","jb_id",$jbIdNew,array("jb_freetext_1", $tmpJbFreetext1, "jb_mediationarea_id", $srvzId, "jb_mediationarea_name", $srvzName));
endif;
endif;
else :
if (!$errHandlerDisabled) :
$acceptOrder = false;
$err[] = array("115", getLngt("Kein Fahrzeug verfügbar."));
endif;
endif;
else :
if (!$errHandlerDisabled) :
$acceptOrder = false;
$err[] = array("115", getLngt("Kein Fahrzeug verfügbar."));
endif;
endif;
if ($iterWhile) :
if ($iterCount > 5) :
$iterWhile = false;
endif;
$iterCount++;
endif;
endwhile;
$debugOut .= "tmpJbFreetext1: " . $tmpJbFreetext1 . "
\n";
$debugOut .= "
\n";
endif; // ($fdsDoExecute == true)
endif; // ($globalParUseRelatedCustomer == "1")
$debugOut .= "END DISPOSITION
\n";
// --------------------------------------------------------
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);
// Output
$outResponse .= "";
if ($errLen > 0) :
orderRequestLogFile("ERRORS", 1);
$outResponse .= "NOT OK";
$outResponse .= "";
for ($i = 0; $i < $errLen; $i++) :
$outResponse .= "";
$outResponse .= "" . $err[$i][0] . "";
$outResponse .= "";
$outResponse .= "";
if ($debug) :
$outResponse .= "" . $debugOut . "";
endif;
orderRequestLogFile($err[$i][0] . " : " . mcEncode($err[$i][1]), 1);
endfor;
$outResponse .= "";
else :
$outResponse .= "OK" . $jbIdNew . "";
if ($debug) :
$outResponse .= "" . $debugOut . "";
endif;
endif;
$outResponse .= "";
// Log entries
orderRequestLogFile($outResponse); // Write response into log
orderRequestLogFile("___________________________________________________________________________________");
// 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
// Fuhrauftrag
// Identifikation des Kunden
... // Kundennummer (EID) {"STBxxxxxx", ...} => csc_id_payer
... // Eingetragener Benutzer für den Kunden => cs.cs_admin => emp.emp_id => emp.usr_id => usr.usr_id => usr.usr_account
... // Passwort für den Benutzer => usr.usr_password
... // Zusätzliche Session-ID, die mit dem Kunden ausgehandelt wurde [mandatory]
... // Kostenstellenname {"abcd", "efgh", ...} => Mapping csc_id [optional]
... // Nummer der Kundengruppe (Bei einer automatischen Preisfindung muss entweder oder gesetzt sein)
... // Name der Kundengruppe (Bei einer automatischen Preisfindung muss entweder oder gesetzt sein)
... // Operation (INS, UPD, DEL)
... // Activates debug output ("ON" or "YES")
// Manuelle EVENTS
[optional]
[optional]
[optional]
...
... // Order no of the customer => tr_commission_no
... // Type of the job => jb_type
... // {HB, HH, ...} => hq_mnemonic => hq_id
// Angefordertes Fahrzeug
... // {1,2,3...} => Mapping "metatype" => vht_id (entweder oder ist mandatory)
... // {"bus", ...} => Mapping "metatype" => vht_id (entweder oder ist mandatory)
... // Gewicht des Transportguts
... // Angeforderte Mindestlänge des Fahrzeugs
... // Angeforderte Mindestbreite des Fahrzeugs
... // Angeforderte Mindesthöhe des Fahrzeugs
... // Angeforderte Mindestanzahl an Stellplätzen im Fahrzeug
... // Startzeit des Auftrags (wenn leer, dann "adhoc"-Auftrag mit aktuellem Zeitstempel) => jb_ordertime und jb_reserv
... // Startzeit des Auftrags in UTC (erst wird nach der Inhalt in geschaut, dann ich )
... // Späteste Erledigungszeit des Auftrags (Bsp: 2014-10-22 09:00:00)
// Späteste Erledigungszeit des Auftrags in UTC (erst wird nach der Inhalt in geschaut, dann ich )
... // Erfassungszeit des Auftrags bei asynchroner Übertragung
... // {HH1000, HH1420, ...} Wunschfahrer => jb.cr_sid => Abgleich mit cr.cr_sid => cr.cr_id => jb.cr_id_order [optional]
CK,DE,EN // Fahrzeug-Filter zur Einschränkung der Fahrzeugvermittlung (Aufstellung siehe Anhang)
... // Bemerkung zum Auftrag
... // Bemerkung zum Auftrag für den Fahrer
// Zusätzliche Informationen pro Auftrag, die gesondert behandelt und bei Rückgaben herangezogen werden können
[optional]
[optional]
[optional]
...
// Stationen
// Station 1 (Abholung)
... // Abholung [optional] {leer, 0 = weder Abholung noch Anlieferung, 1 = nur Abholung, 2 = nur Anlieferung, 3 = beides}
... // Kostenstellenname {"abcd", "efgh", ...} => Mapping csc_id [optional, wenn gesetzt, dann weitere Felder leer]
... // Firmenbezeichnung
... // Firmenzusatz
... // Straße
... // Hausnummer
... // PLZ
... // Ort
... // Bemerkung zur Station
... // Abgabe der Sendung bei ..., Ansprechpartner [optional]
... // Telefonnummer [optional]
... // Email [optional]
// Rechnungsangaben (des belieferten Endkunden)
... // Kostenstellenname {"abcd", "efgh", ...} => Mapping csc_id [optional, wenn gesetzt, dann weitere Felder leer]
... // Firmenbezeichnung
... // Firmenzusatz
... // Straße
... // Hausnummer
... // Etage, Flur
... // PLZ
... // Ort
... // Bemerkung zur Station
... // Abgabe der Sendung bei ..., Ansprechpartner [optional]
... // Telefonnummer [optional]
... // Email [optional]
... // Belegnummer des Endkunden (Rechnungsnummer, Kassenbon)
... // Zahlungsart (leer oder 0 = Bar, 1 = EC–Pin, 2 = EC–Lastschrift, etc.)
... // Art des rabattierten Preises ("" = Standardpreis, 0 = Aktionpreis_1 (z.B. "family card"), 1 = Aktionspreis_2)
... // Bereits geleisteter Betrag (leer = 0 = keine Anzahlung/Bezahlung)
... // Modus (leer oder 0 = Auslieferung, 1 = Retoure, 2 = Montage, 3 = Demontage, 4 = Entsorgung (bei 2 und 3 mindestens Felder "description" und "quantity" gesetzt))
... // Artikelnummer
... // Seriennummer (1)
... // Beschreibung
... // Menge
... // Stückpreis
... // Einzelgewicht eines Artikels
... // Länge eines Artikels
... // Breite eines Artikels
... // Höhe eines Artikels
... // Anzahl Packstücke (leer oder 0 = z.B. keine Lieferung und nur Montage, ansonsten Anzahl)
... // Stellplätze, Kolli
... // Warengruppe
...
// Preisestruktur(en) [optional]
... // 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")
... // Anzahl Zeiteinheiten für Erfüllung des Auftrags (1 Zeiteinheit = 10 Minuten)
... // 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, ...)
... // Auftragsart(en) (Sameday = 0, Nextday = 1, Kurier = 2)
// Calculatorpreise [optional]
// Spezielle Zelle der Preis-/Leistungsmatrix
... // Leistungstyp
... // Preistyp
... // Preis [optional] => überschreibt den in der zelle eingetragenen Preis
... // Menge
...
// Calculatorpreisfunktionen [optional]
... // Nummer der Funktion (Erläuterung siehe bitte unten)
... // Wert für Parameter Nr. 1 der Funktion
... // Wert für Parameter Nr. 2 der Funktion
... // Wert für Parameter Nr. 3 der Funktion
... // Wert für Parameter Nr. 4 der Funktion
... // Wert für Parameter Nr. 5 der Funktion
... // Menge (leer = 1 = default, ansonsten angegebene Anzahl)
...
// 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>
// Station 2
... // Abholung, Anlieferung, beides [optional]
...
... // Weitere Stationen
Calculatorpreisfunktionen:
...
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
10002
490 // Warenwert (Bsp. 490,- €)
10003 : Tagessatz für Lagerungskosten ab dem n. Tag
10003
14 // Anzahl Tage (bei 0 => keine Berechnung => keine Kosten für Endkunde)
1
10004 : Montagebetrag auf Basis des Prozentsatzes p% vom Warenwert
10004
288 // Warenwert
10010 : Preis pro Meter Küchenmontage
10010
5 // Angabe lfd. Meter
20005 : Elektroanschluss bei Küchenmontage
20005
1
20006 : Wasseranschluss bei Küchenmontage
20006
1
10005 : Expresslieferung nach Zonen
10005
22525 // PLZ
20001 : Zusätzliche Montagestunde
20001
2.25
20002 : Pauschale Nachmontage
20002
1.5
20003 : Monteurstunde bei Nachmontage
20003
3
10007 : Prozentsatzes p% des Lieferpreises beim Abholauftrag
10007
197 // Preis des Abholauftrags
1
10009 : Warengruppenabhängiger Preis für die Montage
10009
10 // Warengruppe
1
10006 : Warengruppenabhängiger Preis für die Altmöbelrücknahme
10006
15 // Warengruppe
1
10008 : Preis für Liefergewicht pro x kg höher als das Freigewicht
10008
350 // Gewicht in kg
1
20004 : Endkundenpreis für Einkaufsservice
20004
1
10011 : Verrechnungssatz pro Artikel in Prozent p% vom Verkaufspreis bei Verlust und Schäden
10011
350 // Warenwert
1
20007 : Hantierungshilfsmittel: Verrechnungssatz Euro-Palette
20007
3
20008 : Hantierungshilfsmittel: Verrechnungssatz IKEA-Palette
20008
3
1xxxx : Kosten für Transportverpackung(en) z.B. bei Kleinteilen
1xxxx
1
// PFLICHTFELDER UND OPTIONALE FELDER
// Fuhrauftrag
// Identifikation des Kunden
[mandatory] // Kundennummer (EID) {"STBxxxxxx", ...}
[mandatory] // Eingetragener Benutzer für den Kunden
[mandatory] // Passwort für den Benutzer
[mandatory] // Zusätzliche ausgehandelte Session-ID
[optional] // Bekannte Kostenstelle
[optional] // Nummer der Kundengruppe (Bei einer automatischen Preisfindung muss entweder oder gesetzt sein)
[optional] // Name der Kundengruppe (Bei einer automatischen Preisfindung muss entweder oder gesetzt sein)
[optional] // Operation (INS, UPD, DEL)
[optional] // Activates debug output ("ON" or "YES")
// Manuelle EVENTS
[optional]
[optional]
[optional]
...
[optional] // Eigene Auftragsnummer z.B. aus Lotus
[optional] // Auftragstype (z.B. 1,2,3,...) (Mapping z.B. auf "G", "K", ...)
[mandatory] // HH (HB, B, DD), Städtekürzel
// Angefordertes Fahrzeug
[mandatory] // {2=PKW, 3=Kombi, 4=Kastenwagen, 5=Bus, 6=Großer Bus, 7=LKW}
[optional] // {PKW, ...}
[optional] // Gewicht des Transportguts
[optional] // Angeforderte Mindestlänge des Fahrzeugs
[optional] // Angeforderte Mindestbreite des Fahrzeugs
[optional] // Angeforderte Mindesthöhe des Fahrzeugs
[optional] // Angeforderte Mindestanzahl an Stellplätzen im Fahrzeug
[optional] // Startzeit des Auftrags (wenn leer, dann "adhoc"-Auftrag mit aktuellem Zeitstempel) (Bsp: 2012-02-17 09:30:00)
[optional] // Startzeit des Auftrags in UTC (erst wird nach der Inhalt in geschaut, dann ich )
[optional] // Späteste Erledigungszeit des Auftrags (Bsp: 2014-10-22 09:00:00)
[optional] // Späteste Erledigungszeit des Auftrags in UTC (erst wird nach der Inhalt in geschaut, dann ich )
[optional] // Erfassungszeit des Auftrags bei asynchroner Übertragung
[optional] // {HH1000, HH1420, ...} Wunschfahrer
[optional] // Fahrzeug-Filter zur Einschränkung der Fahrzeugvermittlung (Aufstellung siehe Anhang) (Bsp.: EN=Englisch, HW=Hubwagen, ...)
[mandatory] // Rechnungstext und Bemerkung zum Auftrag
[optional] // Bemerkung zum Auftrag für den Fahrer
// Zusätzliche Informationen pro Auftrag, die gesondert behandelt und bei Rückgaben herangezogen werden können
[optional]
[optional]
[optional]
...
// Stationen
// Station 1 (Abholung)
[optional] // Abholung, Anlieferung, beides {leer, 0, 1, 2, 3}
[optional] // Kostenstellenname {"abcd", "efgh", ...}
[mandatory] // Firmenbezeichnung ODER Person
[optional] // Firmenzusatz
[mandatory] // Straße
[mandatory] // Hausnummer
[optional] // Etage, Flur
[mandatory] // PLZ
[mandatory] // Ort
[optional] // Bemerkung zur Station
[optional] // Abgabe der Sendung bei ..., Ansprechpartner
[optional] // Telefonnummer
[optional] // Email
// Rechnungsangaben (des belieferten Endkunden)
[optional] // Kostenstellenname {"abcd", "efgh", ...} => Mapping csc_id [optional, wenn gesetzt, dann weitere Felder leer]
[optional] // Firmenbezeichnung
[optional] // Firmenzusatz
[optional] // Straße
[optional] // Hausnummer
[optional] // PLZ
[optional] // Ort
[optional] // Bemerkung zur Station
[optional] // Abgabe der Sendung bei ..., Ansprechpartner [optional]
[optional] // Telefonnummer [optional]
[optional] // Email [optional]
[optional] // Belegnummer des Endkunden (Rechnungsnummer, Kassenbon)
[optional] // Zahlungsart (leer oder 0 = Bar, 1 = EC–Pin, 2 = EC–Lastschrift, 20 = Familycard, 21 = Businesscard)
[optional] // Art des rabattierten Preises ("" = Standardpreis, 0 = Aktionpreis_1 (z.B. "family card"), 1 = Aktionspreis_2)
[optional] // Bereits geleisteter Betrag (leer = 0 = keine Anzahlung/Bezahlung)
[optional] // Modus (leer oder 0 = Auslieferung, 1 = Retoure, 2 = Montage, 3 = Demontage, 4 = Entsorgung (bei 2 und 3 mindestens Felder "description" und "quantity" gesetzt))
[optional] // Artikelnummer
[optional] // Seriennummer (1)
[optional] // Beschreibung
[optional] // Menge
[optional] // Stückpreis
[optional] // Einzelgewicht eines Artikels
[optional] // Länge eines Artikels
[optional] // Breite eines Artikels
[optional] // Höhe eines Artikels
[optional] // Anzahl Packstücke (leer oder 0 = z.B. keine Lieferung und nur Montage, ansonsten Anzahl)
[optional] // Stellplätze, Kolli
[optional] // Warengruppe
...
// Preisestruktur(en) [optional]
[optional] // 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")
[mandatory] // Anzahl Zeiteinheiten für Erfüllung des Auftrags (1 Zeiteinheit = 10 Minuten)
[optional] // 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, ...)
[optional] // Auftragsart(en) (Sameday = 0, Nextday = 1, Kurier = 2)
// Calculatorpreise [optional]
// Spezielle Zelle der Preis-/Leistungsmatrix
[mandatory] // Leistungstyp
[mandatory] // Preistyp
[optional] // Preis [optional] => überschreibt den in der zelle eingetragenen Preis
[mandatory] // Menge
...
// Calculatorpreisfunktionen [optional]
[mandatory] // Nummer der Funktion (Erläuterung siehe bitte unten)
[optional] // Wert für Parameter Nr. 1 der Funktion
[optional] // Wert für Parameter Nr. 2 der Funktion
[optional] // Wert für Parameter Nr. 3 der Funktion
[optional] // Wert für Parameter Nr. 4 der Funktion
[optional] // Wert für Parameter Nr. 5 der Funktion
[optional] // Menge (leer = 1 = default, ansonsten angegebene Anzahl)
...
// 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>
// Station 2
[optional] // Abholung, Anlieferung, beides [optional]
...
... // Weitere Stationen
*/
?>