- Endzeiten bei CheckOut und Startzeiten bei CheckIn komplett entfernt
- Zeiten einzeln Ein- und Ausblendbar gemacht - Quelle für Zeilenfarbe einstellbar gemacht - Zeiten werden jetzt bei erreichen bzw überschreiten immer markiert (nur die Zeit) - Nicht benötigte Spalten werden automatisch ausgeblendet - Config Datei Ausgedünnt (Bitte komplette Epirent-Settings (nicht Login) Sektion ersetzen
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
|
||||
error_reporting(E_ALL);
|
||||
require('../config.php');
|
||||
require('../EpiApi.php');
|
||||
@@ -19,23 +20,64 @@ $options = new QROptions([
|
||||
'quietzoneSize' => 1
|
||||
]);
|
||||
|
||||
|
||||
$Epi = new Epirent();
|
||||
|
||||
if(UseDeliveredForCheckOutCompleted){
|
||||
$result = $Epi->requestEpiApi('/v1/packingnote/open?isco=False&cl=' . Epirent_Mandant);
|
||||
const APP_TZ = 'Europe/Berlin';
|
||||
|
||||
}else{
|
||||
$result = $Epi->requestEpiApi('/v1/packingnote/open?isci=False&cl=' . Epirent_Mandant);
|
||||
/** Hilfsfunktionen für die Row-Marking-Logik (ohne weitere Änderungen am Rest) */
|
||||
function dt(?string $s): ?DateTimeImmutable {
|
||||
if (!$s)
|
||||
return null;
|
||||
try {
|
||||
return new DateTimeImmutable($s, new DateTimeZone(APP_TZ));
|
||||
} catch (Throwable $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function dayStart(DateTimeImmutable $d): DateTimeImmutable {
|
||||
return $d->setTime(0, 0, 0);
|
||||
}
|
||||
|
||||
function resolveRowMarkDate($packingjob, $VorbereitungsTimeDetail, $PackingNoteDetail, int $source): ?DateTimeImmutable {
|
||||
$candidate = null;
|
||||
switch ($source) {
|
||||
case 1: $candidate = dt($packingjob->date_start ?? null);
|
||||
break;
|
||||
case 2: $candidate = dt($VorbereitungsTimeDetail->date_start ?? null);
|
||||
break;
|
||||
case 3: $candidate = dt($PackingNoteDetail->date_packing ?? null);
|
||||
break;
|
||||
case 4: $candidate = dt($PackingNoteDetail->date_delivery ?? null);
|
||||
break;
|
||||
default: $candidate = null;
|
||||
break;
|
||||
}
|
||||
if (!$candidate) {
|
||||
$candidate = dt($packingjob->date_start ?? null);
|
||||
}
|
||||
return $candidate ? dayStart($candidate) : null;
|
||||
}
|
||||
|
||||
function rowClassForDate(?DateTimeImmutable $markDate, ?DateTimeImmutable $today): string {
|
||||
if (!$markDate || !$today)
|
||||
return '';
|
||||
if ($markDate == $today)
|
||||
return 'text-dark bg-warning';
|
||||
if ($markDate < $today)
|
||||
return 'bg-danger';
|
||||
return '';
|
||||
}
|
||||
|
||||
if (UseDeliveredForCheckOutCompleted) {
|
||||
$result = $Epi->requestEpiApi('/v1/packingnote/open?isco=False&cl=' . Epirent_Mandant);
|
||||
} else {
|
||||
$result = $Epi->requestEpiApi('/v1/packingnote/open?isci=False&cl=' . Epirent_Mandant);
|
||||
}
|
||||
$data_output = json_decode($result)->payload;
|
||||
|
||||
|
||||
|
||||
if (SortCheckOut == 2) {
|
||||
|
||||
|
||||
|
||||
// Prüfen, ob $data_output ein Array ist
|
||||
if (is_array($data_output)) {
|
||||
usort($data_output, function ($a, $b) {
|
||||
@@ -60,70 +102,54 @@ if (SortCheckOut == 2) {
|
||||
|
||||
foreach ($data_output as $packingjob) {
|
||||
|
||||
$PackingNoteDetail = null;
|
||||
|
||||
$PackingNote_data_output;
|
||||
|
||||
if($packingjob->is_archived != true && UseDeliveredForCheckOutCompleted){
|
||||
$PackingNoteDetailResult = $Epi->requestEpiApi('/v1/packingnote/' . $packingjob->primary_key . '?cl=' . Epirent_Mandant);
|
||||
$PackingNote_data_output = json_decode($PackingNoteDetailResult)->payload[0];
|
||||
}
|
||||
|
||||
if ($packingjob->is_archived != true && (!UseDeliveredForCheckOutCompleted || ($PackingNote_data_output->date_delivered == "0000-00-00" && $PackingNote_data_output->time_delivered == 0))) {
|
||||
if ($packingjob->is_archived != true && UseDeliveredForCheckOutCompleted) {
|
||||
$PackingNoteDetailResult = $Epi->requestEpiApi('/v1/packingnote/' . $packingjob->primary_key . '?cl=' . Epirent_Mandant);
|
||||
$PackingNoteDetail = json_decode($PackingNoteDetailResult)->payload[0];
|
||||
}
|
||||
|
||||
if (
|
||||
$packingjob->is_archived != true
|
||||
&& (
|
||||
!UseDeliveredForCheckOutCompleted
|
||||
|| ($PackingNoteDetail->date_delivered !== "0000-00-00" || (int)$PackingNoteDetail->time_delivered !== 0)
|
||||
)
|
||||
&& (int)$PackingNoteDetail->is_all_out !== 0
|
||||
) {
|
||||
//get OrderDetails
|
||||
$result = $Epi->requestEpiApi('/v1/order/' . $packingjob->order_pk . '?cl=' . Epirent_Mandant);
|
||||
|
||||
$orderdetail_output = json_decode($result)->payload[0];
|
||||
|
||||
// get PackingNote Details
|
||||
if(!UseDeliveredForCheckOutCompleted){
|
||||
$PackingNoteDetailResult = $Epi->requestEpiApi('/v1/packingnote/' . $packingjob->primary_key . '?cl=' . Epirent_Mandant);
|
||||
$PackingNote_data_output = json_decode($PackingNoteDetailResult)->payload[0];
|
||||
// get PackingNote Details, aber nur wenn nicht schon vor der schleife geholt.
|
||||
if (!UseDeliveredForCheckOutCompleted) {
|
||||
$PackingNoteDetailResult = $Epi->requestEpiApi('/v1/packingnote/' . $packingjob->primary_key . '?cl=' . Epirent_Mandant);
|
||||
$PackingNoteDetail = json_decode($PackingNoteDetailResult)->payload[0];
|
||||
}
|
||||
$VorbereitungsTimeDetail;
|
||||
|
||||
$VorbereitungsTimeDetail = null;
|
||||
|
||||
foreach ($orderdetail_output->order_schedule as $scheduledetail) {
|
||||
|
||||
|
||||
if (UsePackingNoteDateForCheckout) {
|
||||
|
||||
$tempTimeObject = new stdClass();
|
||||
$tempTimeObject->date_start = $PackingNote_data_output->date_packing;
|
||||
$tempTimeObject->time_start = $PackingNote_data_output->time_packing;
|
||||
|
||||
$VorbereitungsTimeDetail = $tempTimeObject;
|
||||
} else {
|
||||
if ($scheduledetail->name == Vorbereitungs_Zeitvariable) {
|
||||
$VorbereitungsTimeDetail = $scheduledetail;
|
||||
}
|
||||
if ($scheduledetail->name == Vorbereitungs_Zeitvariable) {
|
||||
$VorbereitungsTimeDetail = $scheduledetail;
|
||||
}
|
||||
}
|
||||
//End Of get Order Details
|
||||
|
||||
if (CheckOut_UseDispoStartForRowMarking || ($VorbereitungsTimeDetail->date_start == null)) {
|
||||
$date = new DateTime($packingjob->date_start);
|
||||
} else if(UseDeliveredForCheckOutCompleted ){
|
||||
{
|
||||
$date = new DateTime($PackingNote_data_output->date_delivery);
|
||||
|
||||
}
|
||||
}else{
|
||||
$date = new DateTime($VorbereitungsTimeDetail->date_start);
|
||||
// --- Row-Marking Datum bestimmen (konfigurierbar) ---
|
||||
$today = dayStart(new DateTimeImmutable('today', new DateTimeZone(APP_TZ)));
|
||||
$todayFilter = $today; // für die Window-Berechnung
|
||||
$limit = null;
|
||||
if (CheckOut_FutureDays != -1) {
|
||||
$limit = $todayFilter->modify('+' . (int) CheckOut_FutureDays . ' day');
|
||||
}
|
||||
|
||||
$date->setTime(0, 0, 0);
|
||||
$today = new DateTime();
|
||||
$today->setTime(0, 0, 0);
|
||||
$markDate = resolveRowMarkDate($packingjob, $VorbereitungsTimeDetail, $PackingNoteDetail, (int) CheckOutRowMarkSource);
|
||||
|
||||
$todayFilter = new DateTime();
|
||||
$todayFilter->setTime(0, 0, 0);
|
||||
if (CheckOut_FutureDays == -1 || $date <= ($todayFilter->modify('+' . CheckOut_FutureDays . ' day'))) {
|
||||
//prüfe, ob entweder unbegrenzte (-1) Anzeige Aktiv ist, oder das Datum kleiner oder Gleich heute + Zukunftsspanne ist
|
||||
if ($date == $today) {
|
||||
if (CheckOut_FutureDays == -1 || ($markDate && $markDate <= $limit)) {
|
||||
$trClass = rowClassForDate($markDate, $today);
|
||||
|
||||
echo "<tr class='text-dark bg-warning'>";
|
||||
} else if ($date < $today) {
|
||||
echo "<tr class=' bg-danger'>";
|
||||
if ($trClass) {
|
||||
echo "<tr class='{$trClass}'>";
|
||||
} else {
|
||||
echo "<tr>";
|
||||
}
|
||||
@@ -136,61 +162,37 @@ if($packingjob->is_archived != true && UseDeliveredForCheckOutCompleted){
|
||||
echo "<td>" . $packingjob->contact->name . "</td>";
|
||||
echo "<td>" . $packingjob->event . "</td>";
|
||||
|
||||
|
||||
if (ShowCheckoutTimeOnCheckout || ShowVorbereitungTimeOnCheckout || ShowPackagingTimeOnCheckout || ShowDeliveryTimeOnCheckout) { echo "<td>";}
|
||||
|
||||
|
||||
if(UseDeliveredForCheckOutCompleted){
|
||||
|
||||
if (CheckOut_UseDispoStartForRowMarking || ($VorbereitungsTimeDetail->date_start == null)) {
|
||||
$date = new DateTime($packingjob->date_start);
|
||||
} else {
|
||||
$date = new DateTime($VorbereitungsTimeDetail->date_start);
|
||||
}
|
||||
|
||||
if ($date == $today) {
|
||||
|
||||
echo "<td class='text-dark bg-warning'>";
|
||||
} else if ($date < $today) {
|
||||
echo "<td class=' bg-danger'>";
|
||||
} else {
|
||||
echo "<td>";
|
||||
if (ShowCheckoutTimeOnCheckout && $packingjob->date_start != null) {
|
||||
echoMarkedTimeLine($packingjob->date_start, (int) $packingjob->time_start, $today, ShowTimesOnCheckout);
|
||||
}
|
||||
if (ShowVorbereitungTimeOnCheckout && $VorbereitungsTimeDetail && $VorbereitungsTimeDetail->date_start != null) {
|
||||
if (ShowCheckoutTimeOnCheckout) {
|
||||
echo "<br>";
|
||||
}
|
||||
echoMarkedTimeLine($VorbereitungsTimeDetail->date_start, (int) $VorbereitungsTimeDetail->time_start, $today, ShowTimesOnCheckout);
|
||||
}
|
||||
if (ShowPackagingTimeOnCheckout && $PackingNoteDetail && $PackingNoteDetail->date_packing != null) {
|
||||
if (ShowCheckoutTimeOnCheckout || ShowVorbereitungTimeOnCheckout) {
|
||||
echo "<br>";
|
||||
}
|
||||
echoMarkedTimeLine($PackingNoteDetail->date_packing, (int) $PackingNoteDetail->time_packing, $today, ShowTimesOnCheckout);
|
||||
}
|
||||
if (ShowDeliveryTimeOnCheckout && $PackingNoteDetail && $PackingNoteDetail->date_delivery != null) {
|
||||
if (ShowCheckoutTimeOnCheckout || ShowVorbereitungTimeOnCheckout || ShowPackagingTimeOnCheckout) {
|
||||
echo "<br>";
|
||||
}
|
||||
echoMarkedTimeLine($PackingNoteDetail->date_delivery, (int) $PackingNoteDetail->time_delivery, $today, ShowTimesOnCheckout);
|
||||
}
|
||||
|
||||
|
||||
if (ShowCheckoutTimeOnCheckout || ShowVorbereitungTimeOnCheckout || ShowPackagingTimeOnCheckout || ShowDeliveryTimeOnCheckout) {
|
||||
echo "</td>";
|
||||
}
|
||||
|
||||
}else{
|
||||
|
||||
echo "<td>";
|
||||
|
||||
}
|
||||
|
||||
if ($VorbereitungsTimeDetail->date_start != null) {
|
||||
|
||||
if(!HideDispoTimes){
|
||||
echo "<small>".date_format(new \DateTime($packingjob->date_start), 'd.m.Y') . " " . getTimeFromSeconds($packingjob->time_start) . "</small><br>";
|
||||
}
|
||||
echo "<i>" . date_format(new \DateTime($VorbereitungsTimeDetail->date_start), 'd.m.Y') . " " . getTimeFromSeconds($VorbereitungsTimeDetail->time_start) . "</i></td>";
|
||||
|
||||
|
||||
|
||||
} else if(!HideDispoTimes){
|
||||
date_format(new \DateTime($packingjob->date_start), 'd.m.Y') . " " . getTimeFromSeconds($packingjob->time_start) . "</td>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!HideCheckInTimeOnCheckout) {
|
||||
if (($VorbereitungsTimeDetail->date_end != null)) {
|
||||
|
||||
if(!HideDispoTimes){
|
||||
|
||||
echo "<small>" . date_format(new \DateTime($packingjob->date_end), 'd.m.Y') . " " . getTimeFromSeconds($packingjob->time_end) . "</small><br>";
|
||||
}
|
||||
echo "<i>" . date_format(new \DateTime($VorbereitungsTimeDetail->date_end), 'd.m.Y') . " " . getTimeFromSeconds($VorbereitungsTimeDetail->time_end) . "</i></td>";
|
||||
|
||||
} else if(!HideDispoTimes){
|
||||
echo date_format(new \DateTime($packingjob->date_end), 'd.m.Y') . " " . getTimeFromSeconds($packingjob->time_end) . "</td>";
|
||||
}
|
||||
}
|
||||
echo "<td>";
|
||||
|
||||
|
||||
if ($packingjob->is_all_out == 0) {
|
||||
echo "<span class='badge badge-success'>";
|
||||
@@ -203,52 +205,65 @@ if($packingjob->is_archived != true && UseDeliveredForCheckOutCompleted){
|
||||
|
||||
echo ($packingjob->pieces_sum_total - abs($packingjob->is_all_out)) . "/" . $packingjob->pieces_sum_total;
|
||||
echo "</span></td>";
|
||||
|
||||
if(ShowShippingIcons){
|
||||
|
||||
if(UseShippingStatus){
|
||||
if(($PackingNote_data_output->status==ShippingOutOrganizedStatus)||($PackingNote_data_output->status==ShippingOrganizedStatus)){
|
||||
echo "<td style='color:#66FF00; text-align:center;'>";
|
||||
}else{
|
||||
echo "<td style='text-align:center;'>";
|
||||
|
||||
}
|
||||
|
||||
if($PackingNote_data_output->is_self_pickup){
|
||||
echo '<i class="fa-solid fa-person-walking fa-lg"></i>';
|
||||
} else{
|
||||
if(preg_match('/'.KurierContainsText.'/i',$PackingNote_data_output->shipping_out)){
|
||||
echo '<i class="fa-solid fa-hand-holding-dollar fa-lg"></i>';
|
||||
if (ShowShippingIcons) {
|
||||
|
||||
if (UseShippingStatus) {
|
||||
if (($PackingNoteDetail->status == ShippingOutOrganizedStatus) || ($PackingNoteDetail->status == ShippingOrganizedStatus)) {
|
||||
echo "<td style='color:#66FF00; text-align:center;'>";
|
||||
} else {
|
||||
echo "<td style='text-align:center;'>";
|
||||
}
|
||||
if(preg_match('/'.SpeditionContainsText.'/i',$PackingNote_data_output->shipping_out)){
|
||||
echo '<i class="fa-solid fa-truck fa-lg"></i>';
|
||||
}
|
||||
if(preg_match('/'.DHLContainsText.'/i',$PackingNote_data_output->shipping_out)){
|
||||
echo '<i class="fa-brands fa-dhl fa-2xl"></i>';
|
||||
}
|
||||
if(preg_match('/'.LKWContainsText.'/i',$PackingNote_data_output->shipping_out)){
|
||||
echo '<i class="fa-solid fa-industry fa-lg"></i><i class="fa-solid fa-truck fa-lg"></i>';
|
||||
}
|
||||
if(preg_match('/'.TransporterContainsText.'/i',$PackingNote_data_output->shipping_out)){
|
||||
echo '<i class="fa-solid fa-industry fa-lg"></i><i class="fa-solid fa-van-shuttle fa-lg"></i>';
|
||||
}
|
||||
if(preg_match('/'.PKWContainsText.'/i',$PackingNote_data_output->shipping_out)){
|
||||
echo '<i class="fa-solid fa-industry fa-lg"></i><i class="fa-solid fa-car fa-lg"></i>';
|
||||
|
||||
if ($PackingNoteDetail->is_self_pickup) {
|
||||
echo '<i class="fa-solid fa-person-walking fa-lg"></i>';
|
||||
} else {
|
||||
if (preg_match('/' . KurierContainsText . '/i', $PackingNoteDetail->shipping_out)) {
|
||||
echo '<i class="fa-solid fa-hand-holding-dollar fa-lg"></i>';
|
||||
}
|
||||
if (preg_match('/' . SpeditionContainsText . '/i', $PackingNoteDetail->shipping_out)) {
|
||||
echo '<i class="fa-solid fa-truck fa-lg"></i>';
|
||||
}
|
||||
if (preg_match('/' . DHLContainsText . '/i', $PackingNoteDetail->shipping_out)) {
|
||||
echo '<i class="fa-brands fa-dhl fa-2xl"></i>';
|
||||
}
|
||||
if (preg_match('/' . LKWContainsText . '/i', $PackingNoteDetail->shipping_out)) {
|
||||
echo '<i class="fa-solid fa-industry fa-lg"></i><i class="fa-solid fa-truck fa-lg"></i>';
|
||||
}
|
||||
if (preg_match('/' . TransporterContainsText . '/i', $PackingNoteDetail->shipping_out)) {
|
||||
echo '<i class="fa-solid fa-industry fa-lg"></i><i class="fa-solid fa-van-shuttle fa-lg"></i>';
|
||||
}
|
||||
if (preg_match('/' . PKWContainsText . '/i', $PackingNoteDetail->shipping_out)) {
|
||||
echo '<i class="fa-solid fa-industry fa-lg"></i><i class="fa-solid fa-car fa-lg"></i>';
|
||||
}
|
||||
}
|
||||
echo "</td>";
|
||||
}
|
||||
echo "</td>";
|
||||
|
||||
}
|
||||
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
|
||||
|
||||
echo "</tr>";
|
||||
}
|
||||
|
||||
echo "</tr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function echoMarkedTimeLine(?string $dateStr, ?int $timeSeconds, DateTimeImmutable $today, $ReturnTime): void {
|
||||
if (!$dateStr)
|
||||
return;
|
||||
$d = dt($dateStr);
|
||||
if (!$d)
|
||||
return;
|
||||
|
||||
$mark = dayStart($d);
|
||||
$cls = rowClassForDate($mark, $today);
|
||||
|
||||
echo $cls ? "<span class=\"{$cls}\">" : "";
|
||||
echo date_format(new \DateTime($dateStr), 'd.m.Y');
|
||||
if($ReturnTime){echo " ".getTimeFromSeconds((string) $timeSeconds);}
|
||||
echo $cls ? "</span>" : "";
|
||||
}
|
||||
|
||||
function getTimeFromSeconds(string $timestring) {
|
||||
|
||||
$hours = floor($timestring / 3600);
|
||||
@@ -260,4 +275,4 @@ function getTimeFromSeconds(string $timestring) {
|
||||
return $timeFormat;
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user