Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
#!/usr/bin/php
<?php
include('dbconnect.php');
//1: maID 2: Datum des Tages, an dem etwas neu berechnet werden soll
if(isset($argv[1]) && isset($argv[2])){
$maID = $argv[1];
$datum = $argv[2];
$query = "select * from zeit where maID = $maID and date(datumzeit) = '$datum'";
$res = $dbc->query($query);
foreach($res as $index=>$row){
if($row['status'] == 'kommt'){
$kommt[] = $index;
}else{
$geht[] = $index;
}
$data[] = $row;
}
if(sizeof($kommt) != sizeof($geht)){
$altersaldo = "select saldomin from saldo where maID = $maID and datum <= '$datum' order by datum desc limit 1;";
$resalt = $dbc->query($altersaldo);
$ausgabe = $resalt->fetch_assoc();
echo $ausgabe['saldomin']."\n";
exit;
}
$gesamt = 0;
for($i = 0; $i < sizeof($kommt); $i++){
$wert1 = new DateTime($data[$kommt[$i]]['datumzeit']);
$wert2 = new DateTime($data[$geht[$i]]['datumzeit']);
$diff = $wert1->diff($wert2);
$min = $diff->format('%i');
$std = $diff->format('%h')*60;
$gesamt = $gesamt + $min + $std;
}
$tag = new DateTime($datum);
$tag = $tag->format('w')-1;
$azmodel = "select * from azmodel az
join ma_azmodel maz on maz.model_nr = az.model_nr
where maID = $maID
and tag_nr = $tag
and datum_ab <= '$datum'
order by datum_ab desc;";
$azres = $dbc->query($azmodel);
$azm = $azres->fetch_assoc();
$azstd = substr($azm['tagstd'], 0, 2);
$azmin = substr($azm['tagstd'], 3, 2);
$sollstd = $azmin + $azstd*60;
$saldo = $gesamt - $sollstd;
/*
//Auskommentiert weil mittlerweile fehl am Platz
//Diese Datei wird nur noch vom Terminal zur Anzeige des heutigen Saldo beim Ausbuchen genutzt
$deleteold = "delete from saldo where maID = $maID and datum = '$datum';";
if($dbc->query($deleteold) === FALSE){
echo "fehler beim löschen: $dbc->error\n";
exit;
}
$insertnew = "insert into saldo (maID, datum, saldomin) values ($maID, '$datum', $saldo)";
if($dbc->query($insertnew) === FALSE){
echo "fehler beim einfügen: $dbc->error\n";
exit;
}
*/
echo "$saldo\n";
}else{
echo "keine / falsche parameter\n";
}
?>