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 '
'; + 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.= ''; + 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| Activité | +Débit | +Crébit | +Solde | +
|---|---|---|---|
| Activité | +Débit | +Crébit | +Solde | +