| Current Path : /home/a/t/a/ataenra/www/ATA/INTRANET/Admin/ |
| Current File : /home/a/t/a/ataenra/www/ATA/INTRANET/Admin/planification.php |
<?php
require_once '../Outils/co.php';
setlocale(LC_TIME, "fr_FR");
//recuperer le numero de la pompe a chaleur et le numero du dossier
$ID = $_GET['ID'];
$Tp = $_GET['Tp'];
//Recuperer information sur la pompe a chaleur choisie
$sth1 = $dbco->prepare("SELECT * FROM dossier D JOIN ".$Tp." P ON P.IDdossier = D.ID WHERE D.ID = '$ID'");
$sth1->execute();
$R1 = $sth1->fetch(PDO::FETCH_OBJ);
//CONDITIONS ACTION UPDATE LA LISTE ACCESSOIRES
if (isset($_POST['Plani'])&&($_POST['Plani'] == "Valider")) {
$ID2 = $_POST['eq1'];
$sth2 = $dbco->prepare("SELECT * FROM eq1planing WHERE ID = '$ID2'");
$sth2->execute();
$R2 = $sth2->fetch(PDO::FETCH_OBJ);
$Calculnbjr = $R2->nbjr - $R1->JChantier;
if (isset($_POST['eq1'])) {if($R2->ch1 == null){
//Update de la base chantier eq1 CHANTIER 1
$UP3 = $dbco->prepare("UPDATE eq1planing set id = :id, nbjr = :nbjr, ch1 =:ch1, idch1 =:idch1, Dch1 =:Dch1 where ID = :id");
$UP3->bindvalue('id',$ID2);
$UP3->bindvalue('nbjr',$Calculnbjr);
$UP3->bindvalue('ch1',$R1->JChantier);
$UP3->bindvalue('idch1',$ID);
$UP3->bindvalue('Dch1',$_POST['dateC'.$ID2.'']);
$UP3->execute();
}elseif($R2->ch2 == null){
//Update de la base chantier eq1 CHANTIER 2
$UP3 = $dbco->prepare("UPDATE eq1planing set id = :id, nbjr = :nbjr, ch2 =:ch2, idch2 =:idch2, Dch2 =:Dch2 where ID = :id");
$UP3->bindvalue('id',$_POST['eq1']);
$UP3->bindvalue('nbjr',$Calculnbjr);
$UP3->bindvalue('ch2',$R1->JChantier);
$UP3->bindvalue('idch2',$ID);
$UP3->bindvalue('Dch2',$_POST['dateC'.$ID2.'']);
$UP3->execute();
}elseif($R2->ch3 == null){
//Update de la base chantier eq1 CHANTIER 3
$UP3 = $dbco->prepare("UPDATE eq1planing set id = :id, nbjr = :nbjr, ch3 =:ch3, idch3 =:idch3, Dch3 =:Dch3 where ID = :id");
$UP3->bindvalue('id',$ID2);
$UP3->bindvalue('nbjr',$Calculnbjr);
$UP3->bindvalue('ch3',$R1->JChantier);
$UP3->bindvalue('idch3',$ID);
$UP3->bindvalue('Dch3',$_POST['dateC'.$ID2.'']);
$UP3->execute();
}
//Update de la base chantier
$UP2 = $dbco->prepare("UPDATE dossier set id = :id, Etat = :Etat, Etatprep =:Etatprep, DatePlanification =:DatePlani where ID = :id");
$UP2->bindvalue('id',$ID);
$UP2->bindvalue('Etat','ChantierP');
$UP2->bindvalue('Etatprep','Termine');
$UP2->bindvalue('DatePlani',$_POST['dateC'.$ID2.'']);
$UP2->execute();
$UP2 = $dbco->prepare("UPDATE ".$Tp." set IDp = :id, EQ = :EQ where IDp = :id");
$UP2->bindvalue('id',$R1->IDprojet);
$UP2->bindvalue('EQ','eq1');
$UP2->execute();
header("location:../../../index.php/agc");
}elseif(isset($_POST['eq2'])) {
//Update de la base chantier eq1
$UP3 = $dbco->prepare("UPDATE eq2planing set id = :id, nbjr = :nbjr, ch1 =:ch1, idch1 =:idch1, Dch1 =:Dch1 where ID = :id");
$UP3->bindvalue('id',$ID2);
$UP3->bindvalue('nbjr',$Calculnbjr);
$UP3->bindvalue('ch1',$R1->JChantier);
$UP3->bindvalue('idch1',$ID);
$UP3->bindvalue('Dch1',$_POST['dateC'.$ID2.'']);
$UP3->execute();
//Update de la base chantier
$UP2 = $dbco->prepare("UPDATE chantier set id = :id, Etat = :Etat, Planification =:Plani, DatePlani =:DatePlani where ID = :id");
$UP2->bindvalue('id',$ID);
$UP2->bindvalue('Etat','ChantierP');
$UP2->bindvalue('Plani','Planifie le');
$UP2->bindvalue('DatePlani',$_POST['dateC'.$ID2.'']);
$UP2->execute();
header("location:../../../index.php/agc");
}
}
else {
//RECUP NUMERO DE SEMAINE
$numS = date('W');$annee = date("Y");$semaine = "$numS";
$date = new DateTime();
$date ->setISOdate($annee, $semaine);
$sth20 = $dbco->prepare("SELECT * FROM eq1planing");
$sth20->execute();
$R20 = $sth20->fetch(PDO::FETCH_OBJ);
$creneau = $R1->JChantier+$R20->ch1+$R20->ch2+$R20->ch3;
$sth2 = $dbco->prepare("SELECT * FROM eq1planing WHERE nbjr >= '$creneau' AND ID > '$numS' LIMIT 12");
$sth2->execute();
$sth3 = $dbco->prepare("SELECT * FROM eq2planing WHERE id = '$ID' AND ID > '$numS'");
$sth3->execute();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<!--<link href="css/bootstrap-4.4.1.css" rel="stylesheet">-->
<link href="css/styleCMD.css" rel="stylesheet" type="text/css">
<title>FORMULAIRE POINTAGE</title>
</head>
<body>
<div class="containerPage">
<form method="post" validate>
<!--FORMULAIRE PAGE 1-->
<div class="containerSection">
<span class="align-middle"><strong>CHOISSISEZ VOTRE DATE POUR LE CHANTIER N° <?php echo $ID; ?></strong></span>
</div>
<div class="container1">
<div class="table-responsive">
<table class="table table-condensed" border="1">
<thead>
<tr>
<th>Creneaux Intervention Disponibles</th>
<th>Choisir</th>
</tr>
</thead>
<tbody>
<tr>
<?php while ($R2 = $sth2->fetch(PDO::FETCH_OBJ)) {?>
<td><?php $date = new DateTime();
$dated = new DateTime();
$dated->setISOdate($annee, $R2->ID);
$date->setISOdate($annee, $R2->ID);
$ajout = $R2->ch1+$R2->ch2+$R2->ch3;
date_modify($date , '+'.$ajout.' day');
echo "Du ".$date ->format('d/m/Y');
$date2 = date_modify($date , '+'.$R1->JChantier.' day');
echo " au ".$date2 ->format('d/m/Y');?></td>
<td><?php echo '<input type="checkbox" class="form-control" name="eq1" value="'.$R2->ID.'"> '?></td>
<?php echo '<input type="text" hidden value="Du '.$date->format('Y-m-d').' au '.$date2->format('Y-m-d').'" name="date'.$R2->ID.'">' ?>
<?php echo '<input type="text" hidden value="'.$dated->format('Y-m-d').'" name="dateC'.$R2->ID.'">' ?>
</tr>
</tbody>
<?php } ?>
</table>
</div>
<div class="row" >
<div class="col-md-3" >
<img src="../Outils/Required/ATA_logo_horiz.jpg" alt="ISO" width=100% class="img-responsive" />
</div>
<div class="col-md-6" >
<p class="text-center">Formulaire Propulsé par</p>
<p class="text-center">ATA-ENRgies 2023</p>
</div>
<div class="col-md-3" >
<input class="btn btn-success" type="submit" name="Plani" value="Valider">
</div>
</div>
</form>
</div>
</body>
</html>
<?php } ?>