dolibarr 19.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
29require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
30
31
35class 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 $datec;
69
73 public $fk_type;
74
78 public $paye;
79
83 public $rappro;
84
88 public $totalpaid;
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 = '';
424 $this->datep = '';
425 $this->datev = '';
426 $this->amount = '';
427 $this->label = '';
428 $this->note = '';
429 $this->fk_bank = '';
430 $this->fk_user_creat = '';
431 $this->fk_user_modif = '';
432 }
433
434
441 public function solde($year = 0)
442 {
443 $reglee = $this->tva_sum_reglee($year);
444
445 $payee = $this->tva_sum_payee($year);
446 $collectee = $this->tva_sum_collectee($year);
447
448 $solde = $reglee - ($collectee - $payee);
449
450 return $solde;
451 }
452
453 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
460 public function tva_sum_collectee($year = 0)
461 {
462 // phpcs:enable
463
464 $sql = "SELECT sum(f.total_tva) as amount";
465 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
466 if ($year) {
467 $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' ";
468 }
469
470 $result = $this->db->query($sql);
471 if ($result) {
472 if ($this->db->num_rows($result)) {
473 $obj = $this->db->fetch_object($result);
474 $ret = $obj->amount;
475 $this->db->free($result);
476 return $ret;
477 } else {
478 $this->db->free($result);
479 return 0;
480 }
481 } else {
482 print $this->db->lasterror();
483 return -1;
484 }
485 }
486
487 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
494 public function tva_sum_payee($year = 0)
495 {
496 // phpcs:enable
497
498 $sql = "SELECT sum(f.total_tva) as total_tva";
499 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
500 if ($year) {
501 $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' ";
502 }
503
504 $result = $this->db->query($sql);
505 if ($result) {
506 if ($this->db->num_rows($result)) {
507 $obj = $this->db->fetch_object($result);
508 $ret = $obj->total_tva;
509 $this->db->free($result);
510 return $ret;
511 } else {
512 $this->db->free($result);
513 return 0;
514 }
515 } else {
516 print $this->db->lasterror();
517 return -1;
518 }
519 }
520
521
522 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
529 public function tva_sum_reglee($year = 0)
530 {
531 // phpcs:enable
532
533 $sql = "SELECT sum(f.amount) as amount";
534 $sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
535
536 if ($year) {
537 $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' ";
538 }
539
540 $result = $this->db->query($sql);
541 if ($result) {
542 if ($this->db->num_rows($result)) {
543 $obj = $this->db->fetch_object($result);
544 $ret = $obj->amount;
545 $this->db->free($result);
546 return $ret;
547 } else {
548 $this->db->free($result);
549 return 0;
550 }
551 } else {
552 print $this->db->lasterror();
553 return -1;
554 }
555 }
556
557
564 public function addPayment($user)
565 {
566 global $conf, $langs;
567
568 $this->db->begin();
569
570 // Clean parameters
571 $this->amount = price2num(trim($this->amount));
572 $this->label = trim($this->label);
573 $this->note = trim($this->note);
574 $this->num_payment = trim($this->num_payment);
575 $this->fk_bank = (int) $this->fk_bank;
576 $this->fk_user_creat = (int) $this->fk_user_creat;
577 $this->fk_user_modif = (int) $this->fk_user_modif;
578 if (empty($this->datec)) {
579 $this->datec = dol_now();
580 }
581
582 // Check parameters
583 if (!$this->label) {
584 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
585 return -3;
586 }
587 if ($this->amount == '') {
588 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
589 return -4;
590 }
591 if (isModEnabled("banque") && (empty($this->accountid) || $this->accountid <= 0)) {
592 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
593 return -5;
594 }
595 if (isModEnabled("banque") && (empty($this->type_payment) || $this->type_payment <= 0)) {
596 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
597 return -5;
598 }
599
600 // Insert into llx_tva
601 $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (";
602 $sql .= "datec";
603 $sql .= ", datep";
604 $sql .= ", datev";
605 $sql .= ", amount";
606 $sql .= ", fk_typepayment";
607 $sql .= ", num_payment";
608 if ($this->note) {
609 $sql .= ", note";
610 }
611 if ($this->label) {
612 $sql .= ", label";
613 }
614 $sql .= ", fk_user_creat";
615 $sql .= ", fk_bank";
616 $sql .= ", entity";
617 $sql .= ") ";
618 $sql .= " VALUES (";
619 $sql .= " '".$this->db->idate($this->datec)."'";
620 $sql .= ", '".$this->db->idate($this->datep)."'";
621 $sql .= ", '".$this->db->idate($this->datev)."'";
622 $sql .= ", ".((float) $this->amount);
623 $sql .= ", '".$this->db->escape($this->type_payment)."'";
624 $sql .= ", '".$this->db->escape($this->num_payment)."'";
625 if ($this->note) {
626 $sql .= ", '".$this->db->escape($this->note)."'";
627 }
628 if ($this->label) {
629 $sql .= ", '".$this->db->escape($this->label)."'";
630 }
631 $sql .= ", '".$this->db->escape($user->id)."'";
632 $sql .= ", NULL";
633 $sql .= ", ".((int) $conf->entity);
634 $sql .= ")";
635
636 dol_syslog(get_class($this)."::addPayment", LOG_DEBUG);
637 $result = $this->db->query($sql);
638 if ($result) {
639 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat'
640
641 // Call trigger
642 //XXX: Should be done just befor commit no ?
643 $result = $this->call_trigger('TVA_ADDPAYMENT', $user);
644 if ($result < 0) {
645 $this->id = 0;
646 $ok = 0;
647 }
648 // End call triggers
649
650 if ($this->id > 0) {
651 $ok = 1;
652 if (isModEnabled("banque") && !empty($this->amount)) {
653 // Insert into llx_bank
654 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
655
656 $acc = new Account($this->db);
657 $result = $acc->fetch($this->accountid);
658 if ($result <= 0) {
659 dol_print_error($this->db);
660 }
661
662 if ($this->amount > 0) {
663 $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs($this->amount), $this->num_payment, '', $user);
664 } else {
665 $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs($this->amount), $this->num_payment, '', $user);
666 }
667
668 // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction
669 if ($bank_line_id > 0) {
670 $this->update_fk_bank($bank_line_id);
671 } else {
672 $this->error = $acc->error;
673 $ok = 0;
674 }
675
676 // Update links
677 $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat");
678 if ($result < 0) {
679 $this->error = $acc->error;
680 $ok = 0;
681 }
682 }
683
684 if ($ok) {
685 $this->db->commit();
686 return $this->id;
687 } else {
688 $this->db->rollback();
689 return -3;
690 }
691 } else {
692 $this->db->rollback();
693 return -2;
694 }
695 } else {
696 $this->error = $this->db->error();
697 $this->db->rollback();
698 return -1;
699 }
700 }
701
702 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
709 public function update_fk_bank($id_bank)
710 {
711 // phpcs:enable
712 $sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.(int) $id_bank;
713 $sql .= ' WHERE rowid = '.(int) $this->id;
714 $result = $this->db->query($sql);
715 if ($result) {
716 return 1;
717 } else {
718 dol_print_error($this->db);
719 return -1;
720 }
721 }
722
733 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
734 {
735 global $langs, $conf;
736
737 if (!empty($conf->dol_no_mouse_hover)) {
738 $notooltip = 1; // Force disable tooltips
739 }
740
741 $result = '';
742
743 $label = '<u>'.$langs->trans("ShowVatPayment").'</u>';
744 $label .= '<br>';
745 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
746 if (!empty($this->label)) {
747 $label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
748 }
749
750 $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id;
751
752 if ($option != 'nolink') {
753 // Add param to save lastsearch_values or not
754 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
755 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
756 $add_save_lastsearch_values = 1;
757 }
758 if ($add_save_lastsearch_values) {
759 $url .= '&save_lastsearch_values=1';
760 }
761 }
762
763 $linkclose = '';
764 if (empty($notooltip)) {
765 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
766 $label = $langs->trans("ShowMyObject");
767 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
768 }
769 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
770 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
771 } else {
772 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
773 }
774
775 $linkstart = '<a href="'.$url.'"';
776 $linkstart .= $linkclose.'>';
777 $linkend = '</a>';
778
779 $picto = 'payment';
780
781 $result .= $linkstart;
782 if ($withpicto) {
783 $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);
784 }
785 if ($withpicto != 2) {
786 $result .= $this->ref;
787 }
788 $result .= $linkend;
789
790 return $result;
791 }
792
798 public function getSommePaiement()
799 {
800 $table = 'payment_vat';
801 $field = 'fk_tva';
802
803 $sql = 'SELECT sum(amount) as amount';
804 $sql .= ' FROM '.MAIN_DB_PREFIX.$table;
805 $sql .= " WHERE ".$field." = ".((int) $this->id);
806
807 dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
808 $resql = $this->db->query($sql);
809 if ($resql) {
810 $amount = 0;
811
812 $obj = $this->db->fetch_object($resql);
813 if ($obj) {
814 $amount = $obj->amount ? $obj->amount : 0;
815 }
816
817 $this->db->free($resql);
818 return $amount;
819 } else {
820 return -1;
821 }
822 }
823
830 public function info($id)
831 {
832 $sql = "SELECT t.rowid, t.tms, t.fk_user_modif, t.datec, t.fk_user_creat";
833 $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
834 $sql .= " WHERE t.rowid = ".(int) $id;
835
836 dol_syslog(get_class($this)."::info", LOG_DEBUG);
837 $result = $this->db->query($sql);
838 if ($result) {
839 if ($this->db->num_rows($result)) {
840 $obj = $this->db->fetch_object($result);
841
842 $this->id = $obj->rowid;
843
844 $this->user_creation_id = $obj->fk_user_creat;
845 $this->user_modification_id = $obj->fk_user_modif;
846 $this->date_creation = $this->db->jdate($obj->datec);
847 $this->date_modification = $this->db->jdate($obj->tms);
848 }
849
850 $this->db->free($result);
851 } else {
852 dol_print_error($this->db);
853 }
854 }
855
863 public function getLibStatut($mode = 0, $alreadypaid = -1)
864 {
865 return $this->LibStatut($this->paye, $mode, $alreadypaid);
866 }
867
868 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
877 public function LibStatut($status, $mode = 0, $alreadypaid = -1)
878 {
879 // phpcs:enable
880 global $langs;
881
882 // Load translation files required by the page
883 $langs->loadLangs(array("customers", "bills"));
884
885 // We reinit status array to force to redefine them because label may change according to properties values.
886 $this->labelStatus = array();
887 $this->labelStatusShort = array();
888
889 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
890 global $langs;
891 //$langs->load("mymodule");
892 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid');
893 $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid');
894 if ($status == self::STATUS_UNPAID && $alreadypaid != 0) {
895 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
896 }
897 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid');
898 $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid');
899 if ($status == self::STATUS_UNPAID && $alreadypaid != 0) {
900 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
901 }
902 }
903
904 $statusType = 'status1';
905 if ($status == 0 && $alreadypaid != 0) {
906 $statusType = 'status3';
907 }
908 if ($status == 1) {
909 $statusType = 'status6';
910 }
911
912 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
913 }
914
922 public function getKanbanView($option = '', $arraydata = null)
923 {
924 global $langs;
925
926 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
927
928 $return = '<div class="box-flex-item box-flex-grow-zero">';
929 $return .= '<div class="info-box info-box-sm">';
930 $return .= '<span class="info-box-icon bg-infobox-action">';
931 $return .= img_picto('', $this->picto);
932 //$return .= '<i class="fa fa-dol-action"></i>'; // Can be image
933 $return .= '</span>';
934 $return .= '<div class="info-box-content">';
935 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
936 if ($selected >= 0) {
937 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
938 }
939 if (property_exists($this, 'amount')) {
940 $return .= ' | <span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->amount).'</span>';
941 }
942 if (property_exists($this, 'type_payment')) {
943 $return .= '<br><span class="opacitymedium">'.$langs->trans("Payement").'</span> : <span class="info-box-label">'.$this->type_payment.'</span>';
944 }
945 if (property_exists($this, 'datev')) {
946 $return .= '<br><span class="opacitymedium">'.$langs->trans("DateEnd").'</span> : <span class="info-box-label" >'.dol_print_date($this->datev).'</span>';
947 }
948 if (method_exists($this, 'LibStatut')) {
949 $return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3, $this->alreadypaid).'</div>';
950 }
951 $return .= '</div>';
952 $return .= '</div>';
953 $return .= '</div>';
954 return $return;
955 }
956}
$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:36
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
tva_sum_collectee($year=0)
Total of the VAT from invoices emitted by the thirdparty.
LibStatut($status, $mode=0, $alreadypaid=-1)
Return the label of a given VAT status.
tva_sum_payee($year=0)
VAT payed.
setUnpaid($user)
Remove tag payed on TVA.
__construct($db)
Constructor.
update($user, $notrigger=0)
Update database.
solde($year=0)
Balance of VAT.
getSommePaiement()
Return amount of payments already done.
addPayment($user)
Create in database.
getLibStatut($mode=0, $alreadypaid=-1)
Return the label of the VAT status f object.
getNomUrl($withpicto=0, $option='', $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Send name clicable (with possibly the picto)
fetch($id, $ref='')
Load object in memory from database.
update_fk_bank($id_bank)
Update link between payment tva and line generate into llx_bank.
setPaid($user)
Tag TVA as payed completely.
initAsSpecimen()
Initialise an instance with random values.
info($id)
Informations of vat payment object.
create($user)
Create in database.
tva_sum_reglee($year=0)
Total of the VAT payed.
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)
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.