130 lines
7.0 KiB
PHP
130 lines
7.0 KiB
PHP
<?
|
||
if ($_POST['id']==0)
|
||
{
|
||
$sql = mysql_query("TRUNCATE temp_kilometry");
|
||
$pobierz_userow=mysql_query("select id,imie,nazwisko from uzytkownicy where usun='0' and id_sta='3' and usun='0' and blok='NIE' group by nazwisko");
|
||
while($u=mysql_fetch_array($pobierz_userow))
|
||
{
|
||
$id_user = $u[id];
|
||
$nazwisko = $u[nazwisko];
|
||
$imie = $u[imie];
|
||
$temp = mysql_query("INSERT INTO `temp_kilometry` ( `temp1` , `temp2` , `temp3` , `temp4` , `temp5` , `temp6` )
|
||
VALUES (
|
||
'$id_user', '$nazwisko', '$imie', '0', '0', '0'
|
||
)");
|
||
}
|
||
$pobierz_userow2=mysql_query("select b.temp1 as id,sum(a.przejechano) as kilometry from kilometry a,temp_kilometry b where a.id=b.temp1 and a.usun='0' and a.wyjazd='0' and a.data_kil >= '".$_POST['data1']."' and a.data_kil <= '".$_POST['data2']."' group by b.temp2");
|
||
while($z=mysql_fetch_array($pobierz_userow2))
|
||
{
|
||
$id1 = $z[id];
|
||
$sluzbowe = $z[kilometry];
|
||
$temp = mysql_query("update temp_kilometry SET temp4='".$sluzbowe."' where temp1='".$id1."'");
|
||
$sluzbowe = '0';
|
||
}
|
||
$pobierz_userow3=mysql_query("select b.temp1 as id,sum(a.przejechano) as kilometry from kilometry a,temp_kilometry b where a.id=b.temp1 and a.usun='0' and a.wyjazd='1' and a.data_kil >= '".$_POST['data1']."' and a.data_kil <= '".$_POST['data2']."' group by b.temp2");
|
||
while($y=mysql_fetch_array($pobierz_userow3))
|
||
{
|
||
$id2 = $y[id];
|
||
$sluzbowe2 = $y[kilometry];
|
||
$temp = mysql_query("update temp_kilometry SET temp5='".$sluzbowe2."' where temp1='".$id2."'");
|
||
$sluzbowe = '0';
|
||
}
|
||
$pobierz_userow4=mysql_query("select b.temp1 as id,sum(a.przejechano) as kilometry from kilometry a,temp_kilometry b where a.id=b.temp1 and a.usun='0' and a.data_kil >= '".$_POST['data1']."' and a.data_kil <= '".$_POST['data2']."' group by b.temp2");
|
||
while($x=mysql_fetch_array($pobierz_userow4))
|
||
{
|
||
$id3 = $x[id];
|
||
$sluzbowe3 = $x[kilometry];
|
||
$temp = mysql_query("update temp_kilometry SET temp6='".$sluzbowe3."' where temp1='".$id3."'");
|
||
$sluzbowe = '0';
|
||
}
|
||
|
||
|
||
$pobierz_userow5=mysql_query("select * from temp_kilometry group by temp2");
|
||
$data1 = $_POST['data1'];
|
||
$data2 = $_POST['data2'];
|
||
if(mysql_num_rows($pobierz_userow)==0)
|
||
{
|
||
uwaga('<center><table><tr><td colspan=2 align=center><br><b>Nie okre<72>lono zakresu dat - spr<70>buj ponownie...</b><br><br></td></tr></table></center>');
|
||
form_zestawienie_km();
|
||
}
|
||
else
|
||
{
|
||
$color=$color1;
|
||
echo '<center><table><tr><td colspan=2 align=center><br><b>Zestawienie kilometrow od '.$data1.' do '.$data2.'</b><br><br></td></tr></table></center>';
|
||
echo '<center><table width=45%><tr style="background:#E5E5E5" width=70% align=center><td><b>Imie Nazwisko</b></td><td><b>S<>u<EFBFBD>obowe</b></td><td><b>Prywatne</b></td><td><b>Suma</b></td></td></tr>';
|
||
while($a=mysql_fetch_array($pobierz_userow5))
|
||
{
|
||
$roznica = ($z['kilometry'] - $u['kilometry']);
|
||
|
||
$color=zmien_color($color);
|
||
echo '<tr style="background-color:'.$color.'"><td style="padding-left:10px; padding-right:10px"><center>'.$a['temp2'].' '.$a['temp3'].'</center></td><td><center>'.$a['temp4'].' km</td><td><center>'.$a['temp5'].' km</td><td><center>'.$a['temp6'].' km</td></center></tr>' ;
|
||
$nazwisko = $a[temp2];
|
||
$imie = $a[temp3];
|
||
$sluzbowe = $a[temp4];
|
||
$prywatne = $a[temp5];
|
||
$suma = $a[temp6];
|
||
$sql2 = mysql_query("INSERT INTO `temp` ( `temp1` , `temp2` , `temp3` , `temp4` , `temp5` , `temp6` , `trmp7` , `tmp8` )
|
||
VALUES (
|
||
'$nazwisko', '$imie', '$sluzbowe', '$prywatne', '$suma', '', '', ''
|
||
)");
|
||
}
|
||
echo '</table></center>';
|
||
echo '<br><center><table width=45%><tr align=left><a class=menu2 href="http://www.malcomm.pl/online/zestawienie_klometry_raport2.php">Eksport do Excel`a</a></tr></table></center>';
|
||
|
||
}
|
||
|
||
}
|
||
else
|
||
{
|
||
$pobierz_userow3=mysql_query("select b.id,b.imie,b.nazwisko,sum(a.przejechano) as kilometry from kilometry a,uzytkownicy b where a.id=b.id and a.usun='0' and a.wyjazd='0' and a.data_kil >= '".$_POST['data1']."' and a.data_kil <= '".$_POST['data2']."' and b.id='".$_POST['id']."'");
|
||
$pobierz_userow4=mysql_query("select b.id,b.imie,b.nazwisko,sum(a.przejechano) as kilometry from kilometry a,uzytkownicy b where a.id=b.id and a.usun='0' and a.data_kil >= '".$_POST['data1']."' and a.data_kil <= '".$_POST['data2']."' and b.id='".$_POST['id']."'");
|
||
$data1 = $_POST['data1'];
|
||
$data2 = $_POST['data2'];
|
||
if(mysql_num_rows($pobierz_userow3)==0)
|
||
{
|
||
uwaga('<center><table><tr><td colspan=2 align=center><br><b>Nie okre<72>lono zakresu dat - spr<70>buj ponownie...</b><br><br></td></tr></table></center>');
|
||
form_zestawienie_km();
|
||
}
|
||
else
|
||
{
|
||
$sql = mysql_query("TRUNCATE temp");
|
||
$color=$color1;
|
||
echo '<center><table><tr><td colspan=2 align=center><br><b>Zestawienie kilometrow od '.$data1.' do '.$data2.'</b><br><br></td></tr></table></center>';
|
||
echo '<center><table width=45%><tr style="background:#E5E5E5" width=70% align=center><td><b>Imie Nazwisko</b></td><td><b>S<>u<EFBFBD>obowe</b></td><td><b>Prywatne</b></td><td><b>Suma</b></td></td></tr>';
|
||
while($x=mysql_fetch_array($pobierz_userow3) and $y=mysql_fetch_array($pobierz_userow4))
|
||
{
|
||
$roznica = ($y['kilometry'] - $x['kilometry']);
|
||
$s1 = $x['kilometry'];
|
||
if ($s1=='')
|
||
$s2 = "0";
|
||
else
|
||
$s2 = $s1;
|
||
|
||
$s3 = $y['kilometry'];
|
||
if ($s3=='')
|
||
$s4 = "0";
|
||
else
|
||
$s4 = $s3;
|
||
$color=zmien_color($color);
|
||
echo '<tr style="background-color:'.$color.'"><td style="padding-left:10px; padding-right:10px"><center>'.$x['nazwisko'].' '.$x['imie'].'</center></td><td><center>'.$s2.' km</td><td><center>'.$roznica.' km</td><td><center>'.$s4.' km</td></center></tr>' ;
|
||
$nazwisko = $x[nazwisko];
|
||
$imie = $x[imie];
|
||
|
||
if ($x['kilometry']=='')
|
||
$sluzbowe = '0';
|
||
else
|
||
$sluzbowe = $x['kilometry'];
|
||
|
||
$prywatne = $roznica;
|
||
$suma = $y['kilometry'];
|
||
$sql2 = mysql_query("INSERT INTO `temp` ( `temp1` , `temp2` , `temp3` , `temp4` , `temp5` , `temp6` , `trmp7` , `tmp8` )
|
||
VALUES (
|
||
'$nazwisko', '$imie', '$sluzbowe', '$prywatne', '$suma', '', '', ''
|
||
)");
|
||
}
|
||
echo '</table></center>';
|
||
echo '<br><center><table width=45%><tr align=left><a class=menu2 href="http://www.malcomm.pl/online/zestawienie_klometry_raport.php">Eksport do Excel`a</a></tr></table></center>';
|
||
|
||
}
|
||
}
|
||
?>
|