Change acc_account => acc_account_ledger because the tmp_pcmn contains now a new column for the type of the account (asset, expense...) which permit to check if the accountancy is valid
This commit is contained in:
parent
eff50763a3
commit
2d7a61034d
18 changed files with 634 additions and 362 deletions
|
|
@ -24,9 +24,9 @@
|
|||
*
|
||||
*/
|
||||
|
||||
function PcmnUpdate(p_value,p_lib,p_parent,p_sessid,p_dossier)
|
||||
function PcmnUpdate(p_value,p_lib,p_parent,p_type,p_sessid,p_dossier)
|
||||
{
|
||||
var win=window.open('line_update.php?l='+p_value+'&n='+p_lib+'&p='+p_parent+'&PHPSESSID='+p_sessid+'&gDossier='+p_dossier,'Modifie','toolbar=no,width=500,height=400,scrollbars=yes,resizable=yes');
|
||||
var win=window.open('line_update.php?l='+p_value+'&n='+p_lib+'&p='+p_parent+'&m'+p_type+'&PHPSESSID='+p_sessid+'&gDossier='+p_dossier,'Modifie','toolbar=no,width=500,height=400,scrollbars=yes,resizable=yes');
|
||||
}
|
||||
|
||||
function RefreshMe() {
|
||||
|
|
|
|||
|
|
@ -24,33 +24,30 @@
|
|||
include_once ("ac_common.php");
|
||||
require_once('class_dossier.php');
|
||||
$gDossier=dossier::id();
|
||||
|
||||
include_once ("postgres.php");
|
||||
include_once("check_priv.php");
|
||||
|
||||
require_once ('class_acc_account.php');
|
||||
/* Admin. Dossier */
|
||||
$rep=DbConnect();
|
||||
include_once ("class_user.php");
|
||||
$User=new User($rep);
|
||||
$User->Check();
|
||||
html_page_start($User->theme,"onLoad='window.focus();'");
|
||||
|
||||
$User->can_request(DbConnect($gDossier),MPCMN);
|
||||
$cn=DbConnect($gDossier);
|
||||
$User->can_request($cn,MPCMN);
|
||||
|
||||
|
||||
include ("user_menu.php");
|
||||
|
||||
/* Modif d'une ligne */
|
||||
if ( isset ($_POST["update"] ) ) {
|
||||
foreach ($_POST as $name => $element) {
|
||||
echo_debug('line_update.php',__LINE__,"name $name $element");
|
||||
}
|
||||
|
||||
echo JS_UPDATE_PCMN;
|
||||
$cn=DbConnect($gDossier);
|
||||
|
||||
$p_val=trim($_POST["p_val"]);
|
||||
$p_lib=FormatString($_POST["p_name"]);
|
||||
$p_parent=trim($_POST["p_val_parent"]);
|
||||
$p_lib=FormatString($_POST["p_lib"]);
|
||||
$p_parent=trim($_POST["p_parent"]);
|
||||
$old_line=trim($_POST["p_old"]);
|
||||
$p_type=$_POST['p_type'];
|
||||
// Check if p_parent and p_val are number
|
||||
if ( ! is_numeric($p_val) || ! is_numeric($p_parent) ) {
|
||||
// not number no update
|
||||
|
|
@ -80,7 +77,7 @@ if ( isset ($_POST["update"] ) ) {
|
|||
echo '<SCRIPT> alert(" Ne peut pas modifier; aucune poste parent"); </SCRIPT>';
|
||||
} else {
|
||||
|
||||
$Ret=ExecSql($cn,"update tmp_pcmn set pcm_val=$p_val, pcm_lib='$p_lib',pcm_val_parent=$p_parent where pcm_val=$old_line");
|
||||
$Ret=ExecSql($cn,"update tmp_pcmn set pcm_val=$p_val, pcm_lib='$p_lib',pcm_val_parent=$p_parent,pcm_type='$p_type' where pcm_val=$old_line");
|
||||
}
|
||||
} else {
|
||||
echo '<script> alert(\'Update Valeurs invalides\'); </script>';
|
||||
|
|
@ -96,27 +93,19 @@ if ( isset ($_POST["update"] ) ) {
|
|||
|
||||
?>
|
||||
<FORM ACTION="line_update.php" METHOD="POST">
|
||||
<TABLE>
|
||||
<TR>
|
||||
<?php
|
||||
$l=$_GET['l'];
|
||||
$p=$_GET['p'];
|
||||
$n=$_GET['n'];
|
||||
|
||||
printf ('<TD>Numéro de classe </TD><TD><INPUT TYPE="TEXT" name="p_val" value="%s"></TD>',$l);
|
||||
echo "</TR><TR>";
|
||||
printf('<TD>Libellé </TD><TD><INPUT TYPE="TEXT" size="70" NAME="p_name" value="%s"></TD>',urldecode($n));
|
||||
echo "</TR><TR>";
|
||||
printf ('<TD>Classe Parent</TD><TD><INPUT TYPE="TEXT" name="p_val_parent" value="%s"></TD>',$p);
|
||||
echo dossier::hidden();
|
||||
<?
|
||||
$acc=new Acc_Account($cn);
|
||||
$acc->pcm_val=$_GET['l'];
|
||||
$acc->pcm_val_parent=$_GET['p'];
|
||||
$acc->pcm_lib=$_GET['n'];
|
||||
$acc->pcm_type=(isset ($_GET['m']))?$_GET['m']:"";
|
||||
echo $acc->form(true);
|
||||
?>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<TABLE>
|
||||
<TR>
|
||||
<TD><INPUT TYPE="Submit" VALUE="Sauve">
|
||||
<INPUT TYPE="HIDDEN" name="update">
|
||||
<?php printf ('<INPUT TYPE="HIDDEN" name="p_old" value="%s">',$l); ?>
|
||||
<?php printf ('<INPUT TYPE="HIDDEN" name="p_old" value="%s">',$acc->pcm_val); ?>
|
||||
</TD><TD><input type="button" Value="Retour sans sauver" onClick='window.close();'></TD></TR>
|
||||
</TABLE>
|
||||
</FORM>
|
||||
|
|
|
|||
|
|
@ -22,66 +22,27 @@
|
|||
* \brief Manage the account
|
||||
*/
|
||||
/*!
|
||||
* \brief Manage the account
|
||||
* \brief Manage the account from the table tmp_pcmn
|
||||
*/
|
||||
require_once ('postgres.php');
|
||||
require_once ('class_dossier.php');
|
||||
require_once ('class_widget.php');
|
||||
|
||||
class Acc_Account {
|
||||
var $db; /*! \enum $db database connection */
|
||||
var $id; /*! \enum $id poste_id (pcm_val)*/
|
||||
var $label; /*! \enum $label label of the poste */
|
||||
var $parent; /*! \enum $parent parent account */
|
||||
var $row; /*! \enum $row double array see get_row */
|
||||
function __construct ($p_cn,$p_id) {
|
||||
var $pcm_val;
|
||||
var $pcm_type;
|
||||
var $pcm_parent;
|
||||
var $pcm_lib;
|
||||
function __construct ($p_cn,$p_id=0) {
|
||||
$this->db=$p_cn;
|
||||
$this->id=$p_id;
|
||||
$this->pcm_val=$p_id;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Get data for poste
|
||||
*
|
||||
* \param $p_from periode from
|
||||
* \param $p_to end periode
|
||||
* \return double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal)
|
||||
* (tot_deb,tot_credit
|
||||
*
|
||||
*/
|
||||
function get_row($p_from,$p_to)
|
||||
{
|
||||
$periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per');
|
||||
|
||||
|
||||
$Res=ExecSql($this->db,"select to_char(j_date,'DD.MM.YYYY') as j_date,".
|
||||
"case when j_debit='t' then j_montant else 0 end as deb_montant,".
|
||||
"case when j_debit='f' then j_montant else 0 end as cred_montant,".
|
||||
" jr_comment as description,jrn_def_name as jrn_name,".
|
||||
"j_debit, jr_internal ".
|
||||
" from jrnx left join jrn_def on jrn_def_id=j_jrn_def ".
|
||||
" left join jrn on jr_grpt_id=j_grpt".
|
||||
" where j_poste=".$this->id." and ".$periode.
|
||||
" order by j_date::date");
|
||||
$array=array();
|
||||
$tot_cred=0.0;
|
||||
$tot_deb=0.0;
|
||||
$Max=pg_NumRows($Res);
|
||||
if ( $Max == 0 ) return null;
|
||||
for ($i=0;$i<$Max;$i++) {
|
||||
$array[]=pg_fetch_array($Res,$i);
|
||||
if ($array[$i]['j_debit']=='t') {
|
||||
$tot_deb+=$array[$i]['deb_montant'] ;
|
||||
} else {
|
||||
$tot_cred+=$array[$i]['cred_montant'] ;
|
||||
}
|
||||
}
|
||||
$this->row=$array;
|
||||
return array($array,$tot_deb,$tot_cred);
|
||||
}
|
||||
/*!\brief Return the name of a account
|
||||
* it doesn't change any data member
|
||||
* \return string with the pcm_lib
|
||||
*/
|
||||
function get_name() {
|
||||
function get_lib() {
|
||||
$ret=pg_exec($this->db,
|
||||
"select pcm_lib from tmp_pcmn where
|
||||
pcm_val=".$this->id);
|
||||
|
|
@ -99,250 +60,66 @@ class Acc_Account {
|
|||
*/
|
||||
function load()
|
||||
{
|
||||
$ret=ExecSql($this->db,"select pcm_lib,pcm_val_parent from
|
||||
$ret=ExecSql($this->db,"select pcm_lib,pcm_val_parent,pcm_type from
|
||||
tmp_pcmn where pcm_val=".$this->id);
|
||||
$r=pg_fetch_all($ret);
|
||||
|
||||
if ( ! $r ) return false;
|
||||
$this->label=$r[0]['pcm_lib'];
|
||||
$this->parent=$r[0]['pcm_val_parent'];
|
||||
$this->pcm_lib=$r[0]['pcm_lib'];
|
||||
$this->pcm_val_parent=$r[0]['pcm_val_parent'];
|
||||
$this->pcm_type=$r[0]['pcm_type'];
|
||||
return true;
|
||||
|
||||
}
|
||||
/*!\brief Get all the value for this object from the database
|
||||
* the data member are set
|
||||
* \return false if this account doesn't exist otherwise true
|
||||
*/
|
||||
function get()
|
||||
{
|
||||
echo "OBSOLETE Acc_Account->get(), a remplacer par Acc_Account->load()";
|
||||
return $this->load();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief give the balance of an account
|
||||
*
|
||||
* \return
|
||||
* balance of the account
|
||||
*
|
||||
*/
|
||||
function get_solde($p_cond=" true ") {
|
||||
$Res=ExecSql($this->db,"select sum(deb) as sum_deb, sum(cred) as sum_cred from
|
||||
( select j_poste,
|
||||
case when j_debit='t' then j_montant else 0 end as deb,
|
||||
case when j_debit='f' then j_montant else 0 end as cred
|
||||
from jrnx join tmp_pcmn on j_poste=pcm_val
|
||||
where
|
||||
j_poste like ('$this->id'::text) and
|
||||
$p_cond
|
||||
) as m ");
|
||||
$Max=pg_NumRows($Res);
|
||||
if ($Max==0) return 0;
|
||||
$r=pg_fetch_array($Res,0);
|
||||
|
||||
return abs($r['sum_deb']-$r['sum_cred']);
|
||||
}
|
||||
/*!
|
||||
* \brief give the balance of an account
|
||||
* \return
|
||||
* balance of the account
|
||||
*
|
||||
*/
|
||||
function get_solde_detail($p_cond="") {
|
||||
|
||||
if ( $p_cond != "") $p_cond=" and ".$p_cond;
|
||||
$sql="select sum(deb) as sum_deb, sum(cred) as sum_cred from
|
||||
( select j_poste,
|
||||
case when j_debit='t' then j_montant else 0 end as deb,
|
||||
case when j_debit='f' then j_montant else 0 end as cred
|
||||
from jrnx join tmp_pcmn on j_poste=pcm_val
|
||||
where
|
||||
j_poste like ('$this->id'::text)
|
||||
$p_cond
|
||||
) as m ";
|
||||
|
||||
$Res=ExecSql($this->db,$sql);
|
||||
$Max=pg_NumRows($Res);
|
||||
if ($Max==0) return 0;
|
||||
$r=pg_fetch_array($Res,0);
|
||||
// if p_start is < p_end the query returns null to avoid any problem
|
||||
// we set it to 0
|
||||
if ($r['sum_deb']=='')
|
||||
$r['sum_deb']=0.0;
|
||||
if ($r['sum_cred']=='')
|
||||
$r['sum_cred']=0.0;
|
||||
|
||||
return array('debit'=>$r['sum_deb'],
|
||||
'credit'=>$r['sum_cred'],
|
||||
'solde'=>abs($r['sum_deb']-$r['sum_cred']));
|
||||
}
|
||||
/*!
|
||||
* \brief isTva tell is a poste is used for VAT
|
||||
* \param none
|
||||
*
|
||||
*
|
||||
* \return 1 is Yes otherwise 0
|
||||
*/
|
||||
function isTVA()
|
||||
{
|
||||
// Load TVA array
|
||||
$a_TVA=get_array($this->db,'select tva_poste
|
||||
from tva_rate');
|
||||
foreach ( $a_TVA as $line_tva)
|
||||
{
|
||||
if ( $line_tva['tva_poste'] == '' )
|
||||
continue;
|
||||
list($tva_deb,$tva_cred)=split(',',$line_tva['tva_poste']);
|
||||
if ( $this->id == $tva_deb ||
|
||||
$this->id == $tva_cred )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
/*!
|
||||
* \brief HtmlTable, display a HTML of a poste for the asked period
|
||||
* \param none
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
|
||||
|
||||
function HtmlTable()
|
||||
{
|
||||
$this->get_name();
|
||||
|
||||
list($array,$tot_deb,$tot_cred)=$this->get_row( $_POST['from_periode'],
|
||||
$_POST['to_periode']
|
||||
);
|
||||
|
||||
if ( count($this->row ) == 0 )
|
||||
return;
|
||||
|
||||
$rep="";
|
||||
|
||||
echo '<h2 class="info">'.$this->id." ".$this->name.'</h2>';
|
||||
echo "<TABLE class=\"result\" width=\"100%\">";
|
||||
echo "<TR>".
|
||||
"<TH> Code interne </TH>".
|
||||
"<TH> Date</TH>".
|
||||
"<TH> Description </TH>".
|
||||
"<TH> Débit </TH>".
|
||||
"<TH> Crédit </TH>".
|
||||
"</TR>";
|
||||
|
||||
foreach ( $this->row as $op ) {
|
||||
echo "<TR>".
|
||||
"<TD>".$op['jr_internal']."</TD>".
|
||||
"<TD>".$op['j_date']."</TD>".
|
||||
"<TD>".$op['description']."</TD>".
|
||||
"<TD>".$op['deb_montant']."</TD>".
|
||||
"<TD>".$op['cred_montant']."</TD>".
|
||||
"</TR>";
|
||||
function form($p_table=true){
|
||||
$array=array(
|
||||
array('label'=>'Actif','value'=>'ACT'),
|
||||
array('label'=>'Passif','value'=>'PAS'),
|
||||
array('label'=>'Actif c. inverse','value'=>'ACTINV'),
|
||||
array('label'=>'Passif c.inverse','value'=>'PASINV'),
|
||||
array('label'=>'Produit','value'=>'PRO'),
|
||||
array('label'=>'Charge','value'=>'CHA'),
|
||||
array('label'=>'Non defini','value'=>'CON')
|
||||
);
|
||||
$wType=new widget("select");
|
||||
$wType->name='p_type';
|
||||
$wType->value=$array;
|
||||
|
||||
}
|
||||
$solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
|
||||
$diff=round(abs($tot_deb-$tot_cred),2);
|
||||
echo "<TR>".
|
||||
"<TD>$solde_type</TD>".
|
||||
"<TD>$diff</TD>".
|
||||
"<TD></TD>".
|
||||
"<TD>$tot_deb</TD>".
|
||||
"<TD>$tot_cred</TD>".
|
||||
"</TR>";
|
||||
if ( ! $p_table ) {
|
||||
$ret=' <TR>
|
||||
<TD>
|
||||
<INPUT TYPE="TEXT" NAME="p_val" SIZE=7>
|
||||
</TD>
|
||||
<TD>
|
||||
<INPUT TYPE="TEXT" NAME="p_lib" size=50>
|
||||
</TD>
|
||||
<TD>
|
||||
<INPUT TYPE="TEXT" NAME="p_parent" size=5>
|
||||
</TD>
|
||||
<TD>';
|
||||
|
||||
echo "</table>";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Display HTML Table Header (button)
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
function HtmlTableHeader()
|
||||
{
|
||||
$submit=new widget();
|
||||
$hid=new widget("hidden");
|
||||
echo '<div class="noprint">';
|
||||
echo "<table >";
|
||||
echo '<TR>';
|
||||
|
||||
echo '<TD><form method="GET" ACTION="">'.
|
||||
dossier::hidden().
|
||||
$submit->Submit('bt_other',"Autre poste").
|
||||
$hid->IOValue("type","poste").$hid->IOValue('p_action','impress')."</form></TD>";
|
||||
|
||||
echo '<TD><form method="POST" ACTION="poste_pdf.php">'.
|
||||
dossier::hidden().
|
||||
$submit->Submit('bt_pdf',"Export PDF").
|
||||
$hid->IOValue("type","poste").
|
||||
$hid->IOValue('p_action','impress').
|
||||
$hid->IOValue("poste_id",$_POST['poste_id']).
|
||||
$hid->IOValue("from_periode",$_POST['from_periode']).
|
||||
$hid->IOValue("to_periode",$_POST['to_periode']);
|
||||
if (isset($_POST['poste_fille']))
|
||||
echo $hid->IOValue('poste_fille','on');
|
||||
echo "</form></TD>";
|
||||
|
||||
echo '<TD><form method="POST" ACTION="poste_csv.php">'.
|
||||
dossier::hidden().
|
||||
$submit->Submit('bt_csv',"Export CSV").
|
||||
$hid->IOValue("type","poste").
|
||||
$hid->IOValue('p_action','impress').
|
||||
$hid->IOValue("poste_id",$_POST['poste_id']).
|
||||
$hid->IOValue("from_periode",$_POST['from_periode']).
|
||||
$hid->IOValue("to_periode",$_POST['to_periode']);
|
||||
if (isset($_POST['poste_fille']))
|
||||
echo $hid->IOValue('poste_fille','on');
|
||||
|
||||
echo "</form></TD>";
|
||||
echo "</table>";
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
/*!
|
||||
* \brief verify that the poste belong to a ledger
|
||||
*
|
||||
* \return 0 ok, -1 no
|
||||
*/
|
||||
function belong_ledger($p_jrn) {
|
||||
$filter=getDbValue($this->db,"select jrn_def_class_cred from jrn_def where jrn_def_id=$p_jrn");
|
||||
if ( trim ($filter) == '')
|
||||
return 0;
|
||||
|
||||
$valid_cred=split(" ",$filter);
|
||||
$sql="select count(*) as poste from tmp_pcmn where ";
|
||||
// Creation query
|
||||
$or="";
|
||||
$SqlFilter="";
|
||||
foreach ( $valid_cred as $item_cred) {
|
||||
if ( strlen (trim($item_cred))) {
|
||||
if ( strstr($item_cred,"*") == true ) {
|
||||
$item_cred=strtr($item_cred,"*","%");
|
||||
$SqlItem="$or pcm_val like '$item_cred'";
|
||||
$or=" or ";
|
||||
} else {
|
||||
$SqlItem="$or pcm_val = '$item_cred' ";
|
||||
$or=" or ";
|
||||
}
|
||||
$SqlFilter=$SqlFilter.$SqlItem;
|
||||
}
|
||||
}//foreach
|
||||
$sql.=$SqlFilter.' and pcm_val='.$this->id;
|
||||
$max=getDbValue($this->db,$sql);
|
||||
if ($max > 0 )
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
$ret.=$wType->IOValue().'</TD>';
|
||||
return $ret;
|
||||
}
|
||||
else {
|
||||
$ret='<TABLE><TR>';
|
||||
$ret.=sprintf ('<TD>Numéro de classe </TD><TD><INPUT TYPE="TEXT" name="p_val" value="%s"></TD>',$this->pcm_val);
|
||||
$ret.="</TR><TR>";
|
||||
$ret.=sprintf('<TD>Libellé </TD><TD><INPUT TYPE="TEXT" size="70" NAME="p_lib" value="%s"></TD>',urldecode($this->pcm_lib));
|
||||
$ret.= "</TR><TR>";
|
||||
$ret.=sprintf ('<TD>Classe Parent</TD><TD><INPUT TYPE="TEXT" name="p_parent" value="%s"></TD>',$this->pcm_val_parent);
|
||||
$ret.='</tr><tr>';
|
||||
$wType->selected=$this->pcm_type;
|
||||
$ret.="<td> Type de poste </td>";
|
||||
$ret.= '<td>'.$wType->IOValue().'</td>';
|
||||
$ret.="</TR> </TABLE>";
|
||||
$ret.=dossier::hidden();
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
/*!\brief for developper only during test */
|
||||
static function test_me() {
|
||||
$cn=DbConnect(dossier::id());
|
||||
$a=new Acc_Account($cn,550);
|
||||
echo ' Journal 4 '.$a->belong_ledger(4);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
352
include/class_acc_account_ledger.php
Normal file
352
include/class_acc_account_ledger.php
Normal file
|
|
@ -0,0 +1,352 @@
|
|||
<?php
|
||||
/*
|
||||
* This file is part of PhpCompta.
|
||||
*
|
||||
* PhpCompta is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* PhpCompta is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with PhpCompta; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
/* $Revision$ */
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
/*! \file
|
||||
* \brief Manage the account
|
||||
*/
|
||||
/*!
|
||||
* \brief Manage the account from the table jrn, jrnx or tmp_pcmn
|
||||
*/
|
||||
require_once ('postgres.php');
|
||||
require_once ('class_dossier.php');
|
||||
|
||||
class Acc_Account_Ledger {
|
||||
var $db; /*! \enum $db database connection */
|
||||
var $id; /*! \enum $id poste_id (pcm_val)*/
|
||||
var $label; /*! \enum $label label of the poste */
|
||||
var $parent; /*! \enum $parent parent account */
|
||||
var $row; /*! \enum $row double array see get_row */
|
||||
function __construct ($p_cn,$p_id) {
|
||||
$this->db=$p_cn;
|
||||
$this->id=$p_id;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Get data for poste
|
||||
*
|
||||
* \param $p_from periode from
|
||||
* \param $p_to end periode
|
||||
* \return double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal)
|
||||
* (tot_deb,tot_credit
|
||||
*
|
||||
*/
|
||||
function get_row($p_from,$p_to)
|
||||
{
|
||||
$periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per');
|
||||
|
||||
|
||||
$Res=ExecSql($this->db,"select to_char(j_date,'DD.MM.YYYY') as j_date,".
|
||||
"case when j_debit='t' then j_montant else 0 end as deb_montant,".
|
||||
"case when j_debit='f' then j_montant else 0 end as cred_montant,".
|
||||
" jr_comment as description,jrn_def_name as jrn_name,".
|
||||
"j_debit, jr_internal ".
|
||||
" from jrnx left join jrn_def on jrn_def_id=j_jrn_def ".
|
||||
" left join jrn on jr_grpt_id=j_grpt".
|
||||
" where j_poste=".$this->id." and ".$periode.
|
||||
" order by j_date::date");
|
||||
$array=array();
|
||||
$tot_cred=0.0;
|
||||
$tot_deb=0.0;
|
||||
$Max=pg_NumRows($Res);
|
||||
if ( $Max == 0 ) return null;
|
||||
for ($i=0;$i<$Max;$i++) {
|
||||
$array[]=pg_fetch_array($Res,$i);
|
||||
if ($array[$i]['j_debit']=='t') {
|
||||
$tot_deb+=$array[$i]['deb_montant'] ;
|
||||
} else {
|
||||
$tot_cred+=$array[$i]['cred_montant'] ;
|
||||
}
|
||||
}
|
||||
$this->row=$array;
|
||||
return array($array,$tot_deb,$tot_cred);
|
||||
}
|
||||
/*!\brief Return the name of a account
|
||||
* it doesn't change any data member
|
||||
* \return string with the pcm_lib
|
||||
*/
|
||||
function get_name() {
|
||||
$ret=pg_exec($this->db,
|
||||
"select pcm_lib from tmp_pcmn where
|
||||
pcm_val=".$this->id);
|
||||
if ( pg_NumRows($ret) != 0) {
|
||||
$r=pg_fetch_array($ret);
|
||||
$this->name=$r['pcm_lib'];
|
||||
} else {
|
||||
$this->name="Poste inconnu";
|
||||
}
|
||||
return $this->name;
|
||||
}
|
||||
/*!\brief Get all the value for this object from the database
|
||||
* the data member are set
|
||||
* \return false if this account doesn't exist otherwise true
|
||||
*/
|
||||
function load()
|
||||
{
|
||||
$ret=ExecSql($this->db,"select pcm_lib,pcm_val_parent from
|
||||
tmp_pcmn where pcm_val=".$this->id);
|
||||
$r=pg_fetch_all($ret);
|
||||
|
||||
if ( ! $r ) return false;
|
||||
$this->label=$r[0]['pcm_lib'];
|
||||
$this->parent=$r[0]['pcm_val_parent'];
|
||||
return true;
|
||||
|
||||
}
|
||||
/*!\brief Get all the value for this object from the database
|
||||
* the data member are set
|
||||
* \return false if this account doesn't exist otherwise true
|
||||
*/
|
||||
function get()
|
||||
{
|
||||
echo "OBSOLETE Acc_Account_Ledger->get(), a remplacer par Acc_Account_Ledger->load()";
|
||||
return $this->load();
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief give the balance of an account
|
||||
*
|
||||
* \return
|
||||
* balance of the account
|
||||
*
|
||||
*/
|
||||
function get_solde($p_cond=" true ") {
|
||||
$Res=ExecSql($this->db,"select sum(deb) as sum_deb, sum(cred) as sum_cred from
|
||||
( select j_poste,
|
||||
case when j_debit='t' then j_montant else 0 end as deb,
|
||||
case when j_debit='f' then j_montant else 0 end as cred
|
||||
from jrnx join tmp_pcmn on j_poste=pcm_val
|
||||
where
|
||||
j_poste like ('$this->id'::text) and
|
||||
$p_cond
|
||||
) as m ");
|
||||
$Max=pg_NumRows($Res);
|
||||
if ($Max==0) return 0;
|
||||
$r=pg_fetch_array($Res,0);
|
||||
|
||||
return abs($r['sum_deb']-$r['sum_cred']);
|
||||
}
|
||||
/*!
|
||||
* \brief give the balance of an account
|
||||
* \return
|
||||
* balance of the account
|
||||
*
|
||||
*/
|
||||
function get_solde_detail($p_cond="") {
|
||||
|
||||
if ( $p_cond != "") $p_cond=" and ".$p_cond;
|
||||
$sql="select sum(deb) as sum_deb, sum(cred) as sum_cred from
|
||||
( select j_poste,
|
||||
case when j_debit='t' then j_montant else 0 end as deb,
|
||||
case when j_debit='f' then j_montant else 0 end as cred
|
||||
from jrnx join tmp_pcmn on j_poste=pcm_val
|
||||
where
|
||||
j_poste like ('$this->id'::text)
|
||||
$p_cond
|
||||
) as m ";
|
||||
|
||||
$Res=ExecSql($this->db,$sql);
|
||||
$Max=pg_NumRows($Res);
|
||||
if ($Max==0) {
|
||||
return array('debit'=>0,
|
||||
'credit'=>0,
|
||||
'solde'=>0) ;
|
||||
}
|
||||
$r=pg_fetch_array($Res,0);
|
||||
// if p_start is < p_end the query returns null to avoid any problem
|
||||
// we set it to 0
|
||||
if ($r['sum_deb']=='')
|
||||
$r['sum_deb']=0.0;
|
||||
if ($r['sum_cred']=='')
|
||||
$r['sum_cred']=0.0;
|
||||
|
||||
return array('debit'=>$r['sum_deb'],
|
||||
'credit'=>$r['sum_cred'],
|
||||
'solde'=>abs($r['sum_deb']-$r['sum_cred']));
|
||||
}
|
||||
/*!
|
||||
* \brief isTva tell is a poste is used for VAT
|
||||
* \param none
|
||||
*
|
||||
*
|
||||
* \return 1 is Yes otherwise 0
|
||||
*/
|
||||
function isTVA()
|
||||
{
|
||||
// Load TVA array
|
||||
$a_TVA=get_array($this->db,'select tva_poste
|
||||
from tva_rate');
|
||||
foreach ( $a_TVA as $line_tva)
|
||||
{
|
||||
if ( $line_tva['tva_poste'] == '' )
|
||||
continue;
|
||||
list($tva_deb,$tva_cred)=split(',',$line_tva['tva_poste']);
|
||||
if ( $this->id == $tva_deb ||
|
||||
$this->id == $tva_cred )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
/*!
|
||||
* \brief HtmlTable, display a HTML of a poste for the asked period
|
||||
* \param none
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
|
||||
|
||||
function HtmlTable()
|
||||
{
|
||||
$this->get_name();
|
||||
|
||||
list($array,$tot_deb,$tot_cred)=$this->get_row( $_POST['from_periode'],
|
||||
$_POST['to_periode']
|
||||
);
|
||||
|
||||
if ( count($this->row ) == 0 )
|
||||
return;
|
||||
|
||||
$rep="";
|
||||
|
||||
echo '<h2 class="info">'.$this->id." ".$this->name.'</h2>';
|
||||
echo "<TABLE class=\"result\" width=\"100%\">";
|
||||
echo "<TR>".
|
||||
"<TH> Code interne </TH>".
|
||||
"<TH> Date</TH>".
|
||||
"<TH> Description </TH>".
|
||||
"<TH> Débit </TH>".
|
||||
"<TH> Crédit </TH>".
|
||||
"</TR>";
|
||||
|
||||
foreach ( $this->row as $op ) {
|
||||
echo "<TR>".
|
||||
"<TD>".$op['jr_internal']."</TD>".
|
||||
"<TD>".$op['j_date']."</TD>".
|
||||
"<TD>".$op['description']."</TD>".
|
||||
"<TD>".$op['deb_montant']."</TD>".
|
||||
"<TD>".$op['cred_montant']."</TD>".
|
||||
"</TR>";
|
||||
|
||||
}
|
||||
$solde_type=($tot_deb>$tot_cred)?"solde débiteur":"solde créditeur";
|
||||
$diff=round(abs($tot_deb-$tot_cred),2);
|
||||
echo "<TR>".
|
||||
"<TD>$solde_type</TD>".
|
||||
"<TD>$diff</TD>".
|
||||
"<TD></TD>".
|
||||
"<TD>$tot_deb</TD>".
|
||||
"<TD>$tot_cred</TD>".
|
||||
"</TR>";
|
||||
|
||||
echo "</table>";
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Display HTML Table Header (button)
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
function HtmlTableHeader()
|
||||
{
|
||||
$submit=new widget();
|
||||
$hid=new widget("hidden");
|
||||
echo '<div class="noprint">';
|
||||
echo "<table >";
|
||||
echo '<TR>';
|
||||
|
||||
echo '<TD><form method="GET" ACTION="">'.
|
||||
dossier::hidden().
|
||||
$submit->Submit('bt_other',"Autre poste").
|
||||
$hid->IOValue("type","poste").$hid->IOValue('p_action','impress')."</form></TD>";
|
||||
|
||||
echo '<TD><form method="POST" ACTION="poste_pdf.php">'.
|
||||
dossier::hidden().
|
||||
$submit->Submit('bt_pdf',"Export PDF").
|
||||
$hid->IOValue("type","poste").
|
||||
$hid->IOValue('p_action','impress').
|
||||
$hid->IOValue("poste_id",$_POST['poste_id']).
|
||||
$hid->IOValue("from_periode",$_POST['from_periode']).
|
||||
$hid->IOValue("to_periode",$_POST['to_periode']);
|
||||
if (isset($_POST['poste_fille']))
|
||||
echo $hid->IOValue('poste_fille','on');
|
||||
echo "</form></TD>";
|
||||
|
||||
echo '<TD><form method="POST" ACTION="poste_csv.php">'.
|
||||
dossier::hidden().
|
||||
$submit->Submit('bt_csv',"Export CSV").
|
||||
$hid->IOValue("type","poste").
|
||||
$hid->IOValue('p_action','impress').
|
||||
$hid->IOValue("poste_id",$_POST['poste_id']).
|
||||
$hid->IOValue("from_periode",$_POST['from_periode']).
|
||||
$hid->IOValue("to_periode",$_POST['to_periode']);
|
||||
if (isset($_POST['poste_fille']))
|
||||
echo $hid->IOValue('poste_fille','on');
|
||||
|
||||
echo "</form></TD>";
|
||||
echo "</table>";
|
||||
echo '</div>';
|
||||
|
||||
}
|
||||
/*!
|
||||
* \brief verify that the poste belong to a ledger
|
||||
*
|
||||
* \return 0 ok, -1 no
|
||||
*/
|
||||
function belong_ledger($p_jrn) {
|
||||
$filter=getDbValue($this->db,"select jrn_def_class_cred from jrn_def where jrn_def_id=$p_jrn");
|
||||
if ( trim ($filter) == '')
|
||||
return 0;
|
||||
|
||||
$valid_cred=split(" ",$filter);
|
||||
$sql="select count(*) as poste from tmp_pcmn where ";
|
||||
// Creation query
|
||||
$or="";
|
||||
$SqlFilter="";
|
||||
foreach ( $valid_cred as $item_cred) {
|
||||
if ( strlen (trim($item_cred))) {
|
||||
if ( strstr($item_cred,"*") == true ) {
|
||||
$item_cred=strtr($item_cred,"*","%");
|
||||
$SqlItem="$or pcm_val like '$item_cred'";
|
||||
$or=" or ";
|
||||
} else {
|
||||
$SqlItem="$or pcm_val = '$item_cred' ";
|
||||
$or=" or ";
|
||||
}
|
||||
$SqlFilter=$SqlFilter.$SqlItem;
|
||||
}
|
||||
}//foreach
|
||||
$sql.=$SqlFilter.' and pcm_val='.$this->id;
|
||||
$max=getDbValue($this->db,$sql);
|
||||
if ($max > 0 )
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
static function test_me() {
|
||||
$cn=DbConnect(dossier::id());
|
||||
$a=new Acc_Account_Ledger($cn,550);
|
||||
echo ' Journal 4 '.$a->belong_ledger(4);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -31,6 +31,7 @@ require_once ('class_widget.php');
|
|||
require_once ('class_dossier.php');
|
||||
require_once ('impress_inc.php');
|
||||
require_once ('header_print.php');
|
||||
require_once ('class_acc_account_ledger.php');
|
||||
|
||||
class Acc_Bilan {
|
||||
var $db; /*!< database connection */
|
||||
|
|
@ -79,9 +80,139 @@ class Acc_Bilan {
|
|||
$r.=$mod->IOValue('b_id');
|
||||
$r.="</tr>";
|
||||
$r.= '</TABLE>';
|
||||
$r.= $w->Submit('result','Impression');
|
||||
return $r;
|
||||
}
|
||||
/*!\brief check and warn if an accound has the wrong saldo
|
||||
* \param $p_message legend of the fieldset
|
||||
* \param $p_type type of the Acccount ACT actif, ACTINV...
|
||||
* \param $p_type the saldo must debit or credit
|
||||
*/
|
||||
private function warning($p_message,$p_type,$p_deb) {
|
||||
$sql="select pcm_val,pcm_lib from tmp_pcmn where pcm_type='$p_type'";
|
||||
$res=ExecSql($this->db,$sql);
|
||||
if ( pg_NumRows($res) ==0 )
|
||||
return;
|
||||
$count=0;
|
||||
$aRows=pg_fetch_all($res);
|
||||
$ret="";
|
||||
|
||||
foreach ($aRows as $line) {
|
||||
/* set the periode filter */
|
||||
$sql=sql_filter_per($this->db,$this->from,$this->to,'p_id','j_tech_per');
|
||||
|
||||
$obj=new Acc_Account_Ledger($this->db,$line['pcm_val']);
|
||||
$solde=$obj->get_solde_detail($sql);
|
||||
$solde_signed=$solde['debit']-$solde['credit'];
|
||||
if (
|
||||
($solde_signed < 0 && $p_deb == 'D' ) ||
|
||||
($solde_signed > 0 && $p_deb == 'C' )
|
||||
) {
|
||||
$ret.= '<li>Erreur pour le compte '.$line['pcm_val'].
|
||||
$line['pcm_lib'].
|
||||
" D: ".$solde['debit'].
|
||||
" C: ".$solde['credit']." diff ".$solde['solde'];
|
||||
$count++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
echo '<fieldset>';
|
||||
echo '<legend>'.$p_message.'</legend>';
|
||||
if ( $count <> 0 ) {
|
||||
echo '<ol>'.$ret.'</ol>';
|
||||
echo '<span class="error">Nbre erreur : '.$count.'</span>';
|
||||
} else
|
||||
echo " Pas d'anomalie détectée";
|
||||
echo '</fieldset>';
|
||||
|
||||
|
||||
}
|
||||
/*!\brief verify that the saldo is good for the type of account */
|
||||
function verify() {
|
||||
echo '<h3> Comptes normaux </h3>';
|
||||
$this->warning('Actif avec un solde crediteur','ACT','D');
|
||||
$this->warning('Passif avec un solde debiteur','PAS','C');
|
||||
$this->warning('Compte de resultat : Charge avec un solde crediteur','CHA','D');
|
||||
$this->warning('Compte de resultat : produit avec un solde debiteur','PRO','C');
|
||||
echo '<hr>';
|
||||
echo '<h3> Comptes inverses </h3>';
|
||||
$this->warning('Compte inverse : actif avec un solde debiteur','ACTINV','C');
|
||||
$this->warning('Compte inverse : passif avec un solde crediteur','PASINV','D');
|
||||
$this->warning('Compte inverse : Charge avec un solde debiteur','CHAINV','C');
|
||||
$this->warning('Compte inverse : produit avec un solde crediteur','PROINV','D');
|
||||
echo '<h3>Solde </h3>';
|
||||
/* set the periode filter */
|
||||
$sql_periode=sql_filter_per($this->db,$this->from,$this->to,'p_id','j_tech_per');
|
||||
/* debit Actif */
|
||||
$sql="select sum(j_montant) from jrnx join tmp_pcmn on (j_poste=pcm_val)".
|
||||
" where j_debit='t' and (pcm_type='ACT' or pcm_type='ACTINV')";
|
||||
$sql.="and $sql_periode";
|
||||
$debit_actif=getDbValue($this->db,$sql);
|
||||
|
||||
/* Credit Actif */
|
||||
$sql="select sum(j_montant) from jrnx join tmp_pcmn on (j_poste=pcm_val)".
|
||||
" where j_debit='f' and (pcm_type='ACT' or pcm_type='ACTINV')";
|
||||
|
||||
$sql.="and $sql_periode";
|
||||
|
||||
$credit_actif=getDbValue($this->db,$sql);
|
||||
$total_actif=abs($debit_actif-$credit_actif);
|
||||
echo 'Total actif '.$total_actif;
|
||||
echo '<br>';
|
||||
/* debit passif */
|
||||
$sql="select sum(j_montant) from jrnx join tmp_pcmn on (j_poste=pcm_val)".
|
||||
" where j_debit='t' and (pcm_type='PAS' or pcm_type='PASINV') ";
|
||||
$sql.="and $sql_periode";
|
||||
|
||||
$debit_passif=getDbValue($this->db,$sql);
|
||||
|
||||
/* Credit Actif */
|
||||
$sql="select sum(j_montant) from jrnx join tmp_pcmn on (j_poste=pcm_val)".
|
||||
" where j_debit='f' and (pcm_type='PAS' or pcm_type='PASINV') ";
|
||||
$sql.="and $sql_periode";
|
||||
$credit_passif=getDbValue($this->db,$sql);
|
||||
$total_passif=abs($debit_passif-$credit_passif);
|
||||
echo 'Total passif '.$total_passif;
|
||||
echo '<br>';
|
||||
/* debit charge */
|
||||
$sql="select sum(j_montant) from jrnx join tmp_pcmn on (j_poste=pcm_val)".
|
||||
" where j_debit='t' and (pcm_type='CHA' or pcm_type='CHAINV')";
|
||||
$sql.="and $sql_periode";
|
||||
$debit_charge=getDbValue($this->db,$sql);
|
||||
|
||||
/* Credit charge */
|
||||
$sql="select sum(j_montant) from jrnx join tmp_pcmn on (j_poste=pcm_val)".
|
||||
" where j_debit='f' and (pcm_type='CHA' or pcm_type='CHAINV')";
|
||||
$sql.="and $sql_periode";
|
||||
$credit_charge=getDbValue($this->db,$sql);
|
||||
$total_charge=abs($debit_charge-$credit_charge);
|
||||
echo 'Total charge '.$total_charge;
|
||||
echo '<br>';
|
||||
|
||||
/* debit prod */
|
||||
$sql="select sum(j_montant) from jrnx join tmp_pcmn on (j_poste=pcm_val)".
|
||||
" where j_debit='t' and (pcm_type='PRO' or pcm_type='PROINV')";
|
||||
$sql.="and $sql_periode";
|
||||
$debit_pro=getDbValue($this->db,$sql);
|
||||
|
||||
/* Credit prod */
|
||||
$sql="select sum(j_montant) from jrnx join tmp_pcmn on (j_poste=pcm_val)".
|
||||
" where j_debit='f' and (pcm_type='PRO' or pcm_type='PROINV')";
|
||||
$sql.="and $sql_periode";
|
||||
$credit_pro=getDbValue($this->db,$sql);
|
||||
$total_pro=abs($debit_pro-$credit_pro);
|
||||
echo 'Total produit '.$total_pro;
|
||||
echo '<br>';
|
||||
if ( $total_actif != $total_passif ) {
|
||||
$diff=$total_actif-$total_passif;
|
||||
echo '<span >Difference Actif - Passif = '.$diff.'</span>';
|
||||
echo '<br>';
|
||||
}
|
||||
$diff=$total_pro-$total_charge;
|
||||
echo '<span >';
|
||||
echo "Difference Produit - Charge ".$diff;
|
||||
echo '</span>';
|
||||
}
|
||||
/*!
|
||||
* \brief get data from the $_GET
|
||||
*
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ require_once ('class_dossier.php');
|
|||
require_once ('class_own.php');
|
||||
require_once ('class_anc_operation.php');
|
||||
require_once ('class_acc_operation.php');
|
||||
require_once ('class_acc_account.php');
|
||||
require_once ('class_acc_account_ledger.php');
|
||||
require_once ('class_pre_op_advanced.php');
|
||||
require_once ('jrn.php');
|
||||
require_once ('class_acexception.php');
|
||||
|
|
@ -472,7 +472,7 @@ class Acc_Ledger {
|
|||
$idx_tva=0;
|
||||
echo_debug('class_acc_ledger',__LINE__,'Code is');
|
||||
echo_debug('class_acc_ledger',__LINE__,$code);
|
||||
$poste=new Acc_Account($this->db,$code['j_poste']);
|
||||
$poste=new Acc_Account_Ledger($this->db,$code['j_poste']);
|
||||
|
||||
// if card retrieve name if the account is not a VAT account
|
||||
if ( strlen(trim($code['j_qcode'] )) != 0 && $poste->isTva() == 0 )
|
||||
|
|
@ -812,7 +812,7 @@ class Acc_Ledger {
|
|||
}
|
||||
|
||||
if ( trim(${'qc_'.$i})=="" && trim(${'poste'.$i}) != "") {
|
||||
$oposte=new Acc_Account($this->db,${'poste'.$i});
|
||||
$oposte=new Acc_Account_Ledger($this->db,${'poste'.$i});
|
||||
$strPoste=$oposte->id;
|
||||
$ret.="<td>".${"poste".$i}." - ".
|
||||
$oposte->get_name().$hidden->IOValue('poste'.$i,${'poste'.$i}).
|
||||
|
|
@ -1040,7 +1040,7 @@ class Acc_Ledger {
|
|||
|
||||
// Check if the account is permitted
|
||||
if ( isset (${'poste'.$i})) {
|
||||
$p=new Acc_Account($this->db,${'poste'.$i});
|
||||
$p=new Acc_Account_Ledger($this->db,${'poste'.$i});
|
||||
if ( $p->belong_ledger ($p_jrn) < 0 )
|
||||
throw new AcException("Le poste ".$p->id." n\'est pas dans ce journal",5);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ require_once("class_parm_code.php");
|
|||
require_once("class_widget.php");
|
||||
|
||||
require_once('class_fiche.php');
|
||||
require_once('class_acc_account.php');
|
||||
require_once('class_acc_account_ledger.php');
|
||||
require_once('user_common.php');
|
||||
/*! \file
|
||||
* \brief Derived from class fiche Administration are a specific kind of card
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
require_once ('class_bud_synthese.php');
|
||||
require_once ('class_anc_account.php');
|
||||
require_once ('class_acc_account.php');
|
||||
require_once ('class_acc_account_ledger.php');
|
||||
require_once ("class.ezpdf.php");
|
||||
require_once ('header_print.php');
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ class Bud_Synthese_Acc extends Bud_Synthese {
|
|||
foreach ($aBudCard as $rBudCard) {
|
||||
$line=array();
|
||||
echo_debug(__FILE__.':'.__LINE__.'- load ','bud_card',$rBudCard);
|
||||
$acc_account=new Acc_Account($this->cn,$rBudCard['pcm_val']);
|
||||
$acc_account=new Acc_Account_Ledger($this->cn,$rBudCard['pcm_val']);
|
||||
$acc_account->load();
|
||||
$line['acc_name']=$acc_account->label;
|
||||
$line['acc_amount']=$acc_account->get_solde($per_acc);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
*/
|
||||
require_once ('class_bud_synthese.php');
|
||||
require_once ('class_anc_account.php');
|
||||
require_once ('class_acc_account.php');
|
||||
require_once ('class_acc_account_ledger.php');
|
||||
|
||||
|
||||
class Bud_Synthese_Anc extends Bud_Synthese {
|
||||
|
|
@ -184,7 +184,7 @@ class Bud_Synthese_Anc extends Bud_Synthese {
|
|||
}
|
||||
$sub['amount']=$sub['unit']*$line['price_unit'];
|
||||
$sub['amount_unit']=$periode;
|
||||
$acc_account=new Acc_Account($this->cn,$pcm_val);
|
||||
$acc_account=new Acc_Account_Ledger($this->cn,$pcm_val);
|
||||
$acc_account->load();
|
||||
$sub['acc_name']=$acc_account->label;
|
||||
$sub['acc_amount']=$acc_account->get_solde($per_acc);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
require_once ('class_widget.php');
|
||||
require_once ('class_bud_synthese.php');
|
||||
require_once ('class_acc_account.php');
|
||||
require_once ('class_acc_account_ledger.php');
|
||||
require_once ('class_bud_hypo.php');
|
||||
|
||||
class Bud_Synthese_Group extends Bud_Synthese {
|
||||
|
|
@ -220,7 +220,7 @@ class Bud_Synthese_Group extends Bud_Synthese {
|
|||
|
||||
// Add amount from Accountancy
|
||||
$tmp=$array;
|
||||
$acc=new Acc_Account($this->cn,0);
|
||||
$acc=new Acc_Account_Ledger($this->cn,0);
|
||||
// $key is the pcm_val and the amount is an array of amount
|
||||
// (index = periode)
|
||||
foreach ($array as $key=>$amount) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
* synthese
|
||||
*/
|
||||
require_once ('class_bud_synthese.php');
|
||||
require_once ('class_acc_account.php');
|
||||
require_once ('class_acc_account_ledger.php');
|
||||
|
||||
class Bud_Synthese_Hypo extends Bud_Synthese {
|
||||
/* function __construct($p_cn) { */
|
||||
|
|
@ -145,7 +145,7 @@ Array
|
|||
$line['total_row']+=$line[$groupe];
|
||||
}
|
||||
// total CE
|
||||
$acc_account=new Acc_Account($this->cn,$pcm_val);
|
||||
$acc_account=new Acc_Account_Ledger($this->cn,$pcm_val);
|
||||
$acc_account->load();
|
||||
$line['acc_name']=$acc_account->label;
|
||||
$line['acc_amount']=$acc_account->get_solde($per_acc);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ require_once("class_parm_code.php");
|
|||
require_once("class_widget.php");
|
||||
|
||||
require_once('class_fiche.php');
|
||||
require_once('class_acc_account.php');
|
||||
require_once('class_acc_account_ledger.php');
|
||||
require_once('user_common.php');
|
||||
/*! \file
|
||||
* \brief Derived from class fiche Customer are a specific kind of card
|
||||
|
|
@ -246,7 +246,7 @@ where
|
|||
" ".$client->strAttribut(ATTR_DEF_PAYS).
|
||||
"</TD>";
|
||||
|
||||
$post=new Acc_Account($this->cn,$client->strAttribut(ATTR_DEF_ACCOUNT));
|
||||
$post=new Acc_Account_Ledger($this->cn,$client->strAttribut(ATTR_DEF_ACCOUNT));
|
||||
/* Filter on the default year */
|
||||
$User=new User($this->cn);
|
||||
$filter_year=" j_tech_per in (select p_id from parm_periode ".
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
/* $Revision$ */
|
||||
// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
|
||||
require_once('class_own.php');
|
||||
require_once('class_acc_account.php');
|
||||
require_once('class_acc_account_ledger.php');
|
||||
require_once('class_action.php');
|
||||
/*! \file
|
||||
* \brief Class Document corresponds to the table document
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ require_once("class_parm_code.php");
|
|||
require_once("class_widget.php");
|
||||
|
||||
require_once('class_fiche.php');
|
||||
require_once('class_acc_account.php');
|
||||
require_once('class_acc_account_ledger.php');
|
||||
require_once('user_common.php');
|
||||
/*! \file
|
||||
* \brief Derived from class fiche Supplier are a specific kind of card
|
||||
|
|
@ -129,7 +129,7 @@ class Supplier extends fiche{
|
|||
" ".$supplier->strAttribut(ATTR_DEF_PAYS).
|
||||
"</TD>";
|
||||
|
||||
$post=new Acc_Account($this->cn,$supplier->strAttribut(ATTR_DEF_ACCOUNT));
|
||||
$post=new Acc_Account_Ledger($this->cn,$supplier->strAttribut(ATTR_DEF_ACCOUNT));
|
||||
/* Filter on the default year */
|
||||
$User=new User($this->cn);
|
||||
$filter_year=" j_tech_per in (select p_id from parm_periode ".
|
||||
|
|
|
|||
|
|
@ -38,10 +38,33 @@ include_once("postgres.php");
|
|||
//-----------------------------------------------------
|
||||
$filter_year=" where p_exercice='".$User->get_exercice()."'";
|
||||
$bilan=new Acc_Bilan($cn);
|
||||
echo '<div class="u_redcontent">';
|
||||
echo '<FORM ACTION="bilan.php" METHOD="GET">';
|
||||
echo '<div class="u_content">';
|
||||
|
||||
echo '<FORM METHOD="GET">';
|
||||
echo widget::hidden('p_action','impress');
|
||||
echo widget::hidden('type','bilan');
|
||||
echo dossier::hidden();
|
||||
echo $bilan->display_form ($filter_year);
|
||||
echo widget::submit_button('verif','Verification comptabilite');
|
||||
echo '</FORM>';
|
||||
|
||||
|
||||
|
||||
if ( isset($_GET['verif'])) {
|
||||
echo '<h2> Etape 2 :Impression </h2>';
|
||||
$bilan->get_request_get();
|
||||
$bilan->verify();
|
||||
require_once ('verif_bilan.inc.php');
|
||||
echo '<FORM METHOD="GET" ACTION="bilan.php">';
|
||||
echo dossier::hidden();
|
||||
echo widget::hidden('b_id',$bilan->id);
|
||||
|
||||
echo widget::hidden('from_periode',$bilan->from);
|
||||
echo widget::hidden('to_periode',$bilan->to);
|
||||
echo widget::submit_button('Impression','Impression');
|
||||
echo '</form>';
|
||||
|
||||
}
|
||||
echo '<span class="notice"> Attention : si le bilan n\'est pas équilibré.<br> Vérifiez <ul>
|
||||
<li>L\'affectation du résultat est fait</li>
|
||||
<li>Vos comptes actifs ont un solde débiteur (sauf les comptes dit inversés)</li>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ if ( isset ($_REQUEST['fd_id'])) {
|
|||
// if amount requested
|
||||
$with_amount= (isset($_REQUEST['with_amount']))?true:false;
|
||||
if ($with_amount)
|
||||
include_once("class_acc_account.php");
|
||||
include_once("class_acc_account_ledger.php");
|
||||
|
||||
echo '<div class="u_content">';
|
||||
$submit=new widget();
|
||||
|
|
|
|||
|
|
@ -549,7 +549,7 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true,$p_
|
|||
else
|
||||
$cond="( j_date >= to_date('$p_start','DD.MM.YYYY') and j_date <= to_date('$p_end','DD.MM.YYYY'))";
|
||||
|
||||
include_once("class_acc_account.php");
|
||||
include_once("class_acc_account_ledger.php");
|
||||
while (ereg("(\[[0-9]*%*D*C*\])",$p_formula,$e) == true) {
|
||||
|
||||
// remove the [ ]
|
||||
|
|
@ -602,7 +602,7 @@ function ParseFormula($p_cn,$p_label,$p_formula,$p_start,$p_end,$p_eval=true,$p_
|
|||
}
|
||||
|
||||
// Get sum of account
|
||||
$P=new Acc_Account($p_cn,$e[0]);
|
||||
$P=new Acc_Account_Ledger($p_cn,$e[0]);
|
||||
echo_debug(__FILE__.":".__LINE__." condition is $cond");
|
||||
|
||||
$detail=$P->get_solde_detail($cond);
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
/*! \file
|
||||
* \brief concerns the management of the "Plan Comptable"
|
||||
*/
|
||||
require_once ('class_acc_account.php');
|
||||
include_once ("ac_common.php");
|
||||
html_page_start($_SESSION['g_theme']);
|
||||
require_once("constant.php");
|
||||
require_once('class_dossier.php');
|
||||
$gDossier=dossier::id();
|
||||
|
|
@ -90,10 +90,11 @@ if (isset ($_GET['action'])) {
|
|||
} // isset action
|
||||
//-----------------------------------------------------
|
||||
/* Ajout d'une ligne */
|
||||
if ( isset ( $_POST["Add"] ) ) {
|
||||
if ( isset ( $_POST["Ajout"] ) ) {
|
||||
extract ($_POST);
|
||||
$p_val=trim($p_val);
|
||||
$p_parent=trim($p_parent);
|
||||
|
||||
if ( isset ( $p_val) && isset ( $p_lib ) && isNumber($p_val) && isNumber($p_parent) ) {
|
||||
$p_val=trim($p_val);
|
||||
$p_lib=FormatString(trim($p_lib));
|
||||
|
|
@ -123,7 +124,7 @@ if ( isset ( $_POST["Add"] ) ) {
|
|||
|
||||
} else
|
||||
{
|
||||
$Ret=ExecSql($cn,"insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent) values ('$p_val','$p_lib',$p_parent)");
|
||||
$Ret=ExecSql($cn,"insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent,pcm_type) values ('$p_val','$p_lib',$p_parent,'$p_type')");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -132,7 +133,7 @@ if ( isset ( $_POST["Add"] ) ) {
|
|||
}
|
||||
}
|
||||
|
||||
$Ret=ExecSql($cn,"select pcm_val,pcm_lib,pcm_val_parent from tmp_pcmn where substr(pcm_val::text,1,1)='".$_SESSION['g_start']."' order by pcm_val::text");
|
||||
$Ret=ExecSql($cn,"select pcm_val,pcm_lib,pcm_val_parent,pcm_type from tmp_pcmn where substr(pcm_val::text,1,1)='".$_SESSION['g_start']."' order by pcm_val::text");
|
||||
$MaxRow=pg_NumRows($Ret);
|
||||
|
||||
?>
|
||||
|
|
@ -148,19 +149,14 @@ echo dossier::hidden();
|
|||
<TH> Classe </TH>
|
||||
<TH> Libellé </TH>
|
||||
<TH> Parent </TH>
|
||||
<TH> Type </TH>
|
||||
</TR>
|
||||
<TR>
|
||||
<?php
|
||||
$line=new Acc_Account($cn);
|
||||
echo $line->form(false);
|
||||
?>
|
||||
<TD>
|
||||
<INPUT TYPE="TEXT" NAME="p_val" SIZE=7>
|
||||
</TD>
|
||||
<TD>
|
||||
<INPUT TYPE="TEXT" NAME="p_lib" size=50>
|
||||
</TD>
|
||||
<TD>
|
||||
<INPUT TYPE="TEXT" NAME="p_parent" size=5>
|
||||
</TD>
|
||||
<TD>
|
||||
<INPUT TYPE="SUBMIT" Value="Add" Name="Add">
|
||||
<INPUT TYPE="SUBMIT" Value="Ajout" Name="Ajout">
|
||||
</TD>
|
||||
</TR>
|
||||
<?php
|
||||
|
|
@ -173,28 +169,32 @@ for ($i=0; $i <$MaxRow; $i++) {
|
|||
} else {
|
||||
$td='<TD class="even">';
|
||||
}
|
||||
echo "<TR> $td";
|
||||
echo "<TR> ";
|
||||
echo "$td";
|
||||
echo $A['pcm_val'];
|
||||
|
||||
echo "</td> $td";
|
||||
// printf ("<A HREF=line_update.php?l=%d&n=%s&p=%s>",$A['pcm_val'],urlencode($A['pcm_lib']),$A['pcm_val_parent']);
|
||||
printf ("<A HREF=\"javascript:PcmnUpdate(%d,'%s','%s','%s',%d)\">",
|
||||
$A['pcm_val'],
|
||||
FormatString($A['pcm_lib']),
|
||||
$A['pcm_val_parent'],
|
||||
$_REQUEST['PHPSESSID'],
|
||||
dossier::id());
|
||||
echo '</td>';
|
||||
echo "$td";
|
||||
printf ("<A HREF=\"javascript:PcmnUpdate(%d,'%s','%s','%s','%s',%d)\">",
|
||||
$A['pcm_val'],
|
||||
FormatString($A['pcm_lib']),
|
||||
$A['pcm_val_parent'],
|
||||
$A['pcm_type'],
|
||||
$_REQUEST['PHPSESSID'],
|
||||
dossier::id());
|
||||
echo $A['pcm_lib'];
|
||||
echo '</A>';
|
||||
echo "</TD>";
|
||||
|
||||
echo $td;
|
||||
echo $A['pcm_val_parent'];
|
||||
echo '</TD>';
|
||||
echo "</td>$td";
|
||||
echo $A['pcm_type'];
|
||||
echo "</TD>";
|
||||
|
||||
|
||||
echo $td;
|
||||
printf ('<A href="?p_action=pcmn&l=%d&action=del&%s">Delete</A>',$A['pcm_val'],$str_dossier);
|
||||
echo "</TD>";
|
||||
|
||||
|
||||
echo "</TR>";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue