Add Anc_Acc_List + export_csv + finish ANC Table

This commit is contained in:
Dany De Bontridder 2011-05-14 19:17:04 +00:00
parent 5f2be33e32
commit 93ac35ea50
6 changed files with 196 additions and 57 deletions

View file

@ -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();

View file

@ -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();
}
}
}
//----------------------------------------------------------------------
// 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 '<form method="get">';
echo $tab->display_form($str_hidden);
echo '<p>'.HtmlInput::submit('Recherche','Recherche').'</p>';
echo '</form>';
if ( isset($_GET['result']))
{
echo $tab->show_button($str_hidden);
$tab->display_html();
}
}

View file

@ -0,0 +1,62 @@
<?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 link between accountancy and analytic, like table but as a listing
*/
require_once('class_anc_print.php');
class Anc_Acc_Link extends Anc_Print
{
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);
}
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;
}
}

View file

@ -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;$i<count($this->arow);$i++)
{
printf('"%s"',$this->arow[$i]['j_poste'].' '.$this->arow[$i]['name']);
$tot_row=0;
for ($x=0;$x<count($this->aheader);$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");
}
}
}
}

View file

@ -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();

View file

@ -0,0 +1,34 @@
<?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 the anc tables in CSV
*/
header('Pragma: public');
header('Content-type: application/csv');
header('Content-Disposition: attachment;filename="anc-table-export.csv"',FALSE);
require_once('class_anc_table.php');
$atable=new Anc_Table($cn);
$atable->get_request();
$atable->export_csv();