$_SESSION['DATA_ETAT']['nbreLigne'] = $z; //$query->rowCount(); header('location:raptrimestriel1.php?selectedTab=rap'); } else { $listeMag = ' AND mouvement.CODE_MAGASIN IN (' . substr($lesMag, 0, strlen($lesMag) - 2) . ') '; if ($in != '') { $in = ' AND ' . substr($in, 6, strlen($in)); } $sql = "SELECT * FROM mouvement INNER JOIN produit ON (mouvement.CODE_PRODUIT LIKE produit.CODE_PRODUIT)\r\n\t\t\t\tWHERE mouvement.MVT_TYPE LIKE 'E' AND MVT_VALID=1 {$in} {$listeMag} GROUP BY MVT_REFLOT ORDER BY produit.PRD_LIBELLE ASC ; "; $query = $cnx->prepare($sql); //Prepare the SQL $query->execute(); //Execute prepared SQL => $query $z = 0; while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $tProduit = StockLotPerime($row['MVT_REFLOT'], $type = 'E', $whereAll); $qeperime = $tProduit['QTE']; $Livraison = StockLotParNature($row['MVT_REFLOT'], 'LIVRAISON', $whereAll); $bonsortie = StockLotParNature($row['MVT_REFLOT'], 'BON DE SORTIE', $whereAll); $Declassement = StockLotParNature($row['MVT_REFLOT'], 'PERTE', $whereAll); $transfetEnt = StockLotParNature($row['MVT_REFLOT'], 'TRANSFERT ENTRANT', $whereAll); $transfetSort = StockLotParNature($row['MVT_REFLOT'], 'TRANSFERT SORTANT', $whereAll); $reportEntree = StockLotParNature($row['MVT_REFLOT'], 'REPORT ENTRANT', $whereAll); $reportSortie = StockLotParNature($row['MVT_REFLOT'], 'REPORT SORTANT', $whereAll); $inventplus = StockLotParNature($row['MVT_REFLOT'], 'INVENTAIRE +', $whereAll); $inventmoins = StockLotParNature($row['MVT_REFLOT'], 'INVENTAIRE -', $whereAll); $entree = $Livraison['QTE'] + $reportEntree['QTE'] + $transfetEnt['QTE']; // ENTREE $sortie = $bonsortie['QTE'] + $Declassement['QTE'] + $reportSortie['QTE'] + $transfetSort['QTE']; //SORTIE $ecart = $inventmoins['QTE'] + $inventplus['QTE'];
function listeDesProduitsStockparLot($defaut = '', $whereAll) { $userName = getField('LOGIN', $_SESSION['GL_USER']['LOGIN'], 'LOGIN', 'compte'); $ilang = getCodelangue($userName); //SQL $whereAll1 = $whereAll; isset($defaut) ? $whereAll .= " AND produit.PRD_LIBELLE LIKE '{$defaut}%'" : ($whereAll .= ""); $sql = "SELECT mouvement.CODE_PRODUIT, mouvement.MVT_MONLOT, mouvement.MVT_REFLOT, produit.PRD_LIBELLE, produit.PRD_PRIXVENTE, produit.ID_UNITE\r\n\tFROM mouvement INNER JOIN produit ON (mouvement.CODE_PRODUIT LIKE produit.CODE_PRODUIT)\r\n\tGROUP BY mouvement.MVT_REFLOT ORDER BY mouvement.CODE_PRODUIT ASC;"; try { $cnx = new PDO(DBD, DBUSER, DBPWD, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); //Connexion to database } catch (PDOException $error) { //Treat error //("Erreur de connexion : " . $error->getMessage() ); die($error->getMessage() . ' ' . __LINE__); } $query = $cnx->prepare($sql); //Prepare the SQL $query->execute(); //Execute prepared SQL => $query $list = ''; $i = 0; $j = 1; while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $tProduit = StockLotPerime($row['MVT_REFLOT'], $type = 'E', $whereAll); $qeperime = $tProduit['QTE']; $Livraison = StockLotParNature($row['MVT_REFLOT'], 'LIVRAISON', $whereAll); $Livraison = StockLotParNature($row['MVT_REFLOT'], 'LIVRAISON', $whereAll); $bonsortie = StockLotParNature($row['MVT_REFLOT'], 'BON DE SORTIE', $whereAll); $Declassement = StockLotParNature($row['MVT_REFLOT'], 'PERTE', $whereAll); $transfetEnt = StockLotParNature($row['MVT_REFLOT'], 'TRANSFERT ENTRANT', $whereAll); $transfetSort = StockLotParNature($row['MVT_REFLOT'], 'TRANSFERT SORTANT', $whereAll); $reportEntree = StockLotParNature($row['MVT_REFLOT'], 'REPORT ENTRANT', $whereAll); $reportSortie = StockLotParNature($row['MVT_REFLOT'], 'REPORT SORTANT', $whereAll); $inventplus = StockLotParNature($row['MVT_REFLOT'], 'INVENTAIRE +', $whereAll); $inventmoins = StockLotParNature($row['MVT_REFLOT'], 'INVENTAIRE -', $whereAll); //Declassement $PDeclassement = StockLotParNature($row['MVT_REFLOT'], 'PERTE', $whereAll); $entree = $Livraison['QTE'] + $reportEntree['QTE'] + $transfetEnt['QTE']; // ENTREE $sortie = $bonsortie['QTE'] + $Declassement['QTE'] + $reportSortie['QTE'] + $transfetSort['QTE']; //SORTIE $ecart = $inventmoins['QTE'] + $inventplus['QTE']; $rest = $entree - $sortie; if ($entree != 0 || $sortie != 0 || $rest != 0) { $i % 2 == 0 ? $col = "tableOddRow" : ($col = "tableEvenRow"); isset($Livraison['QTE']) && $Livraison['QTE'] != 0 ? $livr = $Livraison['QTE'] : ($livr = ''); isset($bonsortie['QTE']) && $bonsortie['QTE'] != 0 ? $bsortie = $bonsortie['QTE'] : ($bsortie = ''); isset($reportEntree['QTE']) && $reportEntree['QTE'] != 0 ? $repEnt = $reportEntree['QTE'] : ($repEnt = ''); isset($reportSortie['QTE']) && $reportSortie['QTE'] != 0 ? $repSort = $reportSortie['QTE'] : ($repSort = ''); isset($transfetEnt['QTE']) && $transfetEnt['QTE'] != 0 ? $transfEnt = $transfetEnt['QTE'] : ($transfEnt = ''); isset($transfetSort['QTE']) && $transfetSort['QTE'] != 0 ? $transfSort = $transfetSort['QTE'] : ($transfSort = ''); isset($Declassement['QTE']) && $Declassement['QTE'] != 0 ? $declass = $Declassement['QTE'] : ($declass = ''); isset($ecart) && $ecart != 0 ? $ecart = $ecart : ($ecart = ''); isset($eentre) && $entre != 0 ? $entre = $entre : ($entre = ''); isset($sortie) && $sortie != 0 ? $qtesortie = $sortie : ($sortie = ''); isset($stocks) && $stocks != 0 ? $stocks = $stocks : ($stocks = ''); isset($qeperime) && $qeperime != 0 ? $qeperime = $qeperime : ($qeperime = ''); isset($data[$i - 1]['qteperime']) && $data[$i - 1]['qteperime'] != 0 ? $qteperime = $data[$i - 1]['qteperime'] : ($qteperime = ''); $list .= ' <tr align="left" valign="middle" class="' . $col . '"> <td height="22" class="text" align="left">' . stripslashes($row['MVT_REFLOT']) . '</td> <td height="22" class="text" align="left">' . stripslashes($row['CODE_PRODUIT']) . '</td> <td class="text" nowrap="nowrap" >' . stripslashes($row['PRD_LIBELLE']) . ' </td> <td class="text" align="right">' . stripslashes(number_format($row['PRD_PRIXVENTE'], 2, ',', ' ')) . ' </td> <td class="text" align="right">' . stripslashes($rest) . ' </td> <td class="text" align="center">' . stripslashes($row['ID_UNITE']) . '</td> </tr>'; $i++; $j++; } } if ($ilang == '1' && $ilang != '') { if ($list == '') { $list = ' <tr class="tableOddRow"> <td height="22" align="left" valign="middle" class="text" colspan="4">Aucun produit disponible ...</td> </tr>'; } } if ($ilang == '2' && $ilang != '') { if ($list == '') { $list = ' <tr class="tableOddRow"> <td height="22" align="left" valign="middle" class="text" colspan="4">No data ...</td> </tr>'; } } if ($ilang == '3' && $ilang != '') { if ($list == '') { $list = ' <tr class="tableOddRow"> <td height="22" align="left" valign="middle" class="text" colspan="4">Nenhum dado ...</td> </tr>'; } } // <td class="text" align="right" >'.(stripslashes($repEnt)).' </td> // <td class="text" align="right" >'.(stripslashes($transfEnt)).' </td> // <td class="text" align="right" >'.(stripslashes($livr)).' </td> // <td class="text" align="right">'.(stripslashes($entree)).' </td> // // <td class="text" align="right" >'.(stripslashes($repSort)).' </td> // <td class="text" align="right" >'.(stripslashes($transfSort)).' </td> // <td class="text" align="right" >'.(stripslashes($bsortie)).' </td> // <td class="text" align="right" >'.(stripslashes($declass)).' </td> // <td class="text" align="right">'.(stripslashes($sortie)).' </td> // <td class="text" align="right">'.(stripslashes($qeperime)).' </td> // // <td class="text" align="right">'.(stripslashes($ecart)).' </td> return $list; }