26require_once NOALYSS_INCLUDE.
'/lib/ac_common.php';
27require_once NOALYSS_INCLUDE.
'/header_print.php';
45 $sql=
"select m.po_id,sum(deb) as sum_deb,sum(cred) as sum_cred,";
46 $sql.=
" po_name||' '||coalesce(po_description,'') as po_name";
47 $sql.=
",ga_description ";
49 $sql.=
" (select po_id,case when oa_debit='t' then oa_amount else 0 end as deb,";
50 $sql.=
"case when oa_debit='f' then oa_amount else 0 end as cred ";
51 $sql.=
" from operation_analytique join poste_analytique using(po_id)";
53 $sql.=
" ) as m join poste_analytique using (po_id)";
54 $sql.=
" left join groupe_analytique on ( poste_analytique.ga_id=groupe_analytique.ga_id)";
55 $sql.=
" where poste_analytique.pa_id=".$this->pa_id;
56 $sql.=
" group by po_id,po_name,po_description,ga_description";
57 $sql.=
" order by po_name";
95 if ( $this->
from !=
"" )
97 $sql.=
" oa_date >= to_date('".$this->from.
"','DD.MM.YYYY')";
100 if ( $this->
to !=
"" )
102 $sql.=
" $and oa_date <= to_date('".$this->to.
"','DD.MM.YYYY')";
107 $sql.=
" $and upper(po_name)>= upper('".$this->from_poste.
"')";
112 $sql.=
" $and upper(po_name)<= upper('".$this->to_poste.
"')";
126 $r=
"<table class=\"result\">";
128 $r.=
"<th>Poste comptable Analytique</th>";
129 $r.=
"<th>Groupe</th>";
130 $r.=
"<th>Débit</th>";
131 $r.=
"<th>Crédit</th>";
132 $r.=
"<th>Solde</th>";
138 if ( is_array(
$array) ==
false )
144 $deb_side=0;$cred_side=0;
149 $r.=($odd%2==0)?
'<tr class="odd">':
'<tr class="even">';
152 $r.=sprintf(
"<td align=\"left\">%s</td>",
h(
$row[
'po_name']));
153 $r.=sprintf(
"<td align=\"left\">%s</td>",
h(
$row[
'ga_description']));
159 $r.=sprintf(
"<td>%s</td>",
$deb);
161 $deb_side=bcadd($deb_side,
$row[
'sum_deb']);
162 $cred_side=bcadd($cred_side,
$row[
'sum_cred']);
165 $r.=
'<tr class="highlight">';
168 $r.=
td(
nbm($deb_side),
'class="num"');
169 $r.=
td(
nbm($cred_side),
'class="num"');
170 $solde_side=abs(bcsub($deb_side,$cred_side));
171 $r.=
td(
nbm($solde_side),
'class="num"');
172 if ( $deb_side == $cred_side )
$r.=
td(
"=");
173 else if ( $deb_side > $cred_side )
$r.=
td(
"D");
187 $r=parent::display_form($p_string);
202 $pdf=
new PDFBalance_Simple($this->
db);
204 $pdf->AliasNbPages();
206 $pdf->setTitle(
"Balance analytique",
true);
208 $pdf->SetFont(
'DejaVu',
'',6);
212 $pdf->write_cell(50,6,
$row[
'po_name'],0,0,
'L');
213 $pdf->write_cell(50,6,
$row[
'ga_description'],0,0,
'L');
214 $pdf->write_cell(20,6,sprintf(
'%s',
nbm(
$row[
'sum_deb'])),0,0,
'R');
215 $pdf->write_cell(20,6,sprintf(
'%s',
nbm(
$row[
'sum_cred'])),0,0,
'R');
216 $pdf->write_cell(20,6,sprintf(
'%s',
nbm(
$row[
'solde'])),0,0,
'R');
217 $pdf->write_cell(20,6,
$row[
'debit'],0,0,
'R');
221 $pdf->output(
'simple-balance-'.
$fDate.
'.pdf',
'D');
231 if ( is_array(
$array) ==
false )
246 $csv->add(
$row[
'sum_deb'],
"number");
247 $csv->add(
$row[
'sum_cred'],
"number");
268 $r.=
'<form method="GET" action="export.php" style="display:inline">';
270 $r.= dossier::hidden();
281 $r.=
'<form method="GET" action="export.php" style="display:inline">';
289 $r.= dossier::hidden();
314 echo
'<form method="GET">';
316 echo
$bal->display_form();
318 if ( isset(
$_GET[
'result']))
320 echo
$bal->show_button(
"",
"");
321 echo
"<h1>HTML</h1>";
322 echo
$bal->display_html();
324 echo
$bal->display_csv();
td($p_string='', $p_extra='')
surround the string with td
nbm($p_number, $p_dec=2)
format the number with a sep.
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
$anc_grandlivre from_poste
manage the simple balance for CA, inherit from balance_ca
display_form($p_string="")
Compute the form to display.
display_pdf()
Display the result in pdf.
load()
load the data from the database
display_html()
compute the html display
set_sql_filter()
Set the filter (account_date)
static test_me()
for testing and debuggind the class it must never be called from production system,...
show_button($p_string="")
Show the button to export in PDF or CSV.
display_csv()
Compute the csv export.
this class is the mother class for the CA printing
static fetch_all($ret)
wrapper for the function pg_fetch_all
static num_row($ret)
wrapper for the function pg_num_rows
Manage the CSV : manage files and write CSV record.
for($i=0;$i< $nb_jrn;$i++) $deb