|
Server IP : 10.128.40.6 / Your IP : 216.73.216.233 Web Server : Apache System : Linux webd006.cluster128.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : logmcpe ( 111175) PHP Version : 7.3.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/logmcpe/www/TMCPRO/pages/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<style>
.orange{ background-color:#FF8000;}
.vert{ background-color:#04B404;}
.rouge{ background-color:#FF0000;}
</style>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script>
$( function() {
$("body").on( "change", "#monChoix", function(){
var selectVal = $(this).val();
var couleur = $( 'option[value="'+selectVal+'"]' ).attr("class") ;
$("#monChoix").attr("class", couleur);
})
var selectVal = $("#monChoix").val();
var couleur = $( 'option[value="'+selectVal+'"]' ).attr("class");
$("#monChoix").attr("class", couleur);
});
</script>
<?php
include 'includes/config_tmcpro.php' ;
include 'includes/stable_functions_tmcpro.php' ;
$_SESSION['page_name']= basename($_SERVER['PHP_SELF']);
// echo "<pre>";
// print_r(s$_POST);
// echo "</pre>";
// echo " +++++++++++ ";
// echo "<pre>";
// print_r($_GET);
// echo "</pre>";
$pagemenu = basename($_SERVER["PHP_SELF"]) ;
$now = time();
function count_week_days($__date_from, $__date_to, $__holidays_between=array(), $__weekend_days=array()) {
$total_days_count = $__date_to > $__date_from ? round(($__date_to - $__date_from)/(24*3600)) : 0;
$full_weeks_count = floor($total_days_count/7);
$weekend_days_count = $full_weeks_count*count($__weekend_days);
$days_left_uncovered = $total_days_count - $full_weeks_count*7;
for($i = 0; $i < $days_left_uncovered; $i++) {
$date_to_check = $i ? strtotime("+{$i} day", $__date_from) : $__date_from;
if(in_array(date('N', $date_to_check), $__weekend_days)) {
$weekend_days_count++;
}
}
$week_days_count = $total_days_count - $weekend_days_count - count($__holidays_between);
return $week_days_count;
}
function dateDifference($strtDate , $endDate )
{
$startDateWeekCnt = round(floor( date('d',strtotime($strtDate)) / 7)) ;
$endDateWeekCnt = round(ceil( date('d',strtotime($endDate)) / 7)) ;
$datediff = strtotime(date('Y-m',strtotime($endDate))."-01") - strtotime(date('Y-m',strtotime($strtDate))."-01");
$totalnoOfWeek = round(floor($datediff/(60*60*24)) / 7) + $endDateWeekCnt - $startDateWeekCnt ;
return $totalnoOfWeek;
}
// jj function dateDifference($date1, $date2)
// {fg
// $first = DateTime::createFromFormat('m/d/Y', $date1);
// $second = DateTime::createFromFormat('m/d/Y', $date2);
// if($date1 > $date2) return week_between_two_dates($date2, $date1);
// return floor($first->diff($second)->days/7);
// }
function GET_type_pre ($name = '', $param = '',$value =1)
{
if(!is_array($value))
$value = array($value) ;
$tab = array(1 => 'Nettoyage courant régulier', 2 => 'Prestation de Vitrerie ', 3 => 'Shampoing Moquette ', 4 => 'Autre prestation spécifique');
$ret = "<select name=\"$name\" $param>";
foreach ($tab as $key => $val) {
$ret .= sprintf('<option value="%s"%s>%s </option>', $key, in_array($key , $value) ? ' selected' : '', $val) ;
}
return $ret."</select>" ;
}
// $days = array(0 s=> 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday');
if(isset($_GET['prt'])){
dbi_query("delete FROM PRESTATIONS_MODIF where modif_id = ".$_GET['prt']);
}
if(isset($_GET['exp']))
{
$EXPprdt = dbi_fetch_row(dbi_query(" SELECT * FROM EXCEPTIONS WHERE excpt_id = '".$_GET['exp']."' ")) ;
if($EXPprdt)
{
$test = dbi_fetch_row(dbi_query("SELECT * FROM EXCEPTIONS where excpt_id > '".$EXPprdt['excpt_id']."' AND presta_id = '".$EXPprdt['presta_id']."' AND exp_id_mere = '0' ORDER BY excpt_id DESC LIMIT 1")) ;
dbi_query("delete FROM EXCEPTIONS where excpt_id = ".$EXPprdt['excpt_id']);
dbi_query("delete FROM EXCEPTIONS where exp_id_mere = '".$EXPprdt['excpt_id']."' " );
if($EXPprdt['new_presta_id'] > 0){
dbi_query("delete FROM PRESTATIONS where presta_id = ".$EXPprdt['new_presta_id']);
}
if($test)
dbi_query("UPDATE EXCEPTIONS SET date_presta= '".$EXPprdt['date_presta']."' where excpt_id = ".$test['excpt_id']." OR exp_id_mere = ".$test['excpt_id']." ");
}
}
function days ($value = 0)
{
$tab = array(0 => 'sunday', 1 => 'monday', 2 => 'tuesday', 3 => 'wednesday', 4 => 'thursday', 5 => 'friday', 6 => 'saturday');
return $tab[$value];
}
function daysfr ($value = 0)
{
$tab = array(0 => 'Dimanche', 1 => 'Lundi', 2 => 'Mardi', 3 => 'Mercredi', 4 => 'Jeudi', 5 => 'Vendredi', 6 => 'Samedi');
return $tab[$value];
}
// echo date('Ymd');
if(isset($_GET['date']) )
{
$year = $month = $day = 0;
list($year ,$month, $day) = explode("-", $_GET['date']);
if( $year >= 1900 and $year <= (date('Y')+1) and $month >=1 and $month <=12 )
$datecal = "$year-$month-01";
else
$datecal = date('Y-m-01');
}
else
$datecal = date('Y-m-01');
// echo ' $$$$$ '.$datecal;
// if()
$client_id = $_SESSION["client_id"] ;
$q= dbi_fetch_row(dbi_query("SELECT * FROM client where client_id = ".$client_id)) ;
if(isset($_POST['DelPrDate']) && isset($_POST['facture']) && ( ($_POST['facture'] == 1 ) OR ($_POST['facture'] == 0) ) )
{
$facture = $ad = $ded = 0;
if($presta_Hduree < 1 )
{
$facture = 1;
$ded = 1;
}
$facture = '';
if(isset($_POST['facture']) && $_POST['facture'] == 1){ $facture = 1;
dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture,ad,ded) VALUES (".$_POST['presta_id'].", ".dateformaint($_POST['date_presta']).", NULL,'".$facture."','".$ad."','".$ded."')" ) ;
header("Location:Prestation_New.php?date=".date('Y-m-01')."&color=success&msg=La prestation est bien annulée");}
if(isset($_POST['facture']) && $_POST['facture'] == 0){ $facture = 0;
dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture,ad,ded) VALUES (".$_POST['presta_id'].", ".dateformaint($_POST['date_presta']).", NULL,'".$facture."','".$ad."','".$ded."')" ) ;
header("Location:Prestation_New.php?date=".date('Y-m-01')."&color=success&msg=La prestation est bien annulée");}
}
elseif(isset($_POST['DelPrDate']) && !isset($_POST['facture']) )
{
header("Location:Prestation_New.php?date=".date('Y-m-01')."&color=danger&msg=Erreur annulation du prestation");
exit;
}
if(isset($_POST['upt2date']))
{
$presta_id = $_POST['presta_id'];
$date_debut = dateformaint($_POST['date_debut']);
$date_fin = dateformaint($_POST['date_fin']);
$j = $h = $d = $s = $f = $ch = $sl = 'NULL' ;
$j = $_POST['presta_jour'] ;
$h = heure2int($_POST['presta_Hdeb']) ;
$d = calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']);
$f = $_POST['presta_forfait'] ;
$sl = $_POST['salarie_id'] ;
$ch = $_POST['chantier_id'] ;
$prest = dbi_fetch_row( dbi_query("SELECT * FROM PRESTATIONS WHERE presta_id = $presta_id ") ) ;
$data = array('presta_jour' => $prest['presta_jour'], 'presta_Hdeb' => $prest['presta_Hdeb'], 'presta_Hduree' => $prest['presta_Hduree'],
'salarie_id' => $prest['salarie_id'], 'presta_forfait' => $prest['presta_forfait'], 'presta_sem' => $prest['presta_sem'], 'chantier_id' => $prest['chantier_id']) ;
$q = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$prest['presta_id']." order by start, modif_id") ;
while (($m = dbi_fetch_row($q)) && $date_fin >= $m['start'])
{
$data['presta_jour'] = $m['presta_jour'] === NULL ? $data['presta_jour'] : $m['presta_jour'] ;
$data['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $data['presta_Hdeb'] : $m['presta_Hdeb'] ;
$data['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $data['presta_Hduree'] : $m['presta_Hduree'] ;
$data['salarie_id'] = $m['salarie_id'] === NULL ? $data['salarie_id'] : $m['salarie_id'] ;
$data['presta_forfait'] = $m['presta_forfait'] === NULL ? $data['presta_forfait'] : $m['presta_forfait'] ;
}
// echo '<pre>';
// print_r($data);
// echo '</pre>';
dbi_query("delete FROM PRESTATIONS_MODIF WHERE presta_id = '".$presta_id."' AND START BETWEEN '".$date_debut."' AND '".$date_fin."' ");
dbi_query("delete FROM PRESTATIONS WHERE client_id = '".$client_id."' AND presta_date_debut BETWEEN '".$date_debut."' AND '".$date_fin."' AND presta_date_debut = presta_date_fin ");
// dbi_query("UPDATE PRESTATIONS_MODIF SET salarie_id = '".$sl."', presta_jour'".$j."', presta_Hdeb'".$h."', presta_Hduree'".$d."',presta_forfait'".$f."' WHERE WHERE presta_id = $presta_id AND START BETWEEN '".$date_debut."' AND '".$date_fin."' ");
$sql = "INSERT INTO PRESTATIONS_MODIF (presta_id, start, salarie_id, presta_jour, presta_Hdeb, presta_Hduree, presta_forfait)
VALUES (".$presta_id.", $date_debut, $sl,$j, $h, $d, $f)";
dbi_query($sql);
$j = $data['presta_jour'] ;
$h = $data['presta_Hdeb'] ;
$d = $data['presta_Hduree'] ;
$f = $data['presta_forfait'] ;
$sl = $data['salarie_id'] ;
$date_fin = date("Ymd", strtotime("+1 day", strtotime($date_fin)));
$sql = "INSERT INTO PRESTATIONS_MODIF (presta_id, start, salarie_id, presta_jour, presta_Hdeb, presta_Hduree,presta_forfait)
VALUES (".$presta_id.", $date_fin, $sl,$j, $h, $d, $f)";
dbi_query($sql);
// echo '<pre>';
// print_r($data);
// echo '</pre>';
header("Location:Prestation_New.php?date=".date('Y-m-01')."");
exit;
}
if(isset($_POST['del2date']))
{
$date_debut = dateformaint($_POST['date_debut']);
$date_fin = dateformaint($_POST['date_fin']);
$facture = '';
if($_POST['facture']) $facture = 1;
while ($date_debut <= $date_fin )
{
$q1 = dbi_query("SELECT * FROM PRESTATIONS WHERE presta_id = '".$_POST['presta_id']."'");
$prest1 = dbi_fetch_row($q1);
$q2 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$prest1['presta_id']." order by start, modif_id ") ;
while (($m2 = dbi_fetch_row($q2)) && $date_debut >= $m2['start'])
{
$prest1['presta_jour'] = $m2['presta_jour'] === NULL ? $prest1['presta_jour'] : $m2['presta_jour'] ;
}
$day = date("w", strtotime( int2date_autre_format($date_debut)));
if( $day == $prest1['presta_jour'])
{
$EXP = dbi_fetch_row(dbi_query("SELECT date_presta FROM EXCEPTIONS WHERE presta_id = ".$prest1['presta_id']." AND date_presta = ".$date_debut." " )) ; ;
if($EXP ){} else {
if( $prest1['presta_sem'] == 1 )
{
// echo $date_debut.' ** '. $prest1['presta_jour'].' == '.$day.'<br/>';
dbi_query(" INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture) VALUES (".$_POST['presta_id'].", ".$date_debut.", NULL,'".$facture."' )") ;
}
else
{
// $nbre = dateDifference(int2date_autre_format($prest1['presta_date_debut']),int2date_autre_format($date_debut)) - 1;
$nbre =count_week_days(strtotime(int2date_autre_format($prest1['presta_date_debut'],'d.m.Y')), strtotime(int2date_autre_format($date_debut,'d.m.Y')));
if( $nbre % $prest1['presta_sem'] == 0) {
dbi_query(" INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture) VALUES ( ".$_POST['presta_id']." , ".$date_debut." , NULL, '".$facture."' ) ") ;
}
}
}
}
// echo $date_debut.' ** '. $prest1['presta_jour'].' == '.$day.'<br/>';
$date_debut = date("Ymd", strtotime("+1 day", strtotime($date_debut)));
}
// dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture) VALUES (".$_POST['presta_id'].", ".$date_prest.", NULL,''".$facture."'' )") ;
// header("Refresh:0; url=Prestation_New.php");
header("Location:Prestation_New.php?date=".date('Y-m-01')."");
exit;
}
if(isset($_POST['UptPrDate']))
{
// echo '<pre>';
// print_r($_POST);
// echo '</pre>';
// presta_id
// if($_POST['presta_id_old'] > 0 )
// $presta_id_old = $_POST['presta_id_old'];
// else
$presta_id = $_POST['presta_id'];
$client_id = $_POST['client_id'];
$chantier_id = $_POST['chantier_id'];
$salarie_id = $_POST['salarie_id'];
$presta_date_debut = dateformaint($_POST['presta_date_debut']);
$presta_jour = date("w", strtotime($_POST['presta_date_debut']));
$presta_Hdeb = heure2int($_POST['presta_Hdeb']);
$presta_Hduree = calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']);
$presta_forfait = $_POST['presta_forfait'];
$presta_sem = 1;
$presta_date_fin = dateformaint($_POST['presta_date_debut']);
if($_POST['prestation_type'] > 0 ) $prestation_type = $_POST['prestation_type']; else $prestation_type = 4;
if(isset( $_POST['presta_id_ponct'] ) && !empty( $_POST['presta_id_ponct'] ) ){
dbi_query(" UPDATE PRESTATIONS SET salarie_id = '$salarie_id',presta_date_debut = '$presta_date_debut',presta_date_fin = '$presta_date_fin',presta_jour = '$presta_jour',presta_Hdeb=$presta_Hdeb,presta_Hduree=$presta_Hduree,presta_forfait=$presta_forfait,presta_sem=$presta_sem WHERE presta_id = ".$_POST['presta_id']." ");
}
elseif( $presta_Hdeb != $_POST['presta_Hdeb_Old'] OR $_POST['salarie_id_Old'] != $salarie_id OR $_POST['date_presta'] != $_POST['presta_date_debut'] OR $presta_Hduree != $_POST['presta_Hduree_Old'] OR $presta_Hduree != $_POST['presta_Hduree_Old'] )
{
$q = dbi_query("SELECT * FROM PRESTATIONS WHERE presta_id = ".$presta_id) ;
$prest = dbi_fetch_row($q);
$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$presta_id." order by start, modif_id ") ;
while (($m = dbi_fetch_row($q1)) && $presta_date_debut >= $m['start'])
{
$prest['presta_sem'] = $m['presta_sem'] === NULL ? $prest['presta_sem'] : $m['presta_sem'] ;
$prest['presta_jour'] = $m['presta_jour'] === NULL ? $prest['presta_jour'] : $m['presta_jour'] ;
$prest['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $prest['presta_Hdeb'] : $m['presta_Hdeb'] ;
$prest['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $prest['presta_Hduree'] : $m['presta_Hduree'] ;
$prest['salarie_id'] = $m['salarie_id'] === NULL ? $prest['salarie_id'] : $m['salarie_id'] ;
$prest['chantier_id'] = $m['chantier_id'] === NULL ? $prest['chantier_id'] : $m['chantier_id'] ;
$prest['presta_forfait'] = $m['presta_forfait'] === NULL ? $prest['presta_forfait'] : $m['presta_forfait'] ;
}
$facture = $ad = $ded = 0;
$presta_Hduree_Old = 0;
$presta_Hduree_Old = $prest['presta_Hduree'] - $presta_Hduree ;
// if( $presta_Hduree_Old < 0 ) $presta_Hduree_Old = $presta_Hduree_Old *(-1);
// if(isset($_POST['facture']) && $_POST['facture'] == 1) $facture = 1;
if(isset($_POST['facture']) && $_POST['facture'] == 1 )
{
$facture = 1;
}
if($presta_Hduree > $prest['presta_Hduree'] )
{
$ad = 1;
$presta_Hduree_Old = $presta_Hduree - $prest['presta_Hduree'] ;
}
elseif($presta_Hduree < $prest['presta_Hduree'] )
{
$ded = 1;
$presta_Hduree_Old = $prest['presta_Hduree'] - $presta_Hduree ;
}
if( $prest['presta_date_debut'] == $prest['presta_date_fin'] )
{
dbi_query(" UPDATE PRESTATIONS SET salarie_id = '$salarie_id',presta_date_debut = '$presta_date_debut',presta_date_fin = '$presta_date_fin',presta_jour = '$presta_jour',presta_Hdeb=$presta_Hdeb,presta_Hduree=$presta_Hduree,presta_forfait=$presta_forfait,presta_sem=$presta_sem WHERE presta_id = ".$_POST['presta_id']." ");
}
elseif( $prest['presta_recur'] == NULL )
{
$sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,prestation_type,presta_recur)
VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,$prestation_type,$presta_id)";
dbi_query($sql);
$last_id = mysqli_insert_id($conn);
dbi_query("INSERT INTO EXCEPTIONS(presta_id, date_presta, new_presta_id,facture,ad,ded,en_cours,Hduree) VALUES (".$presta_id.", ".dateformaint($_POST['date_presta']).", ".$last_id.", '".$facture."', '".$ad."', '".$ded."','1' ,'".$presta_Hduree_Old."')") ;
}
else
{
dbi_query(" UPDATE PRESTATIONS SET salarie_id = '$salarie_id',presta_date_debut = '$presta_date_debut',presta_date_fin = '$presta_date_fin',presta_jour = '$presta_jour',presta_Hdeb=$presta_Hdeb,presta_Hduree=$presta_Hduree,presta_forfait=$presta_forfait,presta_sem=$presta_sem WHERE presta_id = ".$_POST['presta_id']." ");
dbi_query(" UPDATE EXCEPTIONS SET date_presta = ".dateformaint($_POST['date_presta'])." ,facture = '".$facture."',ad = '".$ad."',ded = '".$ded."',Hduree = '".$presta_Hduree_Old."' WHERE new_presta_id = ".$_POST['presta_id']." ");
// echo " UPDATE EXCEPTIONS SET date_presta = ".dateformaint($_POST['date_presta'])." ,facture = '".$facture."',ad = '".$ad."',ded = '".$ded."',Hduree = '".$presta_Hduree_Old."' WHERE new_presta_id = ".$_POST['presta_id']." ";
}
// echo ' $$$$$$$$$ '.$sql;
// $sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,presta_id_old,prestation_type,facture,ad,ded)
// VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour','$presta_Hdeb','$presta_Hduree','$presta_forfait','$presta_sem','$presta_id_old','$prestation_type','$facture','$ad','$ded')";
// echo $sql;
// echo "INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id,facture,ad,ded) VALUES (".$presta_id_old.", ".dateformaint($_POST['date_presta']).", ".$last_id.", '".$facture."', '".$ad."', '".$ded."' )";
// $last_id_EXP = mysqli_insert_id($conn);
// if($_POST['presta_id_old'] > 0 )
// dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id, presta_id_mere,exp_id_mere,en_cours) VALUES (".$_POST['presta_id'].", ".dateformaint($_POST['date_presta']).",NULL,'".$presta_id_old."','".$last_id_EXP."','1' )") ;
// dbi_query("INSERT INTO EXCEPTIONS (presta_id,presta_id_mere, date_presta, new_presta_id) VALUES (".$_POST['presta_id'].",".$presta_id_old.", ".dateformaint($_POST['date_presta']).", ".$last_id." )") ;
}
else
$erreur = 3;
header("Location:Prestation_New.php?date=".$_POST['date_presta']."");
exit;
}
// if(isset($_POST['UptPrDate']))
// {
// $new_presta_id = $_POST['presta_id'];
// $client_id = $_POST['client_id'];
// $chantier_id = $_POST['chantier_id'];
// $salarie_id = $_POST['salarie_id'];
// $presta_date_debut = dateformaint($_POST['presta_date_debut']);
// $presta_jour = date("w", strtotime($_POST['presta_date_debut']));
// $presta_Hdeb = heure2int($_POST['presta_Hdeb']);
// $presta_Hduree = calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']);
// $presta_forfait = $_POST['presta_forfait'];
// $presta_sem = 1;
// $presta_date_fin = dateformaint($_POST['presta_date_debut']);
// if($_POST['prestation_type'] > 0 ) $prestation_type = $_POST['prestation_type']; else $prestation_type = 4;
// if( $presta_Hdeb != $_POST['presta_Hdeb_Old'] OR $_POST['salarie_id_Old'] != $salarie_id OR $_POST['date_presta'] != $_POST['presta_date_debut'] OR $presta_Hduree != $_POST['presta_Hduree_Old'] )
// {
// $sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,new_presta_id,prestation_type)
// VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,$new_presta_id,$prestation_type)";
// dbi_query($sql);
// dbi_query("INSERT INTO EXCEPTIONS (presta_id, date_presta, new_presta_id) VALUES (".$_POST['presta_id'].", ".dateformaint($_POST['date_presta']).", LAST_INSERT_ID())") ;
// }
// }
if(isset($_POST['InsPr']))
{
$client_id = $_POST['client_id'];
$chantier_id = $_POST['chantier_id'];
$salarie_id = $_POST['salarie_id'];
$presta_date_debut = dateformaint($_POST['presta_date_debut']);
$presta_jour = $_POST['presta_jour'];
$presta_Hdeb = heure2int($_POST['presta_Hdeb']);
$presta_Hduree = calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']);
$presta_forfait = $_POST['presta_forfait'];
$presta_sem = $_POST['presta_sem'];
$prestation_type = $_POST['prestation_type'];
if(!empty($_POST['presta_date_fin']))
{
$presta_date_fin = dateformaint($_POST['presta_date_fin']);
$sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,prestation_type)
VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,$prestation_type)";
}
else
$sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,prestation_type)
VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut',NULL,'$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,$prestation_type)";
// echo $sql;
dbi_query($sql);
// $_POST['presta_date_debut']
header("Location:Prestation_New.php?date=".date('Y-m-01')."");
exit;
}
if(isset($_POST['InsPrPonct']))
{
$client_id = $_POST['client_id'];
$chantier_id = $_POST['chantier_id'];
$salarie_id = $_POST['salarie_id'];
$presta_date_debut = dateformaint($_POST['presta_date_debut']);
$presta_date_fin = $presta_date_debut;
$presta_jour = date("w", strtotime( int2date_autre_format($date)));
// $presta_jour = $_POST['presta_jour'];
$presta_Hdeb = heure2int($_POST['presta_Hdeb']);
$presta_Hduree = calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']);
$presta_forfait = $_POST['presta_forfait'];
$presta_sem = 1;
$prestation_type = $_POST['prestation_type'];
$sql = " INSERT INTO PRESTATIONS (client_id,chantier_id,salarie_id,presta_date_debut,presta_date_fin,presta_jour,presta_Hdeb,presta_Hduree,presta_forfait,presta_sem,prestation_type)
VALUES ('$client_id','$chantier_id','$salarie_id','$presta_date_debut','$presta_date_fin','$presta_jour',$presta_Hdeb,$presta_Hduree,$presta_forfait,$presta_sem,$prestation_type)";
// echo $sql;
dbi_query($sql);
header("Location:Prestation_New.php?date=".date('Y-m-01')."");
exit;
}
function create_upt ($presta_id,$client_id,$presta_date_debut,$presta_date_fin,$presta_sem,$presta_jour, $presta_Hdeb,$presta_Hduree , $presta_forfait , $chantier_id ,$salarie_id,$start ,$prestation_type )
{
if(empty($presta_date_fin))
$update = dbi_query("UPDATE PRESTATIONS SET presta_date_debut=$presta_date_debut, presta_date_fin=NULL ,prestation_type=$prestation_type WHERE presta_id = $presta_id ") ;
else
$update = dbi_query("UPDATE PRESTATIONS SET presta_date_debut=$presta_date_debut, presta_date_fin=$presta_date_fin ,prestation_type=$prestation_type WHERE presta_id = $presta_id ") ;
$j = $h = $d = $s = $f = $ch = $sl = 'NULL' ;
$prest = dbi_fetch_row(dbi_query("SELECT * FROM PRESTATIONS WHERE presta_id = $presta_id ")) ;
$data = array('presta_jour' => $prest['presta_jour'], 'presta_Hdeb' => $prest['presta_Hdeb'], 'presta_Hduree' => $prest['presta_Hduree'],
'salarie_id' => $prest['salarie_id'], 'presta_forfait' => $prest['presta_forfait'], 'presta_sem' => $prest['presta_sem'], 'chantier_id' => $prest['chantier_id']) ;
$q = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$prest['presta_id']." order by start, modif_id") ;
while (($m = dbi_fetch_row($q)) && $start >= $m['start'])
{
$data['presta_jour'] = $m['presta_jour'] === NULL ? $data['presta_jour'] : $m['presta_jour'] ;
$data['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $data['presta_Hdeb'] : $m['presta_Hdeb'] ;
$data['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $data['presta_Hduree'] : $m['presta_Hduree'] ;
$data['salarie_id'] = $m['salarie_id'] === NULL ? $data['salarie_id'] : $m['salarie_id'] ;
$data['presta_forfait'] = $m['presta_forfait'] === NULL ? $data['presta_forfait'] : $m['presta_forfait'] ;
$data['presta_sem'] = $m['presta_sem'] === NULL ? $data['presta_sem'] : $m['presta_sem'] ;
$data['chantier_id'] = $m['chantier_id'] === NULL ? $data['chantier_id'] : $m['chantier_id'] ;
}
if($presta_jour != $data['presta_jour']) $j = $presta_jour ;
if($presta_sem != $data['presta_sem']) $s = $presta_sem ;
if($presta_Hdeb != $data['presta_Hdeb']) $h = $presta_Hdeb ;
if($presta_Hduree != $data['presta_Hduree']) $d = $presta_Hduree ;
if($presta_forfait != $data['presta_forfait']) $f = $presta_forfait ;
if($salarie_id != $data['salarie_id']) $sl = $salarie_id ;
if($chantier_id != $data['chantier_id']) $ch = $chantier_id ;
if($j != 'NULL' || $j != 'NULL' || $s != 'NULL' || $h != 'NULL' || $d != 'NULL' || $f != 'NULL' || $sl != 'NULL' || $ch != 'NULL')
{
$sql = "INSERT INTO PRESTATIONS_MODIF (presta_id, start, salarie_id, presta_jour, presta_Hdeb, presta_Hduree,presta_sem, presta_forfait,chantier_id)
VALUES (".$presta_id.", $start, $sl,$j, $h, $d, $s, $f, $ch)";
// echo $sql;
$update += dbi_query($sql) ;
if($j != 'NULL')
{
$qex = dbi_query("SELECT * FROM EXCEPTIONS WHERE presta_id = ".$prest['presta_id']." AND date_presta >= $start ") ;
while ($mex = dbi_fetch_row($qex))
{
$date_presta = $mex['date_presta'];
$day = days($j);
$d1 = new DateTime("$day this week ".$date_presta);
$date_presta2 = $d1->format('Ymd');
dbi_query("UPDATE EXCEPTIONS SET date_presta=$date_presta2 WHERE excpt_id = ".$mex['excpt_id']." ") ;
}
}
}
}
if(isset($_POST['UptPr']))
{
$presta_Hdeb = heure2int($_POST['presta_Hdeb']);
$presta_Hduree = calcul_duree( $_POST['presta_Hdeb'],$_POST['presta_Hfin']);
if(!empty($_POST['presta_date_fin'])) $presta_date_fin = dateformaint($_POST['presta_date_fin']); else $presta_date_fin = NULL ;
create_upt($_POST['presta_id'],$_POST['client_id'],dateformaint($_POST['presta_date_debut']),$presta_date_fin,$_POST['presta_sem'],$_POST['presta_jour'],$presta_Hdeb,$presta_Hduree,$_POST['presta_forfait'],$_POST['chantier_id'],$_POST['salarie_id'],dateformaint($_POST['start']),$_POST['prestation_type']);
if( !empty($_POST['presta_date_fin']) )
{
$presta_date_fin = dateformaint($_POST['presta_date_fin']);
dbi_query(" DELETE FROM PRESTATIONS WHERE presta_recur = ".$_POST['presta_id']." AND presta_date_debut = presta_date_fin AND presta_date_debut > $presta_date_fin ") ;
dbi_query(" DELETE FROM EXCEPTIONS WHERE presta_id = ".$_POST['presta_id']." AND date_presta > $presta_date_fin ") ;
}
/*
$pr = dbi_query("SELECT * FROM PRESTATIONS WHERE presta_recur = ".$_POST['presta_id']." AND presta_date_debut = presta_date_fin AND presta_date_debut > $presta_date_fin ") ;
while ($Lpr = dbi_fetch_row($pr))
{
echo '<pre>';
print_r($Lpr);
echo '</pre>';
}
$pex = dbi_query("SELECT * FROM EXCEPTIONS WHERE presta_id = ".$_POST['presta_id']." AND date_presta > $presta_date_fin ") ;
while ($Lpex = dbi_fetch_row($pex))
{
}*/
header("Location:Prestation_New.php?date=".date('Y-m-01')."");
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>LogMCPRO | Prestations</title>
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Font Awesome -->
<link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- SweetAlert2 -->
<link rel="stylesheet" href="../plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css">
<!-- Toastr -->
<link rel="stylesheet" href="../plugins/toastr/toastr.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="../dist/css/adminlte.min.css">
<!-- Google Font: Source Sans Pro -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
<link rel="stylesheet" href="../plugins/daterangepicker/daterangepicker.css">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Enregistrer le titre de la page --><title> LogMCPRO | Prestations</title>
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Font Awesome -->
<link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- overlayScrollbars -->
<link rel="stylesheet" href="../dist/css/adminlte.min.css">
<!-- Google Font: Source Sans Pro -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
<!-- Select2 -->
<link rel="stylesheet" href="../plugins/select2/css/select2.min.css">
<link rel="stylesheet" href="../plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
<!-- fullCalendar -->
<link rel="stylesheet" href="../plugins/fullcalendar/main.min.css">
<link rel="stylesheet" href="../plugins/fullcalendar-daygrid/main.min.css">
<link rel="stylesheet" href="../plugins/fullcalendar-timegrid/main.min.css">
<link rel="stylesheet" href="../plugins/fullcalendar-bootstrap/main.min.css">
<style>
.myCollapse {
display: none;
}
.myCollapse.in {
display: block;
}
.modal-header {
padding: 15px;
border-bottom: 1px solid #e5e5e5;
}
.modal-header {
background: #226faa;
background: -webkit-gradient(linear,left top,right top,from(#226faa),color-stop(37%,#2989d8),to(#72c0d3));
background: linear-gradient(to right,#226faa 0,#2989d8 37%,#72c0d3 100%);
border-radius: 6px;
color: #fff;
padding: 18px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
border-color: transparent;
}
.modal-header .close {
margin-top: -3px;
font-size: 24px;
font-weight: 400;
color: #fff;
opacity: .9;
width: 28px;
height: 28px;
padding-bottom: 0;
padding-left: 1px;
}
button.close {
padding: 0;
cursor: pointer;
background: 0 0;
border: 0;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
.task-single-col-right {
background: #f0f5f7;
padding: 13px 20px;
border-bottom-right-radius: 6px;
}
@media (min-width: 992px)
.col-md-4 {
width: 33.33333333%;
}
@media (min-width: 992px)
.col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9 {
float: left;
}
@media (min-width: 992px)
.col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9 {
float: left;
}
.col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-xs-1, .col-xs-10, .col-xs-11, .col-xs-12, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9 {
position: relative;
min-height: 1px;
padding-right: 15px;
padding-left: 15px;
}
.staff-profile-image-small {
height: 64px;
width: 64px;
border-radius: 50%;
}
img {
vertical-align: middle;
}
img {
border: 0;
}
.task-single-col-right {
background: #f0f5f7;
padding: 13px 20px;
border-bottom-right-radius: 6px;
}
.task-single-col-left {
padding: 25px;
background: #fff;
border-bottom-left-radius: 6px;
}
.btn-group-vertical>.btn-group:after, .btn-group-vertical>.btn-group:before, .btn-toolbar:after, .btn-toolbar:before, .clearfix:after, .clearfix:before, .container-fluid:after, .container-fluid:before, .container:after, .container:before, .dl-horizontal dd:after, .dl-horizontal dd:before, .form-horizontal .form-group:after, .form-horizontal .form-group:before, .modal-footer:after, .modal-footer:before, .modal-header:after, .modal-header:before, .nav:after, .nav:before, .navbar-collapse:after, .navbar-collapse:before, .navbar-header:after, .navbar-header:before, .navbar:after, .navbar:before, .pager:after, .pager:before, .panel-body:after, .panel-body:before, .row:after, .row:before {
display: table;
content: " ";
</style>
<link href="/open-iconic/font/css/open-iconic-bootstrap.css" rel="stylesheet">
</head>
<body class="hold-transition sidebar-mini">
<span class="oi oi-icon-name" title="icon name" aria-hidden="true"></span>
<!-- Site wrapper -->
<div class="wrapper">
<!-- TOP MENU -->
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
<!-- Menu extensible -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#"><i class="fas fa-bars"></i></a>
</li>
<li>
<h3><button type="button" class="btn btn-info" data-toggle="modal" data-target="#modal-nouvelleprestation"> NOUVELLE PRESTATION REGULIERE</button></h3>
</li>
 
<li>
<h3><button type="button" class="btn btn-info" data-toggle="modal" data-target="#modal-nouvelleprestationpoctuelle"> NOUVELLE PRESTATION PONCTUELLE</button></h3>
</li>
<td>
  <a href="calendar2.php?salarie_id= <?php echo $_SESSION['salarie_name_return'] ; ?>""><button type="button" class="btn btn-block btn-dark" ></i> Retour Planning</button> </a>
</td>
</ul>
<!-- liens TOP MENU DROITE -->
<ul class="navbar-nav ml-auto">
<!-- Placer ici l'élément à positionner à droite du TOP MENU -->
</ul>
</nav> <!-- fin du TOP MENU -->
<!-- BARRE DE NAVIGATION -->
<!-- Couleur et caracteristiques de la barre de navigation-->
<?php include('menu.php');
?>
<!-- Ne pas toucher au dessus / fin de la BARRE DE NAVIGATION-->
<!-- DEMARRAGE DE LA PAGE PRINCIPALE -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="modal fade" id="modal-nouvelleprestationpoctuelle">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Nouvelle Prestation Ponctuelle</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="card-body">
<form action="" method="POST">
<input type="hidden" id="client_id" name="client_id" value="<?php echo $client_id ;?>"/>
<div class="form-row">
<div class="form-group col-md-4">
<label>Date</label>
<div class="input-group">
<div class="input-group-prepend"> <span class="input-group-text"><i class="far fa-calendar-alt"></i></span></div>
<input type="date" class="form-control" id="presta_date_debut" name="presta_date_debut" placeholder="jj/mm/aaaa"/>
</div>
</div>
<div class="form-group col-md-2">
<label for="inputAddresse">Heure Début</label>
<input type="time" id="appt" min="05:00" max="22:00" class="form-control" name="presta_Hdeb" value= "<?php echo int2heure($prest['presta_Hdeb']) ; ?>" required>
</div>
<div class="form-group col-md-2">
<label for="inputsociete">Heure fin</label>
<input type="time" id="appt" min="05:00" max="22:00" class="form-control" name="presta_Hfin" value= "<?php echo int2heure($prest['presta_Hfin']) ; ?>" required>
</div>
<div class="form-group col-md-4"><!-- Liste déroulante jour -->
<label>Salarier </label>
<select class="form-control select2" name="salarie_id" id="salarie_id">
<?php $req =dbi_query("SELECT * FROM salarie WHERE salarie_statut = '1' ORDER BY `salarie`.`salarie_nom` ASC") ;
while( $sal=dbi_fetch_row($req)) { ?>
<option value="<?php echo $sal['salarie_id'] ; ?>" ><?php echo $sal['salarie_nom']." ".$sal['salarie_prenom']; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4"><!-- Liste déroulante jour -->
<label>Chantier </label>
<select class="form-control" name="chantier_id" id="pmonChoix" >
<?php $req1 =dbi_query("SELECT * FROM chantier WHERE `client_id` = $client_id and chantier_type_id = 1") ;
$today_p = date('Ymd');
while( $chant=dbi_fetch_row($req1)) {
$a = '' ;
if($chant['chantier_fin']==0)
{
$a = 'class="vert"' ;
$chantier_desc = $chant['chantier_designation'].' <strong><span class="rouge"> (en cours)</span></strong>';
}
elseif($chant['chantier_fin']<=$today_p){
$a = 'class="rouge"' ;
$chantier_desc = $chant['chantier_designation']." ( ".int2date($chant['chantier_fin'])." )";
}
else{
$a = '' ;
$chantier_desc = $chant['chantier_designation']." ( ".int2date($chant['chantier_fin'])." )";
}
?>
<option <?php echo $a ; ?> value="<?php echo $chant['chantier_ID'] ; ?>" ><?php echo $chantier_desc ; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="inputsociete">Taux</label>
<input type="text" class="form-control" name="presta_forfait" required>
</div>
<div class="form-group col-md-4">
<label for="inputsociete">Type prestation</label>
<?php echo GET_type_pre('prestation_type','id="prestation_type" class="form-control" ' ,1 ) ; ?>
</div>
</div>
</div>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-primary" data-dismiss="modal">Fermer</button>
<button type="submit" name="InsPrPonct" class="btn btn-primary">Enregistrer</button>
</form>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<div class="modal fade" id="modal-nouvelleprestation">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Nouvelle Prestation</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="card-body">
<form action="" method="POST">
<input type="hidden" id="client_id" name="client_id" value="<?php echo $client_id ;?>"/>
<div class="form-row">
<div class="form-group col-md-4">
<label>Date de Début (start)</label>
<div class="input-group">
<div class="input-group-prepend"> <span class="input-group-text"><i class="far fa-calendar-alt"></i></span></div>
<input type="date" class="form-control" id="presta_date_debut" name="presta_date_debut" placeholder="jj/mm/aaaa"/>
</div>
</div>
<div class="form-group col-md-4">
<label>Date de fin (end) </label>
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-calendar-alt"></i></span></div>
<input type="date" class="form-control" id="presta_date_fin" name="presta_date_fin" >
</div>
</div>
<div class="form-group col-md-4">
<label>Nombre semaine </label>
<div class="input-group">
<div class="input-group-prepend"><span class="input-group-text"><i class="far fa-calendar-alt"></i></span></div>
<select class="form-control" name="presta_sem" id="presta_sem">
<option value="1" > 1 </option>
<option value="2" > 2 </option>
<option value="3" > 3 </option>
<option value="4" > 4 </option>
<option value="5" > 5 </option>
<option value="6" > 6 </option>
<option value="7" > 7 </option>
<option value="8" > 8 </option>
<option value="9" > 9 </option>
<option value="10"> 10</option>
<option value="11"> 11 </option>
<option value="12"> 12</option>
<option value="13"> 13</option>
<option value="26"> 26</option>
<option value="52"> 52</option>
</select>
</div>
</div>
<div class="form-group col-md-2">
<label for="inputAddresse">Heure Début</label>
<input type="time" id="appt" min="05:00" max="22:00" class="form-control" name="presta_Hdeb" value= "<?php echo int2heure($prest['presta_Hdeb']) ; ?>" required>
</div>
<div class="form-group col-md-2">
<label for="inputsociete">Heure fin</label>
<input type="time" id="appt" min="05:00" max="22:00" class="form-control" name="presta_Hfin" value= "<?php echo int2heure($prest['presta_Hfin']) ; ?>" required>
</div>
<div class="form-group col-md-4">
<label>Jour de prestation</label>
<select class="form-control" name="presta_jour" id="presta_jour">
<option selected="selected" value="1"> lundi </option>
<option value="2" >mardi </option>
<option value="3" >mercredi </option>
<option value="4" >jeudi </option>
<option value="5" >vendredi </option>
<option value="6" >samedi </option>
<option value="0" >dimanche </option>
</select>
</div>
<div class="form-group col-md-4"><!-- Liste déroulante jour -->
<label>Salarier </label>
<select class="form-control select2" name="salarie_id" id="salarie_id">
<?php $req =dbi_query("SELECT * FROM salarie WHERE salarie_statut = '1' ORDER BY `salarie`.`salarie_nom` ASC") ;
while( $sal=dbi_fetch_row($req)) { ?>
<option value="<?php echo $sal['salarie_id'] ; ?>" ><?php echo $sal['salarie_nom']." ".$sal['salarie_prenom']; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4"><!-- Liste déroulante jour -->
<label>Chantier </label>
<select class="form-control" name="chantier_id" id="ppmonChoix" >
<?php $req1 =dbi_query("SELECT * FROM chantier WHERE `client_id` = $client_id and chantier_type_id = 1") ;
$today_p = date('Ymd');
while( $chant=dbi_fetch_row($req1)) {
$a = '' ;
if($chant['chantier_fin']==0)
{
$a = 'class="vert"' ;
$chantier_desc = $chant['chantier_designation'].' <strong><span class="rouge"> (en cours)</span></strong>';
}
elseif($chant['chantier_fin']<=$today_p){
$a = 'class="rouge"' ;
$chantier_desc = $chant['chantier_designation']." ( ".int2date($chant['chantier_fin'])." )";
}
else{
$a = '' ;
$chantier_desc = $chant['chantier_designation']." ( ".int2date($chant['chantier_fin'])." )";
}
?>
<option <?php echo $a ; ?> value="<?php echo $chant['chantier_ID'] ; ?>" ><?php echo $chantier_desc ; ?></option>
<?php } ?>
</select>
</div>
<div class="form-group col-md-4">
<label for="inputsociete">Taux</label>
<input type="text" class="form-control" name="presta_forfait" required>
</div>
<div class="form-group col-md-4">
<label for="inputsociete">Type prestation</label>
<?php echo GET_type_pre('prestation_type','id="prestation_type" class="form-control" ' ,1 ) ; ?>
</div>
</div>
</div>
</div>
<div class="modal-footer justify-content-between">
<button type="button" class="btn btn-primary" data-dismiss="modal">Fermer</button>
<button type="submit" name="InsPr" class="btn btn-primary">Enregistrer</button>
</form>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>
<div class="modal fade" id="myModal" role="dialog" class="modal fade task-modal-single in" tabindex="-1" aria-labelledby="myLargeModalLabel" >
<div class="modal-dialog modal-lg">
<div class="modal-content data">
<div id="fetch" ></div>
</div>
</div>
</div>
<div id="myModal1" class="modal fade" role="dialog" aria-labelledby="myModal1" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content data">
<div id="fetch1" ></div>
</div>
</div>
</div>
<div class="modal fade" id="PrestUpt" role="dialog" class="modal fade task-modal-single in" tabindex="-1" aria-labelledby="myLargeModalLabel" >
<div class="modal-dialog modal-lg">
<div class="modal-content data">
<div id="jalil" ></div>
</div>
</div>
</div>
</div><!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content-header -->
<!-- PAGE PRINCIPALE -->
<div class="content">
<div class="container-fluid">
<div class="row">
<!-- DEFINITION DES COLONNES -->
<div class="col-lg-3">
<?php $q= dbi_fetch_row(dbi_query("SELECT * FROM client where client_id = ".$client_id)) ; ?>
<?php include('widget_client.php'); ?>
<!-- BARRE DE NAVIGATION DU CLIENT -->
<?php include('menu_client.php'); ?>
<div class="card card-primary ">
<span class="mr-2"> <i class="fas fa-square text-primary"></i> Nettoyage courant régulier</span><br/>
<span class="mr-2"> <i class="fas fa-square text-success"></i> Prestation de Vitrerie</span><br/>
<span class="mr-2"> <i class="fas fa-square text-warning"></i> Shampoing Moquette</span><br/>
<span> <i class="fas fa-square text-pink"> </i> Autre prestation spécifique </span>
</div>
</div>
<!-- PASSAGE A LA COLONNE DE DROITE-->
<!-- /.col -->
<div class="col-lg-9">
<?php
// $_GET["msg"] = 'danger' ;
// $_GET["color"] = 'danger' ;
if( isset($_GET["msg"]) ){
?>
<div class="alert alert-<?php echo $_GET["color"]; ?> alert-dismissible col-12" role="alert">
<strong><?php echo $_GET["color"].': '; ?></strong><?php echo $_GET["msg"]; ?>.
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<?php
}
?>
<?php
// echo '<pre>';
// print_r($_POST);
// echo '<pre>';
?>
<div class="card card-primary">
<div class="card-body p-0">
<?php
$i = 1;
$date = date('Ymd'); ;
$sql= "SELECT * FROM PRESTATIONS WHERE client_id=".$client_id." AND (presta_date_debut != presta_date_fin OR presta_date_fin IS NULL ) AND ( presta_date_fin IS NULL OR presta_date_fin >= $date ) ORDER BY presta_jour ASC";
// ECHO $sql;
// $sql= "SELECT * FROM PRESTATIONS WHERE client_id=".$client_id." AND (presta_date_debut != presta_date_fin OR presta_date_fin IS NULL ) AND ( presta_date_fin IS NULL OR presta_date_fin >= $date ) AND presta_jour = 1 ";
// $sql.= " UNION SELECT * FROM PRESTATIONS WHERE client_id=".$client_id." AND (presta_date_debut != presta_date_fin OR presta_date_fin IS NULL ) AND ( presta_date_fin IS NULL OR presta_date_fin >= $date ) AND presta_jour = 2 ";
// $sql.= " UNION SELECT * FROM PRESTATIONS WHERE client_id=".$client_id." AND (presta_date_debut != presta_date_fin OR presta_date_fin IS NULL ) AND ( presta_date_fin IS NULL OR presta_date_fin >= $date ) AND presta_jour = 3 ";
// $sql.= " UNION SELECT * FROM PRESTATIONS WHERE client_id=".$client_id." AND (presta_date_debut != presta_date_fin OR presta_date_fin IS NULL ) AND ( presta_date_fin IS NULL OR presta_date_fin >= $date ) AND presta_jour = 4 ";
// $sql.= " UNION SELECT * FROM PRESTATIONS WHERE client_id=".$client_id." AND (presta_date_debut != presta_date_fin OR presta_date_fin IS NULL ) AND ( presta_date_fin IS NULL OR presta_date_fin >= $date ) AND presta_jour = 5 ";
// $sql.= " UNION SELECT * FROM PRESTATIONS WHERE client_id=".$client_id." AND (presta_date_debut != presta_date_fin OR presta_date_fin IS NULL ) AND ( presta_date_fin IS NULL OR presta_date_fin >= $date ) AND presta_jour = 6 ";
// $sql.= " UNION SELECT * FROM PRESTATIONS WHERE client_id=".$client_id." AND (presta_date_debut != presta_date_fin OR presta_date_fin IS NULL ) AND ( presta_date_fin IS NULL OR presta_date_fin >= $date ) AND presta_jour = 0 ";
// ECHO $sql;
$q = dbi_query($sql);
?>
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Prestations en cours</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php while($LPr=dbi_fetch_row($q)) {
$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$LPr['presta_id']." order by start, modif_id ") ;
while (($m = dbi_fetch_row($q1)) && $date >= $m['start'])
{
$LPr['presta_jour'] = $m['presta_jour'] === NULL ? $LPr['presta_jour'] : $m['presta_jour'] ;
$LPr['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $LPr['presta_Hdeb'] : $m['presta_Hdeb'] ;
$LPr['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $LPr['presta_Hduree'] : $m['presta_Hduree'] ;
$LPr['salarie_id'] = $m['salarie_id'] === NULL ? $LPr['salarie_id'] : $m['salarie_id'] ;
$LPr['presta_forfait'] = $m['presta_forfait'] === NULL ? $LPr['presta_forfait'] : $m['presta_forfait'] ;
}
if($LPr['salarie_id'] !== NULL)
$salarie = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) as salarie FROM salarie WHERE salarie_id = '".$LPr['salarie_id']."' ")) ;
// if($LPr['salarie_id'] !== NULL)
// list($LPr['salarie_id']) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$LPr['salarie_id']."' ")) ;
?>
<tr>
<td>
<?php echo " <strong>".daysfr($LPr['presta_jour']);?></strong>
, de <strong><?php echo int2heure($LPr['presta_Hdeb']);?></strong> à <strong><?php echo int2heure(addDuree($LPr['presta_Hdeb'], $LPr['presta_Hduree']) );?> </strong> - <strong><?php echo $salarie['salarie'];?></strong> - <strong><?php echo $LPr['presta_forfait'];?></strong>-
<?php if ( $LPr['presta_date_fin'] == NULL ) echo '<b style="color:red">Pas date de fin </b>'; else echo " finit le ".int2date($LPr['presta_date_fin']); ?>
</td>
<td style="text-align:center;vertical-align: middle;white-space: nowrap;"><a class="btn btn-info btn-sm" data-toggle="collapse" href="#prst<?php echo $LPr['presta_id']; ?>" role="button" aria-expanded="false" aria-controls="prst<?php echo $LPr['presta_id']; ?>"><span class="fas fa-eye"></span></a>
<?php echo '<a class="btn btn-success btn-sm" href="#myModal" id="custId" data-toggle="modal" data-id="'.$LPr['presta_id'].'">Modifer</a>';?>
<?php echo '<a class="btn btn-warning btn-sm" href="#myModal1" id="custId" data-toggle="modal" data-id="'.$LPr['presta_id'].'">Modifier Période</a>';?></td>
</tr>
<tr>
<td colspan="4">
<div class="collapse" id="prst<?php echo $LPr['presta_id']; ?>">
<div class="card card-body ">
<span style=" display: inline; ">
<?php
$sqlo= "SELECT * FROM PRESTATIONS Pr LEFT JOIN salarie Sl on Pr.salarie_id = Sl.salarie_id where Pr.presta_id = '".$LPr['presta_id']."'";
$qo = dbi_query($sqlo);
$LPro=dbi_fetch_row($qo);
echo "La prestation d'origine a lieu le <strong>".daysfr($LPro['presta_jour']);?></strong>
, de <strong><?php echo int2heure($LPro['presta_Hdeb']);?></strong> à <strong><?php echo int2heure(addDuree($LPro['presta_Hdeb'], $LPro['presta_Hduree']) );?> </strong> avec <strong><?php echo $LPro['salarie_nom'].' '.$LPro['salarie_prenom'];?></strong> au taux <strong><?php echo $LPro['presta_forfait'];?></strong>
<? // if (mysql_num_rows($q1))
// {
$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$LPr['presta_id']." order by start") ;
?>
<br/><b>Modifications</b><br/>
<?php
while ($m = dbi_fetch_row($q1))
{
if($m['salarie_id'] !== NULL)
list($m['salarie']) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$m['salarie_id']."' ")) ;
// if($m['salarie_id'] !== NULL)
?>
<a href="?prt=<?php echo $m['modif_id'];?>" >Supprimer</a>
A partir du <?php echo int2date($m['start']);?>, la prestation <?php echo ($m['presta_jour'] != NULL || $m['presta_Hdeb'] != NULL || $m['presta_Hduree'] != NULL ? 'a lieu '.($m['presta_jour'] === NULL ? '' : 'le '.daysfr($m['presta_jour'])).($m['presta_Hdeb'] === NULL ? '' : ' de '.int2heure($m['presta_Hdeb'])).($m['presta_Hduree'] === NULL ? '' : ' a '.int2heure(addDuree($m['presta_Hdeb'], $m['presta_Hduree']))).($m['inter'] === NULL ? '' :' et ') : '').(($m['salarie'] === NULL ? '' : ' se fera avec '.$m['salarie'])).(($m['presta_forfait'] === NULL ? '' : ' au taux '.$m['presta_forfait']))?><br/>
<?php
}
// }
// if (mysql_num_rows($q2))
// {
$q2 = dbi_query( "SELECT * FROM EXCEPTIONS e LEFT JOIN PRESTATIONS p ON e.new_presta_id = p.presta_id and e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id") ;
// echo "SELECT * FROM EXCEPTIONS e LEFT JOIN PRESTATIONS p ON e.presta_id = p.presta_id e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id";
// echo "SELECT * FROM EXCEPTIONS e LEFT JOIN PRESTATIONS p ON e.new_presta_id = p.presta_id and e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id";
?>
<b>Exceptions</b><br/>
<?php
while($e = dbi_fetch_row($q2)){
$msgpr = '';
$inter = '' ;
if($e['new_presta_id'] !== NULL)
list($inter) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$e['salarie_id']."' ")) ;
if ( $e['facture'] != 1 && $e['new_presta_id'] === NULL )
$msgpr = ' ( Prestation déduite de la facture ) ' ;
elseif ( $e['facture'] == 1 && $e['new_presta_id'] === NULL )
$msgpr = ' ( Prestation facturée ) ' ;
else if($e['ad'] == '1' && $e['new_presta_id'] != NULL && $e['facture'] == 1 && $e['Hduree'] >0 )
$msgpr = ' ( durée supplémentaire facturée ) ' ;
else if($e['ad'] == '1' && $e['new_presta_id'] != NULL && $e['facture'] != 1 && $e['Hduree'] >0)
$msgpr = ' ( durée supplémentaire non facturée ) ' ;
else if($e['ded'] == '1' && $e['new_presta_id'] != NULL && $e['facture'] == 1 && $e['Hduree'] >0)
$msgpr = ' ( Temps non effectué déduit ) ' ;
else if($e['ded'] == '1' && $e['new_presta_id'] != NULL && $e['facture'] != 1 && $e['Hduree'] >0 )
$msgpr = ' ( Temps non effectué non déduit ) ' ;
?>
<!-- v2 -->
<a href="?exp=<?php echo $e['excpt_id'];?>" >Supprimer</a>
La prestation du <?=int2date($e['date_presta']).($e['presta_date_debut'] != NULL && $e['date_presta'] != $e['presta_date_debut'] ? ' est déplacée au '.int2date($e['presta_date_debut']).' et ' : ' est annulée').($e['presta_Hdeb'] === NULL ? '' : ' aura lieu de '.int2heure($e['presta_Hdeb'])).($e['presta_Hdeb'] === NULL ? '' : ' à ' . int2heure(addDuree($e['presta_Hdeb'], $e['presta_Hduree']))) . ($e['salarie_id'] === NULL ? '' : ' avec ' . $inter) . ($e['presta_forfait'] === NULL ? '' : ' au taux ' . $e['presta_forfait']) . ($e['inter_abs'] == 1 ? ' (absence de l\'intervenant)' : '').$msgpr;?><br/>
<?php
}
// }
?>
</span>
</div>
</div>
</td>
</tr>
<?php ++$i;} ?>
</tbody>
</table>
<!-- THE CALENDAR -->
<div id="calendar"></div>
<?php
$i = 1;
$date = date('Ymd'); ;
$sql= "SELECT * FROM PRESTATIONS WHERE client_id=".$client_id." AND presta_date_fin < $date AND presta_date_debut != presta_date_fin ORDER BY presta_jour ASC";
$q = dbi_query($sql);
?>
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Prestations terminées</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php while($LPr=dbi_fetch_row($q)) {
$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$LPr['presta_id']." order by start, modif_id ") ;
while (($m = dbi_fetch_row($q1)) && $date >= $m['start'])
{
$LPr['presta_jour'] = $m['presta_jour'] === NULL ? $LPr['presta_jour'] : $m['presta_jour'] ;
$LPr['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $LPr['presta_Hdeb'] : $m['presta_Hdeb'] ;
$LPr['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $LPr['presta_Hduree'] : $m['presta_Hduree'] ;
$LPr['salarie_id'] = $m['salarie_id'] === NULL ? $LPr['salarie_id'] : $m['salarie_id'] ;
$LPr['presta_forfait'] = $m['presta_forfait'] === NULL ? $LPr['presta_forfait'] : $m['presta_forfait'] ;
}
if($LPr['salarie_id'] !== NULL)
$salarie = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) as salarie FROM salarie WHERE salarie_id = '".$LPr['salarie_id']."' ")) ;
// if($LPr['salarie_id'] !== NULL)
// list($LPr['salarie_id']) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$LPr['salarie_id']."' ")) ;
?>
<tr>
<td>
<?php echo $i." - Début : <strong>".int2date($LPr['presta_date_debut'])."</strong> Jour : <strong>".daysfr($LPr['presta_jour']);?></strong>
, H Début : <strong><?php echo int2heure($LPr['presta_Hdeb']);?></strong> H Fin : <strong><?php echo int2heure(addDuree($LPr['presta_Hdeb'], $LPr['presta_Hduree']) );?> </strong> Salarié : <strong><?php echo $salarie['salarie'];?></strong> Taux : <strong><?php echo $LPr['presta_forfait'];?></strong>,
<?php if ( $LPr['presta_date_fin'] == NULL ) echo '<b style="color:red">Pas date de fin </b>'; else echo " finit le ".int2date($LPr['presta_date_fin']); ?>
</td>
<td style="text-align:center;vertical-align: middle;white-space: nowrap;"><a class="btn btn-info btn-sm" data-toggle="collapse" href="#prst<?php echo $LPr['presta_id']; ?>" role="button" aria-expanded="false" aria-controls="prst<?php echo $LPr['presta_id']; ?>"><span class="fas fa-eye"></span></a>
<?php echo '<a class="btn btn-success btn-sm" href="#myModal" id="custId" data-toggle="modal" data-id="'.$LPr['presta_id'].'">Modifer</a>';?>
<?php echo '<a class="btn btn-warning btn-sm" href="#myModal1" id="custId" data-toggle="modal" data-id="'.$LPr['presta_id'].'">Modifier Période</a>';?></td>
</tr>
<tr>
<td colspan="4">
<div class="collapse" id="prst<?php echo $LPr['presta_id']; ?>">
<div class="card card-body ">
<span style=" display: inline; ">
<?php
$sqlo= "SELECT * FROM PRESTATIONS Pr LEFT JOIN salarie Sl on Pr.salarie_id = Sl.salarie_id where Pr.presta_id = '".$LPr['presta_id']."'";
$qo = dbi_query($sqlo);
$LPro=dbi_fetch_row($qo);
echo "La prestation d'origine a lieu le <strong>".daysfr($LPro['presta_jour']);?></strong>
, de <strong><?php echo int2heure($LPro['presta_Hdeb']);?></strong> à <strong><?php echo int2heure(addDuree($LPro['presta_Hdeb'], $LPro['presta_Hduree']) );?> </strong> avec <strong><?php echo $LPro['salarie_nom'].' '.$LPro['salarie_prenom'];?></strong> au taux <strong><?php echo $LPro['presta_forfait'];?></strong>
<? // if (mysql_num_rows($q1))
// {
$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$LPr['presta_id']." order by start") ;
?>
<br/><b>Modifications</b><br/>
<?php
while ($m = dbi_fetch_row($q1))
{
if($m['salarie_id'] !== NULL)
list($m['salarie']) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$m['salarie_id']."' ")) ;
// if($m['salarie_id'] !== NULL)
?>
<a href="?prt=<?php echo $m['modif_id'];?>" >Supprimer</a>
A partir du <?php echo int2date($m['start']);?>, la prestation <?php echo ($m['presta_jour'] != NULL || $m['presta_Hdeb'] != NULL || $m['presta_Hduree'] != NULL ? 'a lieu '.($m['presta_jour'] === NULL ? '' : 'le '.daysfr($m['presta_jour'])).($m['presta_Hdeb'] === NULL ? '' : ' de '.int2heure($m['presta_Hdeb'])).($m['presta_Hduree'] === NULL ? '' : ' a '.int2heure(addDuree($m['presta_Hdeb'], $m['presta_Hduree']))).($m['inter'] === NULL ? '' :' et ') : '').(($m['salarie'] === NULL ? '' : ' se fera avec '.$m['salarie'])).(($m['presta_forfait'] === NULL ? '' : ' au taux '.$m['presta_forfait']))?><br/>
<?php
}
// }
// if (mysql_num_rows($q2))
// {
$q2 = dbi_query( "SELECT * FROM EXCEPTIONS e LEFT JOIN PRESTATIONS p ON e.new_presta_id = p.presta_id and e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id") ;
// echo "SELECT * FROM EXCEPTIONS e LEFT JOIN PRESTATIONS p ON e.presta_id = p.presta_id e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id";
// echo "SELECT * FROM EXCEPTIONS e LEFT JOIN PRESTATIONS p ON e.new_presta_id = p.presta_id and e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id";
?>
<b>Exceptions</b><br/>
<?php
while($e = dbi_fetch_row($q2)){
$inter = '' ;
if($e['new_presta_id'] !== NULL)
list($inter) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$e['salarie_id']."' ")) ;
?>
<!-- v2 -->
<a href="?exp=<?php echo $e['excpt_id'];?>" >Supprimer</a>
La prestation du <?=int2date($e['date_presta']).($e['presta_date_debut'] != NULL && $e['date_presta'] != $e['presta_date_debut'] ? ' est déplacée au '.int2date($e['presta_date_debut']).' et ' : ' est annulée').($e['presta_Hdeb'] === NULL ? '' : ' aura lieu de '.int2heure($e['presta_Hdeb'])).($e['presta_Hdeb'] === NULL ? '' : ' à ' . int2heure(addDuree($e['presta_Hdeb'], $e['presta_Hduree']))) . ($e['salarie_id'] === NULL ? '' : ' avec ' . $inter) . ($e['presta_forfait'] === NULL ? '' : ' au taux ' . $e['presta_forfait']) . ($e['inter_abs'] == 1 ? ' (absence de l\'intervenant)' : '').($e['facture'] != 1 ? '' : ' (prestation d’origine facturée au client)')?><br/>
<?php
}
// }
?>
</span>
</div>
</div>
</td>
</tr>
<?php ++$i;} ?>
</tbody>
</table>
<?php /* ?>
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>Prestations terminées</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<?php while($LPr=dbi_fetch_row($q)) {
$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$LPr['presta_id']." order by start, modif_id ") ;
while (($m = dbi_fetch_row($q1)) && $date >= $m['start'])
{
$LPr['presta_jour'] = $m['presta_jour'] === NULL ? $LPr['presta_jour'] : $m['presta_jour'] ;
$LPr['presta_Hdeb'] = $m['presta_Hdeb'] === NULL ? $LPr['presta_Hdeb'] : $m['presta_Hdeb'] ;
$LPr['presta_Hduree'] = $m['presta_Hduree'] === NULL ? $LPr['presta_Hduree'] : $m['presta_Hduree'] ;
$LPr['salarie_id'] = $m['salarie_id'] === NULL ? $LPr['salarie_id'] : $m['salarie_id'] ;
$LPr['presta_forfait'] = $m['presta_forfait'] === NULL ? $LPr['presta_forfait'] : $m['presta_forfait'] ;
}
if($LPr['salarie_id'] !== NULL)
$salarie = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) as salarie FROM salarie WHERE salarie_id = '".$LPr['salarie_id']."' ")) ;
// if($LPr['salarie_id'] !== NULL)
// list($LPr['salarie_id']) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$LPr['salarie_id']."' ")) ;
?>
<tr>
<td>
<?php echo $i." - Début : <strong>".int2date($LPr['presta_date_debut'])."</strong> Jour : <strong>".daysfr($LPr['presta_jour']);?></strong>
, H Début : <strong><?php echo int2heure($LPr['presta_Hdeb']);?></strong> H Fin : <strong><?php echo int2heure(addDuree($LPr['presta_Hdeb'], $LPr['presta_Hduree']) );?> </strong> Salarié : <strong><?php echo $salarie['salarie'];?></strong> Taux : <strong><?php echo $LPr['presta_forfait'];?></strong>,
<?php if ( $LPr['presta_date_fin'] == NULL ) echo '<b style="color:red">Pas date de fin </b>'; else echo " finit le ".int2date($LPr['presta_date_fin']); ?>
</td>
<td style="text-align:center;vertical-align: middle;white-space: nowrap;">
<a class="btn btn-info btn-sm" data-toggle="collapse" href="#prst<?php echo $LPr['presta_id']; ?>" role="button" aria-expanded="false" aria-controls="prst<?php echo $LPr['presta_id']; ?>"><span class="fas fa-eye"></span></a>
<?php echo '<a class="btn btn-success btn-sm" href="#myModal" id="custId" data-toggle="modal" data-id="'.$LPr['presta_id'].'">Modifer</a>';?>
<?php echo '<a class="btn btn-warning btn-sm" href="#myModal1" id="custId" data-toggle="modal" data-id="'.$LPr['presta_id'].'">Modifier Période</a>';?></td>
</tr>
<tr>
<td colspan="4">
<div class="collapse" id="prst<?php echo $LPr['presta_id']; ?>">
<div class="card card-body ">
<span style=" display: inline; ">
<?php
$sqlo= "SELECT * FROM PRESTATIONS Pr LEFT JOIN salarie Sl on Pr.salarie_id = Sl.salarie_id where Pr.presta_id = '".$LPr['presta_id']."'";
$qo = dbi_query($sqlo);
$LPro=dbi_fetch_row($qo);
echo "La prestation d'origine a lieu le <strong>".daysfr($LPro['presta_jour']);?></strong>
, de <strong><?php echo int2heure($LPro['presta_Hdeb']);?></strong> à <strong><?php echo int2heure(addDuree($LPro['presta_Hdeb'], $LPro['presta_Hduree']) );?> </strong> avec <strong><?php echo $LPro['salarie_nom'].' '.$LPro['salarie_prenom'];?></strong> au taux <strong><?php echo $LPro['presta_forfait'];?></strong>
<? // if (mysql_num_rows($q1))
// {
$q1 = dbi_query("SELECT * FROM PRESTATIONS_MODIF WHERE presta_id = ".$LPr['presta_id']." order by start") ;
?>
<br/><b>Modifications</b><br/>
<?php
while ($m = dbi_fetch_row($q1))
{
if($m['salarie_id'] !== NULL)
list($m['salarie']) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$m['salarie_id']."' ")) ;
// if($m['salarie_id'] !== NULL)
?>
<a href="?prt=<?php echo $m['modif_id'];?>" >Supprimer</a>
A partir du <?php echo int2date($m['start']);?>, la prestation <?php echo ($m['presta_jour'] != NULL || $m['presta_Hdeb'] != NULL || $m['presta_Hduree'] != NULL ? 'a lieu '.($m['presta_jour'] === NULL ? '' : 'le '.daysfr($m['presta_jour'])).($m['presta_Hdeb'] === NULL ? '' : ' de '.int2heure($m['presta_Hdeb'])).($m['presta_Hduree'] === NULL ? '' : ' a '.int2heure(addDuree($m['presta_Hdeb'], $m['presta_Hduree']))).($m['inter'] === NULL ? '' :' et ') : '').(($m['salarie'] === NULL ? '' : ' se fera avec '.$m['salarie'])).(($m['presta_forfait'] === NULL ? '' : ' au taux '.$m['presta_forfait']))?><br/>
<?php
}
// }
// if (mysql_num_rows($q2))
// {
$q2 = dbi_query("SELECT * FROM EXCEPTIONS e LEFT JOIN PRESTATIONS p ON e.presta_id = p.presta_id and e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id") ;
// echo "SELECT * FROM EXCEPTIONS e LEFT JOIN PRESTATIONS p ON e.presta_id = p.presta_id e.new_presta_id is not null WHERE e.presta_id = ".$LPr['presta_id']." ORDER BY date_presta, excpt_id";
?>
<b>Exceptions</b><br/>
<?php
while($e = dbi_fetch_row($q2)){
$inter = '' ;
if($e['new_presta_id'] !== NULL)
list($inter) = dbi_fetch_row(dbi_query("SELECT concat(salarie_nom, ' ', salarie_prenom) FROM salarie WHERE salarie_id = '".$e['salarie_id']."' ")) ;
?>
<!-- v2 -->
<a href="?exp=<?php echo $e['excpt_id'];?>" >Supprimer</a>
La prestation du <?=int2date($e['date_presta']).($e['presta_date_debut'] != NULL && $e['date_presta'] != $e['presta_date_debut'] ? ' est déplacée au '.int2date($e['date_presta']).' et ' : ' est annulée').($e['presta_Hdeb'] === NULL ? '' : ' aura lieu de '.int2heure($e['presta_Hdeb'])).($e['presta_Hdeb'] === NULL ? '' : ' à ' . int2heure(addDuree($e['presta_Hdeb'], $e['presta_Hduree']))) . ($e['salarie_id'] === NULL ? '' : ' avec ' . $inter) . ($e['presta_forfait'] === NULL ? '' : ' au taux ' . $e['presta_forfait']) . ($e['inter_abs'] == 1 ? ' (absence de l\'intervenant)' : '').($e['facture'] != 1 ? '' : ' (prestation d’origine facturée au client)')?><br/>
<?php
}
// }
?>
</span>
</div>
</div>
</td>
</tr>
<?php ++$i;} ?>
</tbody>
</table>
<?php */ ?>
</div>
<!-- /.card-body -->
</div>
<!-- /.card -->
</div>
</div>
</div>
</div>
<!-- /.col-md-6 -->
</div>
<!-- /.row -->
</div><!-- /.container-fluid -->
</div>
<!-- /.content -->
</div>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Post Event</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body result">
</div>
</div>
</div>
</div>
<!-- /.content-wrapper -->
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- Control sidebar content goes here -->
<div class="p-3">
<h5>Title</h5>
<p>Sidebar content</p>
</div>
</aside>
<!-- /.control-sidebar -->
<footer class="main-footer">
<div class="float-right d-none d-sm-block">
<b>Version</b> 3.0.1
</div>
<strong>Copyright © 2014-2019 <a href="http://adminlte.io">AdminLTE.io</a>.</strong> All rights
reserved.
</footer>
<!-- Control Sidebar -->
<aside class="control-sidebar control-sidebar-dark">
<!-- Control sidebar content goes here -->
</aside>
<!-- /.control-sidebar -->
</div>
<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- SweetAlert2 -->
<script src="../plugins/sweetalert2/sweetalert2.min.js"></script>
<!-- Toastr -->
<script src="../plugins/toastr/toastr.min.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>
<!-- jQuery UI -->
<script src="../plugins/jquery-ui/jquery-ui.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="../dist/js/demo.js"></script>
<!-- Select2 -->
<script src="../plugins/select2/js/select2.full.min.js"></script>
<!-- fullCalendar 2.2.5 -->
<script src="../plugins/moment/moment.min.js"></script>
<script src="../plugins/fullcalendar/main.min.js"></script>
<script src="../plugins/fullcalendar-daygrid/main.min.js"></script>
<script src="../plugins/fullcalendar-timegrid/main.min.js"></script>
<script src="../plugins/fullcalendar-interaction/main.min.js"></script>
<script src="../plugins/fullcalendar-bootstrap/main.min.js"></script>
<script src='../plugins/fullcalendar/locales/fr.js'></script>
<!-- Page script -->
<!-- Page specific script -->
<script>
$(document).ready(function() {
var datecal = "<?php echo $datecal; ?>";
var salarie_id = "<?php echo $salarie_id; ?>";
// alert(datecal);
let calendarEl = document.getElementById('calendar');
let calendar = new FullCalendar.Calendar(calendarEl, {
locale: 'fr',
plugins: [ 'bootstrap', 'interaction', 'dayGrid', 'timeGrid' ],
firstDay: 1,
defaultDate: datecal,
showNonCurrentDates: false,
fixedWeekCount: false,
header : {
left : 'prev,next today',
center: 'title',
right : 'dayGridMonth,timeGridWeek,timeGridDay'
},
businessHours: {
daysOfWeek: [ 0,1, 2, 3, 4,5,6 ], // Monday - Thursday
startTime: '06:00', // a start time (10am in this example)
endTime: '19:00', // an end time (6pm in this example)
},
events: 'planning.php?date='+datecal+'&salarie_id='+salarie_id,
selectable:true,
selectHelper:true,
editable:false,
eventClick: function(info) {
var idpr = info.event.id;
var datepr = info.event.start.toLocaleDateString();
// alert(idpr);
datepr = datepr.substr(6, 4)+ '' +datepr.substr(3, 2)+ '' +datepr.substr(0, 2);
$.ajax({
type : 'post',
url : 'Prestation_Upt_Date.php', //Here you will fetch records
data : 'idp='+idpr+'&date='+datepr, //Pass $id
success : function(data){
$('#jalil').html(data);//Show fetched data from database
jQuery("#PrestUpt").modal('show');
}
});
// alert('Event: ' + datepr);
// alert('Coordinates: ' + info.jsEvent.pageX + ',' + info.jsEvent.pageY);
// alert('View: ' + info.event.start.toLocaleDateString());
// str = JSON.stringify(info);
// console.log(str); // Logs output to dev tools console.
// alert(str);
// console.log('My object : ' + info);
// var idpevnt = info.event.id;
// var dateevent = info.event.date;
// alert('Event: ' + dateevent);
// alert('Coordinates: ' + info.jsEvent.pageX + ',' + info.jsEvent.pageY);
// alert('View: ' + info.activeStart);
// change the border color just for fun
// info.el.style.borderColor = 'red';
}
// eventClick:function(event)
// {
// alert('Event: ' + event.event.title);
// var idp = event.id;
// var datec = event.date;
// alert(event.start);
// $.ajax({
// type : 'post',
// url : 'Prestation_Upt_Date.php', //Here you will fetch records
// data : 'idp='+idp+'&date='+date, //Pass $id
// success : function(data){
// $('#jalil').html(data);//Show fetched data from database
// jQuery("#PrestUpt").modal('show');
// }
// });
// alert(date);
// }
});
calendar.setOption('locale', 'fr');
calendar.render();
$('.fc-prev-button').click(function(){
var date = calendar.getDate().toLocaleDateString();
var date1 = date.substr(6, 4)+ date.substr(3, 2);
var date2 = datecal.substr(0, 4)+ datecal.substr(5, 2);
if(date1 != date2)
{
var datec = date.substr(6, 4)+ '-' +date.substr(3, 2)+ '-' +date.substr(0, 2);
window.location.href = "Prestation_New.php?date="+datec;
}
});
$('.fc-today-button').click(function(){
var date = calendar.getDate().toLocaleDateString();
var date1 = date.substr(6, 4)+ date.substr(3, 2);
var date2 = datecal.substr(0, 4)+ datecal.substr(5, 2);
if(date1 != date2)
{
var datec = date.substr(6, 4)+ '-' +date.substr(3, 2)+ '-' +date.substr(0, 2);
window.location.href = "Prestation_New.php?date="+datec;
}
});
$('.fc-next-button').click(function(){
var date = calendar.getDate().toLocaleDateString();
var date1 = date.substr(6, 4)+ date.substr(3, 2);
var date2 = datecal.substr(0, 4)+ datecal.substr(5, 2);
if(date1 != date2)
{
var datec = date.substr(6, 4)+ '-' +date.substr(3, 2)+ '-' +date.substr(0, 2);
window.location.href = "Prestation_New.php?date="+datec;
}
});
// $('#salarie_id').on('change',function(){
// $('form').submit();
// });
// $('#annee').on('change',function(){
// $('form').submit();
// });
// $('#mois').on('change',function(){
// $('form').submit();
// });
});
</script>
<script>
$(function () {
//Initialize Select2 Elements
$('.select2').select2()
//Initialize Select2 Elements
$('.select2bs4').select2({
theme: 'bootstrap4'
})
//Datemask dd/mm/yyyy
$('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
//Datemask2 mm/dd/yyyy
$('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
//Money Euro
$('[data-mask]').inputmask()
//Date range picker
$('#reservation').daterangepicker()
//Date range picker with time picker
$('#reservationtime').daterangepicker({
timePicker: true,
timePickerIncrement: 30,
locale: {
format: 'MM/DD/YYYY hh:mm A'
}
})
//Date range as a button
$('#daterange-btn').daterangepicker(
{
ranges : {
'Today' : [moment(), moment()],
'Yesterday' : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month' : [moment().startOf('month'), moment().endOf('month')],
'Last Month' : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
startDate: moment().subtract(29, 'days'),
endDate : moment()
},
function (start, end) {
$('#reportrange span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
}
)
//Timepicker
$('#timepicker').datetimepicker({
format: 'LT'
})
//Bootstrap Duallistbox
$('.duallistbox').bootstrapDualListbox()
//Colorpicker
$('.my-colorpicker1').colorpicker()
//color picker with addon
$('.my-colorpicker2').colorpicker()
$('.my-colorpicker2').on('colorpickerChange', function(event) {
$('.my-colorpicker2 .fa-square').css('color', event.color.toString());
});
$("input[data-bootstrap-switch]").each(function(){
$(this).bootstrapSwitch('state', $(this).prop('checked'));
});
})
</script>
<!-- page script -->
<script>
$(function () {
$("#example1").DataTable();
$('#example2').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false
});
});
</script>
<!--
<script>
$(function () {
//Initialize Select2 Elements
$('.select2').select2()
//Datemask dd/mm/yyyy
$('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
//Datemask2 mm/dd/yyyy
$('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
//Money Euro
$('[data-mask]').inputmask()
//Date range picker
$('#reservation').daterangepicker()
//Date range picker with time picker
$('#reservationtime').daterangepicker({ timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A' })
//Date range as a button
$('#daterange-btn').daterangepicker(
{
ranges : {
'Today' : [moment(), moment()],
'Yesterday' : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month' : [moment().startOf('month'), moment().endOf('month')],
'Last Month' : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
startDate: moment().subtract(29, 'days'),
endDate : moment()
},
function (start, end) {
$('#daterange-btn span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
}
)
//Date picker
$('#datepicker').datepicker({
autoclose: true
})
//iCheck for checkbox and radio inputs
$('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
checkboxClass: 'icheckbox_minimal-blue',
radioClass : 'iradio_minimal-blue'
})
//Red color scheme for iCheck
$('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({
checkboxClass: 'icheckbox_minimal-red',
radioClass : 'iradio_minimal-red'
})
//Flat red color scheme for iCheck
$('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
checkboxClass: 'icheckbox_flat-green',
radioClass : 'iradio_flat-green'
})
//Colorpicker
$('.my-colorpicker1').colorpicker()
//color picker with addon
$('.my-colorpicker2').colorpicker()
//Timepicker
$('.timepicker').timepicker({
showInputs: false
})
})</script>
jQuery 3 --
<script src="../../bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 --
<script src="../../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Select2 --
<script src="../../bower_components/select2/dist/js/select2.full.min.js"></script>
<!-- InputMask --
<script src="../../plugins/input-mask/jquery.inputmask.js"></script>
<script src="../../plugins/input-mask/jquery.inputmask.date.extensions.js"></script>
<script src="../../plugins/input-mask/jquery.inputmask.extensions.js"></script>
<!-- date-range-picker --
<script src="../../bower_components/moment/min/moment.min.js"></script>
<script src="../../bower_components/bootstrap-daterangepicker/daterangepicker.js"></script>
<!-- bootstrap datepicker --
<script src="../../bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js"></script>
<!-- bootstrap color picker --
<script src="../../bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js"></script>
<!-- bootstrap time picker --
<script src="../../plugins/timepicker/bootstrap-timepicker.min.js"></script>
<!-- SlimScroll --
<script src="../../bower_components/jquery-slimscroll/jquery.slimscroll.min.js"></script>
<!-- iCheck 1.0.1 --
<script src="../../plugins/iCheck/icheck.min.js"></script>
<!-- FastClick --
<script src="../../bower_components/fastclick/lib/fastclick.js"></script>
<!-- AdminLTE App -->
<!-- Page script
<script>
$(function () {
//Initialize Select2 Elements
$('.select2').select2()
//Datemask dd/mm/yyyy
$('#datemask').inputmask('dd/mm/yyyy', { 'placeholder': 'dd/mm/yyyy' })
//Datemask2 mm/dd/yyyy
$('#datemask2').inputmask('mm/dd/yyyy', { 'placeholder': 'mm/dd/yyyy' })
//Money Euro
$('[data-mask]').inputmask()
//Date range picker
$('#reservation').daterangepicker()
//Date range picker with time picker
$('#reservationtime').daterangepicker({ timePicker: true, timePickerIncrement: 30, format: 'MM/DD/YYYY h:mm A' })
//Date range as a button
$('#daterange-btn').daterangepicker(
{
ranges : {
'Today' : [moment(), moment()],
'Yesterday' : [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days' : [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month' : [moment().startOf('month'), moment().endOf('month')],
'Last Month' : [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
startDate: moment().subtract(29, 'days'),
endDate : moment()
},
function (start, end) {
$('#daterange-btn span').html(start.format('MMMM D, YYYY') + ' - ' + end.format('MMMM D, YYYY'))
}
)
//Date picker
$('#datepicker').datepicker({
autoclose: true
})
//iCheck for checkbox and radio inputs
$('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
checkboxClass: 'icheckbox_minimal-blue',
radioClass : 'iradio_minimal-blue'
})
//Red color scheme for iCheck
$('input[type="checkbox"].minimal-red, input[type="radio"].minimal-red').iCheck({
checkboxClass: 'icheckbox_minimal-red',
radioClass : 'iradio_minimal-red'
})
//Flat red color scheme for iCheck
$('input[type="checkbox"].flat-red, input[type="radio"].flat-red').iCheck({
checkboxClass: 'icheckbox_flat-green',
radioClass : 'iradio_flat-green'
})
//Colorpicker
$('.my-colorpicker1').colorpicker()
//color picker with addon
$('.my-colorpicker2').colorpicker()
//Timepicker
$('.timepicker').timepicker({
showInputs: false
})
})
</script>
-->
<script type="text/javascript">
$( document ).ready(function() {
$("#salarie_mutuelle").click(function () {
val=$(this).val();
if(val==1){
$("#end").prop('disabled', false);
}else{
$("#end").prop('disabled', true);
}
});
$('#myModal').on('show.bs.modal', function (e) {
var rowid = $(e.relatedTarget).data('id');
// alert(rowid);
$.ajax({
type : 'post',
url : 'Prestation_Upt.php', //Here you will fetch records
data : 'rowid='+ rowid, //Pass $id
success : function(data){
$('#fetch').html(data);//Show fetched data from database
}
});
});
$('#myModal1').on('show.bs.modal', function (e) {
var rowid = $(e.relatedTarget).data('id');
// alert(rowid);
$.ajax({
type : 'post',
url : 'Prestation_Upt1.php', //Here you will fetch records
data : 'rowid='+ rowid, //Pass $id
success : function(data){
$('#fetch1').html(data);//Show fetched data from database
}
});
});
});
</script>
</body>
</html>
