db=$p_cn; $this->id=$p_id; } /*!\brief add a row to the table operation_analytique * \note if $this->oa_group if 0 then a sequence id will be computed for * the oa_group, if $this->j_id=0 then it will be null * */ function add($p_seq=0) { if ( $this->oa_group == 0) { $this->oa_group=NextSequence($this->db,'s_oa_group'); } if ( $this->j_id == 0 ) { $this->j_id="null"; } // we don't save null operations if ( $this->oa_amount == 0 || $this->po_id==-1) return; $sql='insert into operation_analytique ( po_id, pa_id, oa_amount, oa_description, oa_debit, oa_group, j_id, oa_date ) values ('. $this->po_id.",". $this->pa_id.",". $this->oa_amount.",". "' ".pg_escape_string($this->oa_description)."',". "'".$this->oa_debit."',". $this->oa_group.",". $this->j_id.",". "to_date('".$this->oa_date."','DD.MM.YYYY'))"; ExecSql($this->db,$sql); } /*!\brief delete a row from the table operation_analytique * \note be carefull : do not delete a row when we have a group */ function delete() { $sql="delete from operation_analytique where oa_id=".$this->oa_id; ExecSql($this->db,$sql); } /*!\brief update a row in the table operation_analytique * \todo update */ function update() { if ( $this->po_id == -1) { $this->delete();return;} $sql="update operation_analytique set po_id=".$this->po_id." where oa_id=".$this->oa_id; ExecSql($this->db,$sql); } /*!\brief get a list of row from a certain periode * \todo to be done */ function get_list($p_range="") { $sql="select oa_id,po_name,oa_description,". "oa_debit,oa_date,oa_amount,oa_group,j_id ". " from operation_analytique as B". " join poste_analytique using(po_id) ". "where B.pa_id=".$this->pa_id." and oa_amount <> 0.0 ". " order by oa_date ,oa_group,oa_debit,oa_id"; $RetSql=ExecSql($this->db,$sql); if ( pg_NumRows($RetSql) == 0 ) return "Pas d'enregistrement trouvé"; $array=pg_fetch_all($RetSql); $ret.=""; $ret.=JS_VIEW_JRN_MODIFY; $count=0; $group=0; $oldgroup=0; $oldjrid=0; foreach ($array as $row) { $group=$row['oa_group']; if ( $group !=$oldgroup ) { if ( $oldgroup!=0 ) { $efface=new widget('button'); $efface->js="op_remove('".$_REQUEST['PHPSESSID']."',".$oldgroup.")"; $efface->name="Efface"; $efface->label="Efface"; $ret.="
| ". $row['oa_date']. " | ". "". $row['oa_description']. " | "; $ret.="". "Groupe id : ".$row['oa_group']. " | "; $oldgroup=$group; } $class=($count%2==0)?"odd":""; $count++; $cred= ( $row['oa_debit'] == 'f')?"CREDIT":"DEBIT"; $ret.="
| ". $row['po_name']. " | ". "". $row['oa_amount']. " | ". "". $cred. " | ". "".$efface->IOValue()." | "; // get the old jr_id $this->oa_group=$oldgroup; $jr_id=$this->get_jrid(); if ( $jr_id != 0 ){ $detail=new widget('button'); $detail->js="viewOperation($jr_id,'".$_REQUEST['PHPSESSID']."')"; $detail->name="Detail"; $detail->label="Detail"; $ret.="".$detail->IOValue()." | "; } $ret.='