From fd5e996e036d994a8e94301bf704a612cafce08b Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sun, 22 May 2011 16:08:17 +0000 Subject: [PATCH] =?UTF-8?q?0000267:=20Comptabilit=C3=A9=20analytique=20:?= =?UTF-8?q?=20groupe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/export.php | 4 + include/anc_imp.inc.php | 21 ++++- include/class_anc_acc_link.php | 13 --- include/class_anc_group.php | 111 ++++++++++++++++++++++- include/class_anc_print.php | 14 +++ include/export_anc_balance_group_csv.php | 36 ++++++++ include/template/anc_balance_group.php | 78 ++++++++++++++++ 7 files changed, 262 insertions(+), 15 deletions(-) create mode 100644 include/export_anc_balance_group_csv.php create mode 100644 include/template/anc_balance_group.php diff --git a/html/export.php b/html/export.php index 01071b633..a5d375945 100644 --- a/html/export.php +++ b/html/export.php @@ -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']); diff --git a/include/anc_imp.inc.php b/include/anc_imp.inc.php index 3291a8084..8e177de6b 100644 --- a/include/anc_imp.inc.php +++ b/include/anc_imp.inc.php @@ -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 '
'; + echo $gr->display_form($str_hidden); + echo '

'.HtmlInput::submit('Recherche','Recherche').'

'; + echo '
'; + if ( isset($_GET['result'])) + { + echo $gr->show_button($str_hidden); + + echo $gr->display_html(); + } + } diff --git a/include/class_anc_acc_link.php b/include/class_anc_acc_link.php index f13b0847a..bb343e6ed 100644 --- a/include/class_anc_acc_link.php +++ b/include/class_anc_acc_link.php @@ -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 */ diff --git a/include/class_anc_group.php b/include/class_anc_group.php index f05fa7324..fad243546 100644 --- a/include/class_anc_group.php +++ b/include/class_anc_group.php @@ -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.= '
'; + $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.= '
'; + return $r; + } + function export_csv() + { + $array=$this->get_result(); + printf('"groupe";"activité";"débit";"credit";"solde"'); + printf("\r\n"); + bcscale(2); + for ($i=0;$ifrom != '' && isDate ($this->from) == 0) + || + ($this->to != '' && isDate ($this->to) == 0)) + return -1; + + return 0; + } + } diff --git a/include/export_anc_balance_group_csv.php b/include/export_anc_balance_group_csv.php new file mode 100644 index 000000000..8b7d157ca --- /dev/null +++ b/include/export_anc_balance_group_csv.php @@ -0,0 +1,36 @@ +get_request(); +$a->export_csv(); +?> \ No newline at end of file diff --git a/include/template/anc_balance_group.php b/include/template/anc_balance_group.php new file mode 100644 index 000000000..2bdb21b17 --- /dev/null +++ b/include/template/anc_balance_group.php @@ -0,0 +1,78 @@ + + + + +'; +if ( $i==0) { + $prev=$array[$i]['ga_id']; + echo ''; + echo td($array[$i]['ga_id'],' colspan="5" style="width:auto;font-size:120%"'); + echo ''; + ?> + + + + + + + '; + 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 ''; + $tot_group_deb=0;$tot_group_cred=0; + $prev=$array[$i]['ga_id']; + echo ''; + echo td($array[$i]['ga_id'],' colspan="5" style="width:auto;font-size:120%"'); + echo ''; + ?> + + + + + + +'; +else + echo ''; + 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 ''; +$idx++; +endfor; + +echo ''; + +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 ''; +?> + +
ActivitéDébitCrébitSolde
ActivitéDébitCrébitSolde
\ No newline at end of file