noalyss  Version-6.9.1.8
 All Data Structures Namespaces Files Functions Variables Pages
class_acc_operation.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 this file match the tables jrn & jrnx the purpose is to
24  * remove or save accountant writing to these table.
25  */
26 require_once NOALYSS_INCLUDE.'/class/class_user.php';
27 require_once NOALYSS_INCLUDE.'/class/class_acc_ledger.php';
28 
29 /*!
30  * \brief this file match the tables jrn & jrnx the purpose is to
31  * remove or save accountant writing to these table.
32  *
33  */
35 {
36  var $db; /*!< database connx */
37  var $jr_id; /*!< pk of jrn */
38  var $jrn_id; /*!< jrn_def_id */
39  var $debit; /*!< debit or credit */
40  var $user; /*!< current user */
41  var $jrn; /*!< the ledger to use */
42  var $poste; /*!< account */
43  var $date; /*!< the date */
44  var $periode; /*!< periode to use */
45  var $amount; /*!< amount of the operatoin */
46  var $grpt; /*!< the group id */
48  /*!
49  * \brief constructor set automatically the attributes user and periode
50  * \param $p_cn the databse connection
51  */
52  function __construct($p_cn)
53  {
54  global $g_user;
55  $this->db=$p_cn;
56  $this->qcode="";
57  $this->user=$_SESSION['g_user'];
58  $this->periode=$g_user->get_periode();
59  $this->jr_id=0;
60  }
61  /**
62  *@brief retrieve the grpt_id from jrn for a jr_id
63  *@return jrn.jr_grpt_id or an empty string if not found
64  */
65  function seek_group()
66  {
67  $ret=$this->db->get_value('select jr_grpt_id from jrn where jr_id=$1',
68  array($this->jr_id));
69  return $ret;
70  }
71  /**
72  *@brief Insert into the table Jrn
73  *The needed data are :
74  * - this->date
75  * - this->amount
76  * - this->poste
77  * - this->grpt
78  * - this->jrn
79  * - this->type ( debit or credit)
80  * - this->user
81  * - this->periode
82  * - this->qcode
83  * - this->desc optional
84  *@note if the amount is less than 0 then side changes, for example debit becomes
85  *a credit and vice versa
86  *@return jrnx.j_id
87  */
88 
89  function insert_jrnx()
90  {
91  if ( $this->poste == "") { throw new Exception (__FILE__.':'.__LINE__.' Poste comptable vide');return false; }
92  /* for negative amount the operation is reversed */
93  if ( $this->amount < 0 )
94  {
95  $this->type=($this->type=='d')?'c':'d';
96  }
97  $this->amount=abs($this->amount);
98  $debit=($this->type=='c')?'false':'true';
99  $this->desc=(isset($this->desc))?$this->desc:'';
100  $Res=$this->db->exec_sql("select insert_jrnx
101  ($1::text,abs($2)::numeric,$3::account_type,$4::integer,$5::integer,$6::bool,$7::text,$8::integer,upper($9),$10::text)",
102  array(
103  $this->date, //$1
104  round($this->amount,2), //$2
105  $this->poste, //$3
106  $this->grpt, //$4
107  $this->jrn, //$5
108  $debit, //$6
109  $this->user, //$7
110  $this->periode, //$8
111  $this->qcode, // $9
112  $this->desc)); //$10
113  if ( $Res===false) return $Res;
114  $this->jrnx_id=$this->db->get_current_seq('s_jrn_op');
115  return $this->jrnx_id;
116 
117  }
118  /*!\brief set the pj of a operation in jrn. the jr_id must be set
119  *\note if the jr_id it fails
120  */
121  function set_pj()
122  {
123  if ( strlen(trim($this->pj)) == 0 )
124  {
125  $sql="update jrn set jr_pj_number=$1 where jr_id=$2";
126  $this->db->exec_sql($sql,array(null,$this->jr_id));
127  return '';
128  }
129  /* is pj uniq ? */
130  if ( $this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
131  array($this->pj,$this->jrn)
132  ) == 0 )
133  {
134  $sql="update jrn set jr_pj_number=$1 where jr_id=$2";
135  $this->db->exec_sql($sql,array($this->pj,$this->jr_id));
136  }
137  else
138  {
139  /* get pref */
140  $pref=$this->db->get_value("select jrn_def_pj_pref from jrn_def where jrn_def_id=$1",
141  array($this->jrn));
142  /* try another seq */
143  $flag=0;
144  $limit=100;
145  while ( $flag == 0 )
146  {
147  /* limit the search to $limit */
148  if ( $limit < 1 )
149  {
150  $this->pj='';
151  $flag=2;
152  break;
153  }
154 
155  $seq=$this->db->get_next_seq('s_jrn_pj'.$this->jrn);
156  $this->pj=$pref.$seq;
157 
158  /* check if the new pj numb exist */
159  $c=$this->db->count_sql("select jr_id from jrn where jr_pj_number=$1 and jr_def_id=$2",
160  array($this->pj,$this->jrn)
161  );
162  if ( $c == 0 )
163  {
164  $flag=1;
165  break;
166  }
167  $limit--;
168  }
169  /* a pj numb is found */
170  if ( $flag == 1 )
171  {
172  $sql="update jrn set jr_pj_number=$1 where jr_id=$2";
173  $this->db->exec_sql($sql,array($this->pj,$this->jr_id));
174  }
175  }
176  return $this->pj;
177  }
178 
179  /*!
180  *\brief Insert into the table Jrn, the amount is computed from jrnx thanks the
181  * group id ($p_grpt)
182  *
183  * \return sequence of jr_id
184  *
185  */
186 
187  function insert_jrn()
188  {
189  $p_comment=$this->desc;
190 
191  $diff=$this->db->get_value("select check_balance ($1)",array($this->grpt));
192  if ( $diff != 0 )
193  {
194 
195  echo "Erreur : balance incorrecte :diff = $diff";
196  return false;
197  }
198 
199  $echeance=( isset( $this->echeance) && strlen(trim($this->echeance)) != 0)?$this->echeance:null;
200  if ( ! isset($this->mt) )
201  {
202  $this->mt=microtime(true);
203  }
204  // if amount == -1then the triggers will throw an error
205  //
206  $Res=$this->db->exec_sql("insert into jrn (jr_def_id,jr_montant,jr_comment,".
207  "jr_date,jr_ech,jr_grpt_id,jr_tech_per,jr_mt) values (".
208  "$1,$2,$3,".
209  "to_date($4,'DD.MM.YYYY'),to_date($5,'DD.MM.YYYY'),$6,$7,$8)",
210  array ($this->jrn, $this->amount,$p_comment,
211  $this->date,$echeance,$this->grpt,$this->periode,$this->mt)
212  );
213  if ( $Res == false) return false;
214  $this->jr_id=$this->db->get_current_seq('s_jrn');
215  return $this->jr_id;
216  }
217  /*!
218  * \brief Return the internal value, the property jr_id must be set before
219  *
220  * \return null si aucune valeur de trouv
221  *
222  */
223  function get_internal()
224  {
225  if ( ! isset($this->jr_id) )
226  throw new Exception('jr_id is not set',1);
227  $Res=$this->db->exec_sql("select jr_internal from jrn where jr_id=".$this->jr_id);
228  if ( Database::num_row($Res) == 0 ) return null;
229  $l_line=Database::fetch_array($Res);
230  $this->jr_internal= $l_line['jr_internal'];
231  return $this->jr_internal;
232  }
233  /*!\brief search an operation thankx it internal code
234  * \param internal code
235  * \return 0 ok -1 nok
236  */
237  function seek_internal($p_internal)
238  {
239  $res=$this->db->exec_sql('select jr_id from jrn where jr_internal=$1',
240  array($p_internal));
241  if ( Database::num_row($Res) == 0 ) return -1;
242  $this->jr_id=Database::fetch_result($Res,0,0);
243  return 0;
244  }
245  /*!\brief retrieve data from jrnx
246  *\note the data are filtered by the access of the current user
247  * \return an array
248  */
249  function get_jrnx_detail()
250  {
251  global $g_user;
252  $filter_sql=$g_user->get_ledger_sql('ALL',3);
253  $filter_sql=str_replace('jrn_def_id','jr_def_id',$filter_sql);
254  if ( $this->jr_id==0 ) return;
255  $sql=" select jr_date,j_qcode,j_poste,j_montant,jr_internal,case when j_debit = 'f' then 'C' else 'D' end as debit,jr_comment as description,
256  vw_name,pcm_lib,j_debit,coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter,jr_def_id ".
257  " from jrnx join jrn on (jr_grpt_id=j_grpt)
258  join tmp_pcmn on (j_poste=pcm_val)
259  left join vw_fiche_attr on (j_qcode=quick_code)
260  where
261  jr_id=$1 and $filter_sql order by j_debit desc";
262  $res=$this->db->exec_sql($sql,array($this->jr_id));
263  if ( Database::num_row ($res) == 0 ) return array();
265  return $all;
266  }
267  /*!\brief add a comment to the line (jrnx.j_text) */
268  function update_comment($p_text)
269  {
270  $sql="update jrnx set j_text=$1 where j_id=$2";
271  $this->db->exec_sql($sql,array($p_text,$this->jrnx_id));
272  }
273  /*!\brief add a comment to the operation (jrn.jr_text) */
274  function operation_update_comment($p_text)
275  {
276  $sql="update jrn set jr_comment=$1 where jr_id=$2";
277  $this->db->exec_sql($sql,array($p_text,$this->jr_id));
278  }
279  /*!\brief add a limit of payment to the operation (jrn.jr_ech) */
280  function operation_update_date_limit($p_text)
281  {
282  if ( isDate($p_text) == null )
283  {
284  $p_text=null;
285  }
286  $sql="update jrn set jr_ech=to_date($1,'DD.MM.YYYY') where jr_id=$2";
287  $this->db->exec_sql($sql,array($p_text,$this->jr_id));
288  }
289  /*!\brief return the jrn_def_id from jrn */
290  function get_ledger()
291  {
292  $sql="select jr_def_id from jrn where jr_id=$1";
293  $row=$this->db->get_value($sql,array($this->jr_id));
294  return $row;
295  }
296  /*!\brief display_jrnx_detail : get the data from get_jrnx_data and
297  return a string with HTML code
298  * \param table(=0 no code for table,1 code for table,2 code for CSV)
299 
300  */
301  function display_jrnx_detail($p_table)
302  {
303  $show=$this->get_jrnx_detail();
304 
305  $r='';
306  $r_notable='';
307  $csv="";
308  foreach ($show as $l)
309  {
310  $border="";
311  if ( $l['j_poste'] == $this->poste || ($l['j_qcode']==$this->qcode && trim($this->qcode) != ''))
312  $border=' class="highlight"';
313  $r.='<tr '.$border.'>';
314  $r.='<td>';
315  $a=$l['j_qcode'];
316 
317  $r_notable.=$a;
318  $r.=$a;
319  $csv.='"'.$a.'";';
320  $r.='</td>';
321 
322  $r.='<td '.$border.'>';
323  $a=$l['j_poste'];
324  $r_notable.=$a;
325  $r.=$a;
326  $csv.='"'.$a.'";';
327  $r.='</td>';
328 
329  $r.='<td '.$border.'>';
330  // $a=($l['vw_name']=="")?$l['j_qcode']:$l['pcm_lib'];
331  $a=(strlen(trim($l['j_qcode']))==0)?$l['pcm_lib']:$l['vw_name'];
332  $r_notable.=$a;
333  $r.=h($a);
334  $csv.='"'.$a.'";';
335  $r.='</td>';
336 
337  $r.='<td '.$border.'>';
338  $a=$l['j_montant'];
339  $r_notable.=$a;
340  $r.=$a;
341  $csv.=$a.';';
342  $r.='</td>';
343 
344  $r.='<td '.$border.'>';
345  $a=$l['debit'];
346  $r_notable.=$a;
347  $r.=$a;
348  $csv.='"'.$a.'"';
349 
350  $csv.="\r\n";
351  $r.='</td>';
352  $r.='<td '.$border.'>';
353  $a=($l['letter']!=-1)?$l['letter']:'';
354  $r_notable.=$a;
355  $r.=$a;
356  $csv.='"'.$a.'"';
357 
358  $csv.="\r\n";
359  $r.='</td>';
360 
361 
362  $r.='</tr>';
363  }
364  switch ($p_table)
365  {
366  case 1:
367  return $r;
368  break;
369  case 0:
370  return $r_notable;
371  break;
372  case 2:
373  return $csv;
374  }
375  return "ERROR PARAMETRE";
376  }
377  /*!
378  * @brief Get data from jrnx where p_grpt=jrnx(j_grpt)
379  *
380  * @param connection
381  * @return array of 3 elements
382  * - First Element is an array
383  @verbatim
384  Array
385  (
386  [op_date] => 01.12.2009
387  [class_cred0] => 7000008
388  [mont_cred0] => 8880.0000
389  [op_cred0] => 754
390  [text_cred0] =>
391  [jr_internal] => 23VEN-01-302
392  [comment] =>
393  [ech] =>
394  [jr_id] => 302
395  [jr_def_id] => 2
396  [class_deb0] => 4000005
397  [mont_deb0] => 10744.8000
398  [text_deb0] =>
399  [op_deb0] => 755
400  [class_cred1] => 4511
401  [mont_cred1] => 1864.8000
402  [op_cred1] => 756
403  [text_cred1] =>
404  )
405  @endverbatim
406  * - Second : number of line with debit
407  * - Third : number of line with credit
408  */
409  function get_data ($p_grpt)
410  {
411  $Res=$this->db->exec_sql("select
412  to_char(j_date,'DD.MM.YYYY') as j_date,
413  j_text,
414  j_debit,
415  j_poste,
416  coalesce(j_qcode,'-') as qcode,
417  j_montant,
418  j_id,
419  jr_comment,
420  to_char(jr_ech,'DD.MM.YYYY') as jr_ech,
421  to_char(jr_date,'DD.MM.YYYY') as jr_date,
422  jr_id,jr_internal,jr_def_id,jr_pj
423  from jrnx inner join jrn on j_grpt=jr_grpt_id where j_grpt=$1",array($p_grpt));
424  $MaxLine=Database::num_row($Res);
425  if ( $MaxLine == 0 ) return null;
426  $deb=0;
427  $cred=0;
428  for ( $i=0; $i < $MaxLine; $i++)
429  {
430 
431  $l_line=Database::fetch_array($Res,$i);
432  $l_array['op_date']=$l_line['j_date'];
433  if ( $l_line['j_debit'] == 't' )
434  {
435  $l_class=sprintf("class_deb%d",$deb);
436  $l_montant=sprintf("mont_deb%d",$deb);
437  $l_text=sprintf("text_deb%d",$deb);
438  $l_qcode=sprintf("qcode_deb%d",$deb);
439  $l_array[$l_class]=$l_line['j_poste'];
440  $l_array[$l_montant]=$l_line['j_montant'];
441  $l_array[$l_text]=$l_line['j_text'];
442  $l_array[$l_qcode]=$l_line['qcode'];
443  $l_id=sprintf("op_deb%d",$deb);
444  $l_array[$l_id]=$l_line['j_id'];
445  $deb++;
446  }
447  if ( $l_line['j_debit'] == 'f' )
448  {
449  $l_class=sprintf("class_cred%d",$cred);
450  $l_montant=sprintf("mont_cred%d",$cred);
451  $l_array[$l_class]=$l_line['j_poste'];
452  $l_array[$l_montant]=$l_line['j_montant'];
453  $l_id=sprintf("op_cred%d",$cred);
454  $l_array[$l_id]=$l_line['j_id'];
455  $l_text=sprintf("text_cred%d",$cred);
456  $l_array[$l_text]=$l_line['j_text'];
457  $l_qcode=sprintf("qcode_cred%d",$cred);
458  $l_array[$l_qcode]=$l_line['qcode'];
459  $cred++;
460  }
461  $l_array['jr_internal']=$l_line['jr_internal'];
462  $l_array['comment']=$l_line['jr_comment'];
463  $l_array['ech']=$l_line['jr_ech'];
464  $l_array['jr_id']=$l_line['jr_id'];
465  $l_array['jr_def_id']=$l_line['jr_def_id'];
466  }
467  return array($l_array,$deb,$cred);
468  }
469  /**
470  *@brief retrieve data from jrnx and jrn
471  *@return return an object
472  *@note
473  *@see
474  @code
475 
476  @endcode
477  */
478  function get()
479  {
480  $ret=new Acc_Misc($this->db,$this->jr_id);
481  $ret->get();
482  return $ret;
483  }
484  /**
485  *@brief retrieve data from the table QUANT_*
486  *@return return an object or null if there is no
487  * data from the QUANT table
488  *@see Acc_Sold Acc_Purchase Acc_Fin Acc_Detail Acc_Misc
489  */
490  function get_quant()
491  {
492  $ledger_id=$this->get_ledger();
493  if ( $ledger_id=='') throw new Exception(_('Journal non trouvĂ©'));
494  $oledger=new Acc_Ledger($this->db,$ledger_id);
495 
496  // retrieve info from jrn_info
497 
498 
499  switch($oledger->get_type())
500  {
501  case 'VEN':
502  $ret=new Acc_Sold($this->db,$this->jr_id);
503  break;
504  case 'ACH':
505  $ret=new Acc_Purchase($this->db,$this->jr_id);
506  break;
507  case 'FIN':
508  $ret=new Acc_Fin($this->db,$this->jr_id);
509  break;
510  default:
511  $ret=new Acc_Misc($this->db,$this->jr_id);
512  break;
513  }
514  $ret->get();
515  if ( empty($ret->det->array))
516  {
517  $ret=new Acc_Misc($this->db,$this->jr_id);
518  $ret->get();
519  }
520  $ret->get_info();
521  return $ret;
522  }
523  /**
524  * @brief retrieve info from the jrn_info, create 2 new arrays
525  * obj->info->command and obj->info->other
526  * the columns are the idx
527  */
528  function get_info()
529  {
530  $this->info=new stdClass();
531  // other info
532  $array=$this->db->get_value("select ji_value from jrn_info where
533  jr_id=$1 and id_type=$2",array($this->jr_id,'OTHER'));
534  $this->info->other= $array;
535 
536  // Bon de commande
537  $array=$this->db->get_value("select ji_value from jrn_info where
538  jr_id=$1 and id_type=$2",array($this->jr_id,'BON_COMMANDE'));
539  $this->info->command= $array;
540 
541  }
542  /**
543  * Save into jrn_info
544  * @param $p_info msg to save
545  * @param $p_type is OTHER or BON_COMMAND
546  */
547  function save_info($p_info,$p_type)
548  {
549  if ( ! in_array($p_type,array('OTHER','BON_COMMANDE'))) return;
550  if (trim($p_info)=="") {
551  $this->db->exec_sql('delete from jrn_info where jr_id=$1 and id_type=$2',array($this->jr_id,$p_type));
552  return;
553  }
554  $exist=$this->db->get_value('select count(ji_id) from jrn_info where jr_id=$1 and id_type=$2',array($this->jr_id,$p_type));
555  if ( $exist == "0" ) {
556  //insert into jrn_info
557  $this->db->exec_sql('insert into jrn_info(jr_id,id_type,ji_value) values ($1,$2,$3)',
558  array($this->jr_id,$p_type,$p_info));
559  } elseif ( $exist == 1) {
560  //update
561  $this->db->exec_sql('update jrn_info set ji_value=$3 where jr_id=$1 and id_type=$2',
562  array($this->jr_id,$p_type,$p_info));
563  }
564  }
565 
566  function insert_related_action($p_string)
567  {
568  if ($p_string == "") return;
569  $a_action=explode(',',$p_string);
570  for ($i=0;$i<count($a_action);$i++)
571  {
572  $action = new Follow_Up($this->db,$a_action[$i]);
573  $action->operation=$this->jr_id;
574  $action->insert_operation();
575  }
576  }
577  /**
578  *
579  * @param type $p_id
580  */
581  function set_id($p_id)
582  {
583  if (isNumber($p_id)==0) {
584  throw new Exception(_('Acc_Operation::set_id , id invalide '));
585  }
586  $this->jr_id=$p_id;
587  }
588  /**
589  * \brief flag the operation as paid
590  */
591  function set_paid()
592  {
593  // Operation
594  if ( $this->jr_id == 0 )
595  throw new Exception(_('Object invalide, id incorrect'));
596  if (
597  $this->db->get_value('select count(*) from jrn where jr_id=$1',
598  array($this->jr_id)) == 0 )
599  throw new Exception(_('Object invalide, id incorrect'));
600 
601  $this->db->exec_sql("update jrn set jr_rapt = 'paid' where jr_id = $1",
602  array($this->jr_id));
603  }
604  /**
605  * return amount of the jr_id
606  */
607  function get_amount()
608  {
609  if ( $this->jr_id == 0 )
610  throw new Exception(_('Object invalide, id incorrect'));
611  $amount=$this->db->get_value('select jr_montant from jrn where jr_id=$1',
612  array($this->jr_id));
613  return $amount;
614  }
615  static function test_me()
616  {
617  $_SESSION['g_user']=NOALYSS_ADMINISTRATOR;
618  $_SESSION['g_pass']='dany';
619  global $g_user;
621  $g_user=new User($cn);
622  $a=new Acc_Operation($cn);
623  $a->jr_id=1444;
624  $b=$a->get_quant();
625  var_dump($b);
626  }
627 }
628 /////////////////////////////////////////////////////////////////////////////
630 {
631  function __construct($p_cn,$p_jrid=0)
632  {
633  parent::__construct($p_cn);
634  $this->jr_id=$p_jrid;
635  $this->det=new stdClass();
636  }
637  /**
638  *@brief retrieve some common data from jrn as
639  * the datum, the comment,payment limit...
640  */
641  function get()
642  {
643  $sql="SELECT jr_id, jr_def_id, jr_montant, jr_comment, jr_date, jr_grpt_id,
644  jr_internal, jr_tech_date, jr_tech_per, jrn_ech, jr_ech, jr_rapt,jr_ech,
645  jr_valid, jr_opid, jr_c_opid, jr_pj, jr_pj_name, jr_pj_type,
646  jr_pj_number, jr_mt,jr_rapt,jr_date_paid
647  FROM jrn where jr_id=$1";
648  $array=$this->db->get_array($sql,array($this->jr_id));
649  if ( count($array) == 0 ) throw new Exception('Aucune ligne trouvĂ©e');
650  foreach ($array[0] as $key=>$val)
651  {
652  $this->det->$key=$val;
653  }
654  $sql="select n_text from jrn_note where jr_id=$1";
655  $this->det->note=$this->db->get_value($sql,array($this->jr_id));
656  $this->det->note=strip_tags($this->det->note);
657  }
658 }
659 /////////////////////////////////////////////////////////////////////////////
660 /**
661  *@brief this class manage data from the JRNX and JRN
662  * table
663  *@note Data member are the column of the table
664  */
665 class Acc_Misc extends Acc_Detail
666 {
667  var $signature; /*!< signature of the obj ODS */
668  var $array; /*!< an array containing the data from JRNX */
669  function __construct($p_cn,$p_jrid=0)
670  {
671  parent::__construct($p_cn,$p_jrid);
672  $this->signature='ODS';
673  $this->det=new stdClass();
674  }
675  function get()
676  {
677  parent::get();
678  $sql="SELECT j_id, j_date, j_montant, j_poste, j_grpt, j_rapt, j_jrn_def,
679  j_debit, j_text, j_centralized, j_internal, j_tech_user, j_tech_date,
680  j_tech_per, j_qcode,f_id
681  FROM jrnx where j_grpt = $1 order by j_debit desc,j_poste";
682  $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
683  }
684 }
685 /////////////////////////////////////////////////////////////////////////////
686 /**
687  *@brief this class manage data from the QUANT_SOLD
688  * table
689  *@note Data member are the column of the table
690  */
691 class Acc_Sold extends Acc_Detail
692 {
693  function __construct($p_cn,$p_jrid=0)
694  {
695  parent::__construct($p_cn,$p_jrid);
696  $this->signature='VEN';
697  $this->det=new stdClass();
698  }
699  function get()
700  {
701  parent::get();
702  $sql="SELECT qs_id, qs_internal, qs_fiche, qs_quantite, qs_price, qs_vat,
703  qs_vat_code, qs_client, qs_valid, j_id,j_text,qs_vat_sided , qs_unit , j_debit
704  FROM quant_sold join jrnx using(j_id) where j_grpt=$1";
705  $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
706  }
707 
708 }
709 /////////////////////////////////////////////////////////////////////////////
710 /**
711  *@brief this class manage data from the QUANT_PURCHASE
712  * table
713  *@note Data member are the column of the table
714 
715  */
717 {
718  function __construct($p_cn,$p_jrid=0)
719  {
720  parent::__construct($p_cn,$p_jrid);
721  $this->signature='ACH';
722  }
723 
724  function get()
725  {
726  parent::get();
727  $sql="SELECT qp_id, qp_internal, j_id, qp_fiche, qp_quantite, qp_price, qp_vat,
728  qp_vat_code, qp_nd_amount, qp_nd_tva, qp_nd_tva_recup, qp_supplier,
729  qp_valid, qp_dep_priv,j_text,qp_vat_sided,qp_unit , j_debit
730  FROM quant_purchase join jrnx using(j_id) where j_grpt=$1";
731  $this->det->array=$this->db->get_array($sql,array($this->det->jr_grpt_id));
732  }
733 }
734 /////////////////////////////////////////////////////////////////////////////
735 /**
736  *@brief this class manage data from the QUANT_FIN
737  * table
738  *@note Data member are the column of the table
739  */
740 class Acc_Fin extends Acc_Detail
741 {
742  function __construct($p_cn,$p_jrid=0)
743  {
744  parent::__construct($p_cn,$p_jrid);
745  $this->signature='FIN';
746  }
747 
748  function get()
749  {
750  parent::get();
751  $sql="SELECT qf_id, qf_bank, jr_id, qf_other, qf_amount
752  FROM quant_fin where jr_id = $1";
753  $this->det->array=$this->db->get_array($sql,array($this->jr_id));
754  }
755 }
static fetch_all($ret)
wrapper for the function pg_fetch_all
get_internal()
Return the internal value, the property jr_id must be set before.
get_ledger()
return the jrn_def_id from jrn
$bal jrn
$action
seek_group()
retrieve the grpt_id from jrn for a jr_id
this class manage data from the JRNX and JRN table
static num_row($ret)
wrapper for the function pg_NumRows
__construct($p_cn, $p_jrid=0)
this class manage data from the QUANT_PURCHASE table
Data & function about connected users.
Definition: class_user.php:36
__construct($p_cn)
constructor set automatically the attributes user and periode
insert_jrn()
Insert into the table Jrn, the amount is computed from jrnx thanks the group id ($p_grpt) ...
operation_update_date_limit($p_text)
add a limit of payment to the operation (jrn.jr_ech)
isNumber(&$p_int)
Definition: ac_common.php:202
this class manage data from the QUANT_FIN table
set_pj()
set the pj of a operation in jrn. the jr_id must be set
__construct($p_cn, $p_jrid=0)
display_jrnx_detail($p_table)
display_jrnx_detail : get the data from get_jrnx_data and return a string with HTML code ...
get_jrnx_detail()
retrieve data from jrnx
get_data($p_grpt)
Get data from jrnx where p_grpt=jrnx(j_grpt)
__construct($p_cn, $p_jrid=0)
static fetch_array($ret, $p_indice=0)
wrapper for the function pg_fetch_array
class_action for manipulating actions action can be :
insert_related_action($p_string)
get_amount()
return amount of the jr_id
set_paid()
flag the operation as paid
for($i=0;$i<$nb_jrn;$i++) $deb
global $g_user
Find the default module or the first one.
Definition: action.inc.php:24
Class for jrn, class acc_ledger for manipulating the ledger.
$input_from user
Definition: balance.inc.php:73
function trim(s)
remove trailing and heading space
Definition: scripts.js:95
seek_internal($p_internal)
search an operation thankx it internal code
get_info()
retrieve info from the jrn_info, create 2 new arrays obj->info->command and obj->info->other the colu...
$all
save_info($p_info, $p_type)
Save into jrn_info.
h($p_string)
to protect again bad characters which can lead to a cross scripting attack the string to be diplayed ...
Definition: ac_common.php:38
this file match the tables jrn & jrnx the purpose is to remove or save accountant writing to these ta...
this class manage data from the QUANT_SOLD table
static fetch_result($ret, $p_row=0, $p_col=0)
wrapper for the function pg_fetch_all
isDate($p_date)
Definition: ac_common.php:223
$input_from type
Definition: balance.inc.php:70
static connect()
for($j=0;$j< $nb_row;$j++)($j%2==0)?'even' $show
$limit
Definition: dashboard.php:157
$SecUser db
__construct($p_cn, $p_jrid=0)
__construct($p_cn, $p_jrid=0)
insert_jrnx()
Insert into the table Jrn The needed data are :
operation_update_comment($p_text)
add a comment to the operation (jrn.jr_text)
$op jr_id
Definition: ajax_ledger.php:90
update_comment($p_text)
add a comment to the line (jrnx.j_text)
get_quant()
retrieve data from the table QUANT_*