1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
| <?php
define('PAGE', 'accueil');
session_start();
echo "Bienvenue " .$_SESSION['user']['nom_user'];
echo '<br>';
echo "<a href=deconnexion.php>Déconnexion</a>";
$login = $_SESSION['user']['login'];
//require_once('includes/fonctions.php');
require_once('includes/fonctions.php');
$bdd=connexionBD();
//MODIFICATION DU FORMULAURE bon de commande.php
$code_code=$_POST['code_cde'];
$date_code=$_POST['date_cde'];
$nomFRS=$_POST['nom_FRS'];
$objetcde=$_POST['objet_cde'];
if (isset($_POST['modifier'])) {
$req12 = $bdd->prepare("UPDATE bondecommande SET num_fournisseur = (SELECT num_fournisseur FROM fournisseur WHERE nom_fournisseur= :nom_FRS), date_commande = :date_cde WHERE code_commande = :code_BC") or die(print_r($bdd->errorInfo()));
$req12->bindParam(":code_BC",$_POST['code_cde']);
$req12->bindParam(":nom_FRS",$_POST['nom_FRS']);
$req12->bindParam(":date_cde",$_POST['date_cde']);
$req12->execute();
//**********************************************FIN MODIFICATION DU FORMULAIRE bon de commande.php******************************************************
//**********************************************MODIFICATION DU FORMULAIRE de ligne commande.php*******************************************************
$req13 = $bdd->prepare("UPDATE ligne_commande SET num_article = :num_articlee, pu_article = :pu_articlee, qty_cde = :qty_articlee WHERE num_article = (SELECT num_article FROM article WHERE des_article = :des_articlee1) and num_commande = (SELECT Num_commande FROM bondecommande WHERE code_commande = :num_cde)");
$req13->bindParam(":num_cde",$code_code);
$req13->bindParam(":num_articlee",$code_articlee);
$req13->bindParam(":des_articlee1",$des_articlee1);
$req13->bindParam(":pu_articlee",$pu_articlee);
$req13->bindParam(":qty_articlee",$qty_articlee);
foreach ($_POST['des_article'] as $k => $code_articlee) {
$des_articlee1 = $_POST['des_article1'][$k];
$pu_articlee = $_POST['pu_article'][$k];
$qty_articlee = $_POST['qty_article'][$k];
$req13->execute();
}
$req13->closeCursor();
}
if (isset($_POST['supprimer'])) {
$req14 = $bdd->prepare('UPDATE bondecommande SET supprimer=1, supprimer_par=:login WHERE (valide=0 and rejete=0) and code_commande = :num_cde') or die(print_r($bdd->errorInfo()));
$req14->bindParam(":login",$login);
$req14->bindParam(":num_cde",$code_code);
$req14->execute();
}
//******************************FIN MODIFICATION DU FORMULAIRE de ligne de bon de commande.php*******************************************
//******************************AJOUT DU BON DE COMMANDE DANS LA TABLE AVEC DES NUMERO EN FORMAT BC-201406-1****************************
$email = 'xxxxx@yyyyy.kkkk';
$nomemployee = $_SESSION['user']['nom_user'];
$code_code=$_POST['code_cde'];
$date_code=$_POST['date_cde'];
$nomFRS=$_POST['nom_FRS'];
$objetcde=$_POST['objet_cde'];
if (isset($_POST['envoyer'])){
$req5=$bdd->prepare("SET @maxid = (SELECT max(Num_commande) FROM bondecommande WHERE code_commande LIKE concat('BC-',date_format(CURRENT_DATE(),'%Y%m'),'-%'))");
$req5->execute();
$req6=$bdd->prepare("SET @num = (SELECT SUBSTRING_INDEX(code_commande,'-',-1) FROM bondecommande WHERE Num_commande=@maxid)");
$req6->execute();
$req7=$bdd->prepare("SET @num = ifnull(@num+1,1)");
$req7->execute();
$req8 = $bdd->prepare("INSERT INTO bondecommande (code_commande, date_commande, num_fournisseur, objet_commande, soumis, valide, rejete, soumis_par) VALUES(concat('BC-',date_format(CURRENT_DATE(),'%Y%m'),'-',@num), :date_cde, (SELECT num_fournisseur FROM fournisseur WHERE nom_fournisseur= :nom_FRS), :objet_cde, 1, 0, 0, :soumis_par)");
$req8->bindParam(":date_cde",$date_code);
$req8->bindParam(":nom_FRS",$nomFRS);
$req8->bindParam(":objet_cde",$objetcde);
$req8->bindParam(":soumis_par",$login);
$req8->execute();
$resid = $bdd->lastInsertId();
//*****************************************************FIN DE L'AJOUT DU BON DE COMMANDE DANS LA TABLE*********************************
//************************************************************************ENVOI PAR MAIL*****************//
$req99=$bdd->prepare('SELECT code_commande FROM bondecommande WHERE Num_commande = :cde_cde');
$req99->bindParam(":cde_cde",$resid);
$req99->execute();
$datas=$req99->fetch();
$headers ='From: '.$email."\n";
$headers .='Reply-To: '.$email."\n";
$headers .='Content-Type: text/html; charset="utf-8"'."\n";
$headers .='Content-Transfer-Encoding: 8bit';
$destinataire = $email;
$sujet = 'Bon de commande numero '.$datas[0];
$message = 'Un bon de commande de numero ' .$datas[0].' a ete soumis par '.$nomemployee;
ini_set("SMTP","mail.riesgroup.dj" );
mail($destinataire, $sujet, $message, $headers);
}
//************************************************************************FIN ENVOI PAR MAIL*****************//
//***************************************************AJOUT DE LA PARTIE LIGNE DE COMMANDE DANS LA TABLE ligne de commande*****************************
$req9 = $bdd->prepare("INSERT INTO ligne_commande (num_commande, num_article, pu_article, qty_cde) VALUES(:num_cde, (SELECT num_article FROM article WHERE des_article = :num_article), :pu_article, :qty_article)");
$req9->bindParam(":num_cde",$resid);
$req9->bindParam(":num_article",$code_article);
$req9->bindParam(":pu_article",$pu_article);
$req9->bindParam(":qty_article",$qty_article);
foreach ($_POST['code_article'] as $k => $code_article) {
$pu_article = $_POST['pu_article'][$k];
$qty_article = $_POST['qty_article'][$k];
$req9->execute();
}
$req9->closeCursor();
//***************************************************FIN DE L'AJOUT DE LA PARTIE LIGNE DE COMMANDE A LA TABLE***********************************************
//******************************************************************SUPPRESSION DU BON******************************************************************
$choix = $_POST['choix'];
if (isset($_POST['supprimer'])) {
foreach($_POST['choix'] as $choix)
{
$req11 = $bdd->prepare('UPDATE bondecommande SET supprimer=1, supprimer_par=:login WHERE (valide=0 and rejete=0) and Num_commande = :choix') or die(print_r($bdd->errorInfo()));
$req11->bindParam(":login",$login);
$req11->bindParam(":choix",$choix);
$req11->execute();
$req11->rowCount();
if($res=$req11->rowCount()>0){
echo "<script> alert('Le bon a bien été supprimé'); </script>";
}
else
{
echo "<script> alert('Verifier que le bon n\'est pas validé ou rejeté'); </script>";
}
}
}
//*****************************************************************FIN DE LA PARTIE SUPPRESSION DU BON**************************************************
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title>Bon de commande</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<link rel="stylesheet" href="/bondecommande/designn.css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
form
{
text-align:center;
}
</style>
</head>
<body>
<div id="header"></div>
<div id="menu"><?php if ($_SESSION['user']['role_user'] == 'admin') { include('menus_admin.php'); } else { include('menus_users.php'); }?> </div>
<div id="contenu">
<?php
require_once('includes/fonctions_js.php');
$req2 = $bdd->prepare('SELECT nom_fournisseur FROM fournisseur ORDER BY nom_fournisseur');
$req3 = $bdd->prepare('SELECT des_article FROM article ORDER BY des_article');
$req2->execute() or die(print_r($reqq2->errorInfo()));
$req3->execute() or die(print_r($reqq3->errorInfo()));
?>
<form action="bondecommande3.php" method="post">
<table border=3>
<tr><td><label for="FRS">Nom du Fournisseur</label>: <select name="nom_FRS" size="1" style width:"150px"><option><?php while ($data = $req2->fetch()) {?> <option><?php echo $data['nom_fournisseur'];} $req2->closeCursor();?></option></select></td><td><label for="date">Date du bon</label>: <input type="text" name="date_cde" class="calendrier" id="datepicker" /></td></tr>
<tr><td><label for="objet">objet</label>:<input type="text" name="objet_cde" id="objet" /></td></tr>
</table>
<table>
<thead>
<tr>
<th>Code article</th>
<th>Qty à commander</th>
<th>Prix unitaire</th>
<th></th>
</tr>
</thead>
<tfoot>
<tr>
<th colspan="1"><a href="#" onclick="addLigne(this); return false;">Ajouter une ligne</a></th>
<th colspan="1"><a href="article_new.php">Ajouter un nouvel article</a></th>
<th><input type="submit" name="envoyer" value="Envoyer" /></th>
<th><button type="reset" name="effacer">Réinitialiser</button></th>
</tr>
</tfoot>
<tbody>
<tr>
<td><SELECT name="code_article[]" size="1" style width:"150px"><option><?php while ($data = $req3->fetch()) {?> <option><?php echo $data[0];} $req3->closeCursor();?></option></select></td>
<td><input type="text" name="qty_article[]" /></td>
<td><input type="text" name="pu_article[]" /></td>
<td><a href="#" onclick="delLigne(this); return false;">Supprimer</a></td>
</tr>
</tbody>
</table>
<table border="1">
<thead>
<tr>
<th></th>
<th><div align="center">Code Commande</div></th>
<th><div align="center">Date Commande</div></th>
<th><div align="center">nom fournisseur</div></th>
<th><div align="center">Objet Commande</div></th>
<th><div align="center">soumis</div></th>
<th><div align="center">valide</div></th>
<th><div align="center">rejete</div></th>
<th><div align="center">soumis par</div></th>
<th><div align="center">rejeter par</div></th>
<th><div align="center">valider par</div></th>
</tr>
</thead>
<tfoot>
<tr>
<th><input type="submit" name="supprimer" value="Supprimer" onclick="if(window.confirm('Voulez-vous vraiment supprimer ?')){return true;}else{return false;}"/></th>
</tr>
</tfoot>
<tbody>
<?php
//**************************************************************TABLEAU D'AFFICHAGE DE L'ETAT DES BONS*****************************************
$req4 = $bdd->prepare("SELECT bondecommande.Num_commande, bondecommande.code_commande, bondecommande.date_commande, fournisseur.nom_fournisseur AS nom_fournisseur, bondecommande.objet_commande, bondecommande.soumis, bondecommande.valide, bondecommande.rejete, bondecommande.soumis_par, bondecommande.rejete_par, bondecommande.valider_par ' .
'FROM bondecommande INNER JOIN fournisseur ON bondecommande.num_fournisseur = fournisseur.num_fournisseur WHERE bondecommande.soumis_par='".$login."' and bondecommande.supprimer=0 ORDER BY bondecommande.Num_commande DESC LIMIT 5 ");
$req4->execute();
while ($donnees = $req4->fetch())
{
if ($donnees[6]== "1" && $donnees[7]== "0" && $donnees[8]== "0")
{
$couleur = "#AE642D";
}
elseif ($donnees[6]== "1" && $donnees[7]== "1" && $donnees[8]== "0")
{
$couleur = "#766F64";
}
elseif ($donnees[6]== "1" && $donnees[7]== "0" && $donnees[8]== "1")
{
$couleur = "#FD3F92";
}
echo '<tr style=\'background-color:'.$couleur.';\'><td><input type="checkbox" name="choix[]" id="choix[]" value="'.$donnees[0].'"></td><td><a href="ligneBC.php?id='.$donnees[1].'">'.$donnees[1].'</a></td><td>'.$donnees[2].'</td><td>'.$donnees[3].'</td><td>'.$donnees[4].'</td><td>'.$donnees[5].'</td><td>'.$donnees[6].'</td><td>'.$donnees[7].'</td><td>'.$donnees[8].'</td><td>'.$donnees[9].'</td><td>'.$donnees[10].'</td></tr>';
}
$req4->closeCursor();
//********************************************************************FIN DU TABLEAU D'AFFICHAGE DE L'ETAT DES BONS******************************************
?>
</tbody>
</table>
</form>
</div>
<div id="piedpage">Ceci est le pied de page</div>
</body>
</html> |
Partager