post("nb_item","number"); for ($i=0;$i< $nb ;$i++) { $this->{"e_account".$i}=$http->post("e_account'.$i"); $this->{"e_account".$i."_amount"}=$http->post("e_account".$i."_amount","number",0); $this->{"e_account".$i."_type"}=$http->post('e_account'.$i."_type"); } } /*! * \brief save the detail and op in the database * */ function save($p_od_id,$p_nbitem) { try { // save the selling for ($i=0;$i< $p_nbitem ;$i++) { $sql='insert into op_predef_detail (opd_poste,opd_amount,'. 'opd_debit,od_id)'. ' values ($1,$2,$3,$4)'; $this->db->exec_sql($sql,array($this->{"e_account".$i}, $this->{"e_account".$i."_amount"}, ($this->{"e_account".$i."_type"}=='d')?'t':'f', $p_od_id) ); } } catch (Exception $e) { record_log($e); echo ($e->getMessage()); throw $e; } } /*!\brief compute an array accordingly with the FormVenView function */ function compute_array($p_od_id) { $count=0; $p_array=$this->load($p_od_id); foreach ($p_array as $row) { $c=($row['opd_debit']=='t')?'d':'c'; $array+=array("e_account".$count=>$row['opd_poste'], "e_account".$count."_amount"=>$row['opd_amount'], "e_account".$count."_type"=>$c ); $count++; } return $array; } /*!\brief load the data from the database and return an array * \return an array */ function load($p_od_id) { $sql="select opd_id,opd_poste,opd_amount,opd_debit". " from op_predef_detail where od_id= $1 ". " order by opd_debit, opd_id,opd_amount"; $res=$this->db->exec_sql($sql,array($p_od_id)); $array=Database::fetch_all($res); return $array; } }