$f_tr_finishtime_old, "tr_commission_no" => $f_tr_commission_no_old, "tr_signname" => $f_tr_signname_old, "tr_cs_freetext" => $f_tr_cs_freetext_old); // Auf Änderungen in `tour` checken if ($f_tr_status != 1): $restore_values[$i] = array("tr_finishtime" => $f_tr_finishtime, "tr_commission_no" => $f_tr_commission_no, "tr_signname" => $f_tr_signname, "tr_cs_freetext" => $f_tr_cs_freetext); $updateStmt = ""; $delete_old_process = false; if ($f_tr_finishtime != $f_tr_finishtime_old): if (date('Y-m-d H:i:s', strtotime($f_tr_finishtime)) != $f_tr_finishtime): $msg_txts[$i] = "Ungültige Datums-/Zeitangabe: '" . $f_tr_finishtime_ori . "'
\n"; elseif (strtotime($f_tr_finishtime) > time()): $msg_txts[$i] = "Datums-/Zeitangabe liegt in der Zukunft: '" . $f_tr_finishtime_ori . "'
\n"; // elseif (strtotime($f_tr_finishtime) < strtotime($f_jb_ordertime)): // $msg_txts[$i] = "Datums-/Zeitangabe liegt vor dem Auftragsdatum: '" . $f_tr_finishtime_ori . "'
\n"; else: $updateStmt .= "tr_finishtime = '$f_tr_finishtime', "; if ($f_tr_status_ori != 1): $updateStmt .= "tr_status = 1, "; $f_tr_status = 1; else: writeLog("'$f_tr_finishtime' != '$f_tr_finishtime_old'"); $delete_old_process = true; endif; endif; endif; $f_tr_finishtime_max = (strtotime($f_tr_finishtime) > strtotime($f_tr_finishtime_max) ? $f_tr_finishtime : $f_tr_finishtime_max); if ($f_tr_commission_no != $f_tr_commission_no_old): $updateStmt .= "tr_commission_no = '$f_tr_commission_no:MAN', "; writeLog("'$f_tr_commission_no' != '$f_tr_commission_no_old'"); $delete_old_process = true; endif; if ($f_tr_signname != $f_tr_signname_old): $updateStmt .= "tr_signname = '$f_tr_signname', "; endif; if ($f_tr_cs_freetext != $f_tr_cs_freetext_old): // $updateStmt .= "tr_cs_freetext = '$f_tr_cs_freetext', "; endif; if ($delete_old_process && $f_trat_id != "" && $f_tr_status_ori == 1): $updateStmts[] = "DELETE FROM tourarticleprocess WHERE trat_id = $f_trat_id AND tratp_createtime = '$f_tr_finishtime_old'"; endif; if ($updateStmt != ""): $updateStmts[] = "UPDATE tour SET " . substr($updateStmt, 0, -2) . " WHERE jb_id = $f_jb_id AND tr_sort = $i"; endif; endif; //echo $i . "-" . $f_tr_status . "
\n"; if ($f_tr_status != 1 && $f_tr_status != ""): $jb_status = 1; endif; //echo $i . "-" . $jb_status . "
\n"; endfor; // Auf Änderungen in `job` checken $updateStmt = ""; if ($f_cr_sid != $f_cr_sid_old): $sqlquery = "SELECT courier.cr_id FROM couriervehicle, courier WHERE couriervehicle.cr_id = courier.cr_id AND hq_id = " . $hq_id . " AND crvh_sid = '$f_cr_sid'"; $res = $db->query($sqlquery); if (DB::isError($res)) die ("$PHP_SELF: [$sqlquery] " . $res->getMessage()); if ($row = $res->fetch_assoc()): $updateStmt .= "cr_sid = '$f_cr_sid', cr_id = " . $row["cr_id"] . ", cr_id_order = " . $row["cr_id"] . ", "; $res->free(); else: $msg_txt .= "Ungültige Fahrernummer: '" . $f_cr_sid . "'
\n"; $restore_cr_sid = $f_cr_sid; endif; endif; if ($jb_status == 2 && count($updateStmts) > 0): $updateStmt .= "jb_status = 2, jb_finishtime = '" . $f_tr_finishtime_max . "', "; endif; if ($updateStmt != ""): $updateStmts[] = "UPDATE job SET " . substr($updateStmt, 0, -2) . " WHERE jb_id = $f_jb_id"; endif; $tmp_arr = array_count_values($msg_txts); if (count($msg_txts) != $tmp_arr[""] || $msg_txt != ""): $msg_txt = "Bitte vor dem Speichern Fehler beheben!
\n" . $msg_txt; endif; // UPDATE-Statements ausführen if ($msg_txt == ""): if (count($updateStmts) > 0): foreach ($updateStmts as $updateStmt) { writeLog("[$updateStmt]"); $db->query($updateStmt); } $msg_txt = "Die Änderungen wurden gespeichert."; else: $msg_txt = "Es wurden keine Änderungen vorgenommen."; endif; else: $restore_jb_id = $f_jb_id; endif; endif; if ($track_id != ""): $sqlquery = "SELECT job.jb_id, cr_sid, jb_ordertime, jb_status FROM tourarticle, job" . " WHERE trat_serialno = '" . $track_id . "' AND job.jb_id = tourarticle.jb_id" . " AND tr_sort > 1 AND csc_id_payer IN " . $csc_id_sql[$hq_id] . " ORDER BY job.jb_id desc"; $res = $db->query($sqlquery); if (DB::isError($res)) die ("$PHP_SELF: [$sqlquery] " . $res->getMessage()); $content = ""; while ($row = $res->fetch_assoc()): $tmp_content = ""; $sqlquery = "SELECT trat_id, trat_serialno, tr.tr_sort, tr_comp, tr_comp2, tr_person, tr_phone, tr_status, tr_signname," . " tr_finishtime, tr_commission_no, tr_cs_freetext, ad_street, tr_hsno, ad_zipcode, ad_city" . " FROM address AS ad, tour AS tr LEFT JOIN tourarticle AS ta ON (ta.jb_id = tr.jb_id AND ta.tr_sort = tr.tr_sort)" . " WHERE tr.jb_id = " . $row["jb_id"] . " AND tr.ad_id = ad.ad_id ORDER BY tr.tr_sort"; $res1 = $db->query($sqlquery); if (DB::isError($res1)) die ("$PHP_SELF: [$sqlquery] " . $res1->getMessage()); $i = 1; while ($row1 = $res1->fetch_assoc()): if ($row1["tr_sort"] > 1 || $i++ == 1): $row2 = $row1; if ($restore_jb_id == $row["jb_id"]): $row2["tr_finishtime"] = $restore_values[$row2["tr_sort"]]["tr_finishtime"]; $row2["tr_commission_no"] = $restore_values[$row2["tr_sort"]]["tr_commission_no"]; $row2["tr_signname"] = $restore_values[$row2["tr_sort"]]["tr_signname"]; $row2["tr_cs_freetext"] = $restore_values[$row2["tr_sort"]]["tr_cs_freetext"]; else: $tcn_parts = explode(":", $row1["tr_commission_no"]); if (count($tcn_parts) > 1): $row1["tr_commission_no"] = trim($tcn_parts[0]) . ":" . trim($tcn_parts[1]); endif; endif; $tmp_content .= mk_station($row2, $row1); endif; $tr_sort_max = $row1["tr_sort"]; endwhile; $res1->free(); if ($msg_txt != ""): $msg_txt = "

" . $msg_txt; endif; $content .= " \n" . "
\n" . "
\n" . " Auftrag Nr. " . $row["jb_id"] . "

Eingestellt am " . formDate($row["jb_ordertime"]) . " um " . substr($row["jb_ordertime"], 11, 8) . " Uhr
\n" . "
\n" . " \n" . " \n" . " \n" . "
\n" . "
\n" . " \n" . " \n" . " \n" . " \n" . " \n" . " Fahrer:  \n" . " " . $msg_txt . "
" . " \n" . " \n" . " \n" . "
Station 
" . "
Erledigung: Datum/Uhrzeit, Art, Klartext 
" . "
Fahrer  
" . " \n" . $tmp_content . " \n" . " \n" . "  
\n" . "
\n" . "  
\n" . "  
\n" . " \n" . " \n" . " \n"; endwhile; $res->free(); // else: // $msg_txt .= "" . "Tracking-ID nicht gefunden: '$track_id'" . "
\n"; // endif; else: $content = "" . "Parameter 'track_id' fehlt" . "
\n"; endif; function mk_station($row1, $row2) { global $track_id, $msg_txts; $tmp_content = ""; if ($row1["tr_sort"] == 1): $row1["trat_serialno"] = ""; endif; $tr_commission_no_deactivated = ""; $tr_cs_freetext_deactivated = ""; if ($row1["tr_status"] != 1): if ($row1["tr_sort"] % 2 == 0) : $cellColor = "#FFBBBB"; $cellColor2 = "#FFCCCC"; endif; if ($row1["tr_sort"] % 2 == 1) : $cellColor = "#FF9999"; $cellColor2 = "#FFAAAA"; endif; else: if ($row1["tr_sort"] % 2 == 0) : $cellColor = "#DDDDDD"; $cellColor2 = "#EEEEEE"; endif; if ($row1["tr_sort"] % 2 == 1) : $cellColor = "#BBBBFF"; $cellColor2 = "#CCCCFF"; endif; $tr_commission_no_deactivated = "disabled"; $tr_finishtime_deactivated = "disabled"; endif; $tmp_content .= " " . " "; if ($track_id == $row1["trat_serialno"]) $tmp_content .= ""; $tmp_content .= $row1["tr_sort"] . ": " . (trim($row1["trat_serialno"]) != "" ? ($row1["trat_serialno"] . " - " . $row1["tr_comp2"]) : ""); $tmp_content .= "
\n"; $tmp_content .= "" . $row1["tr_comp"]; if (trim($row1["tr_person"]) != ""): $tmp_content .= ", " . $row1["tr_person"]; endif; $tmp_content .= "
\n"; $tmp_content .= $row1["ad_zipcode"] . " " . $row1["ad_city"]; $tmp_content .= ", " . $row1["ad_street"] . " " . $row1["tr_hsno"] . "

\n"; if (trim($row1["tr_phone"]) != ""): $tmp_content .= "Tel.: " . $row1["tr_phone"] . "
\n"; endif; if ($track_id == $row1["trat_serialno"]) $tmp_content .= "
"; $tr_commission_no = ""; if ($row1["ad_zipcode"] . $row1["ad_city"] . $row1["ad_street"] . $row1["tr_hsno"] == "71229LeonbergHertichstraße10"): $tr_commission_no_deactivated = "disabled"; // $tr_cs_freetext_deactivated = "disabled"; else: $tcn_parts = explode(":", $row1["tr_commission_no"]); $tr_commission_no = trim($tcn_parts[0]) . ":" . trim($tcn_parts[1]); endif; $tr_cs_freetext_deactivated = "disabled"; $tr_commission_no_select = "\n"; $row1_tr_sort = $row1["tr_sort"]; $tmp_content .= " \n" . " \n" . "\n" . "\n" . "\n" . "\n" . "\n" . "\n" . " " . $tr_commission_no_select . " \n" . " \n" . (isset($msg_txts[$row1_tr_sort]) ? "
\n" . $msg_txts[$row1_tr_sort] . "" : "") . " \n" . " \n" . " \n" . " \n" . " \n"; return $tmp_content; } function formDate($sqlDate) { if (trim($sqlDate) == "") return ""; return substr($sqlDate, 8, 2) . "." . substr($sqlDate, 5, 2) . "." . substr($sqlDate, 0, 4); } function sqlDate($germanDate) { if (trim($germanDate) == "") return ""; return substr($germanDate, 6, 4) . "-" . substr($germanDate, 3, 2) . "-" . substr($germanDate, 0, 2); } //function writeLog($log_text) //{ // $today = getdate(); // $fileHandle = @fopen("../log/amazon_" . $today['year'] . sprintf("%02d", $today['mon']) . ".log", 'a'); // @fwrite($fileHandle, "[" . date("Y-m-d H:i:s") . "] [" . LOG_NAME . "] " . $log_text . "\n"); // @fclose($fileHandle); // return; //} ?> AUFTRAGSBEARBEITUNG