";
orderDataRequestLogFile($currentTime);
orderDataRequestLogFile($orderDataReq);
if ($selectedLanguage == "" || !is_numeric($selectedLanguage)) : $selectedLanguage = "1"; endif; // Default in English
$languageSelected = $selectedLanguage;
getLanguage(__FILE__);
getCurrentScript(__FILE__);
$err = array();
$orderDataResponse = "";
$xmlorderData = "";
// ---------------------------------------------------------------------------
// GLOBAL MODE OF USAGE
$globalParUseRelatedCustomer = getParameterValue("0", "GLOBAL_USE_RELATED_CUSTOMER", "0");
// *** Parse request ***
$orderDataArray = xml2array($orderDataReq);
if ($debug) :
echo "Order data:
\n\n";
print_r($orderDataArray); echo "
";
endif;
// *** Convert result array to usable parameters ***
// Authentication data
$csEid = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["customer"]);
$csId = getFieldValueFromId("customer","cs_eid",$csEid,"cs_id");
$usrAccount = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["account"]);
$usrPassword = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["password"]);
$sessionId = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["session_id"]);
// Optional customer group data (needed to find e.g. an article price automatically). Has to be set explicitly, because a customer could belong to more groups !!!!
$csGroupId = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["group_no"]);
$csGroupName = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["group_name"]);
if ($csGroupId != "" && is_numeric($csGroupId)) :
$csGroupName = getFieldValueFromId("groups","grp_id",$csGroupId,"grp_name");
elseif ($csGroupName != "") :
$csGroupId = getFieldValueFromId("groups","grp_name",$csGroupName,"grp_id");
endif;
// Reset customer group data if it could not be identified
if ($csGroupId == "" || $csGroupName == "") :
$csGroupId = "";
$csGroupName = "";
endif;
$debugOut .= "usrAccount: " . $usrAccount . "
\n";
$debugOut .= "usrPassword: " . $usrPassword . "
\n";
$debugOut .= "sessionId: " . $sessionId . "
\n";
if (checkRequestAuthenticationData($usrAccount, $usrPassword, $sessionId, $csId)) :
$debugOut .= "Authentication okay!
\n";
// Data
$hqId = getFieldValueFromId("customer","cs_id",$csId,"hq_id");
$cscName = convertSpecial($orderDataArray["xml"]["order_data"]["auth"]["costcenter_name"]);
$cscId = "";
if ($cscName != "") :
$cscId = getFieldValueFromClause("costcenter","csc_id","cs_id = '" . $csId . "' AND csc_name = '" . $cscName . "'");
endif;
// if ($cscId == "" || !is_numeric($cscId)) :
// $cscId = getFieldValueFromClause("costcenter","csc_id","cs_id = '" . $csId . "' AND isnull(csc_pre_id)"); // Root costcenter
// endif;
// Get costcenter data
$operation = convertSpecial($orderDataArray["xml"]["order_data"]["operation"]);
$debugOn = convertSpecial($orderDataArray["xml"]["order_data"]["debug_on"]);
$debugOut .= "operation: " . $operation . "
\n";
$debugOut .= "address_type: " . $address_type . "
\n";
if (!$debug && $debugOn == "ON" || $debugOn == "YES") :
$debug = true;
echo "csId: " . $csId . "
";
echo "csEid: " . $csEid . "
";
endif;
if ($operation == "SET") :
// TO BE DONE!
else :
$orderNumbers = convertSpecial($orderDataArray["xml"]["order_data"]["order_numbers"]);
$orderNumberArray = explode("|", $orderNumbers);
$orderNumberArrayLen = count($orderNumberArray);
$dataFields = convertSpecial($orderDataArray["xml"]["order_data"]["data_fields"]);
$dataFieldArray = explode("|", $dataFields);
$dataFieldArrayLen = count($dataFieldArray);
if ($debug) :
print_r($orderNumberArray); echo "\n\n
";
echo $orderNumberArrayLen . "
";
print_r($dataFieldArray); echo "\n\n
";
echo $dataFieldArrayLen . "
";
endif;
// Iterate array
$xmlorderData .= "";
for ($i = 0; $i < $orderNumberArrayLen; $i++) :
$xmlorderData .= "";
$jbIdOrg = $orderNumberArray[$i];
$xmlorderData .= "" . $jbIdOrg . "";
// First check valid association between authenticated customer and requested job(s) !!!!
// $cscIdPayer = $jobData["job"]["csc_id_payer"];
$cscIdPayer = getFieldValueFromId("job","jb_id",$jbIdOrg,"csc_id_payer");
$csIdPayer = getFieldValueFromId("costcenter","csc_id",$cscIdPayer,"cs_id");
// Get operational job of requested job (!!!!)
$tmpValue = getFieldValueFromClause("phoenix.genericdatacontainer","gdc_content","gdc_obj_type = 'jb' AND gdc_gen_fieldname = 'is_operative' AND gdc_obj_id = '" . $jbIdOrg . "'");
$tmpArray = explode("|", $tmpValue);
$jbId = $tmpArray[0];
$xmlorderData .= "" . $jbId . "";
if ($jbId != "" && is_numeric($jbId)) :
getDBData("job", $jbId);
if ($debug) :
print_r($jobData); echo "\n\n
";
endif;
$xmlorderData .= "";
if ($csIdPayer == $csId) :
// getDBData("tour", $jbId);
for ($j = 0; $j < $dataFieldArrayLen; $j++) :
$fieldName = $dataFieldArray[$j];
$fieldVal = $jobData["job"][$dataFieldArray[$j]];
if ($fieldName == "vht_id" || $fieldName == "vht_id_real") :
$fieldVal = getFieldValueFromClause("phoenix.metatype","mt_value","mt_type = 'vehicletype' AND mt_sort = '" . $fieldVal . "'");
endif;
$xmlorderData .= "";
$xmlorderData .= "";
$xmlorderData .= "";
$xmlorderData .= "";
endfor;
else :
$xmlorderData .= "";
$xmlorderData .= "";
$xmlorderData .= "";
$xmlorderData .= "";
endif;
$xmlorderData .= "";
else :
$xmlorderData .= "";
$xmlorderData .= "";
$xmlorderData .= "";
$xmlorderData .= "";
$xmlorderData .= "";
$xmlorderData .= "";
endif;
$xmlorderData .= "";
endfor;
$xmlorderData .= "";
if ($debug) :
echo "RESPONSE:
" . $xmlorderData . "
";
endif;
endif;
else :
// Authentication data not ok
$err[] = array("101", getLngt("Die Authentifizierungsdaten sind nicht in Ordnung."));
endif;
// print_r($err);
// Check existence of at least one error
$errLen = count($err);
// Output
$orderDataResponse .= "";
if ($errLen > 0) :
orderDataRequestLogFile("ERRORS", 1);
$orderDataResponse .= "NOT OK";
$orderDataResponse .= "";
for ($i = 0; $i < $errLen; $i++) :
$orderDataResponse .= "";
$orderDataResponse .= "" . $err[$i][0] . "";
$orderDataResponse .= "";
$orderDataResponse .= "";
if ($debug) :
$orderDataResponse .= "" . $debugOut . "";
endif;
orderDataRequestLogFile($err[$i][0] . " : " . mcEncode($err[$i][1]), 1);
endfor;
$orderDataResponse .= "";
else :
$orderDataResponse .= "OK" . $xmlorderData;
if ($debug) :
$orderDataResponse .= "" . $debugOut . "";
endif;
endif;
$orderDataResponse .= "";
// Log entries
orderDataRequestLogFile($orderDataResponse); // Write response into log
orderDataRequestLogFile("___________________________________________________________________________________");
// Return output
echo $orderDataResponse;
/*
// REQUEST
// Request for all orderData of the customer
// Customer to be authenticated
... // Kundennummer (EID) {"STBxxxxxx", ...} => csc_id_payer
... // Eingetragener Benutzer für den Kunden => cs.cs_admin => emp.emp_id => emp.usr_id => usr.usr_id => usr.usr_account
... // Passwort für den Benutzer => usr.usr_password
... // Zusätzliche Session-ID, die mit dem Kunden ausgehandelt wurde [mandatory]
... // Kostenstellenname {"abcd", "efgh", ...} => Mapping csc_id [optional]
... // Nummer der Kundengruppe (Bei einer automatischen Preisfindung muss entweder oder gesetzt sein)
... // Name der Kundengruppe (Bei einer automatischen Preisfindung muss entweder oder gesetzt sein)
... // Activates debug output ("ON" or "YES")
GET|SET // Operation (GET or SET costcenter(s), default is "GET" if emty tag)
// List of votian order numbers "17310234|17310296|17310242|...."
// List of data field like "vh_id_real|jb_finishtime|...."
// RESPONSE for GET
OK
// Single order
.... // votian (requested) order number
.... // votian operational order number with real vehicle id
.... // (Requested) field name
.... // Field value
....
// Next single order
....
*/
?>