operation->p_jrn+=5000; extract($_POST); for ($i=0;$i<$this->operation->nb_item;$i++) { $this->{'poste'.$i}=(isset($_POST['qc_'.$i]))?$_POST['qc_'.$i]:$_POST['poste'.$i]; $this->{"amount".$i}=$_POST['amount'.$i]; $this->{"ck".$i}=($_POST['ck'.$i]=='c')?'t':'f'; } } /*! * \brief save the detail and op in the database * */ function save() { try { StartSql($this->db); if ($this->operation->save() == false ) return; // save the selling for ($i=0;$i<$this->operation->nb_item;$i++) { $sql=sprintf('insert into op_predef_detail (opd_poste,opd_amount,'. 'opd_debit,od_id)'. ' values '. "('%s',%.2f,%d,%f,'%s',%d)", $this->{"poste".$i}, $this->{"amount".$i}, $this->{"ck".$i}, $this->operation->od_id ); ExecSql($this->db,$sql); } } catch (Exception $e) { echo ($e->getMessage()); Rollback($this->db); } } /*!\brief compute an array accordingly with the FormVenView function */ function compute_array() { $count=0; $a_op=$this->operation->load(); $array=$this->operation->compute_array($a_op); $p_array=$this->load(); foreach ($p_array as $row) { if ( $row['opd_debit']=='t') { $array+=array('e_client'=>$row['opd_poste']); } else { $array+=array("e_march".$count=>$row['opd_poste'], "e_march".$count."_sell"=>$row['opd_amount'], "e_march".$count."_tva_id"=>$row['opd_tva_id'], "e_quant".$count=>$row['opd_quantity'] ); $count++; } } return $array; } /*!\brief load the data from the database and return an array * \return an array */ function load() { $sql="select opd_id,opd_poste,opd_amount,opd_tva_id,opd_debit,". " opd_quantity from op_predef_detail where od_id=".$this->operation->od_id. " order by opd_id"; $res=ExecSql($this->db,$sql); $array=pg_fetch_all($res); return $array; } function set_od_id($p_id) { $this->operation->od_id=$p_id; } }