"; echo "objId = " . $objId . "
"; echo "result = " . $result . "
"; endif; // **** SAVE NEW SORT SEQUENCE **** if ($f_act == "save" && $objId != "" && is_numeric($objId) && $result != "") : // **** JOB **** // Store job with new sorting sequence if ($objType == "jb") : $trIdArray = array(); $trSort = 1; foreach($result as $key => $value) { foreach($value as $innerKey => $innerValue) { $resultArray = explode(";",$innerValue); $result[$key][$innerKey] = array(0 => $resultArray[0], 1 => $resultArray[1]); $trIdArray[$resultArray[0]] = $trSort; // $trIdArray[] = $trSort++; } } $trIdArrayLen = count($trIdArray); if ($trIdArrayLen > 0) : $trIdKeyArray = array_keys($trIdArray); // Get jb_status $jbId = getFieldValueFromId("tour", "tr_id", $trIdKeyArray[0], "jb_id"); if ($jbId == $objId) : $jbStatus = getFieldValueFromId("job", "jb_id", $jbId, "jb_status"); if ($jbStatus == "9" || $jbStatus == "8" || $jbStatus == "0" || $jbStatus == "1") : $trIdKeyArrayLen = count($trIdKeyArray); TA("B"); $doCommit = true; for ($i = 0; $i < $trIdKeyArrayLen; $i++) : $trSort = $trIdArray[$trIdKeyArray[$i]]; if ($trSort != "" && is_numeric($trSort)) : $res = updateStmt("tour","tr_id",$trIdKeyArray[$i],array("tr_sort", $trSort)); $res2 = updateStmt("jobcalculator","tr_id",$trIdKeyArray[$i],array("tr_sort", $trSort)); $res3 = updateStmt("tourarticle","tr_id",$trIdKeyArray[$i],array("tr_sort", $trSort)); else : $doCommit = false; break; endif; endfor; if ($doCommit) : mk_jb_tourdata($jbId); // Final check for changing state $jbStatus = getFieldValueFromId("job", "jb_id", $jbId, "jb_status"); if ($jbStatus == "9" || $jbStatus == "8" || $jbStatus == "0" || $jbStatus == "1") : TA("C"); // OK, TA ended with the same state of the job else : TA("R"); $statusMessage = getLngt("Der Status des Auftrags wurde während der Verarbeitung durch einen anderen Prozess geändert! Es erfolgte keine Verarbeitung!"); endif; else : TA("R"); endif; TA("E"); else : $statusMessage = getLngt("Der Auftrag muss den Zuweisungsstatus aufweisen, absonsten findet keine Verarbeitung statt!"); endif; else : $statusMessage = getLngt("Anomalie: Die Station passt nicht zum Auftrag! Es erfolgte keine Verarbeitung!"); endif; else : $statusMessage = getLngt("Keine Station vorhanden! Es erfolgte keine Verarbeitung!"); endif; endif; // **** COURIERFILTER **** // Store filter with new sorting sequence if ($objType == "crf") : $crfIdArray = array(); $crfSort = 1; foreach($result as $key => $value) { foreach($value as $innerKey => $innerValue) { $resultArray = explode(";",$innerValue); $result[$key][$innerKey] = array(0 => $resultArray[0], 1 => $resultArray[1]); $crfIdArray[$resultArray[0]] = $crfSort; // $crfIdArray[] = $crfSort++; } } $crfIdArrayLen = count($crfIdArray); if ($crfIdArrayLen > 0) : $crfIdKeyArray = array_keys($crfIdArray); $crfIdKeyArrayLen = count($crfIdKeyArray); TA("B"); $doCommit = true; for ($i = 0; $i < $crfIdKeyArrayLen; $i++) : $crfSort = $crfIdArray[$crfIdKeyArray[$i]]; if ($crfSort != "" && is_numeric($crfSort)) : $res = updateStmt("courierfilter","crf_id",$crfIdKeyArray[$i],array("crf_sort", $crfSort)); else : $doCommit = false; break; endif; endfor; /* if ($doCommit) : // Final check for changing state $jbStatus = getFieldValueFromId("job", "jb_id", $jbId, "jb_status"); if ($jbStatus == "9" || $jbStatus == "8" || $jbStatus == "0" || $jbStatus == "1") : TA("C"); // OK, TA ended with the same state of the job else : TA("R"); $statusMessage = getLngt("Der Status des Auftrags wurde während der Verarbeitung durch einen anderen Prozess geändert! Es erfolgte keine Verarbeitung!"); endif; else : TA("R"); endif; */ TA("E"); else : $statusMessage = getLngt("Keine Station vorhanden! Es erfolgte keine Verarbeitung!"); endif; endif; endif; // **** GET OBJECT DATA WITH CURRENT/NEW SORTING SEQUENCE **** if ($objId != "" && is_numeric($objId)) : // **** JOB **** if ($objType == "jb" && $objId != "" && is_numeric($objId)) : $jobData = array(); getDBData("job", $objId); getDBData("tour", $objId); // getDBData("tourarticle", $objId); // getDBData("genericdatacontainer", $objId); // print_r($jobData); echo "

"; // $jbStatus = getFieldValueFromId("job", "jb_id", $jbId, "jb_status"); // if (true || $jbStatus == "9") : // !!!!!!!! if (true) : // !!!!!!!! $numOfStations = count($jobData["tour"]); for ($i = 0; $i < $numOfStations; $i++) : $j = $i +1; $trId = $jobData["tour"][$j]["tr_id"]; $htmlText = ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; /* $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; */ $htmlText .= "
" . $jobData["tour"][$j]["tr_comp"] . "
" . $jobData["tour"][$j]["ad_street"] . " " . $jobData["tour"][$j]["tr_hsno"] . "
" . $jobData["tour"][$j]["ad_zipcode"] . " " . $jobData["tour"][$j]["ad_city"] . "
" . $jobData["tour"][$j]["tr_person"] . "
" . $jobData["tour"][$j]["tr_phone"] . "
" . $jobData["tour"][$j]["tr_comp"] . "" . $jobData["tour"][$j]["ad_street"] . " " . $jobData["tour"][$j]["tr_hsno"] . "" . $jobData["tour"][$j]["ad_zipcode"] . " " . $jobData["tour"][$j]["ad_city"] . "" . $jobData["tour"][$j]["tr_person"] . "" . $jobData["tour"][$j]["tr_phone"] . "
"; /* $htmlText = $jobData["tour"][$j]["tr_comp"] . "
"; $htmlText .= $jobData["tour"][$j]["ad_street"] . " " . $jobData["tour"][$j]["tr_hsno"] . "
"; $htmlText .= $jobData["tour"][$j]["ad_zipcode"] . " " . $jobData["tour"][$j]["ad_city"] . "
"; $htmlText .= $jobData["tour"][$j]["tr_person"] . "
"; $htmlText .= $jobData["tour"][$j]["tr_phone"] . "
"; */ // $htmlText = htmlspecialchars($htmlText); $urlText = $jobData["tour"][$j]["ad_street"] . " " . $jobData["tour"][$j]["tr_hsno"]. ", " . $jobData["tour"][$j]["ad_zipcode"] . " " . $jobData["tour"][$j]["ad_city"]; $urlText = urlencode(utf8_encode($urlText)); if ($j == 1) : $urlText = "&saddr=" . $urlText; elseif ($j == 2) : $urlText = "&daddr=" . $urlText; elseif ($j > 2) : $urlText = "+to:" . $urlText; endif; if ($f_act == "optimize") : $coordPairArr = get_coords($jobData["tour"][$j]["ad_country"], $jobData["tour"][$j]["ad_zipcode"], $jobData["tour"][$j]["ad_city"], $jobData["tour"][$j]["ad_street"], $jobData["tour"][$j]["tr_hsno"], false); endif; $sortArray[0][$i] = array($trId, $htmlText, $urlText, $coordPairArr); $coordArr[$i] = $coordPairArr; $tabText[$i] = getLngt("Auftrag") . " " . $objId; endfor; // Optimization if ($f_act == "optimize") : $optArr = get_zone_distance($coordArr, $hq_id, $objId, false, true); $optRouteArr = $optArr["optimizedRoute"]; if ($debug) : echo "

"; print_r($coordArr); echo "

"; echo "

"; print_r($optRouteArr); echo "

"; // echo "

"; print_r($optArr["legs"]); echo "

"; echo "
sortArray PRE:
";print_r($sortArray); echo "
"; endif; $optRouteArrLen = count($optRouteArr); if ($optRouteArrLen > 0) : // Iterate stations for renewing optimized vector $tmpSortArr = $sortArray; for ($s = 0; $s < $optRouteArrLen; $s++) : $sortArray[0][($s + 1)] = $tmpSortArr[0][($optRouteArr[$s] + 1)]; // Tricky, because $optRouteArr contains all intermediate stations only !!!! ([0] => 2, [1] => 1, [2] => 0) endfor; endif; if ($debug) : echo "
sortArray POST:
";print_r($sortArray); echo "
"; endif; endif; else : $statusMessage = getLngt("Der Auftrag muss den Zuweisungsstatus aufweisen, absonsten findet keine Verarbeitung statt!"); endif; $objHeader = getLngt("Sortierung der Stationsreihenfolge des Auftrags") . " " . $objId; endif; // **** COURIERFILTER **** if ($objType == "crf" && $objId != "" && is_numeric($objId)) : $crfData = getMatrixFromDbResultByStatement("SELECT " . getDBFields("courierfilter") . " FROM courierfilter AS crf ORDER BY crf.crf_sort"); $crfDataLen = count($crfData); if ($crfDataLen > 0) : // !!!!!!!! for ($i = 0; $i < $crfDataLen; $i++) : // $j = $i + 1; $j = $i; $crfId = $crfData[$j]["crf_id"]; $htmlText = ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= ""; $htmlText .= "
" . $crfData[$j]["crf_sort"] . "" . $crfData[$j]["crf_short"] . "" . $crfData[$j]["crf_text"] . "
"; // $htmlText = htmlspecialchars($htmlText); $sortArray[0][$i] = array($crfId, $htmlText, ""); $tabText[$i] = getLngt("Filter"); endfor; else : $statusMessage = getLngt("Zur Zeit scheinen keine Filter existent!"); endif; $objHeader = getLngt("Sortierung der Filter"); endif; endif; $sortArrayLength = count($sortArray); // echo "
sortArray:
";print_r($sortArray); echo "
"; echo "sortArrayLength = " . $sortArrayLength . "
"; function drawBoxes($sortArray, $tabText, $noMap = "0") { if ($noMap == "0") : $mapUrl = "https://maps.google.com/maps?q=&hl=de&output=embed&source=s_d"; $mapAdArr = array(); endif; $html_output = ""; foreach ($sortArray as $key => $value) { $html_output .= '
' . "\n"; $html_output .= '
' . $tabText[$key] . '
' . "\n"; $html_output .= '
' . "\n"; $html_output .= '
    ' . "\n"; foreach ($value as $boxValue) { // echo "
    boxValue:
    ";print_r($boxValue); echo "
    "; $html_output .= '
  • ' . $boxValue[1] . '
  • ' . "\n"; if ($noMap == "0") : $mapAdArr[] = $boxValue[2]; endif; } // echo "
    "; $html_output .= '
' . "\n"; $html_output .= '
    ' . "\n"; $html_output .= '
    ' . "\n"; $html_output .= '
    ' . "\n"; if ($noMap == "0") : $html_output .= '
    ' . "\n"; $mapUrl .= implode("/", $mapAdArr); // echo $mapUrl . "
    "; $html_output .= ' ' . "\n"; $html_output .= '
    ' . "\n"; endif; } return $html_output; } ?> <?php echo $pageTitel ?> \n"; // echo "\n"; // echo "\n"; echo ''; echo ''; echo "\n"; echo "\n"; echo "\n"; ?>
    " onclick="sortFinishPage('save')"> 3 && $numOfStations <= 25) : ?> " onclick="sortFinishPage('optimize')">