noalyss Version-9
Public Member Functions
Pre_op_ven Class Reference

concerns the predefined operation for VEN ledger More...

+ Inheritance diagram for Pre_op_ven:
+ Collaboration diagram for Pre_op_ven:

Public Member Functions

 __construct ($cn)
 
 compute_array ($p_od_id)
 compute an array accordingly with the FormVenView function More...
 
 display ($p_array)
 Display the form for modifying or adding new predefined operation. More...
 
 get_post ()
 get the post and stove them into data member , before saving them in the db More...
 
 load ($p_od_id)
 load the data from the database and return an array More...
 
 save ($p_od_id, $p_nb_item)
 save the detail and op in the database More...
 
 __construct ($p_cn)
 

Additional Inherited Members

- Static Public Member Functions inherited from Pre_operation_detail
static build_detail ($p_jrn_type, Database $database)
 

Detailed Description

concerns the predefined operation for VEN ledger

Definition at line 29 of file pre_op_ven.class.php.

Constructor & Destructor Documentation

◆ __construct()

Pre_op_ven::__construct (   $cn)

Reimplemented from Pre_operation_detail.

Definition at line 32 of file pre_op_ven.class.php.

33 {
34 parent::__construct($cn);
35 }

References $cn.

Member Function Documentation

◆ compute_array()

Pre_op_ven::compute_array (   $p_od_id)

compute an array accordingly with the FormVenView function

Definition at line 111 of file pre_op_ven.class.php.

112 {
113 $count=0;
114 $array=array();
115 $p_array=$this->load($p_od_id);
116 if (empty($p_array)) return array();
117 foreach ($p_array as $row)
118 {
119 if ( $row['opd_debit']=='t')
120 {
121 $array+=array('e_client'=>$row['opd_poste']);
122 }
123 else
124 {
125 if ( trim($row['opd_poste']) != "")
126 {
127 $array+=array("e_march".$count=>$row['opd_poste'],
128 "e_march".$count."_price"=>$row['opd_amount'],
129 "e_march".$count."_tva_id"=>$row['opd_tva_id'],
130 "e_quant".$count=>$row['opd_quantity'],
131 "e_march".$count."_label"=>$row['opd_comment'],
132 "e_march".$count."_tva_amount"=>$row['opd_tva_amount'],
133 );
134 $count++;
135 }
136 }
137 }
138
139 return $array;
140 }
load($p_od_id)
load the data from the database and return an array
$count

References $array, $count, $p_array, $row, and load().

+ Here is the call graph for this function:

◆ display()

Pre_op_ven::display (   $p_array)

Display the form for modifying or adding new predefined operation.

Parameters
array$p_arrayis the result of compute_array or blank
Returns
string containing HTML code of the form
Exceptions
Exception
See also
compute_array
load

Definition at line 164 of file pre_op_ven.class.php.

165 {
166 global $g_parameter,$g_user;
167
168 $ledger=new Acc_Ledger_Sale($this->db,$p_array['p_jrn']);
169 $flag_tva=$g_parameter->MY_TVA_USE;
170 /* Add button */
171 $f_add_button=new IButton('add_card');
172 $f_add_button->tabindex=-1;
173 $f_add_button->label=_('Créer une nouvelle fiche');
174 $f_add_button->set_attribute('ipopup','ipop_newcard');
175 $f_add_button->set_attribute('jrn',$p_array['p_jrn']);
176 $f_add_button->javascript="this.jrn=\$('p_jrn').value; select_card_type(this);";
177
178 $f_add_button2=new IButton('add_card2');
179 $f_add_button2->tabindex=-1;
180 $f_add_button2->label=_('Créer une nouvelle fiche');
181 $f_add_button2->set_attribute('ipopup','ipop_newcard');
182 $f_add_button2->set_attribute('filter',$ledger->get_all_fiche_def ());
183 // $f_add_button2->set_attribute('jrn',$ledger->id);
184 $f_add_button2->javascript=" this.jrn=\$('p_jrn').value;select_card_type(this);";
185
186 $str_add_button="";
187 $str_add_button2="";
188 if ($g_user->check_action(FICADD)==1)
189 {
190 $str_add_button=$f_add_button->input();
191 $str_add_button2=$f_add_button2->input();
192 }
193
194 $r='';
195 $r.=dossier::hidden();
196 $f_legend=_('En-tête facture client');
197
198
199 /* if we suggest the next pj, then we need a javascript */
200
201 // Display the customer
202 //--
203 $fiche='deb';
204
205 // Save old value and set a new one
206 //--
207 $e_client=( isset ($p_array["e_client"]) )?$p_array["e_client"]:"";
208 $e_client_label=" ";//str_pad("",100,".");
209
210
211 // retrieve e_client_label
212 //--
213
214 if ( noalyss_strlentrim($e_client) != 0)
215 {
216 $fClient=new Fiche($ledger->db);
217 $fClient->get_by_qcode($e_client);
218 $e_client_label=$fClient->strAttribut(ATTR_DEF_NAME).' '.
219 ' Adresse : '.$fClient->strAttribut(ATTR_DEF_ADRESS).' '.
220 $fClient->strAttribut(ATTR_DEF_CP).' '.
221 $fClient->strAttribut(ATTR_DEF_CITY).' ';
222
223
224 }
225
226 $W1=new ICard();
227 $W1->label="Client ".Icon_Action::infobulle(0) ;
228 $W1->name="e_client";
229 $W1->tabindex=3;
230 $W1->value=$e_client;
231 $W1->table=0;
232 $W1->set_dblclick("fill_ipopcard(this);");
233 $W1->set_attribute('ipopup','ipopcard');
234
235 // name of the field to update with the name of the card
236 $W1->set_attribute('label','e_client_label');
237 // name of the field to update with the name of the card
238 $W1->set_attribute('typecard','deb');
239
240 // Add the callback function to filter the card on the jrn
241 $W1->set_callback('filter_card');
242 $W1->set_function('fill_data');
243 $W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
244 $W1->name);
245 $f_client_qcode=$W1->input();
246 $client_label=new ISpan();
247 $client_label->table=0;
248 $f_client=$client_label->input("e_client_label",$e_client_label);
249 $f_client_bt=$W1->search();
250
251
252 // Record the current number of article
253 $min=$ledger->get_min_row();
254 $p_article= ( isset ($p_array["nb_item"]))?$p_array["nb_item"]:$min;
255 $max=($p_article < $min)?$min:$p_article;
256
257 $e_comment=(isset($p_array["e_comment"]))?$p_array["e_comment"]:"";
258 $Hid=new IHidden();
259 $r.=$Hid->input("nb_item",$p_article);
260
261 $f_legend_detail=_("Détail articles vendus");
262
263 // For each article
264 //--
265 for ($i=0;$i< $max;$i++)
266 {
267 // Code id, price & vat code
268 //--
269 $march=(isset($p_array["e_march$i"]))?$p_array["e_march$i"]:""
270 ;
271 $march_price=(isset($p_array["e_march".$i."_price"]))?$p_array["e_march".$i."_price"]:""
272 ;
273 if ( $flag_tva=='Y')
274 {
275 $march_tva_id=(isset($p_array["e_march$i"."_tva_id"]))?$p_array["e_march$i"."_tva_id"]:"";
276 $march_tva_amount=(isset($p_array["e_march$i"."_tva_amount"]))?$p_array["e_march$i"."_tva_amount"]:"";
277 }
278 $march_label=(isset($p_array["e_march".$i."_label"]))?$p_array["e_march".$i."_label"]:"";
279
280 // retrieve the tva label and name
281 //--
282 if ( noalyss_strlentrim($march)!=0 && noalyss_strlentrim($march_label)==0)
283 {
284 $fMarch=new Fiche($ledger->db);
285 $fMarch->get_by_qcode($march);
286 $march_label=$fMarch->strAttribut(ATTR_DEF_NAME);
287 if ( $flag_tva=='Y')
288 {
289 if ( ! (isset($p_array["e_march$i"."_tva_id"])))
290 $march_tva_id=$fMarch->strAttribut(ATTR_DEF_TVA);
291 }
292 }
293 // Show input
294 //--
295 $W1=new ICard();
296 $W1->label="";
297 $W1->name="e_march".$i;
298 $W1->value=$march;
299 $W1->table=1;
300 $W1->set_attribute('typecard','cred');
301 $W1->set_dblclick("fill_ipopcard(this);");
302 $W1->set_attribute('ipopup','ipopcard');
303
304 // name of the field to update with the name of the card
305 $W1->set_attribute('label','e_march'.$i.'_label');
306 // name of the field with the price
307 $W1->set_attribute('price','e_march'.$i.'_price');
308 // name of the field with the TVA_ID
309 $W1->set_attribute('tvaid','e_march'.$i.'_tva_id');
310 // Add the callback function to filter the card on the jrn
311 $W1->set_callback('filter_card');
312 $W1->set_function('fill_data');
313 $W1->javascript=sprintf(' onchange="fill_data_onchange(\'%s\');" ',
314 $W1->name);
315
316 $W1->readonly=false;
317
318 $array[$i]['quick_code']=$W1->input();
319 $array[$i]['bt']=$W1->search();
320 // For computing we need some hidden field for holding the value
321 $array[$i]['hidden']='';
322 if ( $flag_tva=='Y') $array[$i]['hidden'].=HtmlInput::hidden('tva_march'.$i,0);
323
324 $htva=new INum('htva_march'.$i);
325 $htva->readOnly=1;
326 $htva->value=0;
327 $array[$i]['htva']=$htva->input();
328
329 if ( $g_parameter->MY_TVA_USE=='Y')
330 $tvac=new INum('tvac_march'.$i);
331 else
332 $tvac=new IHidden('tvac_march'.$i);
333
334 $tvac->readOnly=1;
335 $tvac->value=0;
336 $array[$i]['tvac']=$tvac->input();
337
338 if ( $g_parameter->MY_UPDLAB == 'Y')
339 {
340 $Span=new IText("e_march".$i."_label");
341
342 $Span->css_size="100%";
343 } else
344 {
345 $Span=new ISpan("e_march".$i."_label");
346 }
347 $Span->value=$march_label;
348 $Span->setReadOnly(false);
349 // card's name, price
350 //--
351 $array[$i]['denom']=$Span->input("e_march".$i."_label",$march_label);
352 // price
353 $Price=new INum();
354 $Price->setReadOnly(false);
355 $Price->prec=4;
356 $Price->size=9;
357 $Price->javascript="onBlur='format_number(this);clean_tva($i);compute_ledger($i)'";
358 $array[$i]['pu']=$Price->input("e_march".$i."_price",$march_price);
359 $array[$i]['tva']='';
360 $array[$i]['amount_tva']='';
361 // if tva is not needed then no tva field
362 if ( $flag_tva == 'Y' )
363 {
364 // vat label
365 //--
366 $Tva=new ITva_Popup($ledger->db);
367 $Tva->in_table=true;
368 $Tva->set_attribute('compute',$i);
369
370 $Tva->js='onblur="format_number(this);clean_tva('.$i.');compute_ledger('.$i.')"';
371 $Tva->value=$march_tva_id;
372 $array[$i]['tva']=$Tva->input("e_march$i"."_tva_id");
373 // vat amount
374 //--
375 $wTva_amount=new INum();
376 $wTva_amount->readOnly=false;
377 $wTva_amount->size=6;
378 $wTva_amount->javascript="onBlur='format_number(this);compute_ledger($i)'";
379 $array[$i]['amount_tva']=$wTva_amount->input("e_march".$i."_tva_amount",$march_tva_amount);
380 }
381 // quantity
382 //--
383 $quant=(isset($p_array["e_quant$i"]))?$p_array["e_quant$i"]:"1"
384 ;
385 $Quantity=new INum();
386 $Quantity->setReadOnly(false);
387 $Quantity->prec=4;
388 $Quantity->size=8;
389 $Quantity->javascript="onChange='format_number(this);clean_tva($i);compute_ledger($i)'";
390 $array[$i]['quantity']=$Quantity->input("e_quant".$i,$quant);
391
392 }// foreach article
393 $f_type=_('Client');
394
395
396 ob_start();
397 require_once NOALYSS_TEMPLATE.'/predf_ledger_detail.php';
398 $r.=ob_get_contents();
399 ob_end_clean();
400
401
402
403 // Set correctly the REQUEST param for jrn_type
404 $r.=HtmlInput::hidden('jrn_type','VEN');
406
407 return $r;
408 }
noalyss_strlentrim($p_string)
Definition: ac_common.php:1549
global $g_parameter
global $g_user
if no group available , then stop
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
if(!headers_sent())
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...
Handle the ledger of sold,.
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Definition: fiche.class.php:38
static ledger_add_item($p_ledger)
Build a HTML string for adding multiple rows.
static hidden($p_name, $p_value, $p_id="")
Html Input.
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
Html Input.
This class handles only the numeric input, the input will call a javascript to change comma to period...
Definition: inum.class.php:42
Html Input.
Definition: ispan.class.php:32
Html Input.
Definition: itext.class.php:30
let you choose a TVA in a popup
const ATTR_DEF_ADRESS
Definition: constant.php:223
const ATTR_DEF_NAME
Definition: constant.php:216
const ATTR_DEF_CP
Definition: constant.php:224
const ATTR_DEF_TVA
Definition: constant.php:221
const ATTR_DEF_CITY
Definition: constant.php:229
const FICADD
$SecUser db

References $array, $fiche, $g_parameter, $g_user, $i, $ledger, $max, $min, $p_array, $r, ATTR_DEF_ADRESS, ATTR_DEF_CITY, ATTR_DEF_CP, ATTR_DEF_NAME, ATTR_DEF_TVA, db, FICADD, HtmlInput\hidden(), if, Html_Input_Noalyss\ledger_add_item(), and noalyss_strlentrim().

+ Here is the call graph for this function:

◆ get_post()

Pre_op_ven::get_post ( )

get the post and stove them into data member , before saving them in the db

See also
save

Definition at line 40 of file pre_op_ven.class.php.

41 {
42 $http=new \HttpInput();
43 $nb=$http->post("nb_item","number");
44 $this->e_client=$http->post("e_client");
45 for ($i=0;$i< $nb;$i++)
46 {
47 $march="e_march".$i;
48 $http->set_empty("");
49 $this->$march=$http->post('e_march'.$i);
50 $this->{"e_march".$i."_tva_id"}=$http->post('e_march'.$i."_tva_id","string",0);
51 $this->{"e_march" . $i . "_tva_id"} =(empty($this->{"e_march" . $i . "_tva_id"}))?0:$this->{"e_march" . $i . "_tva_id"} ;
52
53 $this->{"e_march".$i."_label"}=$http->post('e_march'.$i."_label","string","");
54
55 $http->set_empty(0);
56 $this->{"e_march".$i."_price"}=$http->post('e_march'.$i."_price","number");
57 $this->{"e_march".$i."_tva_amount"}=$http->post('e_march'.$i."_tva_amount","number","0");
58
59 $this->{"e_quant".$i}=$http->post('e_quant'.$i,"number");
60 }
61 }

References $http, $i, and $nb.

◆ load()

Pre_op_ven::load (   $p_od_id)

load the data from the database and return an array

Returns
an array

Definition at line 144 of file pre_op_ven.class.php.

145 {
146 $sql="select opd_id,opd_poste,opd_amount,opd_tva_id,opd_debit,".
147 " opd_quantity , opd_comment,opd_tva_amount from op_predef_detail where od_id= $1 ".
148 " order by opd_id";
149 $res=$this->db->exec_sql($sql,[$p_od_id]);
151 if ($res == false) return array();
152 return $array;
153 }
static fetch_all($ret)
wrapper for the function pg_fetch_all

References $array, $res, $sql, db, and DatabaseCore\fetch_all().

Referenced by compute_array().

+ Here is the call graph for this function:

◆ save()

Pre_op_ven::save (   $p_od_id,
  $p_nb_item 
)

save the detail and op in the database

Definition at line 66 of file pre_op_ven.class.php.

67 {
68 try
69 {
70 // save the client
71 $sql=sprintf('insert into op_predef_detail (od_id,opd_poste,opd_debit)'.
72 ' values '.
73 "(%d,'%s','%s')",
74 $p_od_id,
75 $this->e_client,
76 "t");
77 $this->db->exec_sql($sql);
78 for ($i=0;$i<$p_nb_item;$i++)
79 {
80 if ( noalyss_strlentrim($this->{"e_march".$i})== 0 ) continue;
81 $sql= 'insert into op_predef_detail (opd_poste,'
82 . 'opd_amount,'
83 . 'opd_tva_id,'
84 . 'opd_quantity,'
85 . 'opd_debit,'
86 . 'od_id ,'
87 . 'opd_tva_amount,'
88 . 'opd_comment'.
89 ')'.
90 ' values ($1,$2,$3,$4,$5,$6,$7,$8)';
91 $this->db->exec_sql($sql,
92 array($this->{"e_march".$i},
93 $this->{"e_march".$i."_price"},
94 $this->{"e_march".$i."_tva_id"},
95 $this->{"e_quant".$i},
96 'f',
97 $p_od_id,
98 $this->{"e_march".$i."_tva_amount"},
99 $this->{"e_march".$i."_label"},
100 ));
101 }
102 }
103 catch (Exception $e)
104 {
105 record_log("PREOPVEN01".$e->getMessage().$e->getTraceAsString());
106 throw $e;
107 }
108 }
record_log($p_message)
Record an error message into the log file of the server.
Definition: ac_common.php:1342

References $e, $i, $sql, db, noalyss_strlentrim(), and record_log().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: