/** * @name getProduitsDisponible() * @return array(ProduitMarcheVO) * @desc Retourne la liste des produits disponible en stock */ public function getProduitsDisponible() { $lStockProduit = StockProduitDisponibleViewManager::selectAll(); $lProduits = array(); foreach ($lStockProduit as $lProduit) { // Le Produit if (!isset($lProduits[$lProduit->getNproId()])) { $lProduitMarche = new ProduitMarcheVO(); /*$lProduitMarche->setId(); $lProduitMarche->setIdCompteFerme();*/ $lProduitMarche->setIdNom($lProduit->getNproId()); $lProduitMarche->setNom($lProduit->getNproNom()); /* $lProduitMarche->setDescription(); */ $lProduitMarche->setIdCategorie($lProduit->getCproId()); $lProduitMarche->setCproNom($lProduit->getCproNom()); $lProduitMarche->setUnite($lProduit->getStoQteUnite()); /*$lProduitMarche->setQteMaxCommande($lDetail->getProMaxProduitCommande()); $lProduitMarche->setStockReservation($lDetail->getProStockReservation()); $lProduitMarche->setStockInitial($lDetail->getProStockInitial()); $lProduitMarche->setType($lDetail->getProType());*/ $lProduitMarche->setFerId($lProduit->getFerId()); $lProduitMarche->setFerNom($lProduit->getFerNom()); $lProduits[$lProduit->getNproId()] = $lProduitMarche; } // Le Lot $lLot = new DetailMarcheVO(); $lLot->setId($lProduit->getMLotId()); $lLot->setTaille($lProduit->getMLotQuantite()); $lLot->setPrix($lProduit->getMLotPrix()); $lLots = $lProduits[$lProduit->getNproId()]->getLots(); $lLots[$lProduit->getMLotId()] = $lLot; $lProduits[$lProduit->getNproId()]->setLots($lLots); } return $lProduits; }
/** * @name recherche( $pTypeRecherche, $pTypeCritere, $pCritereRecherche, $pTypeTri, $pCritereTri ) * @param string nom de la table * @param string Le type de critère de recherche * @param array(string) champs à récupérer dans la table * @param array(array(string, object)) Dictionnaire(champ, valeur)) contenant les champs à filtrer ainsi que la valeur du filtre * @param array(array(string, string)) Dictionnaire(champ, sens) contenant les tris à appliquer * @return array(StockProduitDisponibleViewVO) * @desc Récupères les lignes de la table selon le critère de recherche puis trie et renvoie la liste de résultat sous forme d'une collection de StockProduitDisponibleViewVO */ public static function recherche($pTypeRecherche, $pTypeCritere, $pCritereRecherche, $pTypeTri, $pCritereTri) { // Initialisation du Logger $lLogger =& Log::singleton('file', CHEMIN_FICHIER_LOGS); $lLogger->setMask(Log::MAX(LOG_LEVEL)); // Préparation de la requète $lChamps = array(NomProduitManager::CHAMP_NOMPRODUIT_ID . "," . NomProduitManager::CHAMP_NOMPRODUIT_NUMERO . "," . NomProduitManager::CHAMP_NOMPRODUIT_NOM . "," . CategorieProduitManager::CHAMP_CATEGORIEPRODUIT_ID . "," . CategorieProduitManager::CHAMP_CATEGORIEPRODUIT_NOM . "," . FermeManager::CHAMP_FERME_ID . "," . FermeManager::CHAMP_FERME_NUMERO . "," . FermeManager::CHAMP_FERME_NOM . "," . FermeManager::CHAMP_FERME_ID_COMPTE . "," . StockQuantiteManager::CHAMP_STOCKQUANTITE_ID . "," . StockQuantiteManager::CHAMP_STOCKQUANTITE_QUANTITE . "," . StockQuantiteManager::CHAMP_STOCKQUANTITE_QUANTITE_SOLIDAIRE . "," . StockQuantiteManager::CHAMP_STOCKQUANTITE_UNITE . "," . ModeleLotManager::CHAMP_MODELELOT_ID . "," . ModeleLotManager::CHAMP_MODELELOT_QUANTITE . "," . ModeleLotManager::CHAMP_MODELELOT_UNITE . "," . ModeleLotManager::CHAMP_MODELELOT_PRIX); // Préparation de la requète de recherche $lRequete = DbUtils::prepareRequeteRecherche(StockProduitDisponibleViewManager::VUE_STOCKPRODUITDISPONIBLE, $lChamps, $pTypeRecherche, $pTypeCritere, $pCritereRecherche, $pTypeTri, $pCritereTri); $lListeStockProduitDisponible = array(); if ($lRequete !== false) { $lLogger->log("Execution de la requete : " . $lRequete, PEAR_LOG_DEBUG); // Maj des logs $lSql = Dbutils::executerRequete($lRequete); if (mysql_num_rows($lSql) > 0) { while ($lLigne = mysql_fetch_assoc($lSql)) { array_push($lListeStockProduitDisponible, StockProduitDisponibleViewManager::remplir($lLigne[NomProduitManager::CHAMP_NOMPRODUIT_ID], $lLigne[NomProduitManager::CHAMP_NOMPRODUIT_NUMERO], $lLigne[NomProduitManager::CHAMP_NOMPRODUIT_NOM], $lLigne[CategorieProduitManager::CHAMP_CATEGORIEPRODUIT_ID], $lLigne[CategorieProduitManager::CHAMP_CATEGORIEPRODUIT_NOM], $lLigne[FermeManager::CHAMP_FERME_ID], $lLigne[FermeManager::CHAMP_FERME_NUMERO], $lLigne[FermeManager::CHAMP_FERME_NOM], $lLigne[FermeManager::CHAMP_FERME_ID_COMPTE], $lLigne[StockQuantiteManager::CHAMP_STOCKQUANTITE_ID], $lLigne[StockQuantiteManager::CHAMP_STOCKQUANTITE_QUANTITE], $lLigne[StockQuantiteManager::CHAMP_STOCKQUANTITE_QUANTITE_SOLIDAIRE], $lLigne[StockQuantiteManager::CHAMP_STOCKQUANTITE_UNITE], $lLigne[ModeleLotManager::CHAMP_MODELELOT_ID], $lLigne[ModeleLotManager::CHAMP_MODELELOT_QUANTITE], $lLigne[ModeleLotManager::CHAMP_MODELELOT_UNITE], $lLigne[ModeleLotManager::CHAMP_MODELELOT_PRIX])); } } else { $lListeStockProduitDisponible[0] = new StockProduitDisponibleViewVO(); } return $lListeStockProduitDisponible; } $lListeStockProduitDisponible[0] = new StockProduitDisponibleViewVO(); return $lListeStockProduitDisponible; }