Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

Balance Class Reference

Class for manipulating data to print the balance of account. More...


Public Member Functions

 Balance ($p_cn)
 GetRow ($p_from_periode, $p_to_periode)
 retrieve all the row from the ledger in the range of a periode

Data Fields

 $db
 $central
 $row


Detailed Description

Class for manipulating data to print the balance of account.

Definition at line 29 of file class_balance.php.


Constructor & Destructor Documentation

Balance::Balance p_cn  ) 
 

Definition at line 33 of file class_balance.php.

00033                           {
00034     $this->db=$p_cn;
00035     $this->central='N';
00036   }


Member Function Documentation

Balance::GetRow p_from_periode,
p_to_periode
 

retrieve all the row from the ledger in the range of a periode

Parameters:
$p_from_periode start periode
$p_to_periode end periode
Returns:
a double array array of
  • $a['poste']
  • $a['label']
  • $a['sum_deb']
  • $a['sum_cred']
  • $a['solde_deb']
  • $a['solde_cred']

Definition at line 53 of file class_balance.php.

References $a, $array, $i, $M, $r, $Res, $sql, ExecSql(), GetPosteLibelle(), and label.

00053                                                  {
00054     // compute periode
00055     if ( $p_from_periode==$p_to_periode ) {
00056       $per_sql=" j_tech_per = $p_from_periode ";
00057     } else {
00058       $per_sql = "j_tech_per >=  $p_from_periode and j_tech_per <= $p_to_periode ";
00059     }
00060 
00061 
00062     // if centralized
00063     $cent="";
00064 
00065     if ( $this->central=='Y' ) { $cent="j_centralized = true and "; }
00066 
00067     // build query
00068     $sql="select j_poste,sum(deb) as sum_deb, sum(cred) as sum_cred from 
00069           ( select j_poste,
00070              case when j_debit='t' then j_montant else 0 end as deb,
00071              case when j_debit='f' then j_montant else 0 end as cred
00072           from jrnx join tmp_pcmn on j_poste=pcm_val
00073               where 
00074              $cent
00075             $per_sql ) as m group by j_poste order by j_poste::text";
00076 
00077     $Res=ExecSql($this->db,$sql);
00078 
00079     $tot_cred=  0.0;
00080     $tot_deb=  0.0;
00081     $tot_deb_saldo=0.0;
00082     $tot_cred_saldo=0.0;
00083     $M=pg_NumRows($Res);
00084     // Load the array
00085     for ($i=0; $i <$M;$i++) {
00086       $r=pg_fetch_array($Res,$i);
00087       $a['poste']=$r['j_poste'];
00088       $a['label']=substr(GetPosteLibelle($this->db,$r['j_poste'],1),0,40);
00089       $a['sum_deb']=round($r['sum_deb'],2);
00090       $a['sum_cred']=round($r['sum_cred'],2);
00091       $a['solde_deb']=round(( $a['sum_deb']  >=  $a['sum_cred'] )? $a['sum_deb']- $a['sum_cred']:0,2);
00092       $a['solde_cred']=round(( $a['sum_deb'] <=  $a['sum_cred'] )?$a['sum_cred']-$a['sum_deb']:0,2);
00093       $array[$i]=$a;
00094       $tot_cred+=  $a['sum_cred'];
00095       $tot_deb+= $a['sum_deb']; 
00096       $tot_deb_saldo+= $a['solde_deb'];
00097       $tot_cred_saldo+= $a['solde_cred'];
00098       
00099       
00100     }//for i
00101     // Add the saldo
00102     $i+=1;
00103     $a['poste']="";
00104     $a['label']="<b> Totaux </b>";
00105     $a['sum_deb']=$tot_deb;
00106     $a['sum_cred']=$tot_cred;
00107     $a['solde_deb']=$tot_deb_saldo;
00108     $a['solde_cred']=$tot_cred_saldo;
00109     $array[$i]=$a;
00110     $this->row=$array;
00111     return $array;
00112 
00113   }


Field Documentation

Balance::$central
 

Definition at line 31 of file class_balance.php.

Balance::$db
 

Definition at line 30 of file class_balance.php.

Balance::$row
 

Definition at line 32 of file class_balance.php.


The documentation for this class was generated from the following file: