Plugins  LAST
 All Data Structures Files Functions Variables Pages
class_anc_grandlivre_ext.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of NOALYSS.
5  *
6  * NOALYSS is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * NOALYSS is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with NOALYSS; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  */
20 
21 // Copyright Author Dany De Bontridder danydb@aevalys.eu
22 /**
23  * extends class_anc_grandlivre
24  *
25  * @author dany
26  */
27 class Anc_Grandlivre_Ext extends Anc_GrandLivre
28 {
29  /*!
30  * \brief Show the button to export in PDF or CSV
31  * \param $url_csv url of the csv
32  * \param $url_pdf url of the pdf
33  * \param $p_string hidden data to include in the form
34  *
35  *
36  * \return string with the button
37  */
38 
39  function show_button($p_string = "")
40  {
41  $r = "";
42  $r.= '<form method="GET" action="export.php" style="display:inline">';
43  $r.= HtmlInput::hidden("act", "CSV:AncGrandLivre");
44  $r.= HtmlInput::hidden("to", $this->to);
45  $r.= HtmlInput::hidden("from", $this->from);
46  $r.= HtmlInput::hidden("pa_id", $this->pa_id);
47  $r.= HtmlInput::hidden("from_poste", $this->from_poste);
48  $r.= HtmlInput::hidden("to_poste", $this->to_poste);
49  $r.= $p_string;
50  $r.= dossier::hidden();
51  $r.=HtmlInput::submit('bt_csv', "Export en CSV");
52  $r.= '</form>';
53  return $r;
54  }
55 
56  /*!
57  * \brief Show the button to export in PDF all the receipt
58  *
59  * \param $p_string extra hidden value
60  * \return string with the button
61  */
62 
63  function button_export_pdf($p_string = "")
64  {
65  $r = "";
66  $r.= HtmlInput::hidden("to", $this->to);
67  $r.= HtmlInput::hidden("from", $this->from);
68  $r.= HtmlInput::hidden("pa_id", $this->pa_id);
69  $r.= HtmlInput::hidden("from_poste", $this->from_poste);
70  $r.= HtmlInput::hidden("to_poste", $this->to_poste);
71  $r.= $p_string;
72  $r.= dossier::hidden();
73  $r.=HtmlInput::submit('bt_receipt_anal_pdf', _("Export des pièces en PDF"));
74  return $r;
75  }
76 
77  /*!
78  * \brief compute the html display
79  *
80  *
81  * \return string
82  */
83 
84  function display_html()
85  {
86  $r = "";
87  //---Html
88  $array = $this->load();
89  if (is_array($array) == false)
90  {
91  return $array;
92  }
93 
94  if (empty($array))
95  {
96  $r.= _("aucune donnée");
97  return $r;
98  }
99  $r.= '<table class="result" style="width=100%">';
100  $ix = 0;
101  $prev = 'xx';
102  $idx = 0;
103  $tot_deb = $tot_cred = 0;
104 
105  foreach ($array as $row)
106  {
107  if ($prev != $row['po_name'])
108  {
109  if ($ix > 0)
110  {
111  $r.='<tr>';
112  $tot_solde = bcsub($tot_cred, $tot_deb);
113  $sign = ($tot_solde > 0) ? 'C' : 'D';
114  $r.=td('') . td('') . td('') . td('') . td('') . td(nbm($tot_deb), ' class="num"') . td(nbm($tot_cred), ' class="num"') . td(nbm($tot_solde) . $sign, ' class="num"');
115  }
116  $r.='<tr>' . '<td colspan="7" style="width:auto">' . '<h2>' . h($row['po_name'] . ' ' . $row['po_description']) . '</td></tr>';
117  $r.= '<tr>' .
118  '<th>' . '</th>' .
119  '<th>' . _('Date') . '</th>' .
120  '<th>' . _('Poste') . '</th>' .
121  '<th>' . _('Quick_code') . '</th>' .
122  '<th>' . _('Libellé') . '</th>' .
123  '<th>' . _('Document') . '</th>' .
124  '<th>' . _('Pièce') . '</th>' .
125  '<th>' . _('Num.interne') . '</th>' .
126  '<th style="text-align:right">' . _('Debit') . '</th>' .
127  '<th style="text-align:right">' . _('Credit') . '</th>' .
128  '</tr>';
129 
130  $tot_deb = $tot_cred = 0;
131  $prev = $row['po_name'];
132  $ix++;
133  }
134  $class = ($idx % 2 == 0) ? 'even' : 'odd';
135  $idx++;
136  $r.='<tr class="' . $class . '">';
137  $detail = ($row['jr_id'] != null) ? HtmlInput::detail_op($row['jr_id'], $row['jr_internal']) : '';
138  $post_detail = ($row['j_poste'] != null) ? HtmlInput::history_account($row['j_poste'], $row['j_poste']) : '';
139  $card_detail = ($row['f_id'] != null) ? HtmlInput::history_card($row['f_id'], $row['qcode']) : '';
140  $amount_deb = ($row['oa_debit'] == 't') ? $row['oa_amount'] : 0;
141  $amount_cred = ($row['oa_debit'] == 'f') ? $row['oa_amount'] : 0;
142  $tot_deb = bcadd($tot_deb, $amount_deb);
143  $tot_cred = bcadd($tot_cred, $amount_cred);
144 
145  /*
146  * Checked button
147  */
148  $str_ck = "";
149  $str_document = "";
150  if ($row['jr_id'] != null)
151  {
152  /*
153  * Get receipt info
154  */
155  $str_document = HtmlInput::show_receipt_document($row['jr_id']);
156  if ($str_document != "")
157  {
158  $ck = new ICheckBox('ck[]', $row['jr_id']);
159  $str_ck = $ck->input();
160  }
161  }
162 
163  $r.=
164  '<td>' . $str_ck . '</td>' .
165  '<td>' . $row['oa_date'] . '</td>' .
166  td($post_detail) .
167  td($card_detail) .
168  td($row['jr_comment']) .
169  '<td>' . $str_document . '</td>' .
170  td($row['jr_pj_number']) .
171  '<td>' . $detail . '</td>' .
172  '<td class="num">' . nbm($amount_deb) . '</td>' .
173  '<td class="num">' . nbm($amount_cred)
174  . '</td>';
175  $r.= '</tr>';
176  }
177  $r.='<tr>';
178  $tot_solde = bcsub($tot_cred, $tot_deb);
179  $sign = ($tot_solde > 0) ? 'C' : 'D';
180  $r.=td('') . td('') . td('') . td('') . td('') . td(nbm($tot_deb), ' class="num"') . td(nbm($tot_cred), ' class="num"') . td(nbm($tot_solde) . $sign, ' class="num"');
181 
182  $r.= '</table>';
183  return $r;
184  }
185 
186 
187 
188 }
extends class_anc_grandlivre
else $class
Definition: show_import.php:25
display_html()
compute the html display
$ck
Definition: am_card.php:41
button_export_pdf($p_string="")
Show the button to export in PDF all the receipt.
for($i=0;$i< Database::num_row($ret);$i++) $row
$r
show_button($p_string="")
Show the button to export in PDF or CSV.
if(isset($_POST['remove'])) $array