noalyss  Version-6.9.1.8
 All Data Structures Namespaces Files Functions Variables Pages
class_acc_account_ledger.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 // Copyright Author Dany De Bontridder danydb@aevalys.eu
20 /*! \file
21  * \brief Manage the account
22  */
23 /*!
24  * \brief Manage the account from the table jrn, jrnx or tmp_pcmn
25  */
26 require_once NOALYSS_INCLUDE.'/lib/class_ihidden.php';
27 require_once NOALYSS_INCLUDE.'/lib/class_database.php';
28 require_once NOALYSS_INCLUDE.'/class/class_dossier.php';
29 
31 {
32  var $db; /*!< $db database connection */
33  var $id; /*!< $id poste_id (pcm_val)*/
34  var $label; /*!< $label label of the poste */
35  var $parent; /*!< $parent parent account */
36  var $row; /*!< $row double array see get_row */
37  var $tot_deb; /*!< value set by get_row */
38  var $tot_cred; /*!< value by get_row */
39  function __construct ($p_cn,$p_id)
40  {
41  $this->db=$p_cn;
42  $this->id=$p_id;
43  }
44  /**
45  *@brief get the row thanks the resource
46  *@return double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal)
47  * (tot_deb,tot_credit)
48  */
49  private function get_row_sql($Res)
50  {
51  $array=array();
52  $tot_cred=0.0;
53  $tot_deb=0.0;
55  if ( $Max == 0 ) return null;
56  for ($i=0;$i<$Max;$i++)
57  {
59  if ($array[$i]['j_debit']=='t')
60  {
61  $tot_deb+=$array[$i]['deb_montant'] ;
62  }
63  else
64  {
65  $tot_cred+=$array[$i]['cred_montant'] ;
66  }
67  }
68  $this->row=$array;
69  $this->tot_deb=$tot_deb;
70  $this->tot_cred=$tot_cred;
71  return array($array,$tot_deb,$tot_cred);
72 
73  }
74  /*!
75  * \brief Get data for accounting entry between 2 periode
76  *
77  * \param $p_from periode from
78  * \param $p_to end periode
79  * \return double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal)
80  * (tot_deb,tot_credit
81  *
82  */
83  function get_row($p_from,$p_to)
84  {
85  $periode=sql_filter_per($this->db,$p_from,$p_to,'p_id','jr_tech_per');
86 
87  $Res=$this->db->exec_sql("select distinct j_id,jr_id,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,j_date,".
88  "case when j_debit='t' then j_montant else 0 end as deb_montant,".
89  "case when j_debit='f' then j_montant else 0 end as cred_montant,".
90  " jr_comment as description,jrn_def_name as jrn_name,".
91  "j_debit, jr_internal,jr_pj_number ".
92  " from jrnx left join jrn_def on jrn_def_id=j_jrn_def ".
93  " left join jrn on jr_grpt_id=j_grpt".
94  " where j_poste=".$this->id." and ".$periode.
95  " order by j_date");
96  return $this->get_row_sql($Res);
97  }
98  /*!
99  * \brief Get data for accounting entry between 2 date
100  *
101  *\param $p_from date from
102  *\param $p_to end date
103  *\param $let 0 means all rows, 1 only lettered, 2 only unlettered
104  *\param $solded 0 means all account, 1 means only accounts with a saldo <> 0
105  *\note the data are filtered by the access of the current user
106  * \return double array (j_date,deb_montant,cred_montant,description,jrn_name,j_debit,jr_internal)
107  * (tot_deb,tot_credit
108  *
109  */
110  function get_row_date($p_from,$p_to,$let=0,$solded=0)
111  {
112  global $g_user;
113  $filter_sql=$g_user->get_ledger_sql('ALL',3);
114  $sql_let='';
115  switch ($let)
116  {
117  case 0:
118  break;
119  case 1:
120  $sql_let=' and j_id in (select j_id from letter_cred union select j_id from letter_deb)';
121  break;
122  case '2':
123  $sql_let=' and j_id not in (select j_id from letter_cred union select j_id from letter_deb) ';
124  break;
125  }
126  if ( $solded == 1)
127  {
128  $filter=str_replace('jrn_def_id','jr_def_id',$filter_sql);
129  $bal_sql="select sum(amount_deb) as s_deb,sum(amount_cred) as s_cred, j_poste
130  from (select case when j_debit='t' then j_montant else 0 end as amount_deb,
131  case when j_debit='f' then j_montant else 0 end as amount_cred,
132  j_poste
133  from jrnx join jrn on (j_grpt = jr_grpt_id)
134  where
135  j_poste=$1 and
136  $filter and
137  ( to_date($2,'DD.MM.YYYY') <= j_date and
138  to_date($3,'DD.MM.YYYY') >= j_date )) as signed_amount
139  group by j_poste
140  ";
141  $r=$this->db->get_array($bal_sql,array($this->id,$p_from,$p_to));
142  if ( $this->db->count() == 0 ) return array();
143  if ($r[0]['s_deb']==$r[0]['s_cred']) return array();
144  }
145  $Res=$this->db->exec_sql("select jr_id,to_char(j_date,'DD.MM.YYYY') as j_date_fmt,j_date,".
146  "case when j_debit='t' then j_montant else 0 end as deb_montant,".
147  "case when j_debit='f' then j_montant else 0 end as cred_montant,".
148  " case when j_text is null or j_text = '' then jr_comment
149  else jr_comment||' '||j_text end
150  as description,jrn_def_name as jrn_name,".
151  "j_debit, jr_internal,jr_pj_number,
152  coalesce(comptaproc.get_letter_jnt(j_id),-1) as letter ".
153  ",pcm_lib ".
154  ",jr_tech_per,p_exercice,jrn_def_name,jrn_def_code".
155  " from jrnx left join jrn_def on (jrn_def_id=j_jrn_def )".
156  " left join jrn on (jr_grpt_id=j_grpt)".
157  " left join tmp_pcmn on (j_poste=pcm_val)".
158  " left join parm_periode on (p_id=jr_tech_per) ".
159  " where j_poste=$1 and ".
160  " ( to_date($2,'DD.MM.YYYY') <= j_date and ".
161  " to_date($3,'DD.MM.YYYY') >= j_date )".
162  " and $filter_sql $sql_let ".
163  " order by j_date,substring(jr_pj_number,'[0-9]+$') asc",array($this->id,$p_from,$p_to));
164  return $this->get_row_sql($Res);
165  }
166 
167 
168  /*!\brief Return the name of a account
169  * it doesn't change any data member
170  * \return string with the pcm_lib
171  */
172  function get_name()
173  {
174  $ret=$this->db->exec_sql(
175  "select pcm_lib from tmp_pcmn where
176  pcm_val=$1",array($this->id));
177  if ( Database::num_row($ret) != 0)
178  {
180  $this->name=$r['pcm_lib'];
181  }
182  else
183  {
184  $this->name=_("Poste inconnu");
185  }
186  return $this->name;
187  }
188  /*!\brief check if the poste exist in the tmp_pcmn
189  *\return the number of line (normally 1 or 0)
190  */
191  function do_exist()
192  {
193  $sql="select pcm_val from tmp_pcmn where pcm_val= $1";
194  $ret=$this->db->exec_sql($sql,array($this->id));
195  return Database::num_row($ret) ;
196  }
197  /*!\brief Get all the value for this object from the database
198  * the data member are set
199  * \return false if this account doesn't exist otherwise true
200  */
201  function load()
202  {
203  $ret=$this->db->exec_sql("select pcm_lib,pcm_val_parent from
204  tmp_pcmn where pcm_val=$1",array($this->id));
206 
207  if ( ! $r ) return false;
208  $this->label=$r[0]['pcm_lib'];
209  $this->parent=$r[0]['pcm_val_parent'];
210  return true;
211 
212  }
213  /*!\brief Get all the value for this object from the database
214  * the data member are set
215  * \return false if this account doesn't exist otherwise true
216  */
217  function get()
218  {
219  echo "OBSOLETE Acc_Account_Ledger->get(), a remplacer par Acc_Account_Ledger->load()";
220  return $this->load();
221  }
222 
223  /*!
224  * \brief give the balance of an account
225  *
226  * \return
227  * balance of the account
228  *
229  */
230  function get_solde($p_cond=" true ")
231  {
232  $Res=$this->db->exec_sql("select sum(deb) as sum_deb, sum(cred) as sum_cred from
233  ( select j_poste,
234  case when j_debit='t' then j_montant else 0 end as deb,
235  case when j_debit='f' then j_montant else 0 end as cred
236  from jrnx join tmp_pcmn on j_poste=pcm_val
237  where
238  j_poste::text like ('$this->id'::text) and
239  $p_cond
240  ) as m ");
242  if ($Max==0) return 0;
244 
245  return abs($r['sum_deb']-$r['sum_cred']);
246  }
247  /*!
248  * \brief give the balance of an account
249  * \return
250  * balance of the account
251  *
252  */
253  function get_solde_detail($p_cond="")
254  {
255 
256  if ( $p_cond != "") $p_cond=" and ".$p_cond;
257  $sql="select sum(deb) as sum_deb, sum(cred) as sum_cred from
258  ( select j_poste,
259  case when j_debit='t' then j_montant else 0 end as deb,
260  case when j_debit='f' then j_montant else 0 end as cred
261  from jrnx
262  where
263  j_poste::text like ('$this->id'::text)
264  $p_cond
265  ) as m ";
266 
267  $Res=$this->db->exec_sql($sql);
269 
270  if ($Max==0)
271  {
272  return array('debit'=>0,
273  'credit'=>0,
274  'solde'=>0) ;
275  }
277 // if p_start is < p_end the query returns null to avoid any problem
278 // we set it to 0
279  if ($r['sum_deb']=='')
280  $r['sum_deb']=0.0;
281  if ($r['sum_cred']=='')
282  $r['sum_cred']=0.0;
283 
284  return array('debit'=>$r['sum_deb'],
285  'credit'=>$r['sum_cred'],
286  'solde'=>abs(bcsub($r['sum_deb'],$r['sum_cred'])));
287  }
288  /*!
289  * \brief isTva tell is a poste is used for VAT
290  * \param none
291  *
292  *
293  * \return 1 is Yes otherwise 0
294  */
295  function isTVA()
296  {
297  // Load TVA array
298  $a_TVA=$this->db->get_array('select tva_poste
299  from tva_rate');
300  foreach ( $a_TVA as $line_tva)
301  {
302  if ( $line_tva['tva_poste'] == '' )
303  continue;
304  list($tva_deb,$tva_cred)=explode(',',$line_tva['tva_poste']);
305  if ( $this->id == $tva_deb ||
306  $this->id == $tva_cred )
307  {
308  return 1;
309  }
310  }
311  return 0;
312 
313  }
314  /*!
315  * \brief HtmlTable, display a HTML of a poste for the asked period
316  * \param $p_array array for filter
317  * \param $let lettering of operation 0
318  * \return -1 if nothing is found otherwise 0
319  */
320  function HtmlTable($p_array=null,$let=0 , $from_div=0)
321  {
322  if ( $p_array==null)$p_array=$_REQUEST;
323  $this->get_name();
324  list($array,$tot_deb,$tot_cred)=$this->get_row_date( $p_array['from_periode'],
325  $p_array['to_periode'],$let
326  );
327 
328  if ( count($this->row ) == 0 )
329  return -1;
330 
331  $rep="";
332 
333 
334  if ( $from_div == 1)
335  echo "<TABLE id=\"tbpopup\" class=\"resultfooter\" style=\"border-collapse:separate;margin:1%;width:98%;;border-spacing:0px 5px\">";
336  else
337  echo "<TABLE id=\"tb".$from_div."\" class=\"resultfooter\" style=\"border-collapse:separate;margin:1%;width:98%;;border-spacing:0px 2px\">";
338  echo '<tbody>';
339  echo "<TR>".
340  "<TH style=\"text-align:left\"> Date</TH>".
341  "<TH style=\"text-align:left\"> n° de pièce </TH>".
342  "<TH style=\"text-align:left\"> Code interne </TH>".
343  "<TH style=\"text-align:left\"> Description </TH>".
344  "<TH style=\"text-align:right\"> D&eacute;bit </TH>".
345  "<TH style=\"text-align:right\"> Cr&eacute;dit </TH>".
346  th('Prog.','style="text-align:right"').
347  th('Let.','style="text-align:right"');
348  "</TR>"
349  ;
350  $progress=0;$sum_deb=0;$sum_cred=0;
351  bcscale(2);
352  $old_exercice="";
353  $idx=0;
354  foreach ( $this->row as $op )
355  {
356  $vw_operation = sprintf('<A class="detail" style="text-decoration:underline;color:red" HREF="javascript:modifyOperation(\'%s\',\'%s\')" >%s</A>', $op['jr_id'], dossier::id(), $op['jr_internal']);
357  $let = '';
358  $html_let = "";
359  if ($op['letter'] != -1)
360  {
361  $let = strtoupper(base_convert($op['letter'], 10, 36));
363  }
364  $tmp_diff=bcsub($op['deb_montant'],$op['cred_montant']);
365 
366  /*
367  * reset prog. balance to zero if we change of exercice
368  */
369  if ( $old_exercice != $op['p_exercice'])
370  {
371  if ( $old_exercice != '')
372  {
373  $progress=bcsub($sum_deb,$sum_cred);
374  $side="&nbsp;".$this->get_amount_side($progress);
375  echo "<TR class=\"highlight\">".
376  "<TD>$old_exercice</TD>".
377  td('').
378  "<TD></TD>".
379  "<TD>Totaux</TD>".
380  "<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
381  "<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
382  td(nbm(abs($progress)).$side,'style="text-align:right"').
383  td('').
384  "</TR>";
385  $sum_cred=0;
386  $sum_deb=0;
387  $progress=0;
388 
389  }
390  }
391  $progress=bcadd($progress,$tmp_diff);
392  $side="&nbsp;".$this->get_amount_side($progress);
393  $sum_cred=bcadd($sum_cred,$op['cred_montant']);
394  $sum_deb=bcadd($sum_deb,$op['deb_montant']);
395  if ($idx%2 == 0) $class='class="odd"'; else $class=' class="even"';
396  $idx++;
397 
398  echo "<TR $class name=\"tr_" . $let . "_" . $from_div . "\">" .
399  "<TD>".smaller_date(format_date($op['j_date']))."</TD>".
400  td(h($op['jr_pj_number'])).
401  "<TD>".$vw_operation."</TD>".
402  "<TD>".h($op['description'])."</TD>".
403  "<TD style=\"text-align:right\">".nbm($op['deb_montant'])."</TD>".
404  "<TD style=\"text-align:right\">".nbm($op['cred_montant'])."</TD>".
405  td(nbm(abs($progress)).$side,'style="text-align:right"').
406 
407  td($html_let, ' style="color:red;text-align:right"') .
408  "</TR>";
409  $old_exercice=$op['p_exercice'];
410  }
411  echo '<tfoot>';
412  $solde_type=($sum_deb>$sum_cred)?"solde débiteur":"solde créditeur";
413  $diff=bcsub($sum_deb,$sum_cred);
414  $side="&nbsp;".$this->get_amount_side($diff);
415  echo "<TR class=\"highlight\">".
416  "<TD >Totaux</TD><td></td>".
417  "<TD ></TD>".
418  "<TD></TD>".
419  "<TD style=\"text-align:right\">".nbm($sum_deb)."</TD>".
420  "<TD style=\"text-align:right\">".nbm($sum_cred)."</TD>".
421  "<TD style=\"text-align:right\">".nbm(abs($diff)).$side."</TD>".
422 
423  "</TR>";
424  echo "<tr><TD>$solde_type</TD><td></td>".
425  "<TD style=\"text-align:right\">".nbm(abs($diff))."</TD>".
426  "</TR>";
427  echo '</tfoot>';
428  echo '</tbody>';
429 
430  echo "</table>";
431 
432  return;
433  }
434  /**
435  * return the letter C if amount is > 0, D if < 0 or =
436  * @param type $p_amount
437  * @return string
438  */
439  function get_amount_side($p_amount)
440  {
441  if ($p_amount == 0)
442  return "=";
443  if ($p_amount < 0)
444  return "C";
445  if ($p_amount > 0)
446  return "D";
447  }
448  /*!
449  * \brief Display HTML Table Header (button)
450  *
451  * \return none
452  */
453  static function HtmlTableHeader($actiontarget="poste")
454  {
455  switch($actiontarget)
456  {
457  case 'poste':
458  $action_csv='CSV:postedetail';
459  $action_pdf='PDF:postedetail';
460  break;
461  case 'gl_comptes':
462  $action_csv='CSV:glcompte';
463  $action_pdf='PDF:glcompte';
464  break;
465  default:
466  throw new Exception(" Fonction HtmlTableHeader argument actiontarget invalid");
467  }
468  $hid=new IHidden();
469 
470  echo "<table >";
471  echo '<TR>';
472  $str_ople=(isset($_REQUEST['ople']))?HtmlInput::hidden('ople',$_REQUEST['ople']):'';
473  if ($actiontarget=='poste')
474  {
475  echo '<TD><form method="GET" ACTION="">'.
476  dossier::hidden().
477  HtmlInput::submit('bt_other',"Autre poste").
478  $hid->input("type","poste").$hid->input('ac',$_REQUEST['ac'])."</form></TD>";
479  }
480 
481 
482  echo '<TD><form method="GET" ACTION="export.php">'.
483  dossier::hidden().
484  HtmlInput::submit('bt_pdf',"Export PDF").
485  HtmlInput::hidden('act',$action_pdf).
486  $hid->input("type","poste").$str_ople.
487  $hid->input('p_action','impress').
488  $hid->input("from_periode",$_REQUEST['from_periode']).
489  $hid->input("to_periode",$_REQUEST['to_periode'])
490  ;
491 
492  if ( isset($_REQUEST['letter'] )) echo HtmlInput::hidden('letter','2');
493  if ( isset($_REQUEST['solded'] )) echo HtmlInput::hidden('solded','1');
494 
495  if (isset($_REQUEST['from_poste']))
496  echo HtmlInput::hidden('from_poste',$_REQUEST['from_poste']);
497 
498  if (isset($_REQUEST['to_poste']))
499  echo HtmlInput::hidden('to_poste',$_REQUEST['to_poste']);
500 
501  if (isset($_REQUEST['poste_id']))
502  echo HtmlInput::hidden("poste_id",$_REQUEST['poste_id']);
503 
504  if (isset($_REQUEST['poste_fille']))
505  echo $hid->input('poste_fille','on');
506  if (isset($_REQUEST['oper_detail']))
507  echo $hid->input('oper_detail','on');
508 
509  echo "</form></TD>";
510 
511  echo '<TD><form method="GET" ACTION="export.php">'.
512  dossier::hidden().
513  HtmlInput::submit('bt_csv',"Export CSV").
514  HtmlInput::hidden('act',$action_csv).
515  $hid->input("type","poste").$str_ople.
516  $hid->input('p_action','impress').
517  $hid->input("from_periode",$_REQUEST['from_periode']).
518  $hid->input("to_periode",$_REQUEST['to_periode']);
519 
520  if (isset($_REQUEST['from_poste']))
521  echo HtmlInput::hidden('from_poste',$_REQUEST['from_poste']);
522 
523  if (isset($_REQUEST['to_poste']))
524  echo HtmlInput::hidden('to_poste',$_REQUEST['to_poste']);
525 
526  if (isset($_REQUEST['poste_id']))
527  echo HtmlInput::hidden("poste_id",$_REQUEST['poste_id']);
528 
529  if ( isset($_REQUEST['letter'] )) echo HtmlInput::hidden('letter','2');
530  if ( isset($_REQUEST['solded'] )) echo HtmlInput::hidden('solded','1');
531 
532  if (isset($_REQUEST['poste_fille']))
533  echo $hid->input('poste_fille','on');
534  if (isset($_REQUEST['oper_detail']))
535  echo $hid->input('oper_detail','on');
536  if (isset($_REQUEST['poste_id'])) echo $hid->input("poste_id",$_REQUEST['poste_id']);
537 
538  echo "</form></TD>";
539  echo "</form></TD>";
540  echo '<td style="vertical-align:top">';
542  echo '</td>';
543  echo '</tr>';
544  echo "</table>";
545 
546 
547  }
548  /*!
549  * \brief verify that the accounting belong to a ledger
550  *
551  * \return 0 ok, -1 no
552  */
554  {
555  $filter=$this->db->get_value("select jrn_def_class_cred from jrn_def where jrn_def_id=$1", array($p_jrn));
556  if ( trim ($filter) == '')
557  return 0;
558 
559  $valid_cred=explode(" ",$filter);
560  $sql="select count(*) as poste from tmp_pcmn where ";
561  // Creation query
562  $or="";
563  $SqlFilter="";
564  $SqlArray = array();
565  $SqlArrayN = 1;
566  foreach ( $valid_cred as $item_cred)
567  {
568  if ( strlen (trim($item_cred)))
569  {
570  if ( strstr($item_cred,"*") == true )
571  {
572  $SqlItem=$or . 'pcm_val::text like $' . $SqlArrayN++;
573  array_push($SqlArray, strtr($item_cred,"*","%"));
574  $or=" or ";
575  }
576  else
577  {
578  $SqlItem=$or . 'pcm_val::text = $' . $SqlArrayN++;
579  array_push($SqlArray, $item_cred);
580  $or=" or ";
581  }
582  $SqlFilter=$SqlFilter.$SqlItem;
583  }
584  }//foreach
585  $sql.=$SqlFilter . ' and pcm_val::text=$' . $SqlArrayN++;
586  array_push($SqlArray, $this->id);
587  $max=$this->db->get_value($sql, $SqlArray);
588  if ($max > 0 )
589  return 0;
590  else
591  return -1;
592  }
593  /*!\brief With the id of the ledger, get the col jrn_def_class_deb
594  *\param $p_jrn jrn_id
595  *\return array of value, or an empty array if nothing is found
596  *\note
597  *\see
598  */
600  {
601  $l=new Acc_Ledger($this->db,$p_jrn);
602  $row=$l->get_propertie();
603  if ( strlen(trim($row['jrn_def_class_deb'])) == 0 ) return array();
604  $valid_account=explode(" ",$row['jrn_def_class_deb']);
605  return $valid_account;
606  }
607  /*!\brief build a sql statement thanks a array found with get_account_ledger
608  *
609  *\param $p_jrn jrn_id
610  *\return an emty string if nothing is found or a valid SQL statement like
611  \code
612  pcm_val like ... or pcm_val like ...
613  \endcode
614  *\note
615  *\see get_account_ledger
616  */
618  {
620  if ( empty($array) ) return "";
621  $sql="";
622  foreach ( $array as $item_cred)
623  {
624  if ( strlen (trim($item_cred))>0 )
625  {
626  if ( strstr($item_cred,"*") == true )
627  {
628  $item_cred=strtr($item_cred,"*","%");
629  $sql_tmp=" pcm_val::text like '$item_cred' or";
630  }
631  else
632  {
633  $sql_tmp=" pcm_val::text = '$item_cred' or";
634  }
635  $sql.=$sql_tmp;
636  }
637  }//foreach
638  /* remove the last or */
639  $sql=substr($sql,0,strlen($sql)-2);
640  return $sql;
641  }
642  /**
643  * Find the id of the cards which are using the current account
644  *
645  * @return an array of f_id
646  */
647  function find_card()
648  {
649  $sql="select f_id from fiche_detail where ad_id=$1 and ad_value=$2";
650  $account=$this->db->get_array($sql,array(ATTR_DEF_ACCOUNT,$this->id));
651  return $account;
652  }
653  /**
654  * @brief Return a string with the HTML code to display a button to export the
655  * history in CSV
656  * @param type $p_from from date (DD.MM.YYYY)
657  * @param type $p_to to date (DD.MM.YYYY)
658  * @return HTML string
659  */
660  function button_csv($p_from,$p_to) {
661  $href="export.php?".http_build_query(
662  array(
663  "gDossier"=>Dossier::id(),
664  "poste_id"=>$this->id,
665  "ople"=>0,
666  "type"=>"poste",
667  "from_periode"=>$p_from,
668  "to_periode"=>$p_to,
669  "act"=>"CSV:postedetail"
670  )
671  );
672  return '<a class="smallbutton" style="display:inline" href="'.$href.'">'._("Export CSV").'</a>';
673 
674  }
675  /**
676  * @brief Return a string with the HTML code to display a button to export the
677  * history in PDF
678  * @param type $p_from from date (DD.MM.YYYY)
679  * @param type $p_to to date (DD.MM.YYYY)
680  * @return HTML string
681  */
682  function button_pdf($p_from,$p_to) {
683  $href="export.php?".http_build_query(
684  array(
685  "gDossier"=>Dossier::id(),
686  "poste_id"=>$this->id,
687  "ople"=>0,
688  "type"=>"poste",
689  "from_periode"=>$p_from,
690  "to_periode"=>$p_to,
691  "act"=>"PDF:postedetail"
692  )
693  );
694  return '<a class="smallbutton" style="display:inline" href="'.$href.'">'._("Export PDF").'</a>';
695 
696  }
697  /**
698  * @brief Filter in javascript the table with the history
699  * @param type $p_table_id id of the table containting the data to filter
700  * @return html string
701  */
702  function filter_history($p_table_id) {
703  return _('Filtre rapide').' '.HtmlInput::filter_table($p_table_id, '0,1,2,3,5,6,7', 1);
704  }
705  static function test_me()
706  {
708  $a=new Acc_Account_Ledger($cn,550);
709  echo ' Journal 4 '.$a->belong_ledger(4);
710  return $a->belong_ledger(4);;
711 
712  }
713 }
load()
Get all the value for this object from the database the data member are set.
do_exist()
check if the poste exist in the tmp_pcmn
static HtmlTableHeader($actiontarget="poste")
Display HTML Table Header (button)
static fetch_all($ret)
wrapper for the function pg_fetch_all
if($g_user->check_dossier(dossier::id(), true)=='X') $op
Definition: ajax_ledger.php:89
button_csv($p_from, $p_to)
Return a string with the HTML code to display a button to export the history in CSV.
get_row_date($p_from, $p_to, $let=0, $solded=0)
Get data for accounting entry between 2 date.
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
$side
static num_row($ret)
wrapper for the function pg_NumRows
$class
build_sql_account($p_jrn)
build a sql statement thanks a array found with get_account_ledger
get_amount_side($p_amount)
return the letter C if amount is > 0, D if < 0 or =
get_name()
Return the name of a account it doesn't change any data member.
th($p_string, $p_extra='', $raw='')
Definition: ac_common.php:58
nbm($p_number, $p_dec=2)
format the number with a sep.
Definition: ac_common.php:121
Manage the account from the table jrn, jrnx or tmp_pcmn.
format_date($p_date, $p_from_format= 'YYYY-MM-DD', $p_to_format='DD.MM.YYYY')
format the date, when taken from the database the format is MM-DD-YYYY
Definition: ac_common.php:767
HtmlTable($p_array=null, $let=0, $from_div=0)
HtmlTable, display a HTML of a poste for the asked period.
get_solde($p_cond=" true ")
give the balance of an account
$idx
$from_div
get_solde_detail($p_cond="")
give the balance of an account
static fetch_array($ret, $p_indice=0)
wrapper for the function pg_fetch_array
$ret label
static print_window()
Javascript to print the current window.
sql_filter_per($p_cn, $p_from, $p_to, $p_form='p_id', $p_field='jr_tech_per')
Create the condition to filter on the j_tech_per thanks a from and to date.
Definition: ac_common.php:622
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
static filter_table($p_table_id, $p_col, $start_row)
get_row($p_from, $p_to)
Get data for accounting entry between 2 periode.
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.
$from_poste name
$_REQUEST['ac']
function trim(s)
remove trailing and heading space
Definition: scripts.js:95
belong_ledger($p_jrn)
verify that the accounting belong to a ledger
isTVA()
isTva tell is a poste is used for VAT
if(!isset($_REQUEST['p_jrn'])) else $Ledger id
static id()
return the $_REQUEST['gDossier'] after a check
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
static connect()
foreach($Fiche->row as $op) $solde_type
button_pdf($p_from, $p_to)
Return a string with the HTML code to display a button to export the history in PDF.
get_row_sql($Res)
get the row thanks the resource
$SecUser db
filter_history($p_table_id)
Filter in javascript the table with the history.
get_account_ledger($p_jrn)
With the id of the ledger, get the col jrn_def_class_deb.
const ATTR_DEF_ACCOUNT
Definition: constant.php:184
static hidden($p_name, $p_value, $p_id="")
$href
Definition: adm.inc.php:38
static show_reconcile($p_div, $let, $span="")
find_card()
Find the id of the cards which are using the current account.