getOne("SELECT MAX(jb_id) FROM job WHERE (jb_id > 260000 AND jb_id < 265001)"); if ($f_jb_id_child == "") $f_jb_id_child = 260001; else $f_jb_id_child++; $tVal = 1.19; if ($mode == "SCHNELSEN") : $cscIdRelated = "1"; $vhtPrefix = "HH"; $cVal = 0.95; $cBool = true; $tr1_adId = "432200"; $tr1_cscId = "1"; $tr1_comp = "IKEA Schnelsen"; elseif ($mode == "MOORFLEET") : $cscIdRelated = "2"; $vhtPrefix = "HH"; $cVal = 0.95; $cBool = true; $tr1_adId = "433346"; $tr1_cscId = "2"; $tr1_comp = "IKEA Moorfleet"; elseif ($mode == "ALTONA") : $cscIdRelated = "17051"; $vhtPrefix = "HH"; $cVal = 0.95; $cBool = true; $tr1_adId = "439426"; $tr1_cscId = "17051"; $tr1_comp = "IKEA Altona"; endif; // Timeunits $jbTimeUnits = "2"; $jbTimeUnits_M = "4"; // Service $jbService = "1"; $jbService_M = "6"; // Neumöbelmontage if ($hqId == "") : $hqId = $hq_id; endif; // Mapping for payment types // 1 = EC-Pin, 2 = EC-Last, 3=Family, 4= BC, 5=Bar [6=Bar-Mont., 7=EC-Pin-Mont., 8=EC-LAst-Mont., 9=Famil.Mont., 10=Rechnung] $paymentTypeMappingArray = array(); $paymentTypeMappingArray[0] = 0; $paymentTypeMappingArray[1] = 1; $paymentTypeMappingArray[2] = 2; $paymentTypeMappingArray[3] = 10; $paymentTypeMappingArray[4] = 11; $paymentTypeMappingArray[5] = 0; $paymentTypeMappingArray[6] = 0; $paymentTypeMappingArray[7] = 1; $paymentTypeMappingArray[8] = 2; $paymentTypeMappingArray[9] = 10; $paymentTypeMappingArray[10] = 5; // Array for "jobpaymentcollection" $jbpcArray = array(); $jbpcSamsFlagArray = array(); $outText = "" . getLngt("IMPORTDATEI:") . " " . $filename . "

"; function mcStrWrap($aStr) { // $aStr = str_replace("'", "", $aStr); // $aStr = str_replace("'", "\'", $aStr); // $aStr = removeFieldSigns($aStr); // $aStr = str_replace("'", "\'", $aStr); // $aStr = str_replace('\"', '', $aStr); return $aStr; } // $hourStart : Begin of interval (from metatype mapped value) function checkAvailabilityForJob ($crvhId, $currDay, $hourStart, $hourEnd, $jbId, $csId) { global $db, $PHP_SELF; global $f_jb_ordertime, $orderTimePair, $outText, $f_jb_id_child, $generateDeliveryJob, $generateInstallationJob; $retVal = ""; // echo "crvhId : " . $crvhId . "
"; // echo "currDay : " . $currDay . "
"; // echo "hourStart : " . $hourStart . "
"; // echo "hourEnd : " . $hourEnd . "
"; // echo "jbId : " . $jbId . "
"; // echo "csId : " . $csId . "
"; if ($crvhId != "" && $currDay != "" && $hourStart != "" && $hourEnd != "" && $jbId != "" && $csId != "") : echo "jbId : " . $jbId . "
"; // Check the availability of the specified vehicle for the requested interval $hourTimeUnits = 6; $hour = $hourStart; // INIT (!!!!) $jbId_M = $f_jb_id_child; // Get SID from ID $crvhSid = getFieldValueFromId("couriervehicle", "crvh_id", $crvhId, "crvh_sid"); $outText .= "CRVH_SID : " . $crvhSid . " | "; echo "crvhSid : " . $crvhSid . "
"; // Get max ordertime of the job of the current vehicle with the largest ordertime on this day $jbMaxOrdertime = getMaxOfField("job", "jb_ordertime", "cr_sid = '" . $crvhSid . "' AND jb_status IN ('9', '1') AND LEFT(jb_ordertime, 10) = '" . $currDay . "' AND SUBSTRING(jb_ordertime,12,2) >= '" . $hourStart . "' AND SUBSTRING(jb_ordertime,12,2) <= '" . $hourEnd . "'"); echo "jbMaxOrdertime : " . $jbMaxOrdertime . "
"; if ($jbMaxOrdertime != "") : $hour = intval(substr($jbMaxOrdertime,11,2)) + 1; endif; echo "hour : " . $hour . "
"; if ($hour != "") : $intHourStart = intval($hour); echo "intHourStart : " . $intHourStart . "
"; $intHourEnd = intval($hourEnd); echo "intHourEnd : " . $intHourEnd . "
"; for ($i = $intHourStart; $i <= $intHourEnd; $i++) : $startTimeslotToBeChecked = $currDay . "_" . pad($i,2) . "_00"; $endTimeslotToBeChecked = $currDay . "_" . pad($i,2) . "_05"; $capacityProblem = checkAvailableVehicleCapacity($crvhId, $currDay, $startTimeslotToBeChecked, $endTimeslotToBeChecked, $jbId); if ($capacityProblem == "") : // Delivery OR single installation job if ($generateDeliveryJob) : $startTimeslotToBeChecked = $currDay . "_" . pad($i,2) . "_00"; $endTimeslotToBeChecked = $currDay . "_" . pad($i,2) . "_01"; elseif (!$generateDeliveryJob && $generateInstallationJob) : $startTimeslotToBeChecked = $currDay . "_" . pad($i,2) . "_00"; $endTimeslotToBeChecked = $currDay . "_" . pad($i,2) . "_05"; endif; $res = updateStmt("vehicledisposition", "crvh_id", $crvhId, array("jb_id", $jbId), "vhd_timeslot >= '" . $startTimeslotToBeChecked . "' AND vhd_timeslot <= '" . $endTimeslotToBeChecked . "'"); if ($db->affected_rows > 0) : updateVehicleAvailability($crvhId, $csId, $startTimeslotToBeChecked, $hourTimeUnits); // Write redundant data for delivery appointment search later on echo "VEHICLEDISPOSITION: DELIVERY UPDATE ON TIMELINE
"; // Check vehicle restrictions (weight, positions, etc.) // if ($jbId != "") : // $atWeightJb = getTratTotalweight($jbId); // Get the total weight of all articles of the specified job // $capacityFreeWeight = getFieldValueFromClause("vehicleavailability","vha_weight","crvh_id = '" . $crvhId . "' AND vha_day = '" . $currDay . "'"); // Get free weight capacity of the specified vehicle // $capacityFreeWeight = $capacityFreeWeight - $atWeightJb; // updateStmt("vehicleavailability", "crvh_id", $crvhId, array("vha_weight", $capacityFreeWeight), "vha_day = '" . $currDay . "'"); // endif; // Set global defined parameter $f_jb_ordertime .= " " . pad($i,2) . ":00:00"; $orderTimePair[0] = $f_jb_ordertime; $outText .= "JB_ORDERTIME : " . $f_jb_ordertime . " | "; $retVal = "OK"; if (!$generateInstallationJob) : break; // Stop iteration endif; endif; // Installion job if ($generateDeliveryJob && $generateInstallationJob) : $startTimeslotToBeChecked = $currDay . "_" . pad($i,2) . "_02"; $endTimeslotToBeChecked = $currDay . "_" . pad($i,2) . "_05"; $res = updateStmt("vehicledisposition", "crvh_id", $crvhId, array("jb_id", $jbId_M), "vhd_timeslot >= '" . $startTimeslotToBeChecked . "' AND vhd_timeslot <= '" . $endTimeslotToBeChecked . "'"); if ($db->affected_rows > 0) : updateVehicleAvailability($crvhId, $csId, $startTimeslotToBeChecked, $hourTimeUnits); // Write redundant data for delivery appointment search later on echo "VEHICLEDISPOSITION: INSTALLATION UPDATE ON TIMELINE
"; // Check vehicle restrictions (weight, positions, etc.) // if ($jbId != "") : // $atWeightJb = getTratTotalweight($jbId); // Get the total weight of all articles of the specified job // $capacityFreeWeight = getFieldValueFromClause("vehicleavailability","vha_weight","crvh_id = '" . $crvhId . "' AND vha_day = '" . $currDay . "'"); // Get free weight capacity of the specified vehicle // $capacityFreeWeight = $capacityFreeWeight - $atWeightJb; // updateStmt("vehicleavailability", "crvh_id", $crvhId, array("vha_weight", $capacityFreeWeight), "vha_day = '" . $currDay . "'"); // endif; // Set global defined parameter $f_jb_ordertime .= " " . pad($i,2) . ":20:00"; $orderTimePair[1] = $f_jb_ordertime; $outText .= "JB_ORDERTIME : " . $f_jb_ordertime . " | "; $retVal = "OK"; break; // Stop iteration endif; endif; endif; endfor; endif; endif; return $retVal; } // ------------------------------------------------------------------------------------------ // ---- PREPARSER JOBSERVICE START ---------------------------------------------------------- // ------------------------------------------------------------------------------------------ $importFileJobService = str_replace("_JOB_", "_JOBSERVICE_", $importFile); echo $importFile . "
"; echo $importFileJobService . "
"; //if ($fire && $executeImportProcess == "1" && $importFile != "" && $hqId != "" && is_numeric($hqId) && $cscIdRelated != "" && is_numeric($cscIdRelated) && file_exists($importFileJobService)) : if ($importFile != "" && $hqId != "" && is_numeric($hqId) && $cscIdRelated != "" && is_numeric($cscIdRelated) && file_exists($importFileJobService)) : echo "Preparser
\n"; // Service definition $serviceArray = array(); // idnum idname fulo_fahrer fulo_monteur provisionsart baulstg $serviceArray[1] = array("Lieferung", true, false, 0, false , "0002"); $serviceArray[2] = array("Auftragspauschale", false, false, 0, false , "ident_0014"); $serviceArray[3] = array("Kuechenmontage", false, true, 2, true , "ident_0013"); $serviceArray[4] = array("KuechenmontageLfdMeter", false, true, 2, true , "0010"); $serviceArray[5] = array("InstallationEGeraetPauschal", false, true, 2, true , "ident_0005"); $serviceArray[6] = array("KuechendemontageGrundPauschale", false, true, 2, true, "ident_0015"); $serviceArray[7] = array("KuechendemontageLfdMeter", false, true, 2, true , "ident_0025"); $serviceArray[8] = array("Aufmass", true, false, 2, false , "ident_0016"); $serviceArray[9] = array("MontageAnfahrt", false, true, 1, false , "ident_0017"); $serviceArray[10] = array("MontageStunde", false, true, 1, false , "ident_0001"); $serviceArray[11] = array("MontageStundeKArbeitsplatte", false, true, 1, false , "ident_0018"); $serviceArray[12] = array("MoebelmontageGrundPauschale", false, true, 1, false , "ident_0009"); $serviceArray[13] = array("Moebelmontage", false, true, 1, false , "0004"); $serviceArray[14] = array("Sofamontage", true, false, 0, false , "ident_0027"); $serviceArray[15] = array("WasseranschlussBadmoebel", false, true, 1, false , "ident_0011"); $serviceArray[16] = array("InstallationTVGeraet", false, true, 1, false , "ident_0019"); $serviceArray[17] = array("InstallationLautsprecher", false, true, 1, false , "ident_0020"); $serviceArray[18] = array("EntsorgungAltmoebel", true, false, 0, false , "NA"); $serviceArray[19] = array("EntsorgungEGeraet", true, false, 0, false , "ident_0021"); $serviceArray[20] = array("ZusatzKilometerLieferung", true, false, 0, false , "0012"); $serviceArray[21] = array("ZusatzKilometerMontage", false, true, 1, false , "0012"); $serviceArray[22] = array("LagergeldAb6Tag", false, false, 0, false , "0003"); $serviceArray[23] = array("EKS", true, false, 0, false , "ident_0004"); $serviceArray[24] = array("Zusatzmontage", false, true, 1, false , "0014"); $serviceArray[25] = array("Zusatzlieferung", true, false, 0, false , "0013"); $serviceArray[26] = array("Wasseranschluss Küche", false, true, 2, true , "ident_0006"); $serviceArray[27] = array("Verpackung", false, false, 0, false , "ident_0010"); $serviceArray[28] = array("Gewichtszuschlag", true, false, 0, false , "0015"); $serviceArray[29] = array("Abholung", true, false, 0, false , "NA"); $serviceArray[30] = array("Austausch", true, false, 0, false , "NA"); $serviceArray[31] = array("BlaueTasche", true, false, 0, false , "ident_0023"); $serviceArray[32] = array("EntsorgungSofa", true, false, 0, false , "0006:1000"); $serviceArray[33] = array("EntsorgungPolsterbett", true, false, 0, false , "0006:1001"); $serviceArray[34] = array("EntsorgungAnbauwand", true, false, 0, false , "0006:1002"); $serviceArray[35] = array("EntsorgungKleinmoebel", true, false, 0, false , "0006:1003"); $serviceArray[36] = array("EntsorgungBett", true, false, 0, false , "0006:1004"); $serviceArray[37] = array("EntsorgungMatratze", true, false, 0, false , "0006:1005"); $serviceArray[38] = array("Expresslieferung", false, false, 0, false , "NA"); $serviceArray[39] = array("Erste_blaue_Tasche", false, false, 0, false , "ident_0023"); $serviceArray[40] = array("Kuechenzusatzmeter", false, true, 2, true , "ident_0024"); $serviceArray[41] = array("Erneute Anfahrt", true, false, 0, false , "NA"); $serviceArray[42] = array("Montageausfall", false, true, 1, false , "NA"); $jobServiceArray = array(); if (true) : $rowToImport = array(); $rowToImport[0] = "f_jb_id"; // A : Job ID, "KV-Nr." $rowToImport[1] = "f_jb_dummy_01"; // B : ???? $rowToImport[2] = "f_order_id"; // C : Commission no. (tr_sort = "2") $rowToImport[3] = "f_voucher"; // D : Commission no. (tr_sort = "1") $rowToImport[4] = "f_businesscard_no"; // E : Business card number $rowToImport[5] = "f_jb_dummy_02"; // F : Business card number $rowToImport[6] = "f_lfdmeter"; // G: Kosten für laufenden Meter Küche $rowToImport[7] = "f_service_flag"; // H: SAMS-Flag $rowToImport[8] = "f_service_id"; // I: Leistungsart => MAPPING !!!!! (Anliegende Tabelle) $rowToImport[9] = "f_paymenttype"; // J: Zahlart => MAPPING (Lieferung und Montage) !!!!! $rowToImport[10] = "f_fzg"; // K: Rechnungsfahrzeug !!!!!!!!!!!!!! $rowToImport[11] = "f_preisev"; // L: Preis ??? $rowToImport[12] = "f_jb_totalprice"; // M: Preis für Service IKEA $rowToImport[13] = "f_jb_cr_price"; // N: Preis für Service Unternehmer (HTM) $rowToImport[14] = "f_preisunt"; // O: Preis ??? $rowToImport[15] = "f_rueckvergikea"; // P: Preis Rückvergütung IKEA $rowToImport[16] = "f_rueckvergunt"; // Q: Preis Rückvergütung Unternehmer (HTM) $rowToImport[17] = "f_anzahlpf"; // R: ??? $rowToImport[18] = "f_rgnrev"; // S: Rechnungsnr. ??? $rowToImport[19] = "f_rgnrevdatum"; // T: Zugehöriges Datum ??? $rowToImport[20] = "f_rgnrikea"; // U: Rechnungsnr. IKEA ??? $rowToImport[21] = "f_rgnrikeadatum"; // V: Zugehöriges Datum ??? $rowToImport[22] = "f_rgnrunt"; // W: Rechnungsnr. Unternehmer ??? $rowToImport[23] = "f_rgnruntdatum"; // X: Zugehöriges Datum ??? $rowToImport[24] = "f_rgnrrueckvergikea"; // Y: Rechnung Rückvergütung IKEA $rowToImport[25] = "f_rgnrrueckvergikeadatum"; // Z: Zugehöriges Datum ??? $rowToImport[26] = "f_rgnrgutikea"; // AA : Rechnungsgutschrift IKEA $rowToImport[27] = "f_rgnrgutikeadatum"; // AB: Zugehöriges Datum ??? $rowToImport[28] = "f_evabgeschlossen"; // AC: Flag $rowToImport[29] = "f_untabgeschlossen"; // AD: Flag $rowToImport[30] = "f_evtosap"; // AE: Flag $rowToImport[31] = "f_unttosap"; // AF: Flag $rowToImport[32] = "f_rueckvergikeatosap"; // AG: Flag $rowToImport[33] = "f_gutikeatosap"; // AH: Flag $rowToImport[34] = "f_kvs"; // AI: Flag $rowToImport[35] = "f_kvs_info"; // AJ: Flag $rowToImport[36] = "f_dummy"; // AK: Dummy $rowToImportLen = count($rowToImport); // Read file to import $dataPre = importCSV($importFileJobService, $delimiter); $dataLen = count($dataPre); // 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]} = $dataPre[$j][$i]; } $f_jb_id = mcStrWrap($f_jb_id); $f_service_id = mcStrWrap($f_service_id); // Delivery if ($serviceArray[$f_service_id][1]) : $jobServiceArray[$f_jb_id][0] = "1"; endif; // Installation if ($serviceArray[$f_service_id][2]) : $jobServiceArray[$f_jb_id][1] = "1"; endif; } endif; endif; // ------------------------------------------------------------------------------------------ // ---- PREPARSER JOBSERVICE END ------------------------------------------------------------ // ------------------------------------------------------------------------------------------ /* if ($fire && $executeImportProcess == "1") : print_r($jobServiceArray); die(); endif; */ if ($importFile != "" && $hqId != "" && is_numeric($hqId) && $cscIdRelated != "" && is_numeric($cscIdRelated)) : if (file_exists($importFile)) : $currentTime = getDateTime("0"); // *********************** // * IMPORT FILE article * // *********************** if (!(strpos($filename, "import_JOB_") === false)) : $executionCount = 0; $insertCount = 0; $updateCount = 0; $failedCount = 0; $rowToImport = array(); $parImportArticleFieldsGroup == ""; if ($groupId != "") : $parImportArticleFieldsGroup = getParameterValue("0", "IMPORT_JOB_FIELDS", "0"); endif; if ($parImportArticleFieldsGroup != "") : $rowToImport = spliti(",", $parImportArticleFieldsGroup); else : // Default $rowToImport[0] = "f_jb_id"; // A : Job ID, "KV-Nr." $rowToImport[1] = "f_jb_dummy_01"; // B : ???? $rowToImport[2] = "f_crvh_sid"; // C : Vehicle SID delivery $rowToImport[3] = "f_crvh_sid_inst"; // D : Vehicle SID installation $rowToImport[4] = "f_jb_createtime"; // E : Creation datetime of the job $rowToImport[5] = "f_jb_ordertime"; // F : Order datetime of the job $rowToImport[6] = "f_jb_daytime"; // G : Daytime of the job $rowToImport[7] = "f_cmp_comp"; // H : Customer delivery name and firstname $rowToImport[8] = "f_ad_street"; // I : Customer delivery.address.street $rowToImport[9] = "f_ad_addon"; // J : Customer delivery.address.addon $rowToImport[10] = "f_ad_zipcode"; // K : Customer delivery.address.zipcode $rowToImport[11] = "f_ad_city"; // L : Customer delivery.address.city $rowToImport[12] = "f_ad_floor"; // M : Customer delivery.address.floor $rowToImport[13] = "f_tr_phone"; // N : Customer phone $rowToImport[14] = "f_inv_ad_name"; // O : Customer invoice name and firstname $rowToImport[15] = "f_inv_ad_street"; // P : Customer invoice.address.street $rowToImport[16] = "f_inv_ad_addon"; // Q : Customer invoice.address.addon $rowToImport[17] = "f_inv_ad_city"; // R : Customer invoice.address.city $rowToImport[18] = "f_inv_ad_zipcode"; // S : Customer invoice.address.zipcode $rowToImport[19] = "f_dummy"; // T : Dummy endif; $rowToImportLen = count($rowToImport); // Read file to import $data = importCSV($importFile, $delimiter); $dataLen = count($data); // Loop all rows (EXCEPT header row [$j = 1]) for ($j = 0; $j < $dataLen; $j++) { print_r($data[$j]); // Loop for all fields of $fields of the row for ($i = 0; $i < $rowToImportLen; $i++) { ${$rowToImport[$i]} = $data[$j][$i]; } $f_jb_id = mcStrWrap($f_jb_id); $f_crvh_sid = mcStrWrap($f_crvh_sid); $f_crvh_sid_inst = mcStrWrap($f_crvh_sid_inst); $f_jb_createtime = mcStrWrap($f_jb_createtime); $f_jb_ordertime = mcStrWrap($f_jb_ordertime); $f_jb_ordertime = substr($f_jb_ordertime, 6,4) . "-" . substr($f_jb_ordertime, 3,2) . "-" . substr($f_jb_ordertime, 0,2); $f_jb_ordertime_ORG = $f_jb_ordertime; $f_jb_daytime = mcStrWrap($f_jb_daytime); $f_cmp_comp = mcStrWrap($f_cmp_comp); $f_ad_street = mcStrWrap($f_ad_street); $f_ad_addon = mcStrWrap($f_ad_addon); $f_ad_zipcode = mcStrWrap($f_ad_zipcode); $f_ad_city = mcStrWrap($f_ad_city); $f_ad_floor = mcStrWrap($f_ad_floor); $f_tr_phone = mcStrWrap($f_tr_phone); $f_inv_ad_name = mcStrWrap($f_inv_ad_name); $f_inv_ad_street = mcStrWrap($f_inv_ad_street); $f_inv_ad_addon = mcStrWrap($f_inv_ad_addon); $f_inv_ad_city = mcStrWrap($f_inv_ad_city); $f_inv_ad_zipcode = mcStrWrap($f_inv_ad_zipcode); if (true) : // Insert new job if ($fire && $executeImportProcess == "1") : TA("B"); $csIdRelated = getFieldValueFromId("costcenter", "csc_id", $cscIdRelated, "cs_id"); // Check for existence of the vehicle $crvhId = getFieldValueFromClause("couriervehicle", "crvh_id", "crvh_sid = '" . $vhtPrefix . $f_crvh_sid . "'"); if ($crvhId == "") : echo "Fahrzeug " . $vhtPrefix . $f_crvh_sid . " steht nicht im System!
------------------------------------------------------------------
"; endif; echo "JB : " . $f_jb_id . " | SID : " . $vhtPrefix . $f_crvh_sid . " | CRVH : " . $crvhId . " | CS_ID : " . $csIdRelated . " | DT : " . $f_jb_daytime . " | "; // Generate delivery and/or installation job $generateDeliveryJob = false; if ($jobServiceArray[$f_jb_id][0] == "1") : $generateDeliveryJob = true; echo "DEL YES |"; endif; $generateInstallationJob = false; if ($jobServiceArray[$f_jb_id][1] == "1") : $generateInstallationJob = true; echo "INST YES |"; endif; // **** Get daytime intervals from and write FDS **** $orderTimePair = array(); // if ($mode == "SCHNELSEN") : if ($crvhId == "" || $f_jb_daytime == "G") : $f_jb_ordertime .= " 00:00:01"; // echo "IN : G | "; elseif ($f_jb_daytime == "V") : $jbDaytimeInterval = getFieldValueFromClause("metatype","mt_mapped_value","mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $csIdRelated . "' AND mt_sort = '0'"); $hourStart = substr($jbDaytimeInterval,0,2); $hourEnd = substr($jbDaytimeInterval,8,2); $chkFDS = checkAvailabilityForJob($crvhId, $f_jb_ordertime, $hourStart, $hourEnd, $f_jb_id, $csIdRelated); if ($chkFDS == "") : $f_jb_ordertime .= " 00:00:01"; endif; // echo "IN : V | "; elseif ($f_jb_daytime == "N") : $jbDaytimeInterval = getFieldValueFromClause("metatype","mt_mapped_value","mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $csIdRelated . "' AND mt_sort = '1'"); $hourStart = substr($jbDaytimeInterval,0,2); $hourEnd = substr($jbDaytimeInterval,8,2); $chkFDS = checkAvailabilityForJob($crvhId, $f_jb_ordertime, $hourStart, $hourEnd, $f_jb_id, $csIdRelated); if ($chkFDS == "") : $f_jb_ordertime .= " 00:00:01"; endif; // echo "IN : N | "; elseif ($f_jb_daytime == "A") : $jbDaytimeInterval = getFieldValueFromClause("metatype","mt_mapped_value","mt_type = 'day_time' AND mt_objtype = 'cs' AND mt_objid = '" . $csIdRelated . "' AND mt_sort = '2'"); $hourStart = substr($jbDaytimeInterval,0,2); $hourEnd = substr($jbDaytimeInterval,8,2); $chkFDS = checkAvailabilityForJob($crvhId, $f_jb_ordertime, $hourStart, $hourEnd, $f_jb_id, $csIdRelated); if ($chkFDS == "") : $f_jb_ordertime .= " 00:00:01"; endif; // echo "IN : A | "; else : $f_jb_ordertime .= " 00:00:01"; endif; // endif; $orderTimePairLen = count($orderTimePair); // echo "JB_OT : " . $f_jb_ordertime . " | "; echo "
"; $currentTime = $f_jb_ordertime; // $jbFinishtime = $f_jb_ordertime; $jbFinishtime = ""; $f_cs_discount = "0.00"; $f_cs_prov = "0.00"; $f_ad_country = "DE"; $vhtId = "7"; $jbStatus = "9"; $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 = "1"; // Get zone of the zipcode and customer $srvpId = getFieldValueFromId("serviceplz", "srvp_plz", $f_ad_zipcode, "srvp_id"); $srvzId = ""; if ($srvpId != "") : $srvzId = getOneStmt("SELECT srvz.srvz_id FROM servicezone AS srvz, servicezonemapping AS srvzm WHERE srvzm.srvp_id = '" . $srvpId . "' AND srvzm.srvz_id = srvz.srvz_id AND srvz.cs_id = '" . $csIdRelated . "'", "srvz_id"); $srvzName = ""; if ($srvzId != "") : $srvzName = getFieldValueFromId("servicezone","srvz_id",$srvzId,"srvz_name"); endif; endif; // Insert costcenter $csc_id_new = dbInsert("costcenter", array("csc_name", $f_cmp_comp)); $outText .= "CSC_ID : " . $csc_id_new . " | "; // Insert user // $cryptedUsrPassword = cryptDbPassword($f_usr_password); // $usr_id_new = dbInsert("user", array("hq_id",$hqId,"usr_type",'2',"usr_name",$f_usr_name,"usr_firstname",$f_usr_firstname,"usr_email",$f_usr_email,"usr_phone",$f_usr_phone,"usr_phone2",$f_usr_phone2,"usr_fax",$f_usr_fax,"usr_account",$f_usr_account,"usr_password",$cryptedUsrPassword)); // Insert employee // $emp_id_new = dbInsert("employee", array("usr_id",$usr_id_new,"csc_id",$csc_id_new,"emp_rights","111111000000")); // Insert company $cmp_id_new = dbInsert("company", array("cmp_type", "0", "cmp_comp", $f_cmp_comp, "cmp_comp2", $f_cmp_comp2, "cmp_comp3", $f_cmp_comp3, "cmp_comp4", $f_cmp_comp4, "cmp_hsno", $f_cmp_hsno, "cmp_iln", $f_cmp_iln, "cmp_tax_idno", $f_cmp_tax_idno, "cmp_stax_idno", $f_cmp_stax_idno, "tx_id", $g_tx_id, "br_id", $g_br_id, "emp_id_sales", $g_sales_emp_id, "cmp_sales_ranking_man", $f_cmp_sales_ranking_man, "cmp_bank", $f_cmp_bank, "cmp_bankno", $f_cmp_bankno, "cmp_bankacc", $f_cmp_bankacc, "cmp_bankmode", $f_cmp_bankmode, "cmp_iban", $f_cmp_iban, "cmp_swift", $f_cmp_swift, "cmp_hqlino", $f_cmp_hqlino, "cmp_postage", "0", "cmp_inv2hq", $f_cmp_inv2hq, "cmp_authenticated", "1", "cmp_visible", "1", "cmp_match", $f_cmp_match, "cmp_match2", $f_cmp_match2, "cmp_remark", $f_cmp_remark, "cmp_remark2", $f_cmp_remark2, "cmp_newsletter", $f_cmp_newsletter, "cmp_new_date", $currentTime, "cmp_modify_status", "0")); $outText .= "CMP_ID : " . $cmp_id_new . " | "; // Insert customer $f_cs_discount = str_replace (",", ".", $f_cs_discount); $f_cs_prov = str_replace (",", ".", $f_cs_prov); $f_cs_markup_prov = str_replace (",", ".", $f_cs_markup_prov); $cs_id_new = dbInsert("customer", array("cmp_id", $cmp_id_new, "hq_id", $hqId, "cs_eid", $f_cs_eid, "csc_id", $csc_id_new, "csc_id_payer", $g_csc_id, "cs_id_parent", $g2_cs_id, "cs_admin", $emp_id_new, "cs_discount", $f_cs_discount, "cs_invmode", $f_cs_invmode, "cs_jbstatusmail2csc", $f_cs_jbstatusmail2csc, "cs_jbstatusmail_price", $f_cs_jbstatusmail_price, "cs_jbstatusmail_emp", $f_cs_jbstatusmail_emp, "cs_jbstatusmail_pdf", $f_cs_jbstatusmail_pdf, "cs_jbstatusmail_fields", $f_cs_jbstatusmail_fields, "cs_jbstatusmail", $f_cs_jbstatusmail, "cs_jbstatusmail2", $f_cs_jbstatusmail2, "cs_jbstatusmail3", $f_cs_jbstatusmail3, "cs_commission_no", $f_cs_commission_no, "cs_cr_fav_only", $f_cs_cr_fav_only, "cs_jobbatch", $f_cs_jobbatch, "cs_invtext_mode", $f_cs_invtext_mode, "cs_jbedit", $f_cs_jbedit, "cs_fixprice_discount", $f_cs_fixprice_discount, "cs_prov", $f_cs_prov, "cs_markup", $f_cs_markup, "cs_markup_prov", $f_cs_markup_prov, "cs_price_warn_uncomplete", $f_cs_price_warn_uncomplete)); $outText .= "CS_ID : " . $cs_id_new . " | "; // Update new costcenter with new customer updateStmt("costcenter", "csc_id", $csc_id_new, array("cs_id", $cs_id_new, "csc_visible", "1")); // Insert address $tmpArray = insertAddress($f_ad_street, $f_ad_zipcode, $f_ad_city, "", $f_ad_country, $noValidationOfAddress); $ad_id_new = $tmpArray[0]; echo "a
\n"; $outText .= "AD_ID : " . $ad_id_new . " | "; // Update (the new) company-entry with address-id updateStmt("company", "cmp_id", $cmp_id_new, array("ad_id", $ad_id_new)); echo "b
\n"; // Insert invoice address $tmpArray = insertAddress($f_inv_ad_street, $f_inv_ad_zipcode, $f_inv_ad_city, "", $f_ad_country, $noValidationOfAddress); $ad_id_inv_new = $tmpArray[0]; $outText .= "AD_ID_INV : " . $ad_id_inv_new . " | "; echo "c
\n"; // Update the costcenteraddresses insertStmt("costcenteraddress", array("csc_id", $csc_id_new, "cscad_comp", $f_cmp_comp, "cscad_comp2", $f_cmp_comp2, "cscad_comp3", $f_cmp_comp3, "cscad_comp4", $f_cmp_comp4, "ad_id", $ad_id_new, "adt_id", 1, "cscad_hsno", $f_cmp_hsno, "cscad_remark", "", "cscad_person", "", "cscad_phone", $f_usr_phone)); insertStmt("costcenteraddress", array("csc_id", $csc_id_new, "cscad_comp", $f_cmp_comp, "cscad_comp2", $f_cmp_comp2, "cscad_comp3", $f_cmp_comp3, "cscad_comp4", $f_cmp_comp4, "ad_id", $ad_id_inv_new, "adt_id", 2, "cscad_hsno", $f_cmp_hsno, "cscad_remark", "", "cscad_person", "", "cscad_phone", $f_usr_phone)); insertStmt("costcenteraddress", array("csc_id", $csc_id_new, "cscad_comp", $f_cmp_comp, "cscad_comp2", $f_cmp_comp2, "cscad_comp3", $f_cmp_comp3, "cscad_comp4", $f_cmp_comp4, "ad_id", $ad_id_inv_new, "adt_id", 3, "cscad_hsno", $f_cmp_hsno, "cscad_remark", "", "cscad_person", "", "cscad_phone", $f_usr_phone)); insertStmt("costcenteraddress", array("csc_id", $csc_id_new, "cscad_comp", $f_cmp_comp, "cscad_comp2", $f_cmp_comp2, "cscad_comp3", $f_cmp_comp3, "cscad_comp4", $f_cmp_comp4, "ad_id", $ad_id_new, "adt_id", 4, "cscad_hsno", $f_cmp_hsno, "cscad_remark", "", "cscad_person", "", "cscad_phone", $f_usr_phone)); echo "d
\n"; // Insert DEFAULT template for export // $sqlStmtExport = "INSERT INTO exportparameters (hq_id, cs_id, expc_id, expp_parstr, expp_bolchars, expp_eolchars, expp_bofchars, expp_eofchars, expp_name, expp_fileextension)" . // " VALUES ($hqId, $cs_id_new, 110, '100010-,-10-,-r-,-0-,--,-0-,-0-,--,--,- -,- -;-100020-,-5-,-r-,-3-,--,-0-,-0-,--,--,- -,- -;-100030-,-8-,-l-,-4-,--,-0-,- -,--,--,- -,- -;-100040-,-5-,-l-,-5-,--,-0-,- -,--,--,- -,- -;-100050-,-8-,-l-,-6-,--,-0-,- -,--,--,- -,- -;-100060-,-5-,-l-,-7-,--,-0-,- -,--,--,- -,- -;-100070-,-8-,-l-,-8-,--,-0-,- -,--,--,- -,- -;-100080-,-5-,-l-,-9-,--,-0-,- -,--,--,- -,- -;-100090-,-420-,-l-,-24-,--,-0-,- -,--,--,- -,- -;-100110-,-10-,-r-,-1-,--,-0-,- -,-1-,--,- -,- -;-100130-,-2-,-r-,-2-,--,-0-,-0-,--,--,- -,- -;-100150-,-30-,-l-,-10-,--,-0-,- -,--,--,- -,- -;-100160-,-30-,-l-,-12-,--,-0-,- -,--,--,- -,- -;-100170-,-30-,-l-,-13-,--,-0-,- -,--,--,- -,- -;-100180-,-30-,-l-,-14-,--,-0-,- -,--,--,- -,- -;-100190-,-5-,-l-,-15-,--,-0-,- -,--,--,- -,- -;-100200-,-5-,-l-,-16-,--,-0-,- -,--,--,- -,- -;-100210-,-30-,-l-,-17-,--,-0-,- -,--,--,- -,- -;-100220-,-15-,-l-,-11-,--,-0-,- -,--,--,- -,- -;-100230-,-30-,-l-,-18-,--,-0-,- -,--,--,- -,- -;-100240-,-30-,-l-,-19-,--,-0-,- -,--,--,- -,- -;-100250-,-30-,-l-,-20-,--,-0-,- -,--,--,- -,- -;-100260-,-5-,-l-,-21-,--,-0-,- -,--,--,- -,- -;-100270-,-5-,-l-,-22-,--,-0-,- -,--,--,- -,- -;-100280-,-30-,-l-,-23-,--,-0-,- -,--,--,- -,- ', '', '', '', '', 'DEFAULT', NULL)"; // $res = $db->query($sqlStmtExport); // if (DB::isError($res)) : die ("$PHP_SELF: " . $res->getMessage()); endif; // if ($generateDeliveryJob) : echo "generateDeliveryJob: JA"; else : echo "generateDeliveryJob: NEIN"; endif; echo "
"; // if ($generateInstallationJob) : echo "generateInstallationJob: JA"; else : echo "generateInstallationJob: NEIN"; endif; echo "
"; // Delivery job if ($generateDeliveryJob) : if ($orderTimePair[0] != "") : $f_jb_ordertime = $orderTimePair[0]; endif; if ($f_jb_ordertime == "" || $f_jb_ordertime == "0000-00-00 00:00:00") : $f_jb_ordertime = $f_jb_ordertime_ORG . " 00:00:01"; endif; insertStmt("job", array("jb_id", $f_jb_id, "hq_id", $hqId, "csc_id", $csc_id_new, "vht_id", $vhtId, "csc_id_payer", $csc_id_new, "csc_id_related", $cscIdRelated, "jb_payment", "0", "jb_ordertime", $f_jb_ordertime, "jb_reserv", "0", "cr_id", $crId, "cr_sid", $crSid, "cr_id_order", $crId, "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", $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_invmode", $csInvmode, "jb_mediationarea_id", $srvzId, "jb_mediationarea_name", $srvzName, "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", $jbTimeUnits, "jb_service", $jbService, "jb_booktime", "")); // $jbIdNew = getLastInsertId(); $jbIdNew = $f_jb_id; // Take existing job ID from import file $outText .= "JB_ID_DELV : " . $jbIdNew . "
"; // Insert tour data // Station 1 insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $tr1_adId, "tr_sort", "1", "tr_comp", $tr1_comp, "tr_comp2", "", "tr_hsno", "", "tr_floor", $f_ad_floor, "csc_id", $tr1_cscId, "tr_status", "0", "tr_commission_no", $f_voucher, "tr_ware_from_to", "", "tr_person", "", "tr_phone", "", "tr_remark", "")); // Station 2 insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $ad_id_new, "tr_sort", "2", "tr_comp", $f_cmp_comp, "tr_comp2", "", "tr_hsno", "", "csc_id", $csc_id_new, "tr_status", "0", "tr_commission_no", $f_order_id, "tr_ware_from_to", "", "tr_person", "", "tr_phone", $f_tr_phone, "tr_remark", "")); // Insert tourservice data insertStmt("tourservice", array("jb_id", $jbIdNew, "csc_id", $csc_id_new, "tr_sort", "0", "srv_id", "0", "trs_srv_name", "Fixpreis", "srvt_id", "0", "trs_srvt_name", "", "trs_price", $sum_totalprice)); // echo "jbIdNew: " . $jbIdNew . "
"; // echo "jbpIdNew: " . $jbpIdNew . "
"; endif; // Installation job if ($generateInstallationJob) : if ($orderTimePair[1] != "") : $f_jb_ordertime = $orderTimePair[1]; endif; if ($generateDeliveryJob) : $f_jb_id = $f_jb_id_child++; else : $jbIdNew = "0"; endif; if ($orderTimePairLen > 0) : $f_jb_ordertime = $orderTimePair[1]; endif; if ($f_jb_ordertime == "" || $f_jb_ordertime == "0000-00-00 00:00:00") : $f_jb_ordertime = $f_jb_ordertime_ORG . " 00:00:01"; endif; insertStmt("job", array("jb_id", $f_jb_id, "hq_id", $hqId, "csc_id", $csc_id_new, "vht_id", $vhtId, "csc_id_payer", $csc_id_new, "csc_id_related", $cscIdRelated, "jb_payment", "0", "jb_ordertime", $f_jb_ordertime, "jb_reserv", "0", "cr_id", $crId, "cr_sid", $crSid, "cr_id_order", $crId, "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", $jbFinishtime, "emp_id", $usr_id, "jb_serviceprice", "0", "jb_fixprice", $sum_totalprice_M, "jb_totalprice", $sum_totalprice_M, "jb_subtotalprice", $sum_totalprice_M, "jb_cr_price", $f_jb_cr_price_M, "jb_cr_subprice", $f_jb_cr_price_M, "jb_postage", "0", "jb_invmode", $csInvmode, "jb_mediationarea_id", $srvzId, "jb_mediationarea_name", $srvzName, "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", $jbIdNew, "jb_dispoinfo", "", "jb_sales_tax_rate", $txValue, "jb_sales_tax_rate_sign", $txSign, "jb_timeunits", $jbTimeUnits_M, "jb_service", $jbService_M, "jb_booktime", "")); // $jbIdNew = getLastInsertId(); $jbIdNew = $f_jb_id; // Take existing job ID from import file $outText .= "JB_ID_INST : " . $jbIdNew . "
"; // Insert tour data // Station 1 insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $tr1_adId, "tr_sort", "1", "tr_comp", $tr1_comp, "tr_comp2", "", "tr_hsno", "", "tr_floor", $f_ad_floor, "csc_id", $tr1_cscId, "tr_status", "0", "tr_commission_no", $f_voucher, "tr_ware_from_to", "", "tr_person", "", "tr_phone", "", "tr_remark", "")); // Station 2 insertStmt("tour", array("jb_id", $jbIdNew, "ad_id", $ad_id_new, "tr_sort", "2", "tr_comp", $f_cmp_comp, "tr_comp2", "", "tr_hsno", "", "csc_id", $csc_id_new, "tr_status", "0", "tr_commission_no", $f_order_id, "tr_ware_from_to", "", "tr_person", "", "tr_phone", $f_tr_phone, "tr_remark", "")); // Insert tourservice data insertStmt("tourservice", array("jb_id", $jbIdNew, "csc_id", $csc_id_new, "tr_sort", "0", "srv_id", "0", "trs_srv_name", "Fixpreis", "srvt_id", "0", "trs_srvt_name", "", "trs_price", $sum_totalprice_M)); endif; $executionCount++; TA("C"); TA("E"); endif; else : $outText .= getLngt("XXXX!") . "
"; endif; echo "---------------------------
"; } $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 ?>