cn=$p_cn; $this->ji_id=$p_ji_id; } function insert() { if ( ! isset ($this->jr_id) || ! isset ($this->ji_value) || ! isset ($this->id_type ) ) { echo 'Appel incorrecte '.__FILE__.__LINE__; var_dump($this); exit(); } try { $sql=ExecSqlParam( $this->cn, 'insert into jrn_info(jr_id,id_type,ji_value) values ($1,$2,$3)'. ' returning ji_id ', array ($this->jr_id,$this->id_type,$this->ji_value) ); $this->ji_id=pg_fetch_result($sql,0,0); } catch (Exception $e) { echo "Echec sauvegarde info additionnelles"; throw $e; } } function update() { if ( ! isset ($this->jr_id) || ! isset ($this->ji_value) || ! isset ($this->jr_id ) ) { echo 'Appel incorrecte '.__FILE__.__LINE__; var_dump($this); exit(); } try { $sql=ExecSqlParam( $this->cn, 'update jrn_info set jr_id=$1 ,id_type=$2,ji_value=$3 where ji_id=$4)'. array ($this->jr_id,$this->id_type,$this->ji_value,$this->ji_id) ); } catch (Exception $e) { Rollback($this->cn); echo "Echec sauvegarde info additionnelles"; throw $e; } } function load() { $sql="select jr_id,id_type,ji_value from jrn_info where ji_id=".$this->ji_id; $r=ExecSql($this->cn,$sql); if (pg_NumRows ($r) > 0 ) { $this->from_array(pg_fetch_array($r,0)); return 0; }else { return 1; } } function from_array($p_array) { foreach ($p_array as $col=>$value) { $this->$col=$value; } } function set_id($p_ji_id) { $this->$ji_id=$p_ji_id; } function set_jrn_id($p_id) { $this->jr_id=$p_id; } function set_type($p_id) { $this->id_type=$p_id; } function set_value($p_id) { $this->ji_value=$p_id; } /*!\brief load all the jrn_info thanks the jr_id * \return an array of object */ function load_all() { if ( ! isset ($this->jr_id) ) { echo "jr_id is not set ".__FILE__.__LINE__;exit();} $sql="select ji_id from jrn_info where jr_id=".$this->jr_id; $r=ExecSql($this->cn,$sql); if (pg_NumRows($r) == 0 ) return array(); $array=pg_fetch_all($r); $ret=array(); foreach ($array as $row) { $o=new Acc_Ledger_Info($this->cn,$row['ji_id']); $o->load(); $ret[]=clone $o; } return $ret; } function count() { $sql="select ji_id from jrn_info where jr_id=".$this->jr_id; return CountSql($this->cn,$sql); } function search_id_internal($p_internal) { $sql="select jr_id from jrn where jr_internal='$p_internal'"; $r=ExecSql($this->cn,$sql); if (pg_NumRows($r) > 0 ) { $this->jr_id=pg_fetch_result($r,0,0); return $this->jr_id; } else { $this->jr_id=-1; return $this->jr_id; } } static function test_me() { echo "Dossier = ".Dossier::id(); $cn=DbConnect(Dossier::id()); $a=new Acc_Ledger_Info($cn); $a->jr_id=3; $a->id_type='BON_COMMANDE'; $a->ji_value='BON'; var_dump($a); $a->insert(); $a->set_jrn_id(7); $a->set_type('OTHER'); $a->set_value('Autre test'); $a->insert(); } }