dolibarr  17.0.4
tva.class.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2002-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2011-2017 Alexandre Spangaro <aspangaro@open-dsi.fr>
5  * Copyright (C) 2018 Philippe Grand <philippe.grand@atoo-net.com>
6  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
7  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <https://www.gnu.org/licenses/>.
21  */
22 
28 // Put here all includes required by your class file
29 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
30 
31 
35 class Tva extends CommonObject
36 {
40  public $element = 'tva';
41 
45  public $table_element = 'tva';
46 
50  public $picto = 'payment';
51 
56  public $total;
57 
58  public $tms;
59  public $datep;
60  public $datev;
61  public $amount;
62  public $type_payment;
63  public $num_payment;
64 
68  public $totalpaid;
69 
73  public $label;
74 
78  public $fk_bank;
79 
83  public $accountid;
84 
88  public $fk_user_creat;
89 
93  public $fk_user_modif;
94 
98  public $paiementtype;
99 
100 
101  const STATUS_UNPAID = 0;
102  const STATUS_PAID = 1;
103 
109  public function __construct($db)
110  {
111  $this->db = $db;
112  }
113 
114 
121  public function create($user)
122  {
123  global $conf, $langs;
124 
125  $error = 0;
126  $now = dol_now();
127 
128  // Clean parameters
129  $this->amount = trim($this->amount);
130  $this->label = trim($this->label);
131  $this->type_payment = (int) $this->type_payment;
132  $this->note = trim($this->note);
133  $this->fk_account = (int) $this->fk_account;
134  $this->fk_user_creat = (int) $this->fk_user_creat;
135  $this->fk_user_modif = (int) $this->fk_user_modif;
136 
137  // Check parameters
138  // Put here code to add control on parameters values
139 
140  $this->db->begin();
141 
142  // Insert request
143  $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva(";
144  $sql .= "entity,";
145  $sql .= "datec,";
146  $sql .= "datep,";
147  $sql .= "datev,";
148  $sql .= "amount,";
149  $sql .= "label,";
150  $sql .= "note,";
151  $sql .= "fk_account,";
152  $sql .= "fk_typepayment,";
153  $sql .= "fk_user_creat,";
154  $sql .= "fk_user_modif";
155  $sql .= ") VALUES (";
156  $sql .= " ".((int) $conf->entity).", ";
157  $sql .= " '".$this->db->idate($now)."',";
158  $sql .= " '".$this->db->idate($this->datep)."',";
159  $sql .= " '".$this->db->idate($this->datev)."',";
160  $sql .= " '".$this->db->escape($this->amount)."',";
161  $sql .= " '".$this->db->escape($this->label)."',";
162  $sql .= " '".$this->db->escape($this->note)."',";
163  $sql .= " '".$this->db->escape($this->fk_account)."',";
164  $sql .= " '".$this->db->escape($this->type_payment)."',";
165  $sql .= " ".($this->fk_user_creat > 0 ? (int) $this->fk_user_creat : (int) $user->id).",";
166  $sql .= " ".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : (int) $user->id);
167  $sql .= ")";
168 
169  dol_syslog(get_class($this)."::create", LOG_DEBUG);
170  $resql = $this->db->query($sql);
171  if ($resql) {
172  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva");
173 
174  // Call trigger
175  $result = $this->call_trigger('TVA_CREATE', $user);
176  if ($result < 0) {
177  $error++;
178  }
179  // End call triggers
180 
181  if (!$error) {
182  $this->db->commit();
183  return $this->id;
184  } else {
185  $this->db->rollback();
186  return -1;
187  }
188  } else {
189  $this->error = "Error ".$this->db->lasterror();
190  $this->db->rollback();
191  return -1;
192  }
193  }
194 
202  public function update($user, $notrigger = 0)
203  {
204  global $conf, $langs;
205 
206  $error = 0;
207 
208  // Clean parameters
209  $this->amount = trim($this->amount);
210  $this->label = trim($this->label);
211  $this->note = trim($this->note);
212  $this->fk_user_creat = (int) $this->fk_user_creat;
213  $this->fk_user_modif = (int) $this->fk_user_modif;
214 
215  // Check parameters
216  // Put here code to add control on parameters values
217 
218  $this->db->begin();
219 
220  // Update request
221  $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
222  $sql .= " tms='".$this->db->idate($this->tms)."',";
223  $sql .= " datep='".$this->db->idate($this->datep)."',";
224  $sql .= " datev='".$this->db->idate($this->datev)."',";
225  $sql .= " amount=".price2num($this->amount).",";
226  $sql .= " label='".$this->db->escape($this->label)."',";
227  $sql .= " note='".$this->db->escape($this->note)."',";
228  $sql .= " fk_user_creat=".((int) $this->fk_user_creat).",";
229  $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id)."";
230  $sql .= " WHERE rowid=".((int) $this->id);
231 
232  dol_syslog(get_class($this)."::update", LOG_DEBUG);
233  $resql = $this->db->query($sql);
234  if (!$resql) {
235  $this->error = "Error ".$this->db->lasterror();
236  $error++;
237  }
238 
239  if (!$error && !$notrigger) {
240  // Call trigger
241  $result = $this->call_trigger('TVA_MODIFY', $user);
242  if ($result < 0) {
243  $error++;
244  }
245  // End call triggers
246  }
247 
248  if (!$error) {
249  $this->db->commit();
250  return 1;
251  } else {
252  $this->db->rollback();
253  return -1;
254  }
255  }
256 
263  public function setPaid($user)
264  {
265  // phpcs:enable
266  $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
267  $sql .= " paye = 1";
268  $sql .= " WHERE rowid = ".((int) $this->id);
269  $resql = $this->db->query($sql);
270  if ($resql) {
271  return 1;
272  } else {
273  return -1;
274  }
275  }
276 
283  public function setUnpaid($user)
284  {
285  // phpcs:enable
286  $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
287  $sql .= " paye = 0";
288  $sql .= " WHERE rowid = ".((int) $this->id);
289  $resql = $this->db->query($sql);
290  if ($resql) {
291  return 1;
292  } else {
293  return -1;
294  }
295  }
296 
297 
305  public function fetch($id, $user = null)
306  {
307  global $langs;
308  $sql = "SELECT";
309  $sql .= " t.rowid,";
310 
311  $sql .= " t.tms,";
312  $sql .= " t.datep,";
313  $sql .= " t.datev,";
314  $sql .= " t.amount,";
315  $sql .= " t.fk_typepayment,";
316  $sql .= " t.num_payment,";
317  $sql .= " t.label,";
318  $sql .= " t.note,";
319  $sql .= " t.paye,";
320  $sql .= " t.fk_user_creat,";
321  $sql .= " t.fk_user_modif,";
322  $sql .= " t.fk_account";
323 
324  $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
325  //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid";
326  $sql .= " WHERE t.rowid = ".((int) $id);
327 
328  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
329  $resql = $this->db->query($sql);
330  if ($resql) {
331  if ($this->db->num_rows($resql)) {
332  $obj = $this->db->fetch_object($resql);
333 
334  $this->id = $obj->rowid;
335  $this->ref = $obj->rowid;
336  $this->tms = $this->db->jdate($obj->tms);
337  $this->datep = $this->db->jdate($obj->datep);
338  $this->datev = $this->db->jdate($obj->datev);
339  $this->amount = $obj->amount;
340  $this->type_payment = $obj->fk_typepayment;
341  $this->num_payment = $obj->num_payment;
342  $this->label = $obj->label;
343  $this->paye = $obj->paye;
344  $this->note = $obj->note;
345  $this->fk_user_creat = $obj->fk_user_creat;
346  $this->fk_user_modif = $obj->fk_user_modif;
347  $this->fk_account = $obj->fk_account;
348  $this->fk_type = empty($obj->fk_type) ? "" : $obj->fk_type;
349  $this->rappro = empty($obj->rappro) ? "" : $obj->rappro;
350  }
351  $this->db->free($resql);
352 
353  return 1;
354  } else {
355  $this->error = "Error ".$this->db->lasterror();
356  return -1;
357  }
358  }
359 
360 
367  public function delete($user)
368  {
369  global $conf, $langs;
370 
371  $error = 0;
372 
373  // Call trigger
374  $result = $this->call_trigger('TVA_DELETE', $user);
375  if ($result < 0) {
376  return -1;
377  }
378  // End call triggers
379 
380  $sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
381  $sql .= " WHERE rowid=".((int) $this->id);
382 
383  dol_syslog(get_class($this)."::delete", LOG_DEBUG);
384  $resql = $this->db->query($sql);
385  if (!$resql) {
386  $this->error = "Error ".$this->db->lasterror();
387  return -1;
388  }
389 
390 
391  return 1;
392  }
393 
394 
402  public function initAsSpecimen()
403  {
404  $this->id = 0;
405 
406  $this->tms = '';
407  $this->datep = '';
408  $this->datev = '';
409  $this->amount = '';
410  $this->label = '';
411  $this->note = '';
412  $this->fk_bank = '';
413  $this->fk_user_creat = '';
414  $this->fk_user_modif = '';
415  }
416 
417 
424  public function solde($year = 0)
425  {
426 
427  $reglee = $this->tva_sum_reglee($year);
428 
429  $payee = $this->tva_sum_payee($year);
430  $collectee = $this->tva_sum_collectee($year);
431 
432  $solde = $reglee - ($collectee - $payee);
433 
434  return $solde;
435  }
436 
437  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
444  public function tva_sum_collectee($year = 0)
445  {
446  // phpcs:enable
447 
448  $sql = "SELECT sum(f.total_tva) as amount";
449  $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
450  if ($year) {
451  $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' ";
452  }
453 
454  $result = $this->db->query($sql);
455  if ($result) {
456  if ($this->db->num_rows($result)) {
457  $obj = $this->db->fetch_object($result);
458  $ret = $obj->amount;
459  $this->db->free($result);
460  return $ret;
461  } else {
462  $this->db->free($result);
463  return 0;
464  }
465  } else {
466  print $this->db->lasterror();
467  return -1;
468  }
469  }
470 
471  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
478  public function tva_sum_payee($year = 0)
479  {
480  // phpcs:enable
481 
482  $sql = "SELECT sum(f.total_tva) as total_tva";
483  $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
484  if ($year) {
485  $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' ";
486  }
487 
488  $result = $this->db->query($sql);
489  if ($result) {
490  if ($this->db->num_rows($result)) {
491  $obj = $this->db->fetch_object($result);
492  $ret = $obj->total_tva;
493  $this->db->free($result);
494  return $ret;
495  } else {
496  $this->db->free($result);
497  return 0;
498  }
499  } else {
500  print $this->db->lasterror();
501  return -1;
502  }
503  }
504 
505 
506  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
513  public function tva_sum_reglee($year = 0)
514  {
515  // phpcs:enable
516 
517  $sql = "SELECT sum(f.amount) as amount";
518  $sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
519 
520  if ($year) {
521  $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' ";
522  }
523 
524  $result = $this->db->query($sql);
525  if ($result) {
526  if ($this->db->num_rows($result)) {
527  $obj = $this->db->fetch_object($result);
528  $ret = $obj->amount;
529  $this->db->free($result);
530  return $ret;
531  } else {
532  $this->db->free($result);
533  return 0;
534  }
535  } else {
536  print $this->db->lasterror();
537  return -1;
538  }
539  }
540 
541 
548  public function addPayment($user)
549  {
550  global $conf, $langs;
551 
552  $this->db->begin();
553 
554  // Clean parameters
555  $this->amount = price2num(trim($this->amount));
556  $this->label = trim($this->label);
557  $this->note = trim($this->note);
558  $this->num_payment = trim($this->num_payment);
559  $this->fk_bank = (int) $this->fk_bank;
560  $this->fk_user_creat = (int) $this->fk_user_creat;
561  $this->fk_user_modif = (int) $this->fk_user_modif;
562  if (empty($this->datec)) {
563  $this->datec = dol_now();
564  }
565 
566  // Check parameters
567  if (!$this->label) {
568  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
569  return -3;
570  }
571  if ($this->amount == '') {
572  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
573  return -4;
574  }
575  if (isModEnabled("banque") && (empty($this->accountid) || $this->accountid <= 0)) {
576  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
577  return -5;
578  }
579  if (isModEnabled("banque") && (empty($this->type_payment) || $this->type_payment <= 0)) {
580  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
581  return -5;
582  }
583 
584  // Insert into llx_tva
585  $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (";
586  $sql .= "datec";
587  $sql .= ", datep";
588  $sql .= ", datev";
589  $sql .= ", amount";
590  $sql .= ", fk_typepayment";
591  $sql .= ", num_payment";
592  if ($this->note) {
593  $sql .= ", note";
594  }
595  if ($this->label) {
596  $sql .= ", label";
597  }
598  $sql .= ", fk_user_creat";
599  $sql .= ", fk_bank";
600  $sql .= ", entity";
601  $sql .= ") ";
602  $sql .= " VALUES (";
603  $sql .= " '".$this->db->idate($this->datec)."'";
604  $sql .= ", '".$this->db->idate($this->datep)."'";
605  $sql .= ", '".$this->db->idate($this->datev)."'";
606  $sql .= ", ".((float) $this->amount);
607  $sql .= ", '".$this->db->escape($this->type_payment)."'";
608  $sql .= ", '".$this->db->escape($this->num_payment)."'";
609  if ($this->note) {
610  $sql .= ", '".$this->db->escape($this->note)."'";
611  }
612  if ($this->label) {
613  $sql .= ", '".$this->db->escape($this->label)."'";
614  }
615  $sql .= ", '".$this->db->escape($user->id)."'";
616  $sql .= ", NULL";
617  $sql .= ", ".((int) $conf->entity);
618  $sql .= ")";
619 
620  dol_syslog(get_class($this)."::addPayment", LOG_DEBUG);
621  $result = $this->db->query($sql);
622  if ($result) {
623  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat'
624 
625  // Call trigger
626  //XXX: Should be done just befor commit no ?
627  $result = $this->call_trigger('TVA_ADDPAYMENT', $user);
628  if ($result < 0) {
629  $this->id = 0;
630  $ok = 0;
631  }
632  // End call triggers
633 
634  if ($this->id > 0) {
635  $ok = 1;
636  if (isModEnabled("banque") && !empty($this->amount)) {
637  // Insert into llx_bank
638  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
639 
640  $acc = new Account($this->db);
641  $result = $acc->fetch($this->accountid);
642  if ($result <= 0) {
643  dol_print_error($this->db);
644  }
645 
646  if ($this->amount > 0) {
647  $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), $this->num_payment, '', $user);
648  } else {
649  $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), $this->num_payment, '', $user);
650  }
651 
652  // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction
653  if ($bank_line_id > 0) {
654  $this->update_fk_bank($bank_line_id);
655  } else {
656  $this->error = $acc->error;
657  $ok = 0;
658  }
659 
660  // Update links
661  $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat");
662  if ($result < 0) {
663  $this->error = $acc->error;
664  $ok = 0;
665  }
666  }
667 
668  if ($ok) {
669  $this->db->commit();
670  return $this->id;
671  } else {
672  $this->db->rollback();
673  return -3;
674  }
675  } else {
676  $this->db->rollback();
677  return -2;
678  }
679  } else {
680  $this->error = $this->db->error();
681  $this->db->rollback();
682  return -1;
683  }
684  }
685 
686  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
693  public function update_fk_bank($id_bank)
694  {
695  // phpcs:enable
696  $sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.(int) $id_bank;
697  $sql .= ' WHERE rowid = '.(int) $this->id;
698  $result = $this->db->query($sql);
699  if ($result) {
700  return 1;
701  } else {
702  dol_print_error($this->db);
703  return -1;
704  }
705  }
706 
717  public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
718  {
719  global $langs, $conf;
720 
721  if (!empty($conf->dol_no_mouse_hover)) {
722  $notooltip = 1; // Force disable tooltips
723  }
724 
725  $result = '';
726 
727  $label = '<u>'.$langs->trans("ShowVatPayment").'</u>';
728  $label .= '<br>';
729  $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
730  if (!empty($this->label)) {
731  $label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
732  }
733 
734  $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id;
735 
736  if ($option != 'nolink') {
737  // Add param to save lastsearch_values or not
738  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
739  if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
740  $add_save_lastsearch_values = 1;
741  }
742  if ($add_save_lastsearch_values) {
743  $url .= '&save_lastsearch_values=1';
744  }
745  }
746 
747  $linkclose = '';
748  if (empty($notooltip)) {
749  if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
750  $label = $langs->trans("ShowMyObject");
751  $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
752  }
753  $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
754  $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
755  } else {
756  $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
757  }
758 
759  $linkstart = '<a href="'.$url.'"';
760  $linkstart .= $linkclose.'>';
761  $linkend = '</a>';
762 
763  $picto = 'payment';
764 
765  $result .= $linkstart;
766  if ($withpicto) {
767  $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
768  }
769  if ($withpicto != 2) {
770  $result .= $this->ref;
771  }
772  $result .= $linkend;
773 
774  return $result;
775  }
776 
782  public function getSommePaiement()
783  {
784  $table = 'payment_vat';
785  $field = 'fk_tva';
786 
787  $sql = 'SELECT sum(amount) as amount';
788  $sql .= ' FROM '.MAIN_DB_PREFIX.$table;
789  $sql .= " WHERE ".$field." = ".((int) $this->id);
790 
791  dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
792  $resql = $this->db->query($sql);
793  if ($resql) {
794  $amount = 0;
795 
796  $obj = $this->db->fetch_object($resql);
797  if ($obj) {
798  $amount = $obj->amount ? $obj->amount : 0;
799  }
800 
801  $this->db->free($resql);
802  return $amount;
803  } else {
804  return -1;
805  }
806  }
807 
814  public function info($id)
815  {
816  $sql = "SELECT t.rowid, t.tms, t.fk_user_modif, t.datec, t.fk_user_creat";
817  $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
818  $sql .= " WHERE t.rowid = ".(int) $id;
819 
820  dol_syslog(get_class($this)."::info", LOG_DEBUG);
821  $result = $this->db->query($sql);
822  if ($result) {
823  if ($this->db->num_rows($result)) {
824  $obj = $this->db->fetch_object($result);
825 
826  $this->id = $obj->rowid;
827 
828  if ($obj->fk_user_creat) {
829  $cuser = new User($this->db);
830  $cuser->fetch($obj->fk_user_creat);
831  $this->user_creation = $cuser;
832  }
833 
834  if ($obj->fk_user_modif) {
835  $muser = new User($this->db);
836  $muser->fetch($obj->fk_user_modif);
837  $this->user_modification = $muser;
838  }
839 
840  $this->date_creation = $this->db->jdate($obj->datec);
841  $this->date_modification = $this->db->jdate($obj->tms);
842  $this->import_key = $obj->import_key;
843  }
844 
845  $this->db->free($result);
846  } else {
847  dol_print_error($this->db);
848  }
849  }
850 
858  public function getLibStatut($mode = 0, $alreadypaid = -1)
859  {
860  return $this->LibStatut($this->paye, $mode, $alreadypaid);
861  }
862 
863  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
872  public function LibStatut($status, $mode = 0, $alreadypaid = -1)
873  {
874  // phpcs:enable
875  global $langs;
876 
877  // Load translation files required by the page
878  $langs->loadLangs(array("customers", "bills"));
879 
880  // We reinit status array to force to redefine them because label may change according to properties values.
881  $this->labelStatus = array();
882  $this->labelStatusShort = array();
883 
884  if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
885  global $langs;
886  //$langs->load("mymodule");
887  $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid');
888  $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid');
889  if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) {
890  $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
891  }
892  $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid');
893  $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid');
894  if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) {
895  $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
896  }
897  }
898 
899  $statusType = 'status1';
900  if ($status == 0 && $alreadypaid <> 0) {
901  $statusType = 'status3';
902  }
903  if ($status == 1) {
904  $statusType = 'status6';
905  }
906 
907  return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
908  }
909 }
$object ref
Definition: info.php:78
Class to manage bank accounts.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
call_trigger($triggerName, $user)
Call trigger based on this instance.
Put here description of your class.
Definition: tva.class.php:36
tva_sum_collectee($year=0)
Total of the VAT from invoices emitted by the thirdparty.
Definition: tva.class.php:444
LibStatut($status, $mode=0, $alreadypaid=-1)
Renvoi le libelle d'un statut donne.
Definition: tva.class.php:872
tva_sum_payee($year=0)
VAT payed.
Definition: tva.class.php:478
setUnpaid($user)
Remove tag payed on TVA.
Definition: tva.class.php:283
$total
Definition: tva.class.php:56
__construct($db)
Constructor.
Definition: tva.class.php:109
fetch($id, $user=null)
Load object in memory from database.
Definition: tva.class.php:305
update($user, $notrigger=0)
Update database.
Definition: tva.class.php:202
solde($year=0)
Balance of VAT.
Definition: tva.class.php:424
getSommePaiement()
Return amount of payments already done.
Definition: tva.class.php:782
addPayment($user)
Create in database.
Definition: tva.class.php:548
getLibStatut($mode=0, $alreadypaid=-1)
Retourne le libelle du statut d'une TVA (impaye, payee)
Definition: tva.class.php:858
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Send name clicable (with possibly the picto)
Definition: tva.class.php:717
update_fk_bank($id_bank)
Update link between payment tva and line generate into llx_bank.
Definition: tva.class.php:693
setPaid($user)
Tag TVA as payed completely.
Definition: tva.class.php:263
initAsSpecimen()
Initialise an instance with random values.
Definition: tva.class.php:402
info($id)
Informations of vat payment object.
Definition: tva.class.php:814
create($user)
Create in database.
Definition: tva.class.php:121
tva_sum_reglee($year=0)
Total of the VAT payed.
Definition: tva.class.php:513
Class to manage Dolibarr users.
Definition: user.class.php:47
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
dol_now($mode='auto')
Return date for now.
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
$conf db
API class for accounts.
Definition: inc.php:41