noalyss Version-9
anc_listing.class.php
Go to the documentation of this file.
1<?php
2/*
3 * This file is part of NOALYSS.
4 *
5 * NOALYSS is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * NOALYSS is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with NOALYSS; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18*/
19
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
21
22/*!\file
23 * \brief definition of Anc_Listing
24 */
25
26/*!
27 * \brief manage the CA listing
28 *
29 * \return
30 */
31
33{
34 function display_form($p_string="")
35 {
36 echo '<form method="get">';
37 $r=parent::display_form($p_string);
38 $r.=HtmlInput::submit('result', _('Rechercher'));
39 $r.= '</form>';
40 return $r;
41
42 }
43 /*!
44 * \brief complete the object with the data in $_REQUEST
45 */
46
47 function get_request()
48 {
49 parent::get_request();
50 $this->pa_id=(isset($_REQUEST['pa_id']))?$_REQUEST['pa_id']:"";
51 }
52 /*!
53 * \brief compute the html display
54 *
55 *
56 * \return string
57 */
58
59 function display_html()
60 {
61 $idx=0;
62 $r="";
63 //---Html
64 $array=$this->load();
65 if ( is_array($array) == false || empty($array) )
66 {
67 return 0;
68 }
69 $cred=0;$deb=0;
70 bcscale(2);
71 $r.='<div></div>';
72 $r.=_('Cherche').HtmlInput::filter_table("tb_anchop",'0,1,2,3,4,5,6,7',1);
73 $r.= '<table id="tb_anchop" class="sortable" >';
74 $r.= '<tr>'.
75 '<th class=" sorttable_sorted">'._('Date').'</th>'.
76 '<th>'._('Poste').'</th>'.
77 '<th>'._('Quick_code').'</th>'.
78 '<th>'._('Analytique').'</th>'.
79 th(_('Description')).
80 '<th>'._('libelle').'</th>'.
81 '<th>'._('Num.interne').'</th>'.
82 '<th>'._('Montant').'</th>'.
83 '<th>'._('D/C').'</th>'.
84 '</tr>';
85 foreach ( $array as $row )
86 {
87 $class=($idx%2==0)?'even':'odd';
88 $idx++;
89 $r.= '<tr class="'.$class.'">';
90 $detail=($row['jr_id'] != null)?HtmlInput::detail_op($row['jr_id'],$row['jr_internal']):'';
91 $post_detail=($row['j_poste'] != null)?HtmlInput::history_account($row['j_poste'],$row['j_poste']):'';
92 $card_detail=($row['f_id'] != null)?HtmlInput::history_card($row['f_id'],$row['qcode']):'';
93
94 $r.=
95 '<td sorttable_customkey="'.$row['str_order_date'].'">'.$row['oa_date'].'</td>'.
96 td($post_detail,' sorttable_customkey="X'.$row['j_poste'].'"').
97 td($card_detail).
98 '<td>'.HtmlInput::history_anc_account($row['po_id'],h($row['po_name'])).'</td>'.
99 '<td>'.h($row['oa_description']).'</td>'.
100 td($row['jr_comment']).
101 '<td>'.$detail.'</td>'.
102 '<td class="num" sorttable_customkey="'.$row['oa_amount'].'">'.nbm($row['oa_amount']).'</td>'.
103 '<td>'.(($row['oa_debit']=='f')?'C':'D').'</td>';
104 $r.= '</tr>';
105 if ( $row['oa_debit'] == 'f') {$cred=bcadd($cred,$row['oa_amount']);}
106 if ( $row['oa_debit'] == 't') {$deb=bcadd($deb,$row['oa_amount']);}
107 }
108
109 $r.= '</table>';
110 ob_start();
111 echo _("Total");
112 echo '<ol style="list-style:none">';
113 echo '<li>'._('Total')." ".nbm($deb).' D '.'</li>';
114 echo '<li>'._('Total')." ".nbm($cred).' C '.'</li>';
115 echo '<li>';
116 echo _('Solde');
117 $solde=abs(bcsub($deb,$cred));
118 echo $solde." ";
119 echo findSide($deb-$cred);
120 echo '<li>';
121 echo '</ol>';
122
123 $r_solde=ob_get_clean();
124
125 return $r.$r_solde;
126 }
127 /*!
128 * \brief load the data from the database
129 *
130 * \return array
131 */
132 function load()
133 {
134 $op=new Anc_Operation ($this->db);
135 $op->pa_id=$this->pa_id;
136 $array=$op->get_list($this->from,$this->to,$this->from_poste,$this->to_poste);
137 if (! $array )
138 {
139 $this->has_data=0;
140 }
141 else
142 {
143 $this->has_data=count($array);
144 }
145 return $array;
146 }
147 /*!
148 * \brief Compute the csv export
149 * \return string with the csv
150 */
151
152 function display_csv()
153 {
154 $array=$this->load($this->from,$this->to,$this->from_poste,$this->to_poste);
155 if ( empty($array) == true )
156 {
157 return $array;
158
159 }
160 $csv=new Noalyss_Csv("anc_listing");
161 $csv->send_header();
162 $csv->write_header(array("Date","Poste","QuickCode",
163 "Activité","interne","pièce","description","montant","d/c"));
164 foreach ( $array as $row)
165 {
166 // the name and po_id
167 $csv->add($row['oa_date']);
168 $csv->add($row['j_poste']);
169 $csv->add($row['qcode']);
170 $csv->add($row['po_name']);
171 $csv->add($row['jr_internal']);
172 $csv->add($row['jr_pj_number']);
173 $csv->add($row['oa_description']);
174 $csv->add($row['oa_amount'],"number");
175 $csv->add(sprintf("'%s'",(($row['oa_debit']=='f')?'CREDIT':'DEBIT')));
176 $csv->write();
177 }
178 return;
179
180 }
181
182 /*!
183 * \brief show the export button to pdf and CSV
184 * \param $p_string string containing some HTML tag as hidden field
185 * \param
186 * \param
187 *
188 *
189 * \return string containing the html code
190 */
191 function show_button($p_string='')
192 {
193 $r="";
194 $submit=HtmlInput::submit('','');
195 $hidden=new IHidden();
196 /* for the export in PDF
197 * Not yet needed, the html print should be enough
198 $r.= '<form method="GET" action="ca_list_pdf.php" style="display:inline">';
199 $r.= $p_string;
200 $r.= dossier::hidden();
201 $r.= $hidden->input("to",$this->to);
202 $r.= $hidden->input("from",$this->from);
203 $r.= $hidden->input("pa_id",$this->pa_id);
204 $r.= $hidden->input("from_poste",$this->from_poste);
205 $r.= $hidden->input("to_poste",$this->to_poste);
206 $r.=HtmlInput::submit('bt_pdf',"Export en PDF");
207 $r.= '</form>';
208 */
209
210 $r.= '<form method="GET" action="export.php" style="display:inline">';
211 $r.= HtmlInput::hidden("to",$this->to);
212 $r.= HtmlInput::hidden("from",$this->from);
213 $r.= HtmlInput::hidden("pa_id",$this->pa_id);
214 $r.= HtmlInput::hidden("from_poste",$this->from_poste);
215 $r.= HtmlInput::hidden("to_poste",$this->to_poste);
216 $r.=HtmlInput::hidden('act','CSV:AncList');
217 $r.=HtmlInput::hidden('ac',$_REQUEST['ac']);
218 $r.= $p_string;
219 $r.= dossier::hidden();
220 $r.=HtmlInput::submit('bt_csv',"Export en CSV");
221 $r.= '</form>';
222 return $r;
223
224 }
225 /*!
226 * \brief debugging and test function for dev. only
227 * \param
228 * \param
229 * \param
230 *
231 *
232 * \return
233 */
234 static function test_me()
235 {
236 }
237}
th($p_string, $p_extra='', $raw='')
Definition: ac_common.php:58
findSide($p_number)
return D if the number is smaller than 0 , C if bigger and an empty string if equal to 0.
Definition: ac_common.php:121
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:137
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$op
Definition: ajax_admin.php:38
$anc pa_id
h( $row[ 'oa_description'])
$idx
$anc_grandlivre from_poste
$anc_grandlivre to
$anc_grandlivre to_poste
$anc_grandlivre from
$_REQUEST['ac']
$class
manage the CA listing
show_button($p_string='')
show the export button to pdf and CSV
static test_me()
debugging and test function for dev. only
display_csv()
Compute the csv export.
get_request()
complete the object with the data in $_REQUEST
display_html()
compute the html display
load()
load the data from the database
display_form($p_string="")
Compute the form to display.
this class is used to show the form for entering an operation only FOR analytic operation to save it,...
this class is the mother class for the CA printing
static history_account($p_account, $p_mesg, $p_style="", $p_exercice="")
display a div with the history of the account
static detail_op($p_jr_id, $p_mesg)
return a string containing the html code for calling the modifyOperation
static hidden($p_name, $p_value, $p_id="")
static history_card($f_id, $p_mesg, $p_style="", $p_exercice="")
display a div with the history of the card
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Html Input.
Manage the CSV : manage files and write CSV record.
$SecUser db
for($i=0;$i< $nb_jrn;$i++) $deb