dolibarr  20.0.0-beta
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-2024 Frédéric France <frederic.france@free.fr>
7  * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
8  * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
29 // Put here all includes required by your class file
30 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
31 
32 
36 class Tva extends CommonObject
37 {
41  public $element = 'tva';
42 
46  public $table_element = 'tva';
47 
51  public $picto = 'payment';
52 
57  public $total;
58 
59  public $datep;
60  public $datev;
61  public $amount;
62  public $type_payment;
63 
68  public $num_payment;
69 
73  public $datec;
74 
78  public $fk_type;
79 
83  public $paye;
84 
88  public $rappro;
89 
93  public $label;
94 
98  public $fk_bank;
99 
103  public $accountid;
104 
108  public $fk_user_creat;
109 
113  public $fk_user_modif;
114 
118  public $paiementtype;
119 
120 
121  const STATUS_UNPAID = 0;
122  const STATUS_PAID = 1;
123 
129  public function __construct($db)
130  {
131  $this->db = $db;
132  }
133 
134 
141  public function create($user)
142  {
143  global $conf, $langs;
144 
145  $error = 0;
146  $now = dol_now();
147 
148  // Clean parameters
149  $this->amount = trim($this->amount);
150  $this->label = trim($this->label);
151  $this->type_payment = (int) $this->type_payment;
152  $this->note = trim($this->note);
153  $this->fk_account = (int) $this->fk_account;
154  $this->fk_user_creat = (int) $this->fk_user_creat;
155  $this->fk_user_modif = (int) $this->fk_user_modif;
156 
157  // Check parameters
158  // Put here code to add control on parameters values
159 
160  $this->db->begin();
161 
162  // Insert request
163  $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva(";
164  $sql .= "entity,";
165  $sql .= "datec,";
166  $sql .= "datep,";
167  $sql .= "datev,";
168  $sql .= "amount,";
169  $sql .= "label,";
170  $sql .= "note,";
171  $sql .= "fk_account,";
172  $sql .= "fk_typepayment,";
173  $sql .= "fk_user_creat,";
174  $sql .= "fk_user_modif";
175  $sql .= ") VALUES (";
176  $sql .= " ".((int) $conf->entity).", ";
177  $sql .= " '".$this->db->idate($now)."',";
178  $sql .= " '".$this->db->idate($this->datep)."',";
179  $sql .= " '".$this->db->idate($this->datev)."',";
180  $sql .= " '".$this->db->escape($this->amount)."',";
181  $sql .= " '".$this->db->escape($this->label)."',";
182  $sql .= " '".$this->db->escape($this->note)."',";
183  $sql .= " '".$this->db->escape($this->fk_account)."',";
184  $sql .= " '".$this->db->escape($this->type_payment)."',";
185  $sql .= " ".($this->fk_user_creat > 0 ? (int) $this->fk_user_creat : (int) $user->id).",";
186  $sql .= " ".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : (int) $user->id);
187  $sql .= ")";
188 
189  dol_syslog(get_class($this)."::create", LOG_DEBUG);
190  $resql = $this->db->query($sql);
191  if ($resql) {
192  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva");
193 
194  // Call trigger
195  $result = $this->call_trigger('TVA_CREATE', $user);
196  if ($result < 0) {
197  $error++;
198  }
199  // End call triggers
200 
201  if (!$error) {
202  $this->db->commit();
203  return $this->id;
204  } else {
205  $this->db->rollback();
206  return -1;
207  }
208  } else {
209  $this->error = "Error ".$this->db->lasterror();
210  $this->db->rollback();
211  return -1;
212  }
213  }
214 
222  public function update($user, $notrigger = 0)
223  {
224  global $conf, $langs;
225 
226  $error = 0;
227 
228  // Clean parameters
229  $this->amount = trim($this->amount);
230  $this->label = trim($this->label);
231  $this->note = trim($this->note);
232  $this->fk_user_creat = (int) $this->fk_user_creat;
233  $this->fk_user_modif = (int) $this->fk_user_modif;
234 
235  // Check parameters
236  // Put here code to add control on parameters values
237 
238  $this->db->begin();
239 
240  // Update request
241  $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
242  $sql .= " tms='".$this->db->idate($this->tms)."',";
243  $sql .= " datep='".$this->db->idate($this->datep)."',";
244  $sql .= " datev='".$this->db->idate($this->datev)."',";
245  $sql .= " amount=".price2num($this->amount).",";
246  $sql .= " label='".$this->db->escape($this->label)."',";
247  $sql .= " note='".$this->db->escape($this->note)."',";
248  $sql .= " fk_user_creat=".((int) $this->fk_user_creat).",";
249  $sql .= " fk_user_modif=".((int) ($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id));
250  $sql .= " WHERE rowid=".((int) $this->id);
251 
252  dol_syslog(get_class($this)."::update", LOG_DEBUG);
253  $resql = $this->db->query($sql);
254  if (!$resql) {
255  $this->error = "Error ".$this->db->lasterror();
256  $error++;
257  }
258 
259  if (!$error && !$notrigger) {
260  // Call trigger
261  $result = $this->call_trigger('TVA_MODIFY', $user);
262  if ($result < 0) {
263  $error++;
264  }
265  // End call triggers
266  }
267 
268  if (!$error) {
269  $this->db->commit();
270  return 1;
271  } else {
272  $this->db->rollback();
273  return -1;
274  }
275  }
276 
283  public function setPaid($user)
284  {
285  // phpcs:enable
286  $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
287  $sql .= " paye = 1";
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 
303  public function setUnpaid($user)
304  {
305  // phpcs:enable
306  $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
307  $sql .= " paye = 0";
308  $sql .= " WHERE rowid = ".((int) $this->id);
309  $resql = $this->db->query($sql);
310  if ($resql) {
311  return 1;
312  } else {
313  return -1;
314  }
315  }
316 
317 
325  public function fetch($id, $ref = '')
326  {
327  $sql = "SELECT";
328  $sql .= " t.rowid,";
329  $sql .= " t.tms,";
330  $sql .= " t.datep,";
331  $sql .= " t.datev,";
332  $sql .= " t.amount,";
333  $sql .= " t.fk_typepayment,";
334  $sql .= " t.num_payment,";
335  $sql .= " t.label,";
336  $sql .= " t.note,";
337  $sql .= " t.paye,";
338  $sql .= " t.fk_user_creat,";
339  $sql .= " t.fk_user_modif,";
340  $sql .= " t.fk_account";
341  $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
342  $sql .= " WHERE t.rowid = ".((int) $id);
343 
344  dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
345 
346  $resql = $this->db->query($sql);
347  if ($resql) {
348  if ($this->db->num_rows($resql)) {
349  $obj = $this->db->fetch_object($resql);
350 
351  $this->id = $obj->rowid;
352  $this->ref = $obj->rowid;
353  $this->tms = $this->db->jdate($obj->tms);
354  $this->datep = $this->db->jdate($obj->datep);
355  $this->datev = $this->db->jdate($obj->datev);
356  $this->amount = $obj->amount;
357  $this->type_payment = $obj->fk_typepayment;
358  $this->num_payment = $obj->num_payment;
359  $this->label = $obj->label;
360  $this->paye = $obj->paye;
361  $this->note = $obj->note;
362  $this->fk_user_creat = $obj->fk_user_creat;
363  $this->fk_user_modif = $obj->fk_user_modif;
364  $this->fk_account = $obj->fk_account;
365  $this->fk_type = empty($obj->fk_type) ? "" : $obj->fk_type;
366  $this->rappro = empty($obj->rappro) ? "" : $obj->rappro;
367  }
368  $this->db->free($resql);
369 
370  return 1;
371  } else {
372  $this->error = "Error ".$this->db->lasterror();
373  return -1;
374  }
375  }
376 
377 
384  public function delete($user)
385  {
386  global $conf, $langs;
387 
388  $error = 0;
389 
390  // Call trigger
391  $result = $this->call_trigger('TVA_DELETE', $user);
392  if ($result < 0) {
393  return -1;
394  }
395  // End call triggers
396 
397  $sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
398  $sql .= " WHERE rowid=".((int) $this->id);
399 
400  dol_syslog(get_class($this)."::delete", LOG_DEBUG);
401  $resql = $this->db->query($sql);
402  if (!$resql) {
403  $this->error = "Error ".$this->db->lasterror();
404  return -1;
405  }
406 
407 
408  return 1;
409  }
410 
411 
419  public function initAsSpecimen()
420  {
421  $this->id = 0;
422 
423  $this->tms = dol_now();
424  $this->datep = '';
425  $this->datev = '';
426  $this->amount = '';
427  $this->label = '';
428  $this->note = '';
429  $this->fk_bank = 0;
430  $this->fk_user_creat = 0;
431  $this->fk_user_modif = 0;
432 
433  return 1;
434  }
435 
436 
443  public function solde($year = 0)
444  {
445  $reglee = $this->tva_sum_reglee($year);
446 
447  $payee = $this->tva_sum_payee($year);
448  $collectee = $this->tva_sum_collectee($year);
449 
450  $solde = $reglee - ($collectee - $payee);
451 
452  return $solde;
453  }
454 
455  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
462  public function tva_sum_collectee($year = 0)
463  {
464  // phpcs:enable
465 
466  $sql = "SELECT sum(f.total_tva) as amount";
467  $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
468  if ($year) {
469  $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' ";
470  }
471 
472  $result = $this->db->query($sql);
473  if ($result) {
474  if ($this->db->num_rows($result)) {
475  $obj = $this->db->fetch_object($result);
476  $ret = $obj->amount;
477  $this->db->free($result);
478  return $ret;
479  } else {
480  $this->db->free($result);
481  return 0;
482  }
483  } else {
484  print $this->db->lasterror();
485  return -1;
486  }
487  }
488 
489  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
496  public function tva_sum_payee($year = 0)
497  {
498  // phpcs:enable
499 
500  $sql = "SELECT sum(f.total_tva) as total_tva";
501  $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
502  if ($year) {
503  $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' ";
504  }
505 
506  $result = $this->db->query($sql);
507  if ($result) {
508  if ($this->db->num_rows($result)) {
509  $obj = $this->db->fetch_object($result);
510  $ret = $obj->total_tva;
511  $this->db->free($result);
512  return $ret;
513  } else {
514  $this->db->free($result);
515  return 0;
516  }
517  } else {
518  print $this->db->lasterror();
519  return -1;
520  }
521  }
522 
523 
524  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
531  public function tva_sum_reglee($year = 0)
532  {
533  // phpcs:enable
534 
535  $sql = "SELECT sum(f.amount) as amount";
536  $sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
537 
538  if ($year) {
539  $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' ";
540  }
541 
542  $result = $this->db->query($sql);
543  if ($result) {
544  if ($this->db->num_rows($result)) {
545  $obj = $this->db->fetch_object($result);
546  $ret = $obj->amount;
547  $this->db->free($result);
548  return $ret;
549  } else {
550  $this->db->free($result);
551  return 0;
552  }
553  } else {
554  print $this->db->lasterror();
555  return -1;
556  }
557  }
558 
559 
566  public function addPayment($user)
567  {
568  global $conf, $langs;
569 
570  $this->db->begin();
571 
572  // Clean parameters
573  $this->amount = price2num(trim($this->amount));
574  $this->label = trim($this->label);
575  $this->note = trim($this->note);
576  $this->num_payment = trim($this->num_payment);
577  $this->fk_bank = (int) $this->fk_bank;
578  $this->fk_user_creat = (int) $this->fk_user_creat;
579  $this->fk_user_modif = (int) $this->fk_user_modif;
580  if (empty($this->datec)) {
581  $this->datec = dol_now();
582  }
583 
584  // Check parameters
585  if (!$this->label) {
586  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
587  return -3;
588  }
589  if ($this->amount == '') {
590  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
591  return -4;
592  }
593  if (isModEnabled("bank") && (empty($this->accountid) || $this->accountid <= 0)) {
594  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount"));
595  return -5;
596  }
597  if (isModEnabled("bank") && (empty($this->type_payment) || $this->type_payment <= 0)) {
598  $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
599  return -5;
600  }
601 
602  // Insert into llx_tva
603  $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (";
604  $sql .= "datec";
605  $sql .= ", datep";
606  $sql .= ", datev";
607  $sql .= ", amount";
608  $sql .= ", fk_typepayment";
609  $sql .= ", num_payment";
610  if ($this->note) {
611  $sql .= ", note";
612  }
613  if ($this->label) {
614  $sql .= ", label";
615  }
616  $sql .= ", fk_user_creat";
617  $sql .= ", fk_bank";
618  $sql .= ", entity";
619  $sql .= ") ";
620  $sql .= " VALUES (";
621  $sql .= " '".$this->db->idate($this->datec)."'";
622  $sql .= ", '".$this->db->idate($this->datep)."'";
623  $sql .= ", '".$this->db->idate($this->datev)."'";
624  $sql .= ", ".((float) $this->amount);
625  $sql .= ", '".$this->db->escape($this->type_payment)."'";
626  $sql .= ", '".$this->db->escape($this->num_payment)."'";
627  if ($this->note) {
628  $sql .= ", '".$this->db->escape($this->note)."'";
629  }
630  if ($this->label) {
631  $sql .= ", '".$this->db->escape($this->label)."'";
632  }
633  $sql .= ", '".$this->db->escape($user->id)."'";
634  $sql .= ", NULL";
635  $sql .= ", ".((int) $conf->entity);
636  $sql .= ")";
637 
638  dol_syslog(get_class($this)."::addPayment", LOG_DEBUG);
639  $result = $this->db->query($sql);
640  if ($result) {
641  $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat'
642 
643  // Call trigger
644  //XXX: Should be done just before commit no ?
645  $result = $this->call_trigger('TVA_ADDPAYMENT', $user);
646  if ($result < 0) {
647  $this->id = 0;
648  $ok = 0;
649  }
650  // End call triggers
651 
652  if ($this->id > 0) {
653  $ok = 1;
654  if (isModEnabled("bank") && !empty($this->amount)) {
655  // Insert into llx_bank
656  require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
657 
658  $acc = new Account($this->db);
659  $result = $acc->fetch($this->accountid);
660  if ($result <= 0) {
661  dol_print_error($this->db);
662  }
663 
664  if ($this->amount > 0) {
665  $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs((float) $this->amount), $this->num_payment, '', $user);
666  } else {
667  $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs((float) $this->amount), $this->num_payment, '', $user);
668  }
669 
670  // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction
671  if ($bank_line_id > 0) {
672  $this->update_fk_bank($bank_line_id);
673  } else {
674  $this->error = $acc->error;
675  $ok = 0;
676  }
677 
678  // Update links
679  $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat");
680  if ($result < 0) {
681  $this->error = $acc->error;
682  $ok = 0;
683  }
684  }
685 
686  if ($ok) {
687  $this->db->commit();
688  return $this->id;
689  } else {
690  $this->db->rollback();
691  return -3;
692  }
693  } else {
694  $this->db->rollback();
695  return -2;
696  }
697  } else {
698  $this->error = $this->db->error();
699  $this->db->rollback();
700  return -1;
701  }
702  }
703 
704  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
711  public function update_fk_bank($id_bank)
712  {
713  // phpcs:enable
714  $sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.(int) $id_bank;
715  $sql .= ' WHERE rowid = '.(int) $this->id;
716  $result = $this->db->query($sql);
717  if ($result) {
718  return 1;
719  } else {
720  dol_print_error($this->db);
721  return -1;
722  }
723  }
724 
735  public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
736  {
737  global $langs, $conf;
738 
739  if (!empty($conf->dol_no_mouse_hover)) {
740  $notooltip = 1; // Force disable tooltips
741  }
742 
743  $result = '';
744 
745  $label = '<u>'.$langs->trans("ShowVatPayment").'</u>';
746  $label .= '<br>';
747  $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
748  if (!empty($this->label)) {
749  $label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
750  }
751 
752  $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id;
753 
754  if ($option != 'nolink') {
755  // Add param to save lastsearch_values or not
756  $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
757  if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
758  $add_save_lastsearch_values = 1;
759  }
760  if ($add_save_lastsearch_values) {
761  $url .= '&save_lastsearch_values=1';
762  }
763  }
764 
765  $linkclose = '';
766  if (empty($notooltip)) {
767  if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
768  $label = $langs->trans("ShowMyObject");
769  $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
770  }
771  $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
772  $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
773  } else {
774  $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
775  }
776 
777  $linkstart = '<a href="'.$url.'"';
778  $linkstart .= $linkclose.'>';
779  $linkend = '</a>';
780 
781  $picto = 'payment';
782 
783  $result .= $linkstart;
784  if ($withpicto) {
785  $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);
786  }
787  if ($withpicto != 2) {
788  $result .= $this->ref;
789  }
790  $result .= $linkend;
791 
792  return $result;
793  }
794 
800  public function getSommePaiement()
801  {
802  $table = 'payment_vat';
803  $field = 'fk_tva';
804 
805  $sql = 'SELECT sum(amount) as amount';
806  $sql .= ' FROM '.MAIN_DB_PREFIX.$table;
807  $sql .= " WHERE ".$field." = ".((int) $this->id);
808 
809  dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
810  $resql = $this->db->query($sql);
811  if ($resql) {
812  $amount = 0;
813 
814  $obj = $this->db->fetch_object($resql);
815  if ($obj) {
816  $amount = $obj->amount ? $obj->amount : 0;
817  }
818 
819  $this->db->free($resql);
820  return $amount;
821  } else {
822  return -1;
823  }
824  }
825 
832  public function info($id)
833  {
834  $sql = "SELECT t.rowid, t.tms, t.fk_user_modif, t.datec, t.fk_user_creat";
835  $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
836  $sql .= " WHERE t.rowid = ".(int) $id;
837 
838  dol_syslog(get_class($this)."::info", LOG_DEBUG);
839  $result = $this->db->query($sql);
840  if ($result) {
841  if ($this->db->num_rows($result)) {
842  $obj = $this->db->fetch_object($result);
843 
844  $this->id = $obj->rowid;
845 
846  $this->user_creation_id = $obj->fk_user_creat;
847  $this->user_modification_id = $obj->fk_user_modif;
848  $this->date_creation = $this->db->jdate($obj->datec);
849  $this->date_modification = $this->db->jdate($obj->tms);
850  }
851 
852  $this->db->free($result);
853  } else {
854  dol_print_error($this->db);
855  }
856  }
857 
865  public function getLibStatut($mode = 0, $alreadypaid = -1)
866  {
867  return $this->LibStatut($this->paye, $mode, $alreadypaid);
868  }
869 
870  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
879  public function LibStatut($status, $mode = 0, $alreadypaid = -1)
880  {
881  // phpcs:enable
882  global $langs;
883 
884  // Load translation files required by the page
885  $langs->loadLangs(array("customers", "bills"));
886 
887  // We reinit status array to force to redefine them because label may change according to properties values.
888  $this->labelStatus = array();
889  $this->labelStatusShort = array();
890 
891  if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
892  global $langs;
893  //$langs->load("mymodule");
894  $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid');
895  $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid');
896  if ($status == self::STATUS_UNPAID && $alreadypaid != 0) {
897  $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
898  }
899  $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid');
900  $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid');
901  if ($status == self::STATUS_UNPAID && $alreadypaid != 0) {
902  $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
903  }
904  }
905 
906  $statusType = 'status1';
907  if ($status == 0 && $alreadypaid != 0) {
908  $statusType = 'status3';
909  }
910  if ($status == 1) {
911  $statusType = 'status6';
912  }
913 
914  return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
915  }
916 
924  public function getKanbanView($option = '', $arraydata = null)
925  {
926  global $langs;
927 
928  $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
929 
930  $return = '<div class="box-flex-item box-flex-grow-zero">';
931  $return .= '<div class="info-box info-box-sm">';
932  $return .= '<span class="info-box-icon bg-infobox-action">';
933  $return .= img_picto('', $this->picto);
934  //$return .= '<i class="fa fa-dol-action"></i>'; // Can be image
935  $return .= '</span>';
936  $return .= '<div class="info-box-content">';
937  $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
938  if ($selected >= 0) {
939  $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
940  }
941  if (property_exists($this, 'amount')) {
942  $return .= ' | <span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->amount).'</span>';
943  }
944  if (property_exists($this, 'type_payment')) {
945  $return .= '<br><span class="opacitymedium">'.$langs->trans("Payement").'</span> : <span class="info-box-label">'.$this->type_payment.'</span>';
946  }
947  if (property_exists($this, 'datev')) {
948  $return .= '<br><span class="opacitymedium">'.$langs->trans("DateEnd").'</span> : <span class="info-box-label" >'.dol_print_date($this->datev).'</span>';
949  }
950  if (method_exists($this, 'LibStatut')) {
951  $return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3, $this->alreadypaid).'</div>';
952  }
953  $return .= '</div>';
954  $return .= '</div>';
955  $return .= '</div>';
956  return $return;
957  }
958 }
$object ref
Definition: info.php:79
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:37
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
Definition: tva.class.php:924
tva_sum_collectee($year=0)
Total of the VAT from invoices emitted by the thirdparty.
Definition: tva.class.php:462
LibStatut($status, $mode=0, $alreadypaid=-1)
Return the label of a given VAT status.
Definition: tva.class.php:879
tva_sum_payee($year=0)
VAT paid.
Definition: tva.class.php:496
setUnpaid($user)
Remove tag paid on TVA.
Definition: tva.class.php:303
$total
Definition: tva.class.php:57
__construct($db)
Constructor.
Definition: tva.class.php:129
update($user, $notrigger=0)
Update database.
Definition: tva.class.php:222
solde($year=0)
Balance of VAT.
Definition: tva.class.php:443
getSommePaiement()
Return amount of payments already done.
Definition: tva.class.php:800
addPayment($user)
Create in database.
Definition: tva.class.php:566
getLibStatut($mode=0, $alreadypaid=-1)
Return the label of the VAT status f object.
Definition: tva.class.php:865
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Send name clicable (with possibly the picto)
Definition: tva.class.php:735
fetch($id, $ref='')
Load object in memory from database.
Definition: tva.class.php:325
update_fk_bank($id_bank)
Update link between payment tva and line generate into llx_bank.
Definition: tva.class.php:711
setPaid($user)
Tag TVA as paid completely.
Definition: tva.class.php:283
initAsSpecimen()
Initialise an instance with random values.
Definition: tva.class.php:419
info($id)
Information of vat payment object.
Definition: tva.class.php:832
create($user)
Create in database.
Definition: tva.class.php:141
tva_sum_reglee($year=0)
Total of the VAT paid.
Definition: tva.class.php:531
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:745
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolGetStatus($statusLabel='', $statusLabelShort='', $html='', $statusType='status0', $displayMode=0, $url='', $params=array())
Output the badge of a status.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
td amount
Definition: global.inc.php:554