$oInventaire->inv_date = $_REQUEST['invDate']; $oInventaire->inv_lbl = $_REQUEST['invLbl']; for ($i = 1; $i < count($tLigneForm['lot_id']); $i++) { //On hydrate un objet ligne inventaire $oLiginv = new LigneInventaire(); $oLiginv->lot_id = $tLigneForm['lot_id'][$i]; $oLiginv->liginv_lbl = $tLigneForm['liginv_lbl'][$i]; $oLiginv->liginv_qt_reel = $tLigneForm['liginv_qt_reel'][$i]; $oLiginv->liginv_qt_stock = $tLigneForm['liginv_qt_stock'][$i]; $oLiginv->inv_id = $invId; //Si la case liginv_id est != '' c'est un update if ($tLigneForm['liginv_id'][$i] != '') { //On récupére l'id de la ligne $oLiginv->liginv_id = $tLigneForm['liginv_id'][$i]; //On update la ligne $resLiginv = LigneInventaireManager::updLigneInventaire($oLiginv); //Sinon c'est que c'est un insert } else { //on insert la ligne inventaire $resLiginv = LigneInventaireManager::addLigneInventaire($oLiginv); } //code en cas d'exécution du formulaire, modifie les lots pour faire correpondre //leur quantité stock avec leur quantité réelle if (isset($_REQUEST['btnForm']) && $_REQUEST['btnForm'] == 'Executer') { //On hydrate un objet lot $oLot = new Lot(); $oLot = LotManager::getLot($oLiginv->lot_id); $oLot->lot_qt_stock = $oLiginv->liginv_qt_reel; //On update le lot $resLot = LotManager::updLot($oLot); }