$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 .=
"
|
|