0000267: Comptabilité analytique : groupe
This commit is contained in:
parent
2214242a0a
commit
fd5e996e03
7 changed files with 262 additions and 15 deletions
|
|
@ -164,6 +164,10 @@ switch( $_GET['act'])
|
|||
require_once('export_anc_acc_list_csv.php');
|
||||
exit();
|
||||
break;
|
||||
case 'CSV/AncBalGroup':
|
||||
require_once('export_anc_balance_group_csv.php');
|
||||
exit();
|
||||
break;
|
||||
|
||||
default:
|
||||
alert('Action inconnue '.$_GET['act']);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ $menu=array(array("?p_action=ca_imp&sub=listing&$str_dossier",_("Historique"),_(
|
|||
array("?p_action=ca_imp&sub=bc2&$str_dossier",_("Balance croisée"),_("Balance croisée de 2 plans analytiques"),"bc2"),
|
||||
array("?p_action=ca_imp&sub=tab&$str_dossier",_("Tableau"),_("Tableau lié à la comptabilité"),'tab'),
|
||||
array("?p_action=ca_imp&sub=lico&$str_dossier",_("Balance comptabilité"),_("Lien entre comptabilité et Comptabilité analytique"),'lico'),
|
||||
array("?p_action=ca_imp&sub=groupe&$str_dossier",_("Groupe"),_("Balance par groupe"),'gr'),
|
||||
array("?p_action=ca_imp&sub=group&$str_dossier",_("Groupe"),_("Balance par groupe"),'group'),
|
||||
|
||||
);
|
||||
$sub=(isset($_GET['sub']))?$_GET['sub']:'no';
|
||||
|
|
@ -167,3 +167,22 @@ if ( $sub == 'ancgl')
|
|||
echo $gl->display_html();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
// Balance by group
|
||||
//---------------------------------------------------------------------------
|
||||
if ( $sub == 'group')
|
||||
{
|
||||
require_once('class_anc_group.php');
|
||||
$gr=new Anc_Group($cn);
|
||||
$gr->get_request();
|
||||
echo '<form method="get">';
|
||||
echo $gr->display_form($str_hidden);
|
||||
echo '<p>'.HtmlInput::submit('Recherche','Recherche').'</p>';
|
||||
echo '</form>';
|
||||
if ( isset($_GET['result']))
|
||||
{
|
||||
echo $gr->show_button($str_hidden);
|
||||
|
||||
echo $gr->display_html();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,19 +32,6 @@ class Anc_Acc_Link extends Anc_Print
|
|||
$this->cn=$p_cn;
|
||||
}
|
||||
|
||||
function check()
|
||||
{
|
||||
|
||||
/*
|
||||
* check date
|
||||
*/
|
||||
if (($this->from != '' && isDate ($this->from) == 0)
|
||||
||
|
||||
($this->to != '' && isDate ($this->to) == 0))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
*@brief get the parameters
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -27,11 +27,12 @@
|
|||
require_once ('class_database.php');
|
||||
require_once ('constant.php');
|
||||
require_once ('class_dossier.php');
|
||||
require_once('class_anc_print.php');
|
||||
|
||||
/*! \brief class for the group of the analytic account
|
||||
*
|
||||
*/
|
||||
class Anc_Group
|
||||
class Anc_Group extends Anc_Print
|
||||
{
|
||||
var $db;
|
||||
var $ga_id;
|
||||
|
|
@ -126,6 +127,114 @@ class Anc_Group
|
|||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
function set_sql_filter()
|
||||
{
|
||||
$sql="";
|
||||
$and="and ";
|
||||
if ( $this->from != "" )
|
||||
{
|
||||
$sql.=" $and oa_date >= to_date('".$this->from."','DD.MM.YYYY')";
|
||||
$and=" and ";
|
||||
}
|
||||
if ( $this->to != "" )
|
||||
{
|
||||
$sql.=" $and oa_date <= to_date('".$this->to."','DD.MM.YYYY')";
|
||||
$and=" and ";
|
||||
}
|
||||
if ( $this->from_poste != "" )
|
||||
{
|
||||
$sql.=" $and upper(po_name)>= upper('".$this->from_poste."')";
|
||||
$and=" and ";
|
||||
}
|
||||
if ( $this->to_poste != "" )
|
||||
{
|
||||
$sql.=" $and upper(po_name)<= upper('".$this->to_poste."')";
|
||||
$and=" and ";
|
||||
}
|
||||
return $sql;
|
||||
|
||||
}
|
||||
|
||||
function get_result()
|
||||
{
|
||||
$filter_date=$this->set_sql_filter();
|
||||
|
||||
$sql="with m as (select po_id,
|
||||
po_name,
|
||||
ga_id,
|
||||
case when oa_debit = 't' then oa_amount
|
||||
else 0
|
||||
end as amount_deb,
|
||||
case when oa_debit = 'f' then oa_amount
|
||||
else 0
|
||||
end as amount_cred,
|
||||
oa_date
|
||||
from operation_analytique
|
||||
join poste_analytique using (po_id)
|
||||
where pa_id=$1 $filter_date )
|
||||
select sum(amount_cred) as sum_cred, sum(amount_deb)as sum_deb,po_name,ga_id,ga_description
|
||||
from m left join groupe_analytique using (ga_id)
|
||||
group by ga_id,po_name,ga_description
|
||||
order by ga_description,po_name";
|
||||
$ret=$this->db->get_array($sql,array($this->pa_id));
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function display_html()
|
||||
{
|
||||
if ( $this->check() != 0)
|
||||
{
|
||||
alert('Désolé mais une des dates données n\'est pas valide');
|
||||
return;
|
||||
}
|
||||
|
||||
$array=$this->get_result();
|
||||
if ( empty ($array) ) return "";
|
||||
require_once('template/anc_balance_group.php');
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
*@brief display the button export CSV
|
||||
*@param $p_hidden is a string containing hidden items
|
||||
*@return html string
|
||||
*/
|
||||
function show_button($p_hidden)
|
||||
{
|
||||
$r="";
|
||||
$r.= '<form method="GET" action="export.php" style="display:inline">';
|
||||
$r.= HtmlInput::hidden("act","CSV/AncBalGroup");
|
||||
$r.= HtmlInput::hidden("to",$this->to);
|
||||
$r.= HtmlInput::hidden("from",$this->from);
|
||||
$r.= HtmlInput::hidden("pa_id",$this->pa_id);
|
||||
$r.= HtmlInput::hidden("from_poste",$this->from_poste);
|
||||
$r.= HtmlInput::hidden("to_poste",$this->to_poste);
|
||||
$r.= $p_hidden;
|
||||
$r.= dossier::hidden();
|
||||
$r.=HtmlInput::submit('bt_csv',"Export en CSV");
|
||||
$r.= '</form>';
|
||||
return $r;
|
||||
}
|
||||
function export_csv()
|
||||
{
|
||||
$array=$this->get_result();
|
||||
printf('"groupe";"activité";"débit";"credit";"solde"');
|
||||
printf("\r\n");
|
||||
bcscale(2);
|
||||
for ($i=0;$i<count($array);$i++)
|
||||
{
|
||||
printf('"%s";"%s";%s;%s;%s',
|
||||
$array[$i]['ga_id'],
|
||||
$array[$i]['po_name'],
|
||||
nb($array[$i]['sum_deb']),
|
||||
nb($array[$i]['sum_cred']),
|
||||
nb(bcsub($array[$i]['sum_cred'],$array[$i]['sum_deb']))
|
||||
);
|
||||
printf("\r\n");
|
||||
}
|
||||
}
|
||||
static function test_me()
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -164,5 +164,19 @@ class Anc_Print
|
|||
return $sql;
|
||||
|
||||
}
|
||||
function check()
|
||||
{
|
||||
|
||||
/*
|
||||
* check date
|
||||
*/
|
||||
if (($this->from != '' && isDate ($this->from) == 0)
|
||||
||
|
||||
($this->to != '' && isDate ($this->to) == 0))
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
36
include/export_anc_balance_group_csv.php
Normal file
36
include/export_anc_balance_group_csv.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?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 export balance by group
|
||||
*/
|
||||
|
||||
require_once('class_anc_group.php');
|
||||
|
||||
header('Pragma: public');
|
||||
header('Content-type: application/csv');
|
||||
header('Content-Disposition: attachment;filename="anc-balance-group-export.csv"',FALSE);
|
||||
|
||||
$a=new Anc_Group($cn);
|
||||
$a->get_request();
|
||||
$a->export_csv();
|
||||
?>
|
||||
78
include/template/anc_balance_group.php
Normal file
78
include/template/anc_balance_group.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/**
|
||||
* defined variable $array with the result included from class_anc_group
|
||||
*/
|
||||
$prev='';
|
||||
?>
|
||||
|
||||
<table class="result">
|
||||
|
||||
<?php
|
||||
$idx=0;bcscale(2);$solde=0;$tot_group_deb=0;$tot_group_cred=0;
|
||||
for ($i=0;$i<count($array);$i++):
|
||||
echo '<tr>';
|
||||
if ( $i==0) {
|
||||
$prev=$array[$i]['ga_id'];
|
||||
echo '<tr>';
|
||||
echo td($array[$i]['ga_id'],' colspan="5" style="width:auto;font-size:120%"');
|
||||
echo '</tr>';
|
||||
?>
|
||||
<tr>
|
||||
<th>Activité</th>
|
||||
<th style="text-align:right" >Débit</th>
|
||||
<th style="text-align:right">Crébit</th>
|
||||
<th style="text-align:right">Solde</th>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
if ( $prev != $array[$i]['ga_id'])
|
||||
{
|
||||
$prev=$array[$i]['ga_id'];
|
||||
|
||||
echo '<tr>';
|
||||
echo td('Solde');
|
||||
echo td(nbm($tot_group_deb),' class="num"');
|
||||
echo td(nbm($tot_group_cred),' class="num"');
|
||||
echo td(nbm(bcsub($tot_group_cred,$tot_group_deb)),' class="num"');
|
||||
|
||||
echo '</tr>';
|
||||
$tot_group_deb=0;$tot_group_cred=0;
|
||||
$prev=$array[$i]['ga_id'];
|
||||
echo '<tr>';
|
||||
echo td($array[$i]['ga_id'],' colspan="5" style="width:auto;font-size:120%"');
|
||||
echo '</tr>';
|
||||
?>
|
||||
<tr>
|
||||
<th>Activité</th>
|
||||
<th style="text-align:right">Débit</th>
|
||||
<th style="text-align:right" >Crébit</th>
|
||||
<th style="text-align:right" >Solde</th>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
if ($idx %2 == 0)
|
||||
echo '<tr>';
|
||||
else
|
||||
echo '<tr class="odd">';
|
||||
echo td($array[$i]['po_name']);
|
||||
echo td(nbm($array[$i]['sum_deb']),' class="num"');
|
||||
echo td(nbm($array[$i]['sum_cred']),' class="num"');
|
||||
$solde=bcsub($array[$i]['sum_cred'],$array[$i]['sum_deb']);
|
||||
echo td(nbm($solde),' class="num"');
|
||||
$tot_group_deb=bcadd($tot_group_deb,$array[$i]['sum_deb']);
|
||||
$tot_group_cred=bcadd($tot_group_cred,$array[$i]['sum_cred']);
|
||||
echo '</tr>';
|
||||
$idx++;
|
||||
endfor;
|
||||
|
||||
echo '<tr>';
|
||||
|
||||
echo td('Solde');
|
||||
echo td(nbm($tot_group_deb),' class="num"');
|
||||
echo td(nbm($tot_group_cred),' class="num"');
|
||||
echo td(nbm(bcsub($tot_group_cred,$tot_group_deb)),' class="num"');
|
||||
|
||||
echo '</tr>';
|
||||
?>
|
||||
|
||||
</table>
|
||||
Loading…
Add table
Add a link
Reference in a new issue