query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $cscIdPayerArrayOfIFTMIN[] = $row["csc_id_payer"]; $cscIdPayerAssociativeArrayOfIFTMIN[$row["csc_id_payer"]] = $row["csc_name"]; endwhile; $result->free(); // Store changes of the stations and vehicles (drivers) if ($f_act == "save") : if ($numOfStations != "" && is_numeric($numOfStations)) : TA("B"); // First step ALL involved "tr_sort" fields of the specified jobs(!) have to be updated with an offset(!) for ($i = 0; $i < $numOfStations; $i++) : $jbIdSrc = $jobDataSrc[$i]["jb_id"]; $trSortSrc = $jobDataSrc[$i]["tr_sort"]; if ($jbIdSrc != "") : updateStmt("tour", "jb_id", $jbIdSrc, array("tr_sort", ($trSortSrc + $trSortOffset)),"tr_sort = '" . $trSortSrc . "'"); updateStmt("tourarticle", "jb_id", $jbIdSrc, array("tr_sort", ($trSortSrc + $trSortOffset)),"tr_sort = '" . $trSortSrc . "'"); endif; endfor; // Compare all (unique) tracking IDs and update "tr_sort" in "tour" and "tourarticle" // Iterate SOURCE values for ($i = 0; $i < $numOfStations; $i++) : $trackingIdSrc = $jobDataSrc[$i]["trat_serialno"]; $jbIdSrc = $jobDataSrc[$i]["jb_id"]; $trSortSrc = $jobDataSrc[$i]["tr_sort"]; if ($jbIdSrc != "") : // Iterate TARGET values for ($j = 0; $j < $numOfStations; $j++) : $trackingIdTarget = $jobDataTarget[$j]["trat_serialno"]; if ($trackingIdSrc == $trackingIdTarget) : // Has to be true every time because of IFTMIN and Javascript $jbIdTarget = $jobDataTarget[$j]["jb_id"]; $trSortTarget = $jobDataTarget[$j]["tr_sort"]; $crvhSid = $jobDataTarget[$i]["crvh_sid"]; if ($jbIdSrc == $jbIdTarget) : // Has to be true every time because of Javascript // Check jb_status $jbStatusSrc = getFieldValueFromId("job", "jb_id", $jbIdSrc, "jb_status"); $jbStatusTarget = getFieldValueFromId("job", "jb_id", $jbIdTarget, "jb_status"); if (!$specialJbStatusEnabled || ($jbStatusSrc == $specialJbStatusNo && $jbStatusTarget == $specialJbStatusNo)) : if ($trSortSrc == $trSortTarget) : updateStmt("tour", "jb_id", $jbIdSrc, array("tr_sort", $trSortSrc, "tr_cs_freetext", $crvhSid),"tr_sort = '" . ($trSortSrc + $trSortOffset) . "'"); updateStmt("tourarticle", "jb_id", $jbIdSrc, array("tr_sort", $trSortSrc),"tr_sort = '" . ($trSortSrc + $trSortOffset) . "'"); else : updateStmt("tour", "jb_id", $jbIdTarget, array("tr_sort", $trSortTarget, "tr_cs_freetext", $crvhSid),"tr_sort = '" . ($trSortSrc + $trSortOffset) . "'"); updateStmt("tourarticle", "jb_id", $jbIdTarget, array("tr_sort", $trSortTarget),"tr_sort = '" . ($trSortSrc + $trSortOffset) . "'"); endif; else : $statusMessage = getLngt("AUFTRAGSSTATUS NICHT " . $specialJbStatusNo . "!!!"); endif; endif; endif; endfor; endif; endfor; TA("C"); TA("E"); else : $statusMessage = getLngt("Es sind keine Paketnummern vorhanden!"); endif; endif; // Set events for each of the packages if ($f_act == "final_save") : TA("B"); $currentTime = getDateTime("0"); // Write events into "tourarticleprocess" for scanned packages for ($i = 0; $i < $numOfStations; $i++) : $jbIdSrc = $jobDataSrc[$i]["jb_id"]; $trSortSrc = $jobDataSrc[$i]["tr_sort"]; $cscIdSrc = $jobDataSrc[$i]["csc_id"]; // Check for correct data to be final saved regarding the selected costcenter button if ($f_costcenter == $cscIdSrc) : if ($jbIdSrc != "") : if ($trSortSrc != "1") : // Get all tracking IDs being NOT(!) in pick up stations. Only delivery stations! $tmpArray = $scanFieldArray[$jbIdSrc . "_" . $trSortSrc]; $scanField = spliti(",", $tmpArray); $scanFieldLen = count($scanField); // Get all "trat_id" entries and tracking IDs of the station $sqlquery = "SELECT trat.trat_id, trat.trat_serialno" . " FROM phoenix.tourarticle AS trat" . " WHERE trat.jb_id = '" . $jbIdSrc . "' AND" . " trat.tr_sort = '" . $trSortSrc . "'"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $tratIdArray = array(); $trackingIdArray = array(); while ($row = $result->fetch_assoc()): $tratIdArray[] = $row["trat_id"]; $trackingIdArray[] = $row["trat_serialno"]; endwhile; $result->free(); // Check for tracking ID being in scanned field $trackingIdArrayLen = count($trackingIdArray); for ($j = 0; $j < $trackingIdArrayLen; $j++) : // Check for existence of a scan event "201" or "411" $sqlquery = "SELECT tratp.tratp_type, tratp.tratp_state, trat.trat_id" . " FROM phoenix.tourarticle AS trat, phoenix.tourarticleprocess AS tratp" . " WHERE trat.trat_serialno = '" . $trackingIdArray[$j] . "' AND" . " trat.trat_id = tratp.trat_id AND" . " tratp.tratp_type IN ('201','411')"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $numberOfEventExists = ""; $stateOfEventExists = "0"; $tratIdOfEventExists = "0"; while ($row = $result->fetch_assoc()): $numberOfEventExists = $row["tratp_type"]; $stateOfEventExists = $row["tratp_state"]; $tratIdOfEventExists = $row["trat_id"]; endwhile; $result->free(); if ($numberOfEventExists == "") : // Event does not exist in database, find package in current scan field of the page $tmpSearch = array_search($trackingIdArray[$j], $scanField); if ($tmpSearch === FALSE) : $eventNo = "411"; else : $eventNo = "201"; endif; if ($tratIdArray[$j] != "") : // The event has to be placed to the pickup station !!! $tmpTratId = getFieldValueFromClause("tourarticle","trat_id","jb_id = '" . $jbIdSrc . "' AND tr_sort = '1' AND trat_serialno = '" . $trackingIdArray[$j] . "'"); if ($tmpTratId == "") : $tmpTratId = $tratIdArray[$j]; // Fallback if package would not be found at pick up station. endif; insertStmt("tourarticleprocess", array("trat_id", $tmpTratId, "tratp_type", $eventNo, "tratp_state", "1", "tratp_remark", "", "tratp_createtime", $currentTime)); endif; else : // Event does exist and if event equals "not found" then it could be changed in found in current scan field of the page and IFTSTA was not sent if ($stateOfEventExists < "2" && $numberOfEventExists == "411" && $tratIdOfEventExists > "0") : // Find package in current scan field of the page $tmpSearch = array_search($trackingIdArray[$j], $scanField); if (!($tmpSearch === FALSE)) : updateStmt("tourarticleprocess", "trat_id", $tratIdOfEventExists, array("tratp_type", "201", "tratp_createtime", $currentTime), "tratp_type = '411' AND tratp_state < '2'"); endif; endif; endif; endfor; endif; endif; endif; endfor; // Write events for scanned packages (into "tourarticleprocess") being NOT in any electronic manifest $trackingIDsNotFoundArray = spliti(",", $trackingIDsNotFound); $trackingIDsNotFoundArrayLen = count($trackingIDsNotFoundArray); for ($i = 0; $i < $trackingIDsNotFoundArrayLen; $i++) : $trackingIDNotFound = $trackingIDsNotFoundArray[$i]; // Check for existence of a scan event "412" $sqlquery = "SELECT trat.trat_id" . " FROM phoenix.tourarticle AS trat, phoenix.tourarticleprocess AS tratp" . " WHERE trat.trat_serialno = '" . $trackingIDNotFound . "' AND" . " trat.trat_id = tratp.trat_id AND" . " tratp.tratp_type = '412'"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $tmpEventExists = false; while ($row = $result->fetch_assoc()): $tmpEventExists = true; endwhile; $result->free(); if (!$tmpEventExists) : // Final check for the non-existence of the tracking no. if ($trackingIDNotFound != "" && !existsEntry("tourarticle",array("trat_serialno",$trackingIDNotFound))) : // It is nessessary to insert it into the "tourarticle", because the package (tracking ID) is not known and no tourarticle entry does exist. // We can take the first (pick up) station of each job displayed, because all of them have the same pick up address !!! // To simplify matters we take the first job and the first station, equals to the first entry of the list $jbIdSrc = $jobDataSrc["0"]["jb_id"]; $trSortSrc = "1"; $eventNo = "412"; if ($jbIdSrc != "") : insertStmt("tourarticle", array("jb_id", $jbIdSrc, "tr_sort", $trSortSrc, "trat_serialno", $trackingIDNotFound, "trat_state", "1", "trat_createtime", $currentTime)); $tratId = getLastInsertID(); insertStmt("tourarticleprocess", array("trat_id", $tratId, "tratp_type", $eventNo, "tratp_state", "1", "tratp_remark", "", "tratp_createtime", $currentTime)); endif; endif; endif; endfor; // Last step is to finalize the job for ($i = 0; $i < $numOfStations; $i++) : $jbIdSrc = $jobDataSrc[$i]["jb_id"]; $trSortSrc = $jobDataSrc[$i]["tr_sort"]; $cscIdSrc = $jobDataSrc[$i]["csc_id"]; // Check for correct data to be final saved regarding the selected costcenter button if ($f_costcenter == $cscIdSrc) : if ($jbIdSrc != "") : if ($trSortSrc == "1") : // Set jb_status updateStmt("job", "jb_id", $jbIdSrc, array("jb_status", "998", "hq_id", $hq_id)); // ??? , "jb_ordertime", $currentTime, "jb_taketime", $currentTime endif; endif; endif; endfor; TA("C"); TA("E"); $numOfStations = 0; // $f_costcenter = ""; // Call function to finalize the job include_once ("../tools/finalize_job.inc.php"); finalize_jobs(); endif; function getCurrentJobData($jobArrayOfIFTMIN, $scanFieldArray = array(), $driverPool, $f_costcenter) { global $db, $PHP_SELF; global $hq_id; $numOfStations = 0; $htmlOut = ""; $jobArrayOfIFTMINLen = count($jobArrayOfIFTMIN); if ($jobArrayOfIFTMINLen > 0) : $whereClauseJobs = "(" . implode(",", $jobArrayOfIFTMIN) . ")"; // Get data from "job", "tour", "tourarticle" /* $sqlquery = "SELECT jb.jb_id, jb.cr_id, csc.csc_id, csc.csc_name," . " tr.tr_sort, tr.tr_signname, tr.tr_hsno," . " ad.ad_id, ad.ad_street, ad.ad_zipcode, ad.ad_city, ad.ad_country," . " crvh.crvh_sid" . " FROM phoenix.job AS jb LEFT JOIN phoenix.couriervehicle AS crvh ON jb.cr_id = crvh.cr_id," . " phoenix.tour AS tr, phoenix.address AS ad, phoenix.costcenter AS csc" . " WHERE jb.jb_id IN " . $whereClauseJobs . " AND" . " jb.jb_id = tr.jb_id AND" . " tr.ad_id = ad.ad_id AND" . " jb.csc_id_payer = csc.csc_id" . " ORDER BY jb.jb_id, tr.tr_sort"; $sqlquery = "SELECT jb.jb_id, csc.csc_id, csc.csc_name," . " tr.tr_sort, tr.tr_signname, tr.tr_hsno, tr.tr_cs_freetext AS crvh_sid," . " ad.ad_id, ad.ad_street, ad.ad_zipcode, ad.ad_city, ad.ad_country" . " FROM phoenix.job AS jb, phoenix.tour AS tr, phoenix.address AS ad, phoenix.costcenter AS csc" . " WHERE jb.jb_id IN " . $whereClauseJobs . " AND" . " jb.jb_id = tr.jb_id AND" . " tr.ad_id = ad.ad_id AND" . " jb.csc_id_payer = csc.csc_id" . " ORDER BY jb.jb_id, tr.tr_sort"; */ $sqlquery = "SELECT jb.jb_id, csc.csc_id, csc.csc_name, tr.tr_comp, tr.tr_comp2, tr.tr_ware_from_to," . " tr.tr_sort, tr.tr_signname, tr.tr_hsno, tr.tr_cs_freetext AS crvh_sid," . " ad.ad_id, ad.ad_street, ad.ad_zipcode, ad.ad_city, ad.ad_country" . " FROM phoenix.job AS jb, phoenix.tour AS tr, phoenix.address AS ad, phoenix.costcenter AS csc" . " WHERE jb.jb_id IN " . $whereClauseJobs . " AND" . " jb.jb_id = tr.jb_id AND" . " tr.ad_id = ad.ad_id AND" . " jb.csc_id_payer = csc.csc_id" . " ORDER BY jb.jb_id, tr.tr_sort"; // echo $sqlquery . "
"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); $htmlOut .= "\n"; $htmlOut .= "\n"; // if ($f_costcenter == "") : $htmlOut .= " \n"; // endif; // $htmlOut .= " \n"; $htmlOut .= " \n"; $htmlOut .= " \n"; $htmlOut .= " \n"; $htmlOut .= " \n"; $htmlOut .= " \n"; $htmlOut .= " \n"; $htmlOut .= " \n"; $htmlOut .= "\n"; $numOfStations = $result->numRows(); $remJbId = ""; $remCscId = ""; $remCscName = ""; $i = 0; while ($row = $result->fetch_assoc()): // Get the tracking IDs of the stations $trackingIDs = getColVectorFromDB2ArrayByClause("tourarticle", "trat_serialno", "jb_id = '" . $row["jb_id"] . "' AND tr_sort = '" . $row["tr_sort"] . "'", "", ""); $trackingIDsLen = count($trackingIDs); $trackingIDsString = implode(",", $trackingIDs); // Check for existence of event "201" or "411" $existingEventNo = ""; for ($j = 0; $j < $trackingIDsLen; $j++) : // Get all trat_id entries from the current tracking ID(s) $tratIDs = getColVectorFromDB2ArrayByClause("tourarticle", "trat_id", "trat_serialno = '" . $trackingIDs[$j] . "'", "", ""); $tratIDsLen = count($tratIDs); if ($tratIDsLen > 0) : $tratIDsString = implode(",", $tratIDs); // Get all event entries ("201" and "411" only) from the specified trat_id entries $tratTypes = getColVectorFromDB2ArrayByClause("tourarticleprocess", "tratp_type", "trat_id IN (" . $tratIDsString . ") AND tratp_type IN ('201','411')", "", ""); $tratTypesLen = count($tratTypes); if ($tratTypesLen > 0) : $existingEventNo = $tratTypes[0]; endif; endif; endfor; // Get number of stations of the job $numOfStationsOfCurrentJob = getCountOfTable("tour", "jb_id = '" . $row["jb_id"] . "'"); // Driver pool $tmpSearch = array_search($row["crvh_sid"], $driverPool); if ($tmpSearch === FALSE) : $driverPool[] = $row["crvh_sid"]; endif; if ($remJbId != "" && $remJbId != $row["jb_id"]) : $htmlOut .= ""; $htmlOut .= "\n"; endif; // If first character of "tr_comp" equals "*" then add "*" to "tr_comp2" $asterisk_01 = ""; if (substr($row["tr_comp"],0,1) == "*") : $asterisk_01 = " [*]"; endif; // FORM fields // Hidden (Source) $htmlOut .= "\n"; // $htmlOut .= "\n"; $htmlOut .= "\n"; $htmlOut .= "\n"; $htmlOut .= "\n"; $htmlOut .= "\n"; $htmlOut .= "\n"; if ($row["tr_sort"] == "1") : $htmlOut .= "\n"; else : $htmlOut .= "\n"; endif; $htmlOut .= "\n"; // Hidden (Target) $htmlOut .= "\n"; $htmlOut .= "\n"; $htmlOut .= "\n"; // Displayed $htmlOut .= "\n"; // if ($f_costcenter == "") : // $htmlOut .= " \n"; $htmlOut .= " \n"; // endif; // $htmlOut .= " \n"; $htmlOut .= "\n"; $htmlOut .= " \n"; $htmlOut .= " \n"; if ($row["tr_sort"] == "1" || $row["tr_ware_from_to"] == "1") : $htmlOut .= " \n"; else : $streetHttp = urlencode($row["ad_street"]); $zipcodeHttp = urlencode($row["ad_zipcode"]); $cityHttp = urlencode($row["ad_city"]); $hsnoHttp = urlencode($row["tr_hsno"]); $htmlOut .= " \n"; endif; if ($row["tr_sort"] == "1") : $htmlOut .= " \n"; $htmlOut .= " \n"; else : $htmlOut .= " \n"; $tmpScanValue = $scanFieldArray[$row["jb_id"] . "_" . $row["tr_sort"]]; if ($existingEventNo == "201") : $tmpScanValue = $trackingIDsString; elseif ($existingEventNo == "411") : $tmpScanValue = getLngt("Sendung fehlte!"); endif; $htmlOut .= " \n"; endif; $htmlOut .= " \n"; $htmlOut .= " \n"; $htmlOut .= "\n"; $remJbId = $row["jb_id"]; $remCscId = $row["csc_id"]; $remCscName = $row["csc_name"]; $i++; endwhile; $result->free(); $htmlOut .= ""; $htmlOut .= "
" . getLngt("Kostenstelle") . "" . getLngt("Auftrag") . "" . getLngt("Station") . "" . getLngt("Adresse") . "" . " " . "" . getLngt("Sendung") . "" . getLngt("Scan") . "" . getLngt("Fahrer") . " " . " " . getLngt("Aktion") . "
" . ""; if($row["tr_sort"] != "1"): $htmlOut .= " ?"; endif; $htmlOut .= " \n"; // No arrows at the first station (pick up) // Move down if ($row["tr_sort"] >= "2" && $row["tr_sort"] < $numOfStationsOfCurrentJob) : $htmlOut .= "    " . "" . "\n"; else : $htmlOut .= "       "; endif; // Move up if ($row["tr_sort"] > "2") : $htmlOut .= "    " . "" . "\n"; else : $htmlOut .= "       "; endif; $htmlOut .= "
\n"; endif; return array($htmlOut, $numOfStations, $driverPool); } // Init current costcenter for the page if empty (Do this AFTER saving or final saving data!) if ($f_costcenter == "") : $f_costcenter = $cscIdPayerArrayOfIFTMIN[0]; endif; // $outCostcenters = "" . getLngt("AUSWAHL:") . " "; // $outCostcenters .= "\n"; // $outCostcenters .= "          "; $outCostcenters = ""; // Get job data array of specified IFTMIN orders accorting to the selected costcenter $whereClauseCostcenter = ""; /* if ($f_costcenter != "" && is_numeric($f_costcenter)) : $whereClauseCostcenter = " AND jb.csc_id_payer = '" . $f_costcenter . "'"; endif; */ $sqlquery = "SELECT jb.jb_id" . " FROM phoenix.job AS jb" . " WHERE jb.jb_status = '" . $specialJbStatusNo . "' AND" . " jb.hq_id = '" . $hq_id . "'" . $whereClauseCostcenter . " ORDER BY jb.jb_id"; $result = $db->query($sqlquery); if (DB::isError($result)) die ("$PHP_SELF: " . $result->getMessage()); while ($row = $result->fetch_assoc()): $jobArrayOfIFTMIN[] = $row["jb_id"]; endwhile; $result->free(); $tmpJobArray = getCurrentJobData($jobArrayOfIFTMIN, $scanFieldArray, $driverPool, $f_costcenter); $htmlOut = $tmpJobArray[0]; $numOfStations = $tmpJobArray[1]; $driverPool = $tmpJobArray[2]; ?> <?php echo $pageTitel ?>


 






" onclick="javascript:finishSave();">