" . getLngt("IMPORTDATEI:") . " " . $filename . "

"; // Mapping "tour id" to "vehicle SID" /* $tourVehicleArray = array(); $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"; */ $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"; */ function mcStrWrap($aStr) { $aStr = str_replace("'", "", $aStr); $aStr = removeFieldSigns($aStr); // $aStr = str_replace("'", "\'", $aStr); $aStr = str_replace("\"", '', $aStr); return $aStr; } echo "importFile" . $importFile . "
"; echo "hqId" . $hqId . "
"; echo "csId" . $csId . "
"; 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_COUNT_") === false)) : $executionCount = 0; $insertCount = 0; $updateCount = 0; $failedCount = 0; $remTourNo = ""; $jbIdNew = 0; $trSort = 0; // Init for 1st station $tratSort = 1; // Init all serial numbers !!!! $rowToImport = array(); $parImportFieldsGroup == ""; if ($groupId != "") : $parImportFieldsGroup = getParameterValue("0", "IMPORT_TOURS_JOB_FIELDS", "0"); endif; if ($parImportFieldsGroup != "") : $rowToImport = spliti(",", $parImportFieldsGroup); else : $rowToImport[0] = "f_no_row"; // A : (Laufende) Nr. (Datensatz) $rowToImport[1] = "f_jb_tourname"; // B : Auftrag Bezeichnung (Tourname) $rowToImport[2] = "f_tr_commission_no"; // C : Station Kommissionsnummer $rowToImport[3] = "f_tr_comp"; // D : Station Bezeichnung $rowToImport[4] = "f_tr_remark"; // E : Station Bemerkung $rowToImport[5] = "f_tr_sort"; // F : Station Position in Tour $rowToImport[6] = "f_ad_zipcode"; // G : Station PLZ $rowToImport[7] = "f_ad_city"; // H : Station Ort $rowToImport[8] = "f_ad_street"; // I : Station Straße $rowToImport[9] = "f_tr_hsno"; // J : Station Hausnummer $rowToImport[10] = "f_tr_arrival_time"; // K : Station Ankunft $rowToImport[11] = "f_tr_departure_time"; // L : Station Abfahrt $rowToImport[12] = "f_tr_point2point_time"; // M : Station Strecke $rowToImport[13] = "f_tr_point2point_min"; // N : Auftrag Fixe Dauer $rowToImport[14] = "f_dummy_01"; // O : ? endif; // Special handling $parFieldCmpComp = getParameterValue("0", "IMPORT_TOURS_FIELD_TR_COMP", $hqId); if ($parFieldCmpComp == "") : $parFieldCmpComp = getParameterValue("0", "IMPORT_TOURS_FIELD_TR_COMP", "0"); 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_no_row = mcStrWrap($f_no_row); $f_jb_tourname = mcStrWrap($f_jb_tourname); $f_tr_commission_no = mcStrWrap($f_tr_commission_no); $f_tr_comp = mcStrWrap($f_tr_comp); $f_tr_remark = mcStrWrap($f_tr_remark); $f_tr_sort = mcStrWrap($f_tr_sort); $f_ad_zipcode = mcStrWrap($f_ad_zipcode); $f_ad_city = mcStrWrap($f_ad_city); $f_ad_street = mcStrWrap($f_ad_street); $f_tr_hsno = mcStrWrap($f_tr_hsno); $f_tr_arrival_time = mcStrWrap($f_tr_arrival_time); $f_tr_departure_time = mcStrWrap($f_tr_departure_time); $f_tr_point2point_time = mcStrWrap($f_tr_point2point_time); $f_tr_point2point_min = mcStrWrap($f_tr_point2point_min); // Check for existing headline if ($j > 0 || ($f_no_row != "" && is_numeric($f_no_row))) : if ($parFieldCmpComp == "0") : $tmpArray = spliti("_", $f_tr_comp); // Do nothing elseif ($parFieldCmpComp == "1") : $tmpArray = spliti("__", $f_tr_comp); // Two underline chars as delimiter $f_tr_person = $tmpArray[1]; $f_tr_comp = $tmpArray[0]; else : // Default $tmpArray = spliti("_", $f_tr_comp); $f_tr_person = $tmpArray[0]; endif; $tmpArray = spliti("_", $f_tr_remark); $f_tr_phone = $tmpArray[2]; $f_tr_phone = str_replace ("Tel:", "", $f_tr_phone); $f_tr_phone = eregPhoneNo($f_tr_phone); if ($f_tr_hsno == "") : $f_tr_hsno = "."; endif; if ($f_tr_arrival_time != "") : $f_tr_remark .= "\n\nAnkunft: " . $f_tr_arrival_time; endif; if ($f_tr_departure_time != "") : $f_tr_remark .= "\n\nAbfahrt" . $f_tr_departure_time; endif; // $f_tr_remark .= $f_tr_point2point_time // $f_tr_remark .= $f_tr_point2point_min // Move commission number to station remark if ($f_tr_commission_no != "") : $f_tr_remark .= "\n\n[*" . $f_tr_commission_no . "*]"; $f_tr_commission_no = ""; endif; // Clock time depends on headquarters $clockTime = "06:00:00"; /* if ($hqId == "3") : $clockTime = "12:45:00"; endif; */ if ($f_jb_tourname != "") : $f_jb_orderdate = substr($f_jb_tourname, -8); $f_jb_ordertime = "20" . substr($f_jb_orderdate,6,2) . "-" . substr($f_jb_orderdate,2,2) . "-" . substr($f_jb_orderdate,0,2) . " " . $clockTime; endif; // The first row of the tour contains the tour name. The following rows of the same tour are empty for $f_jb_tourname !!!! if ($f_jb_tourname == "") : $f_jb_tourname = $remTourNo; endif; // Set vehicle and courier $crId = ""; /* $crSid = $tourVehicleArray[$f_jb_tourname]; if ($crSid != "") : $crId = getFieldValueFromId("courier","cr_sid",$crSid,"cr_id"); endif; */ $crEid = $tourCourierArray[$f_jb_tourname]; if ($crEid != "") : $crId = getFieldValueFromId("courier","cr_eid",$crEid,"cr_id"); endif; $jbStatus = "9"; $jbTaketime = ""; if ($crId != "" && is_numeric($crId)) : $jbStatus = "1"; $jbTaketime = $currentTime; 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_no_row . ";" . $f_jb_tourname . ";" . $f_tr_commission_no . ";" . $f_tr_comp . ";" . $f_tr_remark . ";" . $f_tr_sort . ";" . $f_ad_zipcode . ";"; echo $f_ad_city . ";" . $f_ad_street . ";" . $f_tr_hsno; // echo ";" . $f_tr_arrival_time . ";" . $f_tr_departure_time . ";" . $f_tr_point2point_time . ";"; // echo $f_tr_point2point_min . ";" . $f_tr_person . ";" . $f_tr_phone . ";" . $f_jb_ordertime; echo "
"; // Check for existence of the imported "tour name" AND "station number" (unique for station) $gdcEntryExists = false; if (existsEntry("genericdatacontainer",array("gdc_obj_type","tr","gdc_gen_fieldname","check_exist","gdc_content",$f_jb_tourname . " " . $f_tr_sort,"gdc_context","COUNT"))) : $gdcEntryExists = true; endif; // Do NOT import if TOURS 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; if ($remTourNo == "" || $remTourNo == $f_jb_tourname) : if ($jbTourdataZipcode != "") : $jbTourdataZipcode .= ";"; endif; $jbTourdataZipcode .= $f_ad_zipcode; if ($jbTourdataCity != "") : $jbTourdataCity .= ";"; endif; $jbTourdataCity .= $f_ad_city; if ($jbTourdataCountry != "") : $jbTourdataCountry .= ";"; endif; $jbTourdataCountry .= "DE"; endif; // Insert address $tmpArray = insertAddress($f_ad_street, $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_jb_tourname) : // Finalize currently imported job // Write "jb_tourdata" of the job currently imported if ($remTourNo != "" && $jbIdNew != "" && is_numeric($jbIdNew)) : $jbTourdata = $jbTourdataZipcode . "|" . $jbTourdataCity . "|" . $jbTourdataCountry; updateStmt("job","jb_id",$jbIdNew,array("jb_tourdata",$jbTourdata)); endif; // Remove existing tourname updateStmt("job","jb_tourname",$f_jb_tourname,array("jb_tourname",""), "jb_tourname = '" . $f_jb_tourname . "'"); // Tour data /* if ($jbIdNew != "" && is_numeric($jbIdNew)) : // updateStmt("job","jb_id",$jbIdNew,array("jb_tourdata",$jbTourdata)); endif; */ $jbIdNew = ""; // Init // 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_jb_tourname, "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(); $trSort = 0; // Init for 1st station $tratSort = 1; // Init all serial numbers !!!! $remTourNo = $f_jb_tourname; // Init for the next job to be imported $jbTourdata = ""; // Init with current values $jbTourdataZipcode = $f_ad_zipcode; $jbTourdataCity = $f_ad_city; $jbTourdataCountry = "DE"; endif; // Check for inserted job if ($jbIdNew != "") : $trSort++; insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $ad_id_new, "tr_sort", $trSort, "tr_comp", $f_tr_comp, "tr_comp2", "", "tr_hsno", $f_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 /* 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)); */ insertStmt("tourservice", array("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); // Tourname // insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "info_0", "gdc_content", $f_jb_tourname . " " . $f_tr_sort, "gdc_context", "COUNT")); insertStmt("genericdatacontainer", array("gdc_obj_type", "tr", "gdc_obj_id", $trIdNew, "gdc_gen_fieldname", "check_exist", "gdc_content", $f_jb_tourname . " " . $f_tr_sort, "gdc_context", "COUNT")); // 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; */ $executionCount++; endif; TA("C"); TA("E"); endif; endif; else : $outText .= getLngt("Der Datensatz existiert schon! Es erfolgte kein Import!") . " [" . $f_jb_tourname . " " . $f_tr_sort . "]
"; endif; endif; // Check for headline } // If at least onne imported job does exist ($jbIdNew > 0) then finalize last imported job // Write "jb_tourdata" of the job currently imported if ($jbIdNew != "" && is_numeric($jbIdNew)) : $jbTourdata = $jbTourdataZipcode . "|" . $jbTourdataCity . "|" . $jbTourdataCountry; updateStmt("job","jb_id",$jbIdNew,array("jb_tourdata",$jbTourdata)); endif; $outText .= getLngt("Einträge in der Importdatei: " . $dataLen . "
"); $outText .= getLngt("Verarbeitete Einträge: " . $executionCount . "
"); 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; ?> <?php echo $pageTitel ?>