207 lines
10 KiB
PHP
207 lines
10 KiB
PHP
<?php
|
|
$_SESSION['m1']=3; $_SESSION['m2']=11;
|
|
|
|
error_reporting(E_ALL); error_reporting(1);
|
|
|
|
//--------- jahrauswahl
|
|
|
|
$pjahr=date('W', (mktime(0, 0, 0, 1, 1, $jahr+1) - 4*86400));
|
|
$ijahr=date('W', (mktime(0, 0, 0, 1, 1, $jahr) - 4*86400));
|
|
$mjahr=date('W', (mktime(0, 0, 0, 1, 1, $jahr-1) - 4*86400));
|
|
if($_GET['wahl']==1){ if($_GET['kw']==1) { $kw=$mjahr; $jahr=$_GET['jahr']-1;} else { $kw=$_GET['kw']-1; $jahr=$_GET['jahr'];}}
|
|
elseif($_GET['wahl']==2){ if($_GET['kw']==$ijahr) { $kw=1; $jahr=$_GET['jahr']+1; } else { $kw=$_GET['kw']+1; $jahr=$_GET['jahr']; }
|
|
} else {
|
|
$jahr = (int)date('Y');
|
|
$kw = (int)date('W');
|
|
}
|
|
/* $jahr = $jahr; $kw = $kw; */
|
|
//------------------- next sunnday of kw
|
|
$temp = strtotime("next Sunday");
|
|
$tag=date('d', $temp); $monat=date('m', $temp); $jahr=date('Y', $temp);
|
|
$sasodatum=$tag.".".$monat.".".$jahr;
|
|
$sasonorm=$GLOBALS['mysql']->query_single("SELECT * FROM sasonorm WHERE kw='".$kw."' AND jahr='".$jahr."'");
|
|
$saso_norm=$sasonorm['norm'];
|
|
$jahr_aktuell = (int)date('Y');
|
|
$kw_aktuell = (int)date('W');
|
|
//------------------------------------------ komplette Tabelle speichern
|
|
if(isset($_POST['testsave'])) {
|
|
foreach($_POST['list'] as $row) {
|
|
$pak=$row['exemplare']/$row['norm']; $pak2=ceil($pak); // Pakete ausrechnen
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET gewicht='".$row['gewicht']."',gewicht4='".$row['gewicht4']."',exemplare='".$row['exemplare']."' WHERE id='".$row['tid']."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET Norm='".$row['norm']."',Pakete='".$pak2."',rampe='".$row['rampe']."' WHERE id='".$row['tid']."'");
|
|
}
|
|
$success[]='Alle Touren wurden geändert.'; $template->assign('success', $success);
|
|
}
|
|
//---------------------------------------- Tour minus
|
|
//--------------------------------------------------------------------------------------
|
|
//---------------- Abnahme-Tour löschen
|
|
elseif(isset($_POST['delete2'])) {
|
|
if($_POST['delete2']>1000) {
|
|
$GLOBALS['mysql']->query("DELETE FROM tourenliste WHERE id='".$_POST['delete2']."'");
|
|
}
|
|
}
|
|
elseif(isset($_POST['tourminus'])) {
|
|
$row_tour = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE tour3='".$_POST['tourminus']."'"); $typ=8;
|
|
$GLOBALS['mysql']->query("DELETE FROM tourenliste WHERE tour='".$row_tour['id']."' and kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."'");
|
|
$template->assign('danger', "SaSo Tour:".$_POST['tourminus']." geloescht.");
|
|
}
|
|
//---------------------------------------- Tour add
|
|
//---------------- neue Tour Hinzufügen
|
|
elseif(isset($_POST['dazu'])) {
|
|
$ptourid=$_POST['plus'];
|
|
$ptourid=$ptourid-7200;
|
|
$row_tourp = $GLOBALS['mysql']->query_single("SELECT * FROM tourenliste WHERE tour='".$ptourid."' and kw='".$kw_aktuell."' AND jahr='".$jahr_aktuell."'");
|
|
$row_tourpp = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE id='".$_POST['plus']."'");
|
|
|
|
if($row_tourp['Norm']<1) { $success="nur möglich wenn eine Paketnorm festgelegt ist."; $template->assign('error', $success); }
|
|
elseif($row_tourp['exemplare']<1) { $success="nur möglich wenn Exemplare festgelegt sind."; $template->assign('error', $success); }
|
|
else {
|
|
$ppakete=$row_tourp['exemplare']/$row_tourp['Norm'];
|
|
$ppakete=$ppakete/2;
|
|
$ppakete2=ceil($ppakete);
|
|
$GLOBALS['mysql']->insert("INSERT INTO tourenliste (tour,gewicht2,gewicht4,zeit,time,rampe,exemplare,pakete2,gewicht,kw,tag,monat,jahr,typ,utyp,infotext,Norm,Pakete)
|
|
VALUES(
|
|
'".$_POST['plus']."',
|
|
'".$row_tourp['gewicht2']."',
|
|
'".$row_tourp['gewicht4']."',
|
|
'".$row_tourp['zeit']."',
|
|
'".$row_tourp['time']."',
|
|
'".$row_tourp['rampe']."',
|
|
'".$row_tourp['exemplare']."',
|
|
'".$ppakete."',
|
|
'".$row_tourp['gewicht']."',
|
|
'".$row_tourp['kw']."',
|
|
'".$row_tourp['tag']."',
|
|
'".$row_tourp['monat']."',
|
|
'".$row_tourp['jahr']."',
|
|
'".$row_tourp['typ']."',
|
|
'".$row_tourp['utyp']."',
|
|
'".$row_tourpp['infotitel']."',
|
|
'".$row_tourp['Norm']."',
|
|
'".$row_tourp['Pakete']."')
|
|
");
|
|
$success="Hinweis: SaSo 2.Auto Tour:".$ptourid." gespeichert."; $template->assign('success', $success);
|
|
}
|
|
}
|
|
|
|
//--------------------------------
|
|
elseif(isset($_POST['managetour'])) {
|
|
$clone = $GLOBALS['mysql']->query_single("SELECT * FROM tourenliste WHERE kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."' and typ=8");
|
|
$row_tour = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE tour3='".$_POST['managetour']."'"); $typ=8;
|
|
$tourdata = $GLOBALS['mysql']->query_single("SELECT * FROM tliste WHERE kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."' and typ=8 and tour='".$_POST['managetour']."'");
|
|
$test=$tourdata['gewicht']/100; $test=$tourdata['gewicht']+$test; // pauschal aufrechnen
|
|
$abnahme=$clone['tag']; // $abnahme=$clone['tag']+7200;
|
|
$GLOBALS['mysql']->insert("INSERT INTO tourenliste (tour,tag,monat,jahr,kw,gewicht,gewicht4,gewicht2,exemplare,zeit,Norm,typ)
|
|
VALUES(
|
|
'".$abnahme."',
|
|
'".$clone['tag']."',
|
|
'".$clone['monat']."',
|
|
'".$clone['jahr']."',
|
|
'".$clone['kw']."',
|
|
'".$test."',
|
|
'".$tourdata['gewicht']."',
|
|
'".$tourdata['gewicht2']."',
|
|
'".$tourdata['exemplare']."',
|
|
'".$tourdata['zeit']."',
|
|
'".$tourdata['norm']."',
|
|
'".$typ ."')
|
|
");
|
|
$template->assign('alert-success', "SaSo Tour:".$_POST['managetour']." gespeichert.");
|
|
}
|
|
//---------------------------------------- Norm speichern
|
|
elseif(isset($_POST['sasonorm'])) {
|
|
if($_POST['sasonorm']!=0) {
|
|
$saso_norm = $GLOBALS['mysql']->query("SELECT * FROM tourenliste WHERE kw='".$kw."' and jahr='".$jahr."' and typ=8");
|
|
while($row = $saso_norm->fetch_assoc()) {
|
|
if($row['tour']<"1000") {
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET Norm='".$_POST['sasonorm']."' WHERE id='".$row['id']."'");
|
|
$pak=$row['exemplare']/$_POST['sasonorm']; $pak2=ceil($pak); // Pakete ausrechnen
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET Pakete='".$pak2."' WHERE id='".$row['id']."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET pakete2='".$pak2."' WHERE id='".$row['id']."'");
|
|
}
|
|
$key++;
|
|
}
|
|
}
|
|
$template->assign('success', 'Die Norm wurde angepasst und alle Touren neu berechnet');
|
|
}
|
|
//------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
//------------------------- Paketmenge und Cargewichte berechnen ---------------------------------------------------------------------------------------
|
|
$saso_fail = $GLOBALS['mysql']->query("SELECT * FROM tourenliste WHERE kw='".$kw."' and jahr='".$jahr."' and typ=8 AND tour>1000 ORDER BY zeit"); $key=0;
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------------------------- Auslesen Touren
|
|
$saso_tour = $GLOBALS['mysql']->query("SELECT * FROM tourenliste WHERE kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."' and typ=8 AND zeit >= 19 ORDER BY zeit"); $key=0;
|
|
while($row = $saso_tour->fetch_assoc()) {
|
|
$saso_tour2[$key]['zeit']=$row['zeit'];
|
|
$saso_tour2[$key]['id']=$row['id'];
|
|
$saso_tour2[$key]['tid']=$key; $row_tour = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE id='".$row['tour']."'");
|
|
$saso_tour2[$key]['tourid']=$row['tour'];
|
|
$saso_tour2[$key]['tour']=$row_tour['tour'];
|
|
$saso_tour2[$key]['tname']=$row_tour['tour3'];
|
|
$saso_tour2[$key]['exemplare']=$row_tour['exemplare'];
|
|
$saso_tour2[$key]['gewicht']=$row['gewicht'];
|
|
$saso_tour2[$key]['gewicht4']=$row['gewicht4'];
|
|
$saso_tour2[$key]['pakete']=$row['Pakete'];
|
|
$saso_tour2[$key]['pakete2']=$row['pakete2'];
|
|
$saso_tour2[$key]['rampe']=$row['rampe'];
|
|
$saso_tour2[$key]['norm']=$row['Norm']; if($row['Norm']<1) {$normtest=1;}
|
|
$key++;
|
|
}
|
|
|
|
$saso_tour = $GLOBALS['mysql']->query("SELECT * FROM tourenliste WHERE kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."' and typ=8 AND zeit <= 19 ORDER BY zeit");
|
|
while($row = $saso_tour->fetch_assoc()) {
|
|
$saso_tour2[$key]['zeit']=$row['zeit'];
|
|
$saso_tour2[$key]['id']=$row['id'];
|
|
$saso_tour2[$key]['tid']=$key; $row_tour = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE id='".$row['tour']."'");
|
|
$saso_tour2[$key]['tourid']=$row['tour'];
|
|
$saso_tour2[$key]['tour']=$row_tour['tour'];
|
|
$saso_tour2[$key]['tname']=$row_tour['tour3'];
|
|
$saso_tour2[$key]['exemplare']=$row_tour['exemplare'];
|
|
$saso_tour2[$key]['gewicht']=$row['gewicht'];
|
|
$saso_tour2[$key]['gewicht4']=$row['gewicht4'];
|
|
$saso_tour2[$key]['pakete']=$row['Pakete'];
|
|
$saso_tour2[$key]['pakete2']=$row['pakete2'];
|
|
|
|
$gewicht2=$row['gewicht']/$row['Pakete'];
|
|
$gewicht3=$gewicht2*$row['pakete2'];
|
|
$saso_tour2[$key]['gewicht3']=ceil($gewicht3);
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET gewicht2='".$gewicht2."' WHERE id='".$row['id']."'");
|
|
$saso_tour2[$key]['gewicht2']=$gewicht2;
|
|
|
|
$saso_tour2[$key]['rampe']=$row['rampe'];
|
|
$saso_tour2[$key]['norm']=$row['Norm']; if($row['Norm']<1) {$normtest=1;}
|
|
$key++;
|
|
}
|
|
//-------------- stellzeiten
|
|
$ssz_tour = $GLOBALS['mysql']->query("SELECT * FROM tliste WHERE kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."' and typ=8 ORDER BY tour"); $key=0;
|
|
while($row = $ssz_tour->fetch_assoc()) {
|
|
$ssz[$key]['id']=$row['id'];
|
|
$ssz[$key]['zeit']=$row['zeit'];
|
|
$ssz[$key]['tid']=$key;
|
|
|
|
$dabfrage = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE tour3='".$row['tour']."' ");
|
|
if($dabfrage['num_rows'] != 0) {
|
|
$ssz[$key]['tdb']=2;
|
|
$tabfrage = $GLOBALS['mysql']->query_single("SELECT * FROM tourenliste WHERE kw='".$kw_aktuell."' and jahr='".$jahr_aktuell."' and tour='".$dabfrage['id']."' ");
|
|
if($tabfrage['num_rows'] != 0) { $ssz[$key]['tdb']=1; }
|
|
}
|
|
$ssz[$key]['tour']=$row['tour'];
|
|
$ssz[$key]['gewicht']=$row['gewicht'];
|
|
$key++;
|
|
}
|
|
//-----------------------------------------------
|
|
// echo "<pre>"; print_r($ssz); echo "</pre>";
|
|
//-----------------------------------------------
|
|
$tourplus = $GLOBALS['mysql']->query_array("SELECT * FROM touren WHERE typ=8 and id>8000 ORDER BY id");
|
|
//-----------------------------------------------
|
|
$template->assign('tourplus', $tourplus);
|
|
$template->assign('normtest', $normtest);
|
|
$template->assign('jahr', $jahr);
|
|
$template->assign('kw', $kw);
|
|
$template->assign('datum', $datum);
|
|
$template->assign('saso_tour2', $saso_tour2);
|
|
$template->assign('ssz', $ssz);
|
|
$template->assign('content', 'tpl/isaso.tpl');
|
|
?>
|