40 parent::__construct($p_cn);
54 $r = parent::display_form($p_hidden);
55 $icard =
new ISelect(
'card_poste');
56 $icard->value = array(
57 array(
'value' => 1,
'label' =>
'Par fiche'),
58 array(
'value' => 2,
'label' =>
'Par poste comptable')
61 $r .= $icard->input();
62 $r .= HtmlInput::request_to_hidden(array(
'ac'));
78 $sql_from =
"oa_date >= to_date('" . $this->
from .
"','DD.MM.YYYY')";
81 if (trim($this->
to) !=
"" &&
isDate($this->
to) != NULL) {
82 $sql_to =
"oa_date <= to_date('" . $this->
to .
"','DD.MM.YYYY')";
85 if ($sql_to !=
"" && $sql_from !=
"") {
88 $sResult = $sWhere . $sql_from . $sql_and . $sql_to;
91 create temporary table table_analytic as
94 po.po_description,sum(
96 WHEN oa1.oa_debit = true THEN oa1.oa_amount * (-1)::numeric
99 coalesce(jrnx.j_poste,fd1.ad_value) as card_account,
101 FROM operation_analytique as oa1
102 JOIN poste_analytique po USING (po_id)
103 left join fiche_detail as fd1 on (oa1.f_id=fd1.f_id and fd1.ad_id=5)
104 left JOIN jrnx USING (j_id)
105 left join tmp_pcmn ON (jrnx.j_poste::text = tmp_pcmn.pcm_val::text)
107 GROUP BY po.po_id, po.po_name, po.pa_id, coalesce(jrnx.j_poste,fd1.ad_value), tmp_pcmn.pcm_lib, po.po_description
110 WHEN oa1.oa_debit = true THEN oa1.oa_amount * (-1)::numeric
112 END) <> 0::numeric ";
113 $this->
db->exec_sql(
$sql);
127 $sql_from =
"oa_date >= to_date('" . $this->
from .
"','DD.MM.YYYY')";
130 if (trim($this->
to) !=
"" &&
isDate($this->
to) != NULL) {
131 $sql_to =
"oa_date <= to_date('" . $this->
to .
"','DD.MM.YYYY')";
134 if ($sql_to !=
"" && $sql_from !=
"") {
137 $sResult = $sWhere . $sql_from . $sql_and . $sql_to;
139 create temporary table table_analytic as
140 with m as (select oa_id,po_id,
141 coalesce(jrnx.f_id,operation_analytique.f_id) as f_id1,
142 case when jrnx.j_qcode is not null then
143 ( SELECT fiche_detail.ad_value
145 WHERE fiche_detail.ad_id = 1 AND fiche_detail.f_id = jrnx.f_id)
146 when jrnx.f_id is null and operation_analytique.f_id is not null then
147 ( SELECT fiche_detail.ad_value
149 WHERE fiche_detail.ad_id = 1 AND fiche_detail.f_id = operation_analytique.f_id)
152 case when jrnx.j_qcode is not null then
154 when jrnx.f_id is null then
155 (SELECT fiche_detail.ad_value
157 WHERE fiche_detail.ad_id = 23 AND fiche_detail.f_id = operation_analytique.f_id) end as j_qcode
158 FROM operation_analytique
159 left JOIN jrnx USING (j_id) )
160 SELECT po.po_id, po.pa_id, po.po_name, po.po_description, sum(
162 WHEN operation_analytique.oa_debit = true THEN operation_analytique.oa_amount * (-1)::numeric
163 ELSE operation_analytique.oa_amount
167 m.j_qcode as card_account
168 FROM operation_analytique
169 JOIN poste_analytique po USING (po_id)
172 GROUP BY po.po_id, po.po_name, po.pa_id, m.f_id1, m.j_qcode,m.name, po.po_description
175 WHEN operation_analytique.oa_debit = true THEN operation_analytique.oa_amount * (-1)::numeric
176 ELSE operation_analytique.oa_amount
178 $this->
db->exec_sql(
$sql);
194 $header =
"select distinct po_id,po_name from table_analytic
196 pa_id=$1 " . $sql_from_poste . $sql_to_poste .
" order by po_name";
197 $this->aheader = $this->
db->get_array(
$header, array($this->
pa_id));
199 $this->arow = $this->
db->get_array(
"select distinct card_account,name
202 pa_id=$1 " . $sql_from_poste . $sql_to_poste .
" order by card_account", array($this->
pa_id));
204 $this->sql =
'select sum_amount from table_analytic where card_account=$1 and po_id=$2 and pa_id=' . $this->
pa_id .
' ' . $sql_from_poste . $sql_to_poste;
217 $header =
"select distinct po_id,po_name from table_analytic
219 pa_id=$1 " . $sql_from_poste . $sql_to_poste .
" order by po_name";
220 $this->aheader = $this->
db->get_array(
$header, array($this->
pa_id));
222 $this->arow = $this->
db->get_array(
"select distinct f_id,card_account,name from table_analytic
224 pa_id=$1 " . $sql_from_poste . $sql_to_poste .
" order by name", array($this->
pa_id));
225 $this->sql =
'select sum_amount from table_analytic where f_id=$1 and po_id=$2 and pa_id=' . $this->
pa_id .
' ' . $sql_from_poste . $sql_to_poste;
236 $r .=
'<form method="GET" action="export.php" style="display:inline">';
237 $r .= HtmlInput::hidden(
"act",
"CSV:AncTable");
238 $r .= HtmlInput::hidden(
"to", $this->
to);
239 $r .= HtmlInput::hidden(
"from", $this->
from);
240 $r .= HtmlInput::hidden(
"pa_id", $this->
pa_id);
241 $r .= HtmlInput::hidden(
"from_poste", $this->
from_poste);
242 $r .= HtmlInput::hidden(
"to_poste", $this->
to_poste);
243 $r .= HtmlInput::hidden(
"card_poste", $this->card_poste);
245 $r .= dossier::hidden();
246 $r .= HtmlInput::submit(
'bt_csv',
_(
"Export en CSV"));
254 if ($this->
check() != 0) {
255 alert(
_(
"Date invalide"));
259 if ($this->card_poste ==
'1') {
262 echo
'<table class="result">';
265 foreach ($this->aheader as $h) {
266 echo
'<th style="text-align:right">' .
h($h[
'po_name']) .
'</th>';
268 echo
th(
'Total',
' style="text-align:right"');
274 for (
$i = 0;
$i < count($this->arow);
$i++) {
275 $tr = (
$i % 2 == 0) ?
'<tr class="even">' :
'<tr class="odd">';
277 echo
td(HtmlInput::history_card($this->arow[
$i][
'f_id'], $this->arow[
$i][
'card_account'] .
' ' . $this->arow[
$i][
'name']));
279 for (
$x = 0;
$x < count($this->aheader);
$x++) {
280 $amount = $this->
db->get_value($this->sql, array($this->arow[
$i][
'f_id'], $this->aheader[
$x][
'po_id']));
282 if (isset($tot_col[
$x])) {
290 $tot_row = bcadd($tot_row,
$amount);
292 $side = ($tot_row < 0) ?
'D' :
'C';
294 echo
td(
nbm(abs($tot_row)) .
" " .
$side,
' class="num"');
295 $tot_global = bcadd($tot_global, $tot_row);
300 echo
'<tr class="highlight">';
302 for (
$i = 0;
$i < count($this->aheader);
$i++) {
303 $side = ($tot_col[
$i] < 0) ?
"D" :
"C";
305 echo
td(
nbm(abs($tot_col[
$i])) .
" " .
$side,
' class="num"');
307 $side = ($tot_global > 0) ?
"C" :
"D";
309 echo
td(
nbm($tot_global) .
" " .
$side,
' class="num " ');
313 if ($this->card_poste ==
'2') {
316 echo
'<table class="result">';
318 echo
th(
'poste comptable ');
319 foreach ($this->aheader as $h) {
320 echo
'<th style="text-align:right">' .
h($h[
'po_name']) .
'</th>';
322 echo
th(
'Total',
' style="text-align:right"');
328 for (
$i = 0;
$i < count($this->arow);
$i++) {
329 $tr = (
$i % 2 == 0) ?
'<tr class="even">' :
'<tr class="odd">';
331 echo
td(HtmlInput::history_account($this->arow[
$i][
'card_account'], $this->arow[
$i][
'card_account'] .
' ' . $this->arow[
$i][
'name']));
333 for (
$x = 0;
$x < count($this->aheader);
$x++) {
334 $amount = $this->
db->get_value($this->sql, array($this->arow[
$i][
'card_account'], $this->aheader[
$x][
'po_id']));
336 if (isset($tot_col[
$x])) {
344 $tot_row = bcadd($tot_row,
$amount);
346 $side = ($tot_row < 0) ?
'D' :
'C';
348 echo
td(
nbm(abs($tot_row)) .
" " .
$side,
' class="num"');
349 $tot_global = bcadd($tot_global, $tot_row);
354 echo
'<tr class="highlight">';
358 for (
$i = 0;
$i < count($this->aheader);
$i++) {
359 $side = ($tot_col[
$i] < 0) ?
"D" :
"C";
360 echo
td(
nbm(abs($tot_col[
$i])) .
" " .
$side,
' class="num"');
362 $side = ($tot_global > 0) ?
"C" :
"D";
365 echo
td(
nbm($tot_global) .
" " .
$side,
' class="num input_text" ');
376 if ($this->
check() != 0) {
377 throw new Exception (
"DATE INVALIDE");
383 if ($this->card_poste ==
'1') {
387 foreach ($this->aheader as $h) {
388 $csv->add($h[
'po_name']);
397 for (
$i = 0;
$i < count($this->arow);
$i++) {
399 $csv->add($this->arow[
$i][
'card_account'] .
' ' . $this->arow[
$i][
'name']);
401 for (
$x = 0;
$x < count($this->aheader);
$x++) {
402 $amount = $this->
db->get_value($this->sql, array($this->arow[
$i][
'f_id'], $this->aheader[
$x][
'po_id']));
404 if (isset($tot_col[
$x])) {
410 $tot_row = bcadd($tot_row,
$amount);
412 $csv->add($tot_row,
"number");
421 for (
$x = 0;
$x < count($this->aheader);
$x++) {
422 $csv->add($tot_col[
$x],
"number");
423 $sum_col = bcadd($sum_col, $tot_col[
$x]);
425 $csv->add($sum_col,
"number");
430 if ($this->card_poste ==
'2') {
433 $csv->add(
_(
"Poste"));
434 $csv->add(
_(
"Description"));
435 foreach ($this->aheader as $h) {
436 $csv->add($h[
'po_name']);
444 for (
$i = 0;
$i < count($this->arow);
$i++) {
446 $csv->add($this->arow[
$i][
'card_account']);
447 $csv->add($this->arow[
$i][
'name']);
449 for (
$x = 0;
$x < count($this->aheader);
$x++) {
450 $amount = $this->
db->get_value($this->sql, array($this->arow[
$i][
'card_account'], $this->aheader[
$x][
'po_id']));
452 if (isset($tot_col[
$x])) {
458 $tot_row = bcadd($tot_row,
$amount);
460 $csv->add($tot_row,
"number");
471 for (
$x = 0;
$x < count($this->aheader);
$x++) {
472 $csv->add($tot_col[
$x],
"number");
473 $sum_col = bcadd($sum_col, $tot_col[
$x]);
475 $csv->add($sum_col,
"number");
th($p_string, $p_extra='', $raw='')
isDate($p_date)
Verifie qu'une date est bien formaté en d.m.y et est valable.
td($p_string='', $p_extra='')
surround the string with td
nbm($p_number, $p_dec=2)
format the number with a sep.
alert($p_msg, $buffer=false)
alert in javascript
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
h( $row[ 'oa_description'])
$anc_grandlivre from_poste
_("actif, passif,charge,...")
link between accountancy and analytic, like table but as a listing
printing analytic and accountancy as a table
load_card()
load the data does not return anything but give a value to this->aheader and this->arow
show_button($p_hidden)
display the button export CSV
create_temp_table_account()
create the temporary table TABLE_ANALYTIC to store values for an account.
load_poste()
load the data does not return anything but give a value to this->aheader and this->arow
display_form($p_hidden='')
display form to get the parameter
create_temp_table_card()
create the temporary table TABLE_ANALYTIC to store values for a card
static escape_string($p_string)
wrapper for the function pg_escape_string
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Manage the CSV : manage files and write CSV record.
if(count($a_accounting)==0) $header