| Current Path : /home/a/t/a/ataenra/www/ATA/INTRANET/Admin/ |
| Current File : /home/a/t/a/ataenra/www/ATA/INTRANET/Admin/commande2.php |
<?php
require_once '../Outils/co.php';
//recuperer le numero de la pompe a chaleur et le numero du dossier
$ID = $_GET['ID'];
$Tp = $_GET['Tp'];
$Tm = $_GET['Tm'];
//CONDITIONS ACTION UPDATE LA LISTE ACCESSOIRES
if (isset($_POST['Com'])&&($_POST['Com'] == "Commander")) {
//supprimer le post com du submit
$_POST['Com'] ="";
//recuperer dans article la listes des checkbox cochees
$articles = "";
// echo "test1";
foreach($_POST as $Accessoires) {
$articles.=" '".$Accessoires."', ";
}
//echo $articles;
//Variables pour le UP de la base
$DateCom = date("Y-m-d");
//Update de la base
$UP2 = $dbco->prepare("UPDATE dossier set id = :id, Etatprep = :Etatprep, DateCommande =:Dateco where ID = :id");
$UP2->bindvalue('id',$ID);
$UP2->bindvalue('Etatprep','A preparer');
$UP2->bindvalue('Dateco',$DateCom);
$UP2->execute();
$UP2 = $dbco->prepare("UPDATE ".$Tp." set IDp = :id, articles =:articles where IDp = :id");
$UP2->bindvalue('id',$_POST['IDp']);
$UP2->bindvalue('articles',$articles);
$UP2->execute();
require "../GenPDF/4DossierClient/pdfcommande.php";
header("location:../../../index.php/agc");
}
else {
//Recuperer information sur la pompe a chaleur choisie
$sth1 = $dbco->prepare("SELECT * FROM dossier D JOIN client C ON D.IDclient = C.IDc JOIN ".$Tp." P ON D.IDprojet = P.IDp WHERE D.ID = '$ID'");
$sth1->execute();
$R1 = $sth1->fetch(PDO::FETCH_OBJ);
$sth2 = $dbco->prepare("SELECT * FROM ".$Tm." WHERE IDm = '$R1->IDmateriel'");
$sth2->execute();
$R2 = $sth2->fetch(PDO::FETCH_OBJ);
//Fabriquer la variable des accessoires a recuperer selon le chantier
$posetype =""; $modhyd ="";
if($R1->modhyd == "Radiateurs"){$modhyd = " '23',";}elseif($R1->modhyd == "Plancher"){$modhyd =" '24',";}elseif($R1->modhyd == "Plancher + Radiateurs"){$modhyd =" '23', '24',";}
if($R1->TypePose == "Au Sol sur pieds"){$posetype = " '16',";}elseif($R1->TypePose == "Au Mur sur chaise"){$posetype = " '18',";}
if($R1->TabElecE == "E1"){$elec = " '28',";}elseif($R1->TabElecE == "E2"){$elec = " '29',";}elseif($R1->TabElecE == "E3"){$elec = " '30',";}
if($R1->PlombGE == "P1"){$plomb = " '25',";}elseif($R1->PlombGE == "P2"){$plomb = " '26',";}elseif($R1->PlombGE == "P3"){$plomb = " '27',";}
//Fabriquer la variable des accessoires a recuperer selon la pompe a chaleur
$required ="'4', '6', '11', '15',";
//Si liaison eau, vanne antigel et type de tube.
if($R2->Liaison == "Eau"){if($R2->TypeL == "1 pouce"){$liaison ="'5', '39',";}elseif($R2->TypeL == "1 pouce 1/4"){$liaison ="'5', '40',";}}
//Si liaison gaz, type de liaison cuivre.
if($R2->Liaison == "Gaz"){if($R2->TypeL == "1/4 - 5/8"){$liaison = "'20'";}elseif($R2->TypeL == "1/4 - 1/2"){$liaison = "'21'";}elseif($R2->TypeL == "3/8 - 5/8"){$liaison = "'22',";}}
//Ballon tampon demandé
$Bal="";
if($R2->tampon == "Ballon 50L"){$Bal = " '8',";}elseif($R2->tampon == "Ballon 100L"){$Bal = " '9',";}elseif($R2->tampon == "Ballon 200L"){$Bal = " '10',";}
//Type de cable UE
if($R2->sectionalim == "3G2.5mm2"){$cableUe = " '31',";}elseif($R2->sectionalim == "3G6.0mm2"){$cableUe = " '32',";}
elseif($R2->sectionalim == "3G10mm2"){$cableUe = " '33',";}elseif($R2->sectionalim == "5G2.5mm2"){$cableUe = " '35',";}
$cableUi =" '34',";
$materiel =" '36'";
if($R2->typepac == 'Monobloc'){
if($R2->Elec =="Mono"){ if($R2->protecUE == "16") {$protecUE = " '41',";}elseif($R2->protecUE == "20") {$protecUE = " '42',";}elseif($R2->protecUE == "32") {$protecUE = " '43',";}elseif($R2->protecUE == "40") {$protecUE = " '60',";}
}elseif($R2->Elec =="Tri"){if($R2->protecUE == "10") {$protecUE = " '44',";}elseif($R2->protecUE == "16") {$protecUE = " '45',";}elseif($R2->protecUE == "20") {$protecUE = " '46',";}elseif($R2->protecUE == "25") {$protecUE = " '47',";}}
$protecG = $R2->protecUE;
if($R2->Elec =="Mono"){if($protecG <= 40){$ProtecINT = "'48',";}elseif($protecG > 40){$ProtecINT = "'49',";}}
if($R2->Elec =="Tri"){if($protecG <= 25){$ProtecINT = "'50',";}elseif($protecG > 25 && $protecG < 40 ){$ProtecINT = "'51',";}elseif($protecG > 40 && $protecG < 63 ){$ProtecINT = "'52',";}}
$PACK= "($liaison$Bal$modhyd$required$posetype$plomb$elec$cableUe$cableUi$protecUE$ProtecINT$materiel)";
}
if($R2->typepac != 'Monobloc'){
if(($R2->typepac != 'Monobloc')&&($R2->Elec =="Mono")){
if($R2->protecUE == "16") {$protecUE = " '41',";}elseif($R2->protecUE == "20") {$protecUE = " '42',";}elseif($R2->protecUE == "32") {$protecUE = " '43',";}
if($R2->protecUI == "16") {$protecUI = " '53',";}elseif($R2->protecUI == "20") {$protecUI = " '54',";}elseif($R2->protecUI == "32") {$protecUI = " '55',";}}
if(($R2->typepac != 'Monobloc')&&($R2->Elec =="Tri")){
if($R2->protecUE == "10") {$protecUE = " '44',";}elseif($R2->protecUE == "16") {$protecUE = " '45',";}elseif($R2->protecUE == "20") {$protecUE = " '46',";}elseif($R2->protecUE == "25") {$protecUE = " '47',";}
if($R2->protecUI == "10") {$protecUI = " '56',";}elseif($R2->protecUI == "16") {$protecUI = " '57',";}elseif($R2->protecUI == "20") {$protecUI = " '58',";}elseif($R2->protecUI == "25") {$protecUI = " '59',";}}
$protecG = $R2->protecUE+$R2->protecUI;
if($R2->Elec =="Mono"){if($protecG < 40){$ProtecINT = "'48',";}elseif($protecG > 40){$ProtecINT = "'49',";}}
if($R2->Elec =="Tri"){if($protecG < 25){$ProtecINT = "'50',";}elseif($protecG > 25 && $protecG < 40 ){$ProtecINT = "'51',";}elseif($protecG > 40 && $protecG < 63 ){$ProtecINT = "'52',";}}
$PACK= "($liaison$Bal$modhyd$required$posetype$plomb$elec$cableUe$cableUi$protecUE$protecUI$ProtecINT$materiel)";
}
$sth3 = $dbco->prepare("SELECT * FROM accessoires WHERE ID IN $PACK AND FRS ='VAM'");
$sth3->execute();
$sth4 = $dbco->prepare("SELECT * FROM accessoires WHERE ID IN $PACK AND FRS ='Stock'");
$sth4->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 COMMANDE</title>
</head>
<body>
<div class="containerPage">
<form method="post" validate>
<!--FORMULAIRE PAGE 1-->
<div class="containerSection">
<span class="align-middle"><strong>MATERIEL POUR LE CHANTIER N°<?php echo $ID; ?></strong></span>
</div>
<div class="container1">
<div class="table-responsive">
<h5 class="btn-lg btn-info"><center> VERIFIER ET POINTER LE MATERIEL A COMMANDER</center> </h5>
<table class="table table-condensed" border="1">
<thead>
<tr>
<th>REF</th>
<th>DESIGNATION</th>
<th>CHECK</th>
</tr>
</thead>
<tbody>
<tr>
<?php if($R2->Marque == "Airwell"){echo '<tr><td>'.$R2->Ref.'</td><td>'.$R2->modele.'</td><td></td></tr>';} ?>
<?php if($R2->Marque == "Daikin"){echo '<tr><td>'.$R2->Ref.'</td><td>'.$R2->modele.'</td><td></td></tr>';} ?>
<?php while ($R3 = $sth3->fetch(PDO::FETCH_OBJ)) {?>
<td><?php echo $R3->REF; ?></td>
<td><?php echo $R3->DESIGNATION; ?></td>
<td><?php echo '<input type="checkbox" class="form-control" name="'.$R3->ID.'" value="'.$R3->ID.'" checked> '?></td>
</tr>
<?php } ?>
<tr>
<td></td>
<td>GESTION STOCK CONSOMMABLES</td>
<td></td>
</tr>
<?php while ($R4 = $sth4->fetch(PDO::FETCH_OBJ)) {?>
<td><?php echo $R4->REF; ?></td>
<td><?php echo $R4->DESIGNATION; ?></td>
<td></td>
</tr>
<?php } ?>
</tbody>
</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 type='hidden' name='IDp' value='<?php echo $R1->IDprojet; ?>'>
<input class="btn btn-success" type="submit" name="Com" value="Commander">
</div>
</div>
</form>
</div>
</div>
</body>
</html>
<?php } ?>