jb-data.de/scripts/imarktplatz.php
2025-08-11 22:23:30 +02:00

103 lines
4.4 KiB
PHP

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
if($_SESSION['benutzer']==12) { $planer="T. Muerbe"; }
else if($_SESSION['benutzer']==13) { $planer="Anett"; }
else if($_SESSION['benutzer']==18) { $planer="Joerg Basse"; }
else if($_SESSION['benutzer']==44) { $planer="I. Steinmacher"; }
else $planer="Frank";
$jahr_aktuell = (int)date('Y');
$kw_aktuell = (int)date('W');
//----------------------------------------------- Normplan speichern
if(isset($_POST['mpnorm'])) {
$GLOBALS['mysql']->insert("UPDATE tourenliste SET Norm='".$_POST['mpnorm']."' WHERE typ=10 and kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."' and typ=10");
$template->assign('success', 'Die Norm wurde angepasst und alle Touren neu berechnet');
}
//----------------------------------------------- Gewicht speichern
if(isset($_POST['gewicht'])) {
$GLOBALS['mysql']->insert("UPDATE tourenliste SET gewicht2='".$_POST['gewicht']."' WHERE kw='".$kw_aktuell."' AND jahr='".$jahr_aktuell."' and typ=10");
}
//---------------------- Erscheinungstag speichern
elseif(isset($_POST['datesave'])) {
$tmp = $GLOBALS['mysql']->query("SELECT * FROM touren WHERE typ=10");
while($row = $tmp->fetch_assoc()) {
$teilen = explode(".",$_POST['datumstadt']);
$GLOBALS['mysql']->insert("UPDATE tourenliste SET tag='".$teilen[0]."' WHERE tour='".$row['id']."' and kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."'");
$GLOBALS['mysql']->insert("UPDATE tourenliste SET monat='".$teilen[1]."' WHERE tour='".$row['id']."' and kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."'");
$GLOBALS['mysql']->insert("UPDATE tourenliste SET jahr='".$teilen[2]."' WHERE tour='".$row['id']."' and kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."'");
}
$success[]='Der Marktplatz-Abholtag wurde ge&auml;ndert.'; $template->assign('success', $success);
}
//------------------------ speicherbutten
elseif(isset($_POST['datasave'])) {
foreach($_POST['list'] as $row) {
$GLOBALS['mysql']->insert("UPDATE tourenliste SET exemplare='".$row['exemplare']."',zeit='".$row['szeit']."' WHERE id='".$row['tid']."'");
}
$success[]='Alle Touren wurden ge&auml;ndert.'; $template->assign('success', $success);
}
//--------------------- auslesen
$key=0;
$rs_tour = $GLOBALS['mysql']->query("SELECT * FROM tourenliste WHERE kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."' and typ=10");
while($row = $rs_tour->fetch_assoc()) {
$row_tour = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE id='".$row['tour']."'");
$wochentag=date('l',mktime(0,0,0,$row['monat'],$row['tag'],$row['jahr']));
$taginfo2=$GLOBALS['core']->translateDate($wochentag);
$datumstadt=$row['tag'].".".$row['monat'].".".$row['jahr'];
$datumstadt2=$wochentag=$GLOBALS['core']->translateDate($wochentag)." - ".$row['tag'].".".$row['monat'].".".$row['jahr'];
$rs_tour2[$key]['tour']=$row_tour['tour'];
$rs_tour2[$key]['id']=$row['id'];
if($row['Norm']>0) {
$rs_tour2[$key]['norm']=$row['Norm'];
} else {
$pak=0;
$mnorm=$row['Norm'];
// -----------------------------error einfügen Norm fehlt
}
if($row['gewicht']==0) {
$pak=0;
// -----------------------------error einfügen Gewicht fehlt
}
if($row['exemplare']>0) { //exemplare auslesen
$rs_tour2[$key]['exemplare']=$row['exemplare'];
} else {
$rs_tour2[$key]['exemplare']=$row_tour['exemplare'];
}
//---- Pakete berechnen und speichern
if ($mnorm==0) {$mnorm=60;}
$pak=$rs_tour2[$key]['exemplare']/$mnorm;
$rs_tour2[$key]['pakete']=ceil($pak);
$GLOBALS['mysql']->insert("UPDATE tourenliste SET Pakete='".$pak."' WHERE id='".$row['id']."'");
//---- Gesamtgewicht berechnen und speichern
$mpgewicht=$pak*$row['gewicht2'];
$mpgewicht=$mpgewicht+0.027; // ausrechnung anpassen
$rs_tour2[$key]['gewicht']=round($mpgewicht);
$mpkg=$row['gewicht2'];
$GLOBALS['mysql']->insert("UPDATE tourenliste SET gewicht='".$rs_tour2[$key]['gewicht']."' WHERE id='".$row['id']."'");
$rs_tour2[$key]['tid']=$key;
$mpnorm=$row['Norm'];
$rs_tour2[$key]['zeit']=$row['zeit'];
$rs_tour2[$key]['gewicht']=$row['gewicht'];
$rs_tour2[$key]['norm']=$row['Norm'];
$key++;
}
$template->assign('mpnorm', $mpnorm);
$template->assign('mpkg', $mpkg);
$template->assign('datumstadt',$datumstadt);
$template->assign('datumstadt2',$datumstadt2);
$template->assign('jahr_aktuell', $jahr_aktuell);
$template->assign('kw_aktuell', $kw_aktuell);
$template->assign('rs_tour2', $rs_tour2);
$template->assign('content', 'tpl/imarktplatz.tpl');
?>