1. Import

This commit is contained in:
2026-03-29 10:34:57 +02:00
parent b0e00c1259
commit a1129565af
4899 changed files with 3007593 additions and 0 deletions

View File

@@ -0,0 +1,687 @@
<?php
/*=======================================================================
*
* import_LYRECO.php
*
* Autor: Marc Vollmann
*
=======================================================================*/
// $doNotIncludeGeocode = true;
include_once ("../import/import.php");
include_once ("../include/inc_vehicle.inc.php");
include_once ("../include/inc_job.inc.php");
// Execution-Time for script
set_time_limit(0);
// Check HTTP-Parameters
getSecHttpVars("1",array("f_act", "statusMessage", "importFile", "executeImportProcess", "deactivateMenu", "objType", "objId"));
getLanguage(__FILE__);
$deactivateMenuStatic = "1";
$pageTitel = getLngt("IMPORT AUFTRÄGE");
include_once ("../admin/menu.php");
include_once ("../include/html.inc.php");
getCurrentScript(__FILE__);
// Get special user types from parameter
$specialUserTypeIsLoggedIn = false;
$specialUserType = "";
$specialUserHqId = "";
$specialUserFTPServerList = "";
$specialUserDirSpecialForObjType = "";
$userTypesSpecialArray = getDatatransferSpecialUserData($userType);
if (count($userTypesSpecialArray) > 0) :
$specialUserTypeIsLoggedIn = true;
list($specialUserType, $specialUserHqId, $specialUserFTPServerList, $specialUserObjType, $specialUserObjId, $specialUserDirSpecialForObjType) = $userTypesSpecialArray;
if ($objType == $specialUserObjType && $objId == $specialUserObjType) :
$hqId = $specialUserHqId;
endif;
endif;
// Check for authentication access
$empHasAdminRights = false;
if (!$specialUserTypeIsLoggedIn) :
$usrAccessArray["hq"] = "1";
authCheckForAccess($hq_id, $usr_id, $emp_id, "1", $customerId, $cscIdRoot, $cscIdActual);
if (!(authCheckEmployeeRights($emp_id, "22"))) : gotoReferer("1"); endif;
$empIdRootAdmin = getEmpIdOfRootAdmin($userTypeName);
if ($empIdRootAdmin != "" && $emp_id == $empIdRootAdmin) :
$empHasAdminRights = true;
endif;
endif;
$debug = false;
if ($empIdRootAdmin == $emp_id) :
$debug = false;
endif;
if ($f_act != "executeImport" || $executeImportProcess != "1") : $executeImportProcess = ""; endif; // Execute import after check run
$showExecutionProcessButton = true;
$outText = "";
$closeWindow = "0";
$delimiter = ";";
$fire = true; // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$currentDate = getDateTime(3);
$objType = strtolower($objType);
// Import for special customer ONLY !!!!
$csId = "";
$csEid = "";
$cscIdPayer = "";
if ($objType == "cs" && $objId != "" && is_numeric($objId)) :
$csId = $objId;
endif;
if ($objType == "csc" && $objId != "" && is_numeric($objId)) :
$cscIdPayer = $objId;
$csId = getFieldValueFromClause("costcenter", "cs_id", "csc_id = '" . $cscIdPayer . "'");
endif;
$csAddress = array();
$adIdFrom = 0;
if ($csId != "") :
$hqId = getFieldValueFromClause("customer", "hq_id", "cs_id = '" . $csId . "'");
$csEid = getFieldValueFromClause("customer", "cs_eid", "cs_id = '" . $csId . "'");
// $csAddress = getAddress($csId, "customer");
$csAddress = getAddress($csId, "costcenteraddress");
$adIdFrom = $csAddress["id"];
// USE FOLLOWING FIX ADDRESS
// $adIdFrom = "220594"; // Invoice address
// $adIdFrom = "125964"; // Pick-up address
// $trHsnoFrom = "4";
endif;
if ($hqId == "") :
$hqId = $hq_id;
endif;
$cscIdPayerExtern = getParameterValue("0", "CSC_ID_PAYER_EXTERN", $hqId);
$pickUpStationFinishedByDefault = true;
// Current file to be imported
$importFile = urldecode($importFile);
$posLastSlash = strripos($importFile, "/");
$posLastSlash++;
$pathname = substr($importFile, 0, $posLastSlash);
$filename = substr($importFile, $posLastSlash);
$outText = "<span class=\"f10bp1_blue\">" . getLngt("IMPORTDATEI:") . "</span>&nbsp;" . $filename . "<br><br>";
// Mapping "tour id" to "vehicle SID"
$tourVehicleArray = array();
if ($hqId == "107") :
// ESSEN
$tourVehicleArray["294501"] = "E501";
$tourVehicleArray["294502"] = "E502";
$tourVehicleArray["294503"] = "E503";
$tourVehicleArray["294504"] = "E504";
$tourVehicleArray["294505"] = "E505";
$tourVehicleArray["294506"] = "E506";
$tourVehicleArray["294507"] = "E507";
$tourVehicleArray["294508"] = "E508";
$tourVehicleArray["294509"] = "E509";
$tourVehicleArray["294510"] = "E510";
$tourVehicleArray["294511"] = "E511";
$tourVehicleArray["294512"] = "E512";
$tourVehicleArray["294590"] = "E590";
elseif ($hqId == "110") :
// NÜRNBERG
/*
$tourVehicleArray["299001"] = "N156";
$tourVehicleArray["299002"] = "N157";
$tourVehicleArray["299003"] = "N153";
$tourVehicleArray["299004"] = "N154";
$tourVehicleArray["299005"] = "N155";
$tourVehicleArray["299050"] = "N106";
*/
endif;
/*
294501 E501  e8020201  Schmidt  Alexander  0176 62283533
294502 E502  e8020202  Brazinskas  Zilvinas  0152 55904274
294503 E503  e8020203  Orakov  Anton  0152 01985959
294504 E504  e8020204  Isaak  Alexander  0152 53172115
294505 E505  e8020205  Fakhridinov  Dzhamshed  0177 8515225
294506 E506  e8020206  Ehlert  Günter  0171 3179072
294507 E507  e8020207  El Kourouchi  Rachid  0177 8457400
294508 E508  e8020208  Prokhorov  Vladimir  0176 22000601
294509 E509  e8020209  Ulle  Achim  0157 50623924
294510 E510  e8020210  Vogel  Waldemar  0157 87262689
294511 E511  e8020211  Smirnov  Igor  0176 32432192
294512 E512  e8020212  Cetin  Muammer  0172 2704315
294590 E590  e8020213  Chahbari  Majid  0176 47746437
$tourCourierArray = array();
$tourCourierArray["294501"] = "e8020201";
$tourCourierArray["294502"] = "e8020202";
$tourCourierArray["294503"] = "e8020203";
$tourCourierArray["294504"] = "e8020204";
$tourCourierArray["294505"] = "e8020205";
$tourCourierArray["294506"] = "e8020206";
$tourCourierArray["294507"] = "e8020207";
$tourCourierArray["294508"] = "e8020208";
$tourCourierArray["294509"] = "e8020209";
$tourCourierArray["294510"] = "e8020210";
$tourCourierArray["294511"] = "e8020211";
$tourCourierArray["294512"] = "e8020212";
$tourCourierArray["294590"] = "e8020213";
// **** NEU SEIT 27.07.2016 ****
stepenka 01  e8020401 E355 294590 nostris 01  e8021001 E370  89882390000008452644
stepenka 02  e8020402 E356 294501 nostris 02  e8021002 E371  89882390000012935618
stepenka 03  e8020403 E357 294502 nostris 03  e8021003 E372  89882390000012935675
stepenka 04  e8020404 E358 294503 nostris 04  e8021004 E373  89882390000012935683
stepenka 05  e8020405 E359 294504 nostris 05  e8021005 E374  89882390000012935709
stepenka 06  e8020406 E360 294505 nostris 06  e8021006 E375  89882390000012935626
stepenka 07  e8020407 E361 294506 nostris 07  e8021007 E376  89882390000008451471
stepenka 08  e8020408 E362 294507 nostris 08  e8021008 E377  89882390000012935584
stepenka 09  e8020409 E363 294508 nostris 09  e8021009 E378  89882390000012935576
stepenka 10  e8020410 E364 294509 nostris 10  e8021010 E379  89882390000012935568
stepenka 11  e8020411 E365 294510 nostris 11  e8021011 E380  89882390000012935550
stepenka 12  e8020412 E366 294511 nostris 12  e8021012 E381  89882390000012935733
stepenka 13  e8020413 E367 294512 nostris 13  e8021013 E382  89882390000008451448
stepenka 14  e8020414 E368 294513 nostris 14  e8021014 E383  89882390000012935634
*/
$tourCourierArray = array();
if ($hqId == "107") :
// ESSEN
$tourCourierArray["294590"] = "e8021001"; // nostris 01
$tourCourierArray["294501"] = "e8021002"; // nostris 02
$tourCourierArray["294502"] = "e8021003"; // nostris 03
$tourCourierArray["294503"] = "e8021004"; // nostris 04
$tourCourierArray["294504"] = "e8021005"; // nostris 05
$tourCourierArray["294505"] = "e8021006"; // nostris 06
$tourCourierArray["294506"] = "e8021007"; // nostris 07
$tourCourierArray["294507"] = "e8021008"; // nostris 08
$tourCourierArray["294508"] = "e8021009"; // nostris 09
$tourCourierArray["294509"] = "e8021010"; // nostris 10
$tourCourierArray["294510"] = "e8021011"; // nostris 11
$tourCourierArray["294511"] = "e8021012"; // nostris 12
$tourCourierArray["294512"] = "e8021013"; // nostris 13
$tourCourierArray["294513"] = "e8021014"; // nostris 14
elseif ($hqId == "110") :
// NÜRNBERG
$tourCourierArray["299001"] = "n8124502"; // Hokamp Benjamin 0157 84862698
$tourCourierArray["299002"] = "n8124503"; // Schulz Michael 0152 53666367
$tourCourierArray["299003"] = "n8124504"; // Möller Rene 0171 5823128
$tourCourierArray["299004"] = "n8124505"; // Kirschner Sascha 0152 53910965
$tourCourierArray["299005"] = "n8124506"; // Schulz Thomas 0176 24177518
$tourCourierArray["299050"] = "n8124507"; // Holler Stefan 0157 35374266
endif;
// SID array (fix!)
$tourSIDArray = array();
if ($hqId == "107") :
// ESSEN
$tourSIDArray["294590"] = "E370"; // 89882390000008452644
$tourSIDArray["294501"] = "E371"; // 89882390000012935618
$tourSIDArray["294502"] = "E372"; // 89882390000012935675
$tourSIDArray["294503"] = "E373"; // 89882390000012935683
$tourSIDArray["294504"] = "E374"; // 89882390000012935709
$tourSIDArray["294505"] = "E375"; // 89882390000012935626
$tourSIDArray["294506"] = "E376"; // 89882390000008451471
$tourSIDArray["294507"] = "E377"; // 89882390000012935584
$tourSIDArray["294508"] = "E378"; // 89882390000012935576
$tourSIDArray["294509"] = "E379"; // 89882390000012935568
$tourSIDArray["294510"] = "E380"; // 89882390000012935550
$tourSIDArray["294511"] = "E381"; // 89882390000012935733
$tourSIDArray["294512"] = "E382"; // 89882390000008451448
$tourSIDArray["294513"] = "E383"; // 89882390000012935634
elseif ($hqId == "110") :
// NÜRNBERG
$tourSIDArray["299001"] = "N156";
$tourSIDArray["299002"] = "N157";
$tourSIDArray["299003"] = "N153";
$tourSIDArray["299004"] = "N154";
$tourSIDArray["299005"] = "N155";
$tourSIDArray["299050"] = "N106";
endif;
function mcStrWrap($aStr)
{
$aStr = str_replace("'", "", $aStr);
$aStr = removeFieldSigns($aStr);
// $aStr = str_replace("'", "\'", $aStr);
$aStr = str_replace("\"", '', $aStr);
return $aStr;
}
if ($importFile != "" && $hqId != "" && is_numeric($hqId) && $csId != "" && is_numeric($csId)) :
if (file_exists($importFile)) :
$currentTime = getDateTime("0");
// ***********************
// * IMPORT FILE article *
// ***********************
if (!(strpos($filename, $csEid . "_import_LYRECO_") === false)) :
$executionCount = 0;
$insertCount = 0;
$updateCount = 0;
$failedCount = 0;
$remTourNo = "";
$jbIdNew = 0;
$trSort = 2; // Init for 2nd station equals first delivery !!!!
$tratSort = 1; // Init all serial numbers !!!!
$jobNewArray = array();
$useJbNewArray = false;
$rowToImport = array();
$parImportFieldsGroup == "";
if ($groupId != "") :
$parImportFieldsGroup = getParameterValue("0", "IMPORT_LYRECO_JOB_FIELDS", "0");
endif;
if ($parImportFieldsGroup != "") :
$rowToImport = spliti(",", $parImportFieldsGroup);
else :
/*
Tour Lieferung/Rückholung Bearbeitungsdatum Lieferscheinnummer Auftragsnummer Warenempfänger Name Ansprechpartner Auslieferangaben Straße,Hausnr. Länderkürzel Postleitszahl Ort ? Packstücke Paletten Gewicht Besteller Kundenbestellnummer Sendungsidentifikationsnummer ? ? ? ? ? ? ? ? ? Lieferdatum ? 2
299050 D 20141203 1039740933 38061862 100755403 AUDI AG Markus Dilger T06-Ingols,UG,G004 Ettinger Str. / Südstraße DE 85049 INGOLSTADT ? 1 0 0 MARKUS DILGER 5701829128 869 ? ? ? ? ? ? ? ? ? 20141202 ? 2
*/
$rowToImport[0] = "f_tour_no"; // A : Tour
$rowToImport[1] = "f_shipment_mode"; // B : Lieferung/Rückholung
$rowToImport[2] = "f_jb_orderdate"; // C : Bearbeitungsdatum (Ausführungsdatum)
$rowToImport[3] = "f_tr_commission_no"; // D : Lieferscheinnummer
$rowToImport[4] = "f_order_id"; // E : Fremdauftragsnummer
$rowToImport[5] = "f_customer_id"; // F : Warenempfänger (spezielle Kundennummer)
$rowToImport[6] = "f_tr_comp"; // G : Firma Anlieferung
$rowToImport[7] = "f_tr_cs_freetext"; // H : Ansprechpartner (Person Anlieferung / Bemerkung)
$rowToImport[8] = "f_tr_comp2"; // I : Auslieferangaben (Firma2 Anlieferung)
$rowToImport[9] = "f_ad_street_hsno"; // J : Adresse.Straße_Hausnummer
$rowToImport[10] = "f_ad_country"; // K : Adresse.Land
$rowToImport[11] = "f_ad_zipcode"; // L : Adresse.PLZ
$rowToImport[12] = "f_ad_city"; // M : Adresse.Ort
$rowToImport[13] = "f_dummy_01"; // N : ?
$rowToImport[14] = "f_trat_packingpieces"; // O : Packstücke
$rowToImport[15] = "f_trat_palets"; // P : Paletten
$rowToImport[16] = "f_trat_weight"; // Q : Gewicht
$rowToImport[17] = "f_tr_person"; // R : Ansprechpartner
$rowToImport[18] = "f_tr_remark2"; // S : Kundenbestellnummer (Bemerkung)
$rowToImport[19] = "f_tr_remark3"; // T : Sendungsidentifikationsnummer (Bemerkung)
$rowToImport[20] = "f_dummy_04"; // U : ?
$rowToImport[21] = "f_dummy_05"; // V : ?
$rowToImport[22] = "f_tr_remark4"; // W : Bemerkung (4.) [Anlieferbemerkung]
$rowToImport[23] = "f_dummy_06"; // X : ?
$rowToImport[24] = "f_tr_phone"; // Y : Telefon
endif;
$rowToImportLen = count($rowToImport);
// Read file to import
$data = importCSV($importFile, $delimiter, "1");
$dataLen = count($data);
// Loop all rows (EXCEPT header row [$j = 1])
for ($j = 0; $j < $dataLen; $j++) {
// Loop for all fields of $fields of the row
for ($i = 0; $i < $rowToImportLen; $i++) {
${$rowToImport[$i]} = $data[$j][$i];
}
$f_tour_no = mcStrWrap($f_tour_no);
$f_shipment_mode = mcStrWrap($f_shipment_mode);
$f_jb_orderdate = mcStrWrap($f_jb_orderdate);
$f_jb_ordertime = substr($f_jb_orderdate, 0,4) . "-" . substr($f_jb_orderdate, 4,2) . "-" . substr($f_jb_orderdate, 6,2) . " 06:00:00";
$f_tr_commission_no = mcStrWrap($f_tr_commission_no);
$f_order_id = mcStrWrap($f_order_id);
$f_customer_id = mcStrWrap($f_customer_id);
$f_tr_comp = mcStrWrap($f_tr_comp);
$f_tr_comp2 = mcStrWrap($f_tr_comp2);
$f_tr_cs_freetext = mcStrWrap($f_tr_cs_freetext);
// $f_tr_remark = mcStrWrap($f_tr_remark);
$f_tr_remark = ""; // Init
$f_ad_street_hsno = mcStrWrap($f_ad_street_hsno);
$f_ad_country = mcStrWrap($f_ad_country);
if ($f_ad_country == "" || $f_ad_country == "D") : $f_ad_country = "DE"; endif;
$f_ad_zipcode = mcStrWrap($f_ad_zipcode);
$f_ad_city = mcStrWrap($f_ad_city);
$f_tr_phone = mcStrWrap($f_tr_phone);
$f_dummy_01 = mcStrWrap($f_dummy_01);
$f_trat_packingpieces = mcStrWrap($f_trat_packingpieces);
$f_trat_palets = mcStrWrap($f_trat_palets);
$f_trat_weight = mcStrWrap($f_trat_weight);
$f_trat_weight = str_replace (",", ".", $f_trat_weight);
$f_tr_person = mcStrWrap($f_tr_person);
$f_tr_remark2 = mcStrWrap($f_tr_remark2);
$f_tr_remark3 = mcStrWrap($f_tr_remark3);
$f_dummy_04 = mcStrWrap($f_dummy_04);
$f_dummy_05 = mcStrWrap($f_dummy_05);
$f_dummy_06 = mcStrWrap($f_dummy_06);
$f_tr_remark4 = mcStrWrap($f_tr_remark4);
// $f_jb_totalprice = str_replace (",", ".", $f_jb_totalprice);
if ($f_tr_remark2 != "") : $f_tr_remark .= " | Kundenbestellnummer: " . $f_tr_remark2; endif;
if ($f_tr_remark3 != "") : $f_tr_remark .= " | Sendungsidentifikationsnummer: " . $f_tr_remark3; endif;
// if ($f_tr_remark4 != "") : $f_tr_remark .= " | " . $f_tr_remark4; endif;
$f_trat_remark = $f_trat_palets;
// Set vehicle and courier
$crId = "";
/*
$crSid = $tourVehicleArray[$f_tour_no];
if ($crSid != "") :
$crId = getFieldValueFromId("courier","cr_sid",$crSid,"cr_id");
endif;
*/
$crEid = $tourCourierArray[$f_tour_no];
if ($crEid != "") :
$crId = getFieldValueFromId("courier","cr_eid",$crEid,"cr_id");
$crSid = $tourSIDArray[$f_tour_no];
endif;
$jbStatus = "9";
$jbTaketime = "";
if ($crId != "" && is_numeric($crId)) :
// $jbStatus = "1"; // jb_status will be set after the whole job is generated
$jbTaketime = $currentTime;
$useJbNewArray = true;
endif;
$jbType = "";
$jbFinishtime = "";
$jbRemark = "";
$vhtId = "";
$jbCrFilter = "";
$sum_totalprice = 0;
$f_jb_cr_price = 0;
$jbCrvhWeight = 0;
$jbCrvhLength = 0;
$jbCrvhWidth = 0;
$jbCrvhHeight = 0;
$jbCrvhPosition = 0;
echo $f_tour_no . ";" . $f_shipment_mode . ";" . $f_jb_orderdate . ";" . $f_tr_commission_no . ";" . $f_order_id . ";" . $f_customer_id . ";";
echo $f_tr_comp . ";" . $f_tr_comp2 . ";" . $f_tr_remark . ";" . $f_ad_street_hsno . ";" . $f_ad_country . ";" . $f_ad_zipcode . ";";
echo $f_ad_city . ";" . $f_tr_phone . ";" . $f_tr_person . ";" . $f_tr_remark2 . ";" . $f_tr_remark3 . ";" . $f_tr_remark4 . ";";
echo "<br>";
// Check for existence of the imported order number (for the same day ONLY)
$gdcEntryExists = false;
// if (existsEntry("genericdatacontainer",array("gdc_obj_type","tr","gdc_gen_fieldname","info_2","gdc_content",$f_tr_commission_no,"gdc_context","LYRECO"))) :
if (existsEntry("genericdatacontainer",array("gdc_obj_type","tr","gdc_gen_fieldname","check_exist","gdc_content",$f_tr_commission_no . "_" . $currentDate,"gdc_context","LYRECO"))) :
$gdcEntryExists = true;
endif;
// Do NOT import if LYRECO number does exist !!!!
if (!$gdcEntryExists) :
// Insert new article
if ($executeImportProcess == "1") :
TA("B");
if ($cscIdPayer == "") :
// Get root costcenter
$cscIdPayer = getFieldValueFromClause("costcenter", "csc_id", "cs_id = '" . $csId . "' AND (isnull(csc_pre_id) OR csc_pre_id = '')");
endif;
/*
$crId = "";
$crSid = "";
if ($crvhId != "") :
$crId = getFieldValueFromId("couriervehicle","crvh_id",$crvhId,"cr_id");
if ($crId != "") :
$crSid = $vhtPrefix . $f_crvh_sid;
endif;
endif;
*/
$txValue = "4";
$txSign = "V";
$noValidationOfAddress = true;
$jbTourdataZipcode = $csAddress["zipcode"] . ";" . $f_ad_zipcode;
$jbTourdataCity = $csAddress["city"] . ";" . $f_ad_city;
$jbTourdataCountry = "DE;DE";
$jbTourdata = $jbTourdataZipcode . "|" . $jbTourdataCity . "|" . $jbTourdataCountry;
// Insert address
$tmpArray = insertAddress($f_ad_street_hsno, $f_ad_zipcode, $f_ad_city, "", $f_ad_country, $noValidationOfAddress);
$ad_id_new = $tmpArray[0];
$outText .= "AD_ID : " . $ad_id_new . " | ";
if ($fire) :
// Insert new job because new cartage note does begin
if ($remTourNo == "" || $remTourNo != $f_tour_no) :
$jbIdNew = "";
// Remove existing tourname
updateStmt("job","jb_tourname",$f_tour_no,array("jb_tourname",""), "jb_tourname = '" . $f_tour_no . "'");
// Insert job
insertStmt("job", array("hq_id", $hqId, "csc_id", "", "vht_id", $vhtId, "csc_id_payer", $cscIdPayer, "csc_id_related", "0", "jb_payment", "0",
"jb_ordertime", $f_jb_ordertime, "jb_reserv", "1", "cr_id", $crId, "cr_sid", $crSid, "cr_id_order", $crId,
"jb_cr_filter", $jbCrFilter, "jb_cr_filter_opt", "", "jb_waitstorno", "0",
"jb_taketime", $jbTaketime, "jb_status", $jbStatus, "jb_autoranking", "0", "jb_type", $jbType,
"jb_incomplete", "0", "jb_globaljob", "0", "jb_tourname", $f_tour_no,
"jb_finishtime", $jbFinishtime, "emp_id", $usr_id,
"jb_serviceprice", "0", "jb_fixprice", $sum_totalprice, "jb_totalprice", $sum_totalprice, "jb_subtotalprice", $sum_totalprice,
"jb_cr_price", $f_jb_cr_price, "jb_cr_subprice", $f_jb_cr_price,
"jb_postage", "0", "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", "0", "jb_dispoinfo", "",
"jb_sales_tax_rate", $txValue, "jb_sales_tax_rate_sign", $txSign, "jb_timeunits", "0",
"jb_service", "", "jb_booktime", ""));
$jbIdNew = getLastInsertId();
$jobNewArray[] = $jbIdNew;
$trSort = 2; // Init for 2nd station equals first delivery !!!!
$tratSort = 1; // Init all serial numbers !!!!
$remTourNo = $f_tour_no;
endif;
// Check for inserted job
if ($jbIdNew != "") :
// Insert stations
if ($trSort == 2) :
$trStatus = "0";
$trFinishtime = "";
if ($pickUpStationFinishedByDefault) :
$trStatus = "1";
$trFinishtime = $currentTime;
endif;
// Insert pick up station during first iteration
insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $adIdFrom, "tr_sort", "1", "tr_comp", "Lyreco", "tr_comp2", "",
"tr_hsno", $trHsnoFrom, "tr_floor", $f_ad_floor, "csc_id", $cscIdPayer, "tr_status", $trStatus, "tr_finishtime", $trFinishtime,
"tr_commission_no", "", "tr_ware_from_to", "",
"tr_person", "", "tr_phone", "", "tr_remark", ""));
$trIdPickUpNew = getLastInsertID();
endif;
insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $ad_id_new, "tr_sort", $trSort, "tr_comp", $f_tr_comp, "tr_comp2", "",
"tr_hsno", "", "csc_id", $cscIdPayerExtern, "tr_status", "0",
"tr_commission_no", $f_tr_commission_no, "tr_ware_from_to", "",
"tr_person", $f_tr_person, "tr_phone", $f_tr_phone, "tr_remark", $f_tr_remark, "tr_cs_freetext", $f_tr_cs_freetext));
$trIdNew = getLastInsertID();
// Insert tourservice data
// !!!! MIT tr_id !!!! insertStmt("tourservice", array("tr_id", $trIdNew, "jb_id", $jbIdNew, "csc_id", $cscIdPayer, "tr_sort", $trSort,
insertStmt("tourservice", array("tr_id", $trIdNew, "jb_id", $jbIdNew, "csc_id", $cscIdPayer, "tr_sort", $trSort,
"srv_id", "0", "trs_srv_name", "Fixpreis", "srvt_id", "0", "trs_srvt_name", "",
"trs_price", $sum_totalprice));
// Generate invoice text
// mk_jb_invtext($jbIdNew, false);
// ****
// 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;
// ****
// Fremdauftragsnummer "$f_order_id"
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "info_0", "gdc_content", $f_order_id, "gdc_context", "LYRECO"));
// Kundennummer "$f_customer_id"
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "info_1", "gdc_content", $f_customer_id, "gdc_context", "LYRECO"));
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "info_cust_no", "gdc_content", $f_customer_id, "gdc_context", "LYRECO"));
// Lieferscheinnummer "$f_tr_commission_no"
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "info_2", "gdc_content", $f_tr_commission_no, "gdc_context", "LYRECO"));
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "check_exist", "gdc_content", $f_tr_commission_no . "_" . $currentDate, "gdc_context", "LYRECO"));
// Sendungsnummer "f_tr_remark3"
insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "info_3", "gdc_content", $f_tr_remark3, "gdc_context", "LYRECO"));
// Insert tourarticle data (delivery stations)
insertStmt("tourarticle", array("tr_id", $trIdNew, "jb_id", $jbIdNew, "tr_sort", $trSort, "trat_sort", "1", "at_id", "", "trat_quantity", "0",
"trat_weight", $f_trat_weight, "trat_price", "0", "trat_packingpieces", $f_trat_packingpieces, "trat_serialno", $f_tr_commission_no,
"trat_remark", $f_trat_remark, "trat_createtime", $currentTime));
// Insert tourarticle data (pick up station only)
// ATTENTION: Execution only if pick-up station is NOT finished by default
if (!$pickUpStationFinishedByDefault) :
insertStmt("tourarticle", array("tr_id", $trIdPickUpNew, "jb_id", $jbIdNew, "tr_sort", "1", "trat_sort", $tratSort, "at_id", "", "trat_quantity", "0",
"trat_weight", $f_trat_weight, "trat_price", "0", "trat_packingpieces", $f_trat_packingpieces, "trat_serialno", $f_tr_commission_no,
"trat_remark", $f_trat_remark, "trat_createtime", $currentTime));
$tratSort++;
endif;
$trSort++;
$executionCount++;
endif;
TA("C");
TA("E");
endif;
endif;
else :
$outText .= getLngt("Der Datensatz existiert schon! Es erfolgte kein Import!") . " [" . $f_order_id . "]<br>";
endif;
}
// Set generated jobs to status "taken"
$jobNewArrayLen = count($jobNewArray);
if ($jobNewArrayLen > 0) :
for ($i = 0; $i < $jobNewArrayLen; $i++) :
updateStmt("job", "jb_id", $jobNewArray[$i], array("jb_status", "1"));
endfor;
endif;
$outText .= getLngt("Einträge in der Importdatei: " . $dataLen . "<br>");
$outText .= getLngt("Verarbeitete Einträge: " . $executionCount . "<br>");
else :
$statusMessage .= getLngt("Die angegebene Datei scheint nicht kompatibel zur angeforderten Importfunktionalität!");
endif;
else :
$statusMessage .= getLngt("Die angegebene Datei existiert nicht!");
endif;
else :
$statusMessage .= getLngt("Es wurde keine Datei spezifiziert!");
endif;
?>
<html>
<head>
<title><?php echo $pageTitel ?></title>
<link rel="stylesheet" type="text/css" href="../css/phoenix.css">
<style type="text/css">
<?php include_once ("../css/navigation.css.php"); ?>
</style>
<?php include_once ("../include/js_framework.inc.php"); ?>
<script type="text/javascript">
<!--
// NAVIGATION
<?php echo $jsMenuOut; ?>
function finishPageExecuteImportProcess(f_act) {
document.forms[0].f_act.value=f_act;
document.forms[0].executeImportProcess.value = '1';
document.forms[0].submit();
};
function onBodyLoad() {
displayStatusMessage();
var closeWindow = '<?php echo $closeWindow ?>';
if (closeWindow == '1') {
opener.document.forms[0].submit();
window.close();
};
};
-->
</script>
</head>
<body onLoad="<?php echo $phpCurrentNavigationOnLoad ?>onBodyLoad();">
<?php echo $phpMenuOut ?>
<?php echo $phpReducedMenuOut ?>
<?php echo $phpPageTitelOut ?>
<div class="maincontent" name="maincontent" id="maincontent">
<div>
<form name="import_form" action="../import/import_LYRECO.php" method="post">
<input type="hidden" name="f_act" value="">
<?php echo $phpCurrentNavigationInputHidden ?>
<input type="hidden" name="deactivateMenu" value="<?php echo ec($deactivateMenu) ?>">
<input type="hidden" name="importFile" value="<?php echo $importFile; ?>">
<input type="hidden" name="executeImportProcess" value="<?php echo $executeImportProcess; ?>">
<input type="hidden" name="objType" value="<?php echo $objType; ?>">
<input type="hidden" name="objId" value="<?php echo $objId; ?>">
<?php echo htmlDivLineSpacer("10px"); ?>
<?php
if ($showExecutionProcessButton && $executeImportProcess != "1") :
echo defineButtonType10(getLngt("Import starten"), "action_import", "finishPageExecuteImportProcess('executeImport');", "200");
echo htmlDivLineSpacer("5px");
echo defineButtonType10(getLngt("Schließen"), "action_close", "window.close();", "200");
echo htmlDivLineSpacer("5px");
endif;
?>
<?php echo htmlDivLineSpacer("20px"); ?>
<div>
<table border="1" margin="10" padding="10">
<tr>
<td style="vertical-align:top;">
<?php echo $outText; ?>
</td>
</tr>
</table>
</div>
</form>
</div>
</div>
</body>
</html>