| Current Path : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_Materiel/TypeProjet/Ensemble/ |
| Current File : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_Materiel/TypeProjet/Ensemble/AddP.php |
<?php
//trouver le prix du materiel ajouté et multiplier par quantité
$art = $dbco->prepare("SELECT PV FROM ".$table_produits." WHERE ID_Produit = '".$_GET['IDd']."' "); $art->execute(); $Art = $art->fetch(PDO::FETCH_OBJ);
$pv_tarif = $_GET['QT']*$Art->PV;
//ajouter dans la table jointure Materiel
$Add = $dbco->prepare("INSERT INTO ".$table_jointure." (ID_ens, ID_produit, QT_p, PV_p) VALUES (:ID_ens, :ID_produit, :QT_p, :PV_p)");
$Add->bindParam(':ID_ens',$_GET['IDmat']);
$Add->bindParam(':ID_produit',$_GET['IDd']);
$Add->bindParam(':QT_p',$_GET['QT']);
$Add->bindParam(':PV_p',$pv_tarif);
$Add->execute();
//on calcul le prix de l'ensemble materiel
$pt = $dbco->query("SELECT SUM(PV_p) AS T FROM ".$table_jointure." WHERE ID_ens ='".$_GET['IDmat']."'");
$PT = $pt->fetch();
$pt->closeCursor();
$P1= round($PT['T'], 2);
//on calcul le prix de l'ensemble articles
$pt = $dbco->query("SELECT SUM(PV_articles) AS T FROM ".$table_jointure_access." WHERE ID_ens ='".$_GET['IDmat']."'");
$PT = $pt->fetch();
$pt->closeCursor();
$P2= round($PT['T'], 2);
$PTT = $P1+$P2;
//on met a jour le prix du pack
$UP2 = $dbco->prepare("UPDATE $table_ensemble set ID_Ens = :id, ens_pv=:ens_pv where ID_Ens = :id");
$UP2->bindvalue('id',$_GET['IDmat']);
$UP2->bindvalue('ens_pv',$PTT);
$UP2->execute();
header("location:New_Ensemble.php?IDm=".$_GET['IDm']."&A=V");
?>