Permalink
Cannot retrieve contributors at this time
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?
timerec3public/saldolist.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
89 lines (83 sloc)
3.5 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
session_start(); | |
if(!$_SESSION['userarray']['admin']){ | |
echo "keine Rechte!"; | |
exit; | |
} | |
include('dbconnect.php'); | |
$jahrdanach = $_GET['y']+1; | |
$jahrdavor = $_GET['y']-1; | |
$allma = $dbc->query("select nachname, vorname, maID, vggrp from mitarbeiter where gleitzeit = 1 order by nachname;"); | |
foreach($allma as $ma){ | |
$saldodata = $dbc->query("select floor(sum(saldomin)/60) as std, abs(sum(saldomin)%60) as min from saldo where maID = $ma[maID] and datum <= '$_GET[y]-01-01';"); | |
$saldodata = $saldodata->fetch_array(); | |
$saldostd = $saldodata[0]; | |
$saldomin = $saldodata[1]; | |
if(abs($saldostd) < 10 || abs($saldostd) == 0){ | |
if($saldostd < 0){ | |
$saldostd = "-0".abs($saldostd); | |
}else{ | |
$saldostd = "0".$saldostd; | |
} | |
} | |
$saldomin = ($saldomin < 10 || $saldomin == 0) ? "0".$saldomin : $saldomin; | |
$saldo = $saldostd . ":" . $saldomin; | |
$alldata[$ma['maID']][] = $ma['maID']; | |
$alldata[$ma['maID']][] = $ma['nachname']; | |
$alldata[$ma['maID']][] = $ma['vorname']; | |
$alldata[$ma['maID']][] = $saldo; | |
$alldata[$ma['maID']][] = $ma['vggrp']; | |
} | |
if($_GET['csv'] === 'true'){ | |
$csv = "Personalnummer;Nachname;Vorname;Saldo;Vergütungsgruppe\n"; | |
foreach($alldata as $data){ | |
foreach($data as $value){ | |
$csv .= "$value;"; | |
} | |
$csv .= "\n"; | |
} | |
header("Content-type: text/csv"); | |
header("Content-Disposition: attachment; filename=Saldo-$_GET[y].csv"); | |
echo $csv; | |
exit; | |
} | |
?> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>timerec | Tableau</title> | |
<link rel="stylesheet" type="text/css" href="style.css" media="screen"> | |
<link rel="stylesheet" type="text/css" href="print.css" media="print"> | |
<link rel="shortcut icon" href="favicon.ico"> | |
</head> | |
<body> | |
<?php | |
echo "<div id='headline'> | |
<div id='home'> | |
<a href='index.php?ma=".$_SESSION['infoarray']['maID']."'><button><< Menü</button></a> | |
</div> | |
<div id='back'><a href='saldolist.php?y=$jahrdavor'><button><<<</button></a></div> | |
Saldoliste Jahresanfang <b>$_GET[y]</b> → <a href='saldolist.php?y=$_GET[y]&csv=true'>Download</a> | |
<div id='forward'><a href='saldolist.php?y=$jahrdanach'><button>>>></button></a></div> | |
</div> | |
<h2 id='ueberschrift' style='display: none'>Saldoliste Jahresanfang <b>$_GET[y]</b></h2> | |
</div>"; | |
if($alldata){ | |
echo "<div id='azmodell'><table> | |
<tr class='topline'><th>Personalnummer</th><th>Nachname</th><th>Vorname</th><th>Saldo</th><th class='help' title='Vergütungsgruppe'>VG</th></tr>"; | |
$switch = false; | |
foreach($alldata as $maID=>$data){ | |
$line = $switch ? "2" : "1"; | |
$switch = !$switch; | |
echo "<tr class='line$line'>"; | |
foreach($data as $value){ | |
echo "<td>$value</td>"; | |
} | |
echo "</tr>"; | |
} | |
echo "</table></div>"; | |
} | |
?> | |
</body> | |
</html> |