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']) . '&nbsp;</td>
				<td class="text" align="right">' . stripslashes(number_format($row['PRD_PRIXVENTE'], 2, ',', ' ')) . '&nbsp;</td>
				<td class="text" align="right">' . stripslashes($rest) . '&nbsp;</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)).'&nbsp;</td>
    //	<td class="text" align="right" >'.(stripslashes($transfEnt)).'&nbsp;</td>
    //	<td class="text" align="right" >'.(stripslashes($livr)).'&nbsp;</td>
    //	<td class="text" align="right">'.(stripslashes($entree)).'&nbsp;</td>
    //
    //	<td class="text" align="right" >'.(stripslashes($repSort)).'&nbsp;</td>
    //	<td class="text" align="right" >'.(stripslashes($transfSort)).'&nbsp;</td>
    //	<td class="text" align="right" >'.(stripslashes($bsortie)).'&nbsp;</td>
    //	<td class="text" align="right" >'.(stripslashes($declass)).'&nbsp;</td>
    //	<td class="text" align="right">'.(stripslashes($sortie)).'&nbsp;</td>
    //	<td class="text" align="right">'.(stripslashes($qeperime)).'&nbsp;</td>
    //
    //	<td class="text" align="right">'.(stripslashes($ecart)).'&nbsp;</td>
    return $list;
}
Beispiel #2
0
 //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'];
     $rest = $entree - $sortie;
     //+ ($ecart);
     //ENTREE PERIODIQUE
     $Plivraison = StockLotParNaturePeriode($row['MVT_REFLOT'], 'LIVRAISON', $wherePeriode);
     $PreportEntree = StockLotParNaturePeriode($row['MVT_REFLOT'], 'REPORT ENTRANTT', $wherePeriode);
     $PtransfetEnt = StockLotParNaturePeriode($row['MVT_REFLOT'], 'TRANSFERT ENTRANT', $wherePeriode);
     $PEntree = $Plivraison['QTE'] + $PreportEntree['QTE'] + $PtransfetEnt['QTE'];
     // ENTREE
     //Declassement
     $PDeclassement = StockLotParNaturePeriode($row['MVT_REFLOT'], 'PERTE', $wherePeriode);
     //Execute prepared SQL => $query
     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 + $ecart;
         //echo  'Ent'.$entree.' Sort'.$sortie.'<br>';
         array_push($_SESSION['DATA_INV']['ligne'], array('codeinventaire' => '', 'reflot' => $row['MVT_REFLOT'], 'monlot' => $row['MVT_MONLOT'], 'dateperemp' => $row['MVT_DATEPEREMP'], 'codeproduit' => $row['CODE_PRODUIT'], 'produit' => addslashes($row['PRD_LIBELLE']), 'qteentre' => $entree, 'qtesortie' => $sortie, 'stockst' => $rest, 'stocksp' => '', 'prix' => $row['MVT_PA'], 'unite' => $row['ID_UNITE']));
     }
     $_SESSION['DATA_INV']['nbreLigne'] = $query->rowCount();
     //print_r($_SESSION['DATA_INV']);
     header('location:ficheinventaire1.php?selectedTab=int');
     break;
 default:
     ///Nothing