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

85 lines
No EOL
3.6 KiB
PHP

<?php
//-------------------- wiederkehrende abfragen
$a_touren = $GLOBALS['a_touren'];
$a_fahrzg = $GLOBALS['a_fahrzg'];
$a_fahrer = $GLOBALS['a_fahrer'];
//--------------------
if(isset($_GET['a']))
$action=$_GET['a'];
else
$action='load_free_cars';
switch($action):
case 'car_save';
$GLOBALS['mysql']->insert("UPDATE tourenliste SET auto='".$_POST['car']."' WHERE id='".$_POST['tourID']."'");
$row_tourl = $GLOBALS['mysql']->query_single("SELECT * FROM tourenliste WHERE id='".$_POST['tourID']."'");
$ttemp=$row_tourl['tour']; $ta_id= array_search($ttemp, array_column($a_touren, 'id'));
$atemp=$_POST['car']; $aa_id= array_search($atemp, array_column($a_fahrzg, 'id'));
$back['lastnote']="Fahrzeug ".$a_fahrzg[$aa_id]['kz']." für Tour ".$row_tourx['tour']." gespeichert.";
$back['success'] = true;
$back['zeile'] = $_POST['tourID'];
$back['alt'] = 5;
echo json_encode($back);
break;
case 'user_save';
// $ttemp=$row['tour']; $ta_id= array_search($ttemp, array_column($a_touren, 'id'));
// $atemp=$row['auto']; $aa_id= array_search($atemp, array_column($a_fahrzg, 'id'));
// $mtemp=$row['fahrer']; $ma_id= array_search($mtemp, array_column($a_fahrer, 'id'));
$GLOBALS['mysql']->insert("UPDATE tourenliste SET fahrer='".$_POST['user']."' WHERE id='".$_POST['tourID']."'");
$row_tourl = $GLOBALS['mysql']->query_single("SELECT * FROM tourenliste WHERE id='".$_POST['tourID']."'");
$ttemp=$row_tourl['tour']; $ta_id= array_search($ttemp, array_column($a_touren, 'id'));
$atemp=$_POST['car']; $aa_id= array_search($atemp, array_column($a_fahrzg, 'id'));
$back['lastnote']="Fahrer ".$a_fahrer[$ma_id]['name']." für Tour ".$row_tourx['tour']." gespeichert.";
$back['success'] = true;
$back['zeile'] = $_POST['tourID'];
$back['alt'] = 5;
echo json_encode($back);
break;
case 'info_save';
$GLOBALS['mysql']->insert("UPDATE tourenliste SET infotext='".$_POST['info']."' WHERE id='".$_POST['tourID']."'");
$GLOBALS['mysql']->insert("UPDATE tourenliste SET m_update='".$_SESSION['benutzer']."' WHERE id='".$_POST['tourID']."'");
$back['success'] = true;
$back['lastnote']="Information: ".$_POST['info']." hinzugefügt.";
$back['alt'] = 5;
echo json_encode($back);
break;
case 'smscheck';
$tempsms = $GLOBALS['mysql']->query("SELECT * FROM tourenliste WHERE tag='".$_POST['tag']."' and monat='".$_POST['monat']."' and jahr='".$_POST['jahr']."' ORDER BY tour"); $key=0;
while($row = $tempsms->fetch_assoc()) {
$tour=0; $tour=$row['tour'];
//$stat=" "; $stat=[$row['status']];
if($row['smsstatus']==0) { $stat="<i class='fal fa-comment-alt fa-1x' style='color:gray' ></i>"; }
if($row['smsstatus']==1) { $stat="<i class='fas fa-comment-alt-exclamation fa-1x' style='color:orange' ></i>"; }
if($row['smsstatus']==2) { $stat="<i class='fas fa-comment-alt-check fa-1x' style='color:green' ></i>"; }
if($row['smsstatus']==8) { $stat="<i class='fas fa-comment-alt-dots fa-1x' style='color:gray' ></i>"; }
if($row['smsstatus']==20){ $stat="<i class='fas fa-spinner fa-spin fa-1x' style='color:gray' ></i>"; }
if($row['smsstatus']==3) { $stat="<i class='fas fa-comment-alt-times fa-1x' style='color:red' ></i>"; }
if($row['smsstatus']==4) { $stat="<i class='fas fa-comment-alt-times fa-1x' style='color:red' ></i>"; }
if($row['smsstatus']==5) { $stat="<i class='fas fa-comment-alt-times fa-1x' style='color:red' ></i>"; }
$key++;
$t[$key]=$row['tour'];
$s[$key]=$stat;
}
$back['t'] = $t;
$back['s'] = $s;
$back['success'] = true;
$back['length'] = $key;
echo json_encode($back);
//echo'<pre>'; print_r($back); echo'</pre>';
break;
endswitch;
?>