get('roleid'); $userId = $current_user->get('id'); global $adb; $res = false; $q = "INSERT INTO `etat_stock` (`grossiste` , `date` ,`creator_id` ,`date_creation`) VALUES ('".addslashes($_POST["grossiste"])."' , '".$_POST["date"]."' , '".$userId."' , NOW());"; $res = $adb->query($q); $last_id = $adb->getLastInsertID(); for ($x = 0; $x < sizeof($_POST['produit']) ; $x++) { $lot = empty($_POST["lot"][$x]) ? 'null' : '"'.$_POST["lot"][$x].'"'; $dper = empty($_POST["dper"][$x]) ? 'null' : '"'.$_POST["dper"][$x].'"'; $qte = empty($_POST["qte"][$x]) ? 'null' : '"'.$_POST["qte"][$x].'"'; if(!empty($_POST["produit"][$x])){ $query2 = "INSERT INTO `lignes_etat_stock` (`id_etat_stock` , `produit`, `lot`, `dper`, `qte`) VALUES ('".$last_id."','".addslashes($_POST["produit"][$x])."',".$lot.",".$dper.",".$qte.");"; $adb->query($query2); } } //Ajax if($res == true){ echo '1'; }else{ echo '0'; } ?>