230 lines
No EOL
11 KiB
PHP
230 lines
No EOL
11 KiB
PHP
<?php
|
|
$_SESSION['slohn']=9.19;
|
|
$_SESSION['m1']=6; $_SESSION['m2']=1;
|
|
|
|
error_reporting(E_ALL);
|
|
ini_set('display_errors',1);
|
|
|
|
if($_GET['wahl']==1){if($_GET['monat']==1) { $monat=12; $jahr=$_GET['jahr']-1;} else { $monat=$_GET['monat']-1; $jahr=$_GET['jahr'];}}
|
|
elseif($_GET['wahl']==2) {if($_GET['monat']==12) { $monat=1; $jahr=$_GET['jahr']+1;} else { $monat=$_GET['monat']+1; $jahr=$_GET['jahr']; }}
|
|
elseif($_GET['id']>0 && $_GET['wahl']==0) { $monat=$_GET['monat']; $jahr=$_GET['jahr'];
|
|
} else {
|
|
$tjahr = (int)date('Y'); $tmonat = (int)date('m');
|
|
if($tmonat==1) { $monat=12; $jahr=$tjahr-1;} else { $monat=$tmonat-1; $jahr=$tjahr;}
|
|
|
|
$kw_aktuell = (int)date('W');
|
|
}
|
|
|
|
//---------------------------------------------- Abzug Strafgelder etc. -------------------------------
|
|
if(isset($_POST['abz_summe'])) {
|
|
|
|
$GLOBALS['mysql']->insert("INSERT INTO ma_abzahlung (monat,jahr,grund,summe,mid)
|
|
VALUES(
|
|
'".$_POST['abz_monat']."',
|
|
'".$_POST['abz_jahr']."',
|
|
'".$_POST['abz_grund']."',
|
|
'".$_POST['abz_summe']."',
|
|
'".$_POST['mid']."'
|
|
)
|
|
");
|
|
|
|
$ma_id=$_POST['mid'];
|
|
}
|
|
|
|
//---------------------------------------------- berechnung lohnlauf ---------------------------------
|
|
if(isset($_GET['vs'])) {
|
|
if($_GET['vs']>0) {
|
|
$_GET['vs']=0;
|
|
$row_ma = $GLOBALS['mysql']->query_single("SELECT * FROM mitarbeiter WHERE id='".$_GET['id']."'");
|
|
$ma_id= $row_ma['id'];
|
|
$ma_tk= $row_ma['tarif'];
|
|
$inc_typ1= $row_ma['inc_typ1'];
|
|
$inc_typ2= $row_ma['inc_typ2'];
|
|
$inc_tour1= $row_ma['inc_tour1'];
|
|
$inc_tour2= $row_ma['inc_tour2'];
|
|
|
|
$tdaten = $GLOBALS['mysql']->query("SELECT * FROM tourenliste WHERE monat='".$monat."' AND jahr='".$jahr."' AND fahrer='".$ma_id."'");
|
|
while($row_td = $tdaten->fetch_assoc()) {
|
|
$tour_id=$row_td['id'];
|
|
$leer=$row_td['tarif'];
|
|
$tmpd = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE id='".$row_td['tour']."'");
|
|
//---------- bug
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET utyp='".$tmpd['utyp']."' WHERE id='".$tour_id."'");
|
|
//----------
|
|
$tmpx1 = $GLOBALS['mysql']->query_single("SELECT * FROM ma_lohn WHERE mid='".$_GET['id']."' AND tour='".$row_td['tour']."' ");
|
|
$tmpx2 = $GLOBALS['mysql']->query_single("SELECT * FROM ma_lohn WHERE mid='".$_GET['id']."' AND typ='".$row_td['typ']."' ");
|
|
if($tmpx1['num_rows']>0) {
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET tarif='".$tmpx1['geld']."' WHERE id='".$tour_id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET tarifh='".$tmpx1['stunden']."' WHERE id='".$tour_id."'");
|
|
}
|
|
elseif($tmpx2['num_rows']>0) {
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET tarif='".$tmpx2['geld']."' WHERE id='".$tour_id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET tarifh='".$tmpx2['stunden']."' WHERE id='".$tour_id."'");
|
|
echo $row_id;
|
|
} else {
|
|
//---------- bug ende
|
|
if ($ma_tk==0) { $tourlohn=$tmpd['tarif0']; }
|
|
if ($ma_tk==1) { $tourlohn=$tmpd['tarif1']; }
|
|
if ($ma_tk==2) { $tourlohn=$tmpd['tarif2']; }
|
|
if ($ma_tk==3) { $tourlohn=$tmpd['tarif3']; }
|
|
if ($ma_tk==4) { $tourlohn=$tmpd['tarif4']; }
|
|
$tourh=$tmpd['tarifh'];
|
|
if ($inc_typ1 ==$row_td['typ']) { $tourlohn=0; }
|
|
if ($inc_typ2 ==$row_td['typ']) { $tourlohn=0; }
|
|
if ($inc_tour1==$row_td['tour']) { $tourlohn=0; }
|
|
if ($inc_tour2==$row_td['tour']) { $tourlohn=0; }
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET tarif='".$tourlohn."' WHERE id='".$tour_id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET tarifh='".$tourh."' WHERE id='".$tour_id."'");
|
|
}
|
|
$ds++;
|
|
}
|
|
}
|
|
}
|
|
//-------------------------------------------------------------------------------------------------
|
|
if($_GET['id']>0) {
|
|
$lohn=0; $key=0; $kei=0;
|
|
//------------------------------------------------
|
|
$ma_daten = $GLOBALS['mysql']->query_single("SELECT * FROM mitarbeiter WHERE id='".$_GET['id']."'");
|
|
$ma_id=$_GET['id']; // id für anzeige
|
|
$ma_name=$ma_daten['name']; // name für anzeige
|
|
$lgeheim=$ma_daten['lohngeheim'];
|
|
//--------------- Grundlohn laden
|
|
$ma_gldaten = $GLOBALS['mysql']->query_single("SELECT * FROM ma_glohn WHERE monat='".$monat."' AND jahr='".$jahr."'");
|
|
if($ma_gldaten['num_rows']==0) {
|
|
$GLOBALS['mysql']->insert("INSERT INTO ma_glohn (mid,monat,jahr,glohn)
|
|
VALUES(
|
|
'".$_GET['id']."',
|
|
'".$monat."',
|
|
'".$jahr."',
|
|
'".$ma_daten['tarifg']."')
|
|
");
|
|
$ma_g_lohn=$ma_daten['tarifg']; //grundlohn aus Mitarbeiterdaten !!!!
|
|
//------------------------------------------------------------------------------
|
|
//----------- erstmaliges berechnen nach Vorgaben aus Tourdaten ----------------
|
|
//------------------------------------------------------------------------------
|
|
/*
|
|
$ds=0;
|
|
$row_ma = $GLOBALS['mysql']->query_single("SELECT * FROM mitarbeiter WHERE id='".$_GET['id']."'");
|
|
$ma_id= $ma_daten['id'];
|
|
$ma_tk= $ma_daten['tarif'];
|
|
//---------------------------------
|
|
$tdaten = $GLOBALS['mysql']->query("SELECT * FROM tourenliste WHERE monat='".$monat."' AND jahr='".$jahr."' AND fahrer='".$ma_id."'");
|
|
while($row_td = $tdaten->fetch_assoc()) {
|
|
$tour_id=$row_td['id'];
|
|
$leer=$row_td['tarif'];
|
|
$tmpd = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE id='".$row_td['tour']."'");
|
|
//---------- bug
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET utyp='".$tmpd['utyp']."' WHERE id='".$tour_id."'");
|
|
//---------- bug ende
|
|
if ($ma_tk==0) { $tourlohn=$tmpd['tarif0']; }
|
|
if ($ma_tk==1) { $tourlohn=$tmpd['tarif1']; }
|
|
if ($ma_tk==2) { $tourlohn=$tmpd['tarif2']; }
|
|
if ($ma_tk==3) { $tourlohn=$tmpd['tarif3']; }
|
|
if ($ma_tk==4) { $tourlohn=$tmpd['tarif4']; }
|
|
$tourh=$tmpd['tarifh'];
|
|
$sonder1 = $GLOBALS['mysql']->query_single("SELECT * FROM ma_lohn WHERE mid='".$ma_id."' AND typ='".$row_td['typ']."'");
|
|
if($sonder1['num_rows']>0) { $tourlohn=$sonder1['geld']; $tourh=$sonder1['stunden']; }
|
|
$sonder2 = $GLOBALS['mysql']->query_single("SELECT * FROM ma_lohn WHERE mid='".$ma_id."' AND tour='".$row_td['tour']."'");
|
|
if($sonder2['num_rows']>0) { $tourlohn=$sonder2['geld']; $tourh=$sonder2['stunden']; }
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET tarif='".$tourlohn."' WHERE id='".$tour_id."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET tarifh='".$tourh."' WHERE id='".$tour_id."'");
|
|
$ds++;
|
|
}
|
|
*/
|
|
|
|
//------------------------------------------------------------------------------
|
|
//------------------------------------------------------------------------------
|
|
} else {
|
|
$ma_g_lohn=$ma_gldaten['glohn']; //grundlohn aus History !!!!
|
|
}
|
|
//------------------------------------------------ letzten 3 Grundlöhne -----------------------
|
|
$ma_glohn = $GLOBALS['mysql']->query_array("SELECT * FROM ma_glohn WHERE mid='".$_GET['id']."' ORDER BY id DESC LIMIT 4");
|
|
$template->assign('ma_glohn', $ma_glohn); //echo'<pre>'; print_r($ma_glohn); echo'</pre>';
|
|
//------------------------------------------------------------------------------------------
|
|
$ma_g_lohntyp=$ma_daten['tarifgtyp']; //grundlohn typ mindestlohn für pauschalkräfte
|
|
$ma_g_lohn=$ma_daten['tarifg'];
|
|
$ma_lohntyp=$ma_daten['tarif']; // lohntyp
|
|
// $lohn=$row_td['tarif'];
|
|
$typen = $GLOBALS['mysql']->query("SELECT * FROM tourentyp");
|
|
while($row_tt = $typen->fetch_assoc()) {
|
|
$zaehler = $GLOBALS['mysql']->query_single("SELECT * FROM tourenliste WHERE monat='".$monat."' AND jahr='".$jahr."' AND fahrer='".$_GET['id']."' AND typ='".$row_tt['tid']."' ORDER BY tag"); $key=0;
|
|
$ldata[$kei]['wert']=$zaehler['num_rows']; // anzahl zeilen
|
|
$ldata[$kei]['tt_tid']=$row_tt['tid'];
|
|
$ldata[$kei]['name1']=$row_tt['tname'];
|
|
$ldata[$kei]['name2']=$row_tt['tinfotitel'];
|
|
$tdaten = $GLOBALS['mysql']->query("SELECT * FROM tourenliste WHERE monat='".$monat."' AND jahr='".$jahr."' AND fahrer='".$_GET['id']."' AND typ='".$row_tt['tid']."' ORDER BY tag"); $key=0; $senddata= array();
|
|
while($row_td = $tdaten->fetch_assoc()) {
|
|
$senddata[$key]['tid']=$row_td['id'];
|
|
$senddata[$key]['astunden']=$row_td['tarifh'];
|
|
$senddata[$key]['time']=$row_td['time'];
|
|
$tmpd = $GLOBALS['mysql']->query_single("SELECT * FROM touren WHERE id='".$row_td['tour']."'");
|
|
$senddata[$key]['name1']=$tmpd['tour'];
|
|
$senddata[$key]['name2']=$tmpd['tour3'];
|
|
|
|
|
|
$tarif_daten = $GLOBALS['mysql']->query_single("SELECT * FROM tariftyp WHERE id='".$ma_daten['tarifgtyp']."'"); //ma-tariftyp
|
|
if($tarif_daten['stunden']>0) {
|
|
$zwischenlohn=$row_td['tarifh']*$_SESSION['slohn'];
|
|
$senddata[$key]['lohn']=$zwischenlohn;
|
|
$lohn=$lohn+($row_td['tarifh']*$_SESSION['slohn']);
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET tarif='".$zwischenlohn."' WHERE id='".$row_td['id']."'"); ///////////////////////////////
|
|
} else {
|
|
$senddata[$key]['lohn']=$row_td['tarif'];
|
|
$lohn=$lohn+$row_td['tarif'];
|
|
}
|
|
$key++;
|
|
}
|
|
$ldata[$kei]['sdata']=$senddata;
|
|
$kei++;
|
|
}
|
|
$template->assign('ma_daten', $ma_daten);
|
|
|
|
$template->assign('tarif_daten', $tarif_daten);
|
|
}
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
//--------------- zusammenfassung Planer
|
|
$temp1 = $GLOBALS['mysql']->query("SELECT * FROM planer_bez WHERE id<80"); $zz=0;
|
|
while($row = $temp1->fetch_assoc()) {
|
|
$kd = $GLOBALS['mysql']->query_single("SELECT * FROM planer WHERE mid='".$ma_id."' AND monat='".$monat."' AND jahr='".$jahr."' AND grund='".$row['id']."'");
|
|
if($kd['num_rows']>0) {
|
|
// $zz++;
|
|
$tmp[$zz]['a']=$kd['num_rows']." x";
|
|
$tmp[$zz]['b']=$row['bez'];
|
|
$zz++;
|
|
}
|
|
|
|
}
|
|
//echo "<pre>"; print_r($tmp); echo "</pre>";
|
|
$template->assign('tmp', $tmp);
|
|
|
|
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
$mitarbeiterlist = $GLOBALS['mysql']->query_array("SELECT * FROM mitarbeiter WHERE aktiv>0 AND typ<97 AND lohnabr =0 ORDER BY name");
|
|
$template->assign('mitarbeiterlist', $mitarbeiterlist);
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
$tariftyp = $GLOBALS['mysql']->query_array("SELECT * FROM tariftyp WHERE aktiv>0 ORDER BY id");
|
|
$template->assign('tariftyp', $tariftyp);
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
$ma_abz = $GLOBALS['mysql']->query_array("SELECT * FROM ma_abzahlung WHERE mid='".$ma_id."' ORDER BY jahr,monat");
|
|
$template->assign('ma_abz', $ma_abz);
|
|
//-----------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
$template->assign('ma_lohntyp', $ma_lohntyp);
|
|
|
|
$template->assign('ma_id', $ma_id);
|
|
$template->assign('ma_g_lohn', $ma_g_lohn);
|
|
$template->assign('ma_g_lohntyp', $ma_g_lohntyp);
|
|
$template->assign('ma_name', $ma_name);
|
|
//$template->assign('ma_lohn', $ma_lohn);
|
|
$template->assign('monat', $monat);
|
|
$template->assign('jahr', $jahr);
|
|
$template->assign('ldata', $ldata);
|
|
$template->assign('senddata', $senddata);
|
|
|
|
|
|
|
|
$template->assign('content', 'tpl/a_lohn2018.tpl'); //_list
|
|
|
|
?>
|