From 93ac35ea508279dc56c99e7d6ef462b5ddb87ccb Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 14 May 2011 19:17:04 +0000 Subject: [PATCH] Add Anc_Acc_List + export_csv + finish ANC Table --- html/export.php | 7 +- include/anc_imp.inc.php | 24 +++++- include/class_anc_acc_link.php | 62 +++++++++++++++ include/class_anc_table.php | 115 ++++++++++++++++------------ include/export_anc_acc_list_csv.php | 11 ++- include/export_anc_table_csv.php | 34 ++++++++ 6 files changed, 196 insertions(+), 57 deletions(-) create mode 100644 include/class_anc_acc_link.php create mode 100644 include/export_anc_table_csv.php diff --git a/html/export.php b/html/export.php index 581abd0d1..01071b633 100644 --- a/html/export.php +++ b/html/export.php @@ -157,9 +157,14 @@ switch( $_GET['act']) exit(); break; case 'CSV/AncTable': - require_once('export_table_csv.php'); + require_once('export_anc_table_csv.php'); exit(); break; + case 'CSV/AncAccList': + require_once('export_anc_acc_list_csv.php'); + exit(); + break; + default: alert('Action inconnue '.$_GET['act']); exit(); diff --git a/include/anc_imp.inc.php b/include/anc_imp.inc.php index fc3bfb071..968908c75 100644 --- a/include/anc_imp.inc.php +++ b/include/anc_imp.inc.php @@ -37,6 +37,7 @@ $menu=array(array("?p_action=ca_imp&sub=listing&$str_dossier",_("Listing"),_("Li array("?p_action=ca_imp&sub=bs&$str_dossier",_("Balance simple"),_("Balance simple d'un plan analytique"),"bs"), 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",_("Lien comptabilité"),_("Lien entre comptabilité et Comptabilité analytique"),'lico'), array("?p_action=ca_imp&sub=groupe&$str_dossier",_("Groupe"),_("Balance par groupe"),'gr'), ); @@ -128,4 +129,25 @@ if ( $sub == 'tab') echo $tab->show_button($str_hidden); $tab->display_html(); } - } \ No newline at end of file + } + +//---------------------------------------------------------------------- +// linked between accountancy and analytic +//--------------------------------------------------------------------------- +if ( $sub == 'lico') + { + require_once('class_anc_acc_list.php'); + $tab=new Anc_Acc_List($cn); + $tab->get_request(); + echo '
'; + echo $tab->display_form($str_hidden); + echo '

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

'; + + echo '
'; + if ( isset($_GET['result'])) + { + echo $tab->show_button($str_hidden); + $tab->display_html(); + } + } + diff --git a/include/class_anc_acc_link.php b/include/class_anc_acc_link.php new file mode 100644 index 000000000..23a3f5831 --- /dev/null +++ b/include/class_anc_acc_link.php @@ -0,0 +1,62 @@ +cn=$p_cn; + } + + /** + *@brief get the parameters + */ + function get_request() + { + parent::get_request(); + $this->card_poste=HtmlInput::default_value('card_poste',1,$_GET); + } + function set_sql_filter() + { + $sql=""; + $and=" and "; + if ( $this->from != "" ) + { + $sql.="$and oa_date >= to_date('".$this->from."','DD.MM.YYYY')"; + } + if ( $this->to != "" ) + { + $sql.=" $and oa_date <= to_date('".$this->to."','DD.MM.YYYY')"; + } + + return $sql; + + } + + +} + diff --git a/include/class_anc_table.php b/include/class_anc_table.php index c1cf8fec8..a8b3d3359 100644 --- a/include/class_anc_table.php +++ b/include/class_anc_table.php @@ -23,22 +23,10 @@ /*!\file * \brief object to show a table: link between accountancy and analytic */ -require_once('class_anc_print.php'); +require_once('class_anc_acc_link.php'); -class Anc_Table extends Anc_Print +class Anc_Table extends Anc_Acc_Link { - function __contruct($p_cn) - { - $this->cn=$p_cn; - } - /** - *@brief get the parameters - */ - function get_request() - { - parent::get_request(); - $this->card_poste=HtmlInput::default_value('card_poste',1,$_GET); - } /** *@brief display form to get the parameter * - card_poste 1 by card, 2 by account @@ -61,41 +49,7 @@ class Anc_Table extends Anc_Print $r.=$icard->input(); return $r; } - /** - * load the data - * does not return anything but give a value to this->aheader and this->arow - */ - function load_card() - { - $date=$this->set_sql_filter(); - $date=($date != '')?" $date":''; - $sql_from_poste=($this->from_poste!='')?" and po.po_name >= upper('".Database::escape_string($this->from_poste)."')":''; - $sql_to_poste=($this->to_poste!='')?" and po.po_name <= upper('".Database::escape_string($this->to_poste)."')":''; - $header="select distinct po_id,po_name from v_table_analytic_card where - pa_id=$1 ".$date.$sql_from_poste.$sql_to_poste." order by po_name"; - $this->aheader=$this->db->get_array($header,array($this->pa_id)); - - $this->arow=$this->db->get_array("select distinct f_id,j_qcode,name from v_table_analytic_card where - pa_id=$1 ".$date.$sql_from_poste.$sql_to_poste." order by name",array($this->pa_id)); - $this->sql='select sum_amount from v_table_analytic_card where f_id=$1 and po_id=$2 and pa_id='.$this->pa_id.' '.$date.$sql_from_poste.$sql_to_poste; - } - function set_sql_filter() - { - $sql=""; - $and=" and "; - if ( $this->from != "" ) - { - $sql.="$and oa_date >= to_date('".$this->from."','DD.MM.YYYY')"; - } - if ( $this->to != "" ) - { - $sql.=" $and oa_date <= to_date('".$this->to."','DD.MM.YYYY')"; - } - - return $sql; - - } /** * load the data @@ -116,6 +70,26 @@ class Anc_Table extends Anc_Print pa_id=$1 ".$date.$sql_from_poste.$sql_to_poste." order by j_poste",array($this->pa_id)); $this->sql='select sum_amount from v_table_analytic_account where j_poste=$1 and po_id=$2 and pa_id='.$this->pa_id.' '.$date.$sql_from_poste.$sql_to_poste; } + + /** + * load the data + * does not return anything but give a value to this->aheader and this->arow + */ + function load_card() + { + $date=$this->set_sql_filter(); + $date=($date != '')?" $date":''; + $sql_from_poste=($this->from_poste!='')?" and po.po_name >= upper('".Database::escape_string($this->from_poste)."')":''; + $sql_to_poste=($this->to_poste!='')?" and po.po_name <= upper('".Database::escape_string($this->to_poste)."')":''; + + $header="select distinct po_id,po_name from v_table_analytic_card where + pa_id=$1 ".$date.$sql_from_poste.$sql_to_poste." order by po_name"; + $this->aheader=$this->db->get_array($header,array($this->pa_id)); + + $this->arow=$this->db->get_array("select distinct f_id,j_qcode,name from v_table_analytic_card where + pa_id=$1 ".$date.$sql_from_poste.$sql_to_poste." order by name",array($this->pa_id)); + $this->sql='select sum_amount from v_table_analytic_card where f_id=$1 and po_id=$2 and pa_id='.$this->pa_id.' '.$date.$sql_from_poste.$sql_to_poste; + } /** *@brief display the button export CSV *@param $p_hidden is a string containing hidden items @@ -131,6 +105,7 @@ class Anc_Table extends Anc_Print $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.= HtmlInput::hidden("card_poste",$this->card_poste); $r.= $p_hidden; $r.= dossier::hidden(); $r.=HtmlInput::submit('bt_csv',"Export en CSV"); @@ -264,7 +239,7 @@ class Anc_Table extends Anc_Print { echo ';"'.$h['po_name'].'"'; } - echo ',"Total"'; + echo ';"Total"'; printf("\r\n"); /* * Show all the result @@ -294,8 +269,50 @@ class Anc_Table extends Anc_Print printf("\r\n"); + } + } + if ( $this->card_poste=='2') + { + $this->load_poste(); + + echo '"Poste"'; + foreach ($this->aheader as $h) + { + echo ';"'.$h['po_name'].'"'; + } + echo ';"Total"'; + printf("\r\n"); + /* + * Show all the result + */ + + for ($i=0;$iarow);$i++) + { + + printf('"%s"',$this->arow[$i]['j_poste'].' '.$this->arow[$i]['name']); + $tot_row=0; + for ($x=0;$xaheader);$x++) + { + $amount=$this->db->get_value($this->sql,array($this->arow[$i]['j_poste'],$this->aheader[$x]['po_id'])); + if ($amount==null)$amount=0; + if ( isset($tot_col[$x])) + { + $tot_col[$x]=bcadd($tot_col[$x],$amount); + } + else + { + $tot_col[$x]=$amount; + } + printf(";%s",nb($amount)); + $tot_row=bcadd($tot_row,$amount); + } + printf(";%s",nb($tot_row)); + printf("\r\n"); + + } } } + } \ No newline at end of file diff --git a/include/export_anc_acc_list_csv.php b/include/export_anc_acc_list_csv.php index a1bb0276c..161634a17 100644 --- a/include/export_anc_acc_list_csv.php +++ b/include/export_anc_acc_list_csv.php @@ -21,17 +21,16 @@ // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr /*!\file -* \brief export the operation in pdf +* \brief export analytic list in csv * */ header('Pragma: public'); header('Content-type: application/csv'); -header('Content-Disposition: attachment;filename="jrn.csv"',FALSE); +header('Content-Disposition: attachment;filename="export-anc-list.csv"',FALSE); -require_once ('class_anc_listing.php'); +require_once ('class_anc_acc_list.php'); -$cn=new Database(dossier::id()); -$bal=new Anc_Listing($cn); +$bal=new Anc_Acc_List($cn); $bal->get_request(); -echo $bal->display_csv(); +echo $bal->export_csv(); diff --git a/include/export_anc_table_csv.php b/include/export_anc_table_csv.php new file mode 100644 index 000000000..6dc543da1 --- /dev/null +++ b/include/export_anc_table_csv.php @@ -0,0 +1,34 @@ +get_request(); +$atable->export_csv(); \ No newline at end of file