dolibarr 21.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
30require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
31
32
37class Tva extends CommonObject
38{
42 public $element = 'tva';
43
47 public $table_element = 'tva';
48
52 public $picto = 'payment';
53
59 public $total;
60
64 public $datep;
65
69 public $datev;
70
74 public $amount;
75
79 public $type_payment;
80
85 public $num_payment;
86
90 public $datec;
91
95 public $fk_type;
96
100 public $paye;
101
105 public $rappro;
106
110 public $label;
111
115 public $fk_bank;
116
120 public $accountid;
121
125 public $fk_user_creat;
126
130 public $fk_user_modif;
131
135 public $paiementtype;
136
137
138 const STATUS_UNPAID = 0;
139 const STATUS_PAID = 1;
140
146 public function __construct($db)
147 {
148 $this->db = $db;
149 }
150
151
158 public function create($user)
159 {
160 global $conf, $langs;
161
162 $error = 0;
163 $now = dol_now();
164
165 // Clean parameters
166 $this->amount = (float) price2num($this->amount);
167 $this->label = trim($this->label);
168 $this->type_payment = (int) $this->type_payment;
169 $this->note = trim($this->note);
170 $this->fk_account = (int) $this->fk_account;
171 $this->fk_user_creat = (int) $this->fk_user_creat;
172 $this->fk_user_modif = (int) $this->fk_user_modif;
173
174 // Check parameters
175 // Put here code to add control on parameters values
176
177 $this->db->begin();
178
179 // Insert request
180 $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva(";
181 $sql .= "entity,";
182 $sql .= "datec,";
183 $sql .= "datep,";
184 $sql .= "datev,";
185 $sql .= "amount,";
186 $sql .= "label,";
187 $sql .= "note,";
188 $sql .= "fk_account,";
189 $sql .= "fk_typepayment,";
190 $sql .= "fk_user_creat,";
191 $sql .= "fk_user_modif";
192 $sql .= ") VALUES (";
193 $sql .= " ".((int) $conf->entity).", ";
194 $sql .= " '".$this->db->idate($now)."',";
195 $sql .= " '".$this->db->idate($this->datep)."',";
196 $sql .= " '".$this->db->idate($this->datev)."',";
197 $sql .= " '".$this->db->escape($this->amount)."',";
198 $sql .= " '".$this->db->escape($this->label)."',";
199 $sql .= " '".$this->db->escape($this->note)."',";
200 $sql .= " '".$this->db->escape($this->fk_account)."',";
201 $sql .= " '".$this->db->escape($this->type_payment)."',";
202 $sql .= " ".($this->fk_user_creat > 0 ? (int) $this->fk_user_creat : (int) $user->id).",";
203 $sql .= " ".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : (int) $user->id);
204 $sql .= ")";
205
206 dol_syslog(get_class($this)."::create", LOG_DEBUG);
207 $resql = $this->db->query($sql);
208 if ($resql) {
209 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva");
210
211 // Call trigger
212 $result = $this->call_trigger('TVA_CREATE', $user);
213 if ($result < 0) {
214 $error++;
215 }
216 // End call triggers
217
218 if (!$error) {
219 $this->db->commit();
220 return $this->id;
221 } else {
222 $this->db->rollback();
223 return -1;
224 }
225 } else {
226 $this->error = "Error ".$this->db->lasterror();
227 $this->db->rollback();
228 return -1;
229 }
230 }
231
239 public function update($user, $notrigger = 0)
240 {
241 global $conf, $langs;
242
243 $error = 0;
244
245 // Clean parameters
246 $this->amount = (float) price2num($this->amount);
247 $this->label = trim($this->label);
248 $this->note = trim($this->note);
249 $this->fk_user_creat = (int) $this->fk_user_creat;
250 $this->fk_user_modif = (int) $this->fk_user_modif;
251
252 // Check parameters
253 // Put here code to add control on parameters values
254
255 $this->db->begin();
256
257 // Update request
258 $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
259 $sql .= " tms='".$this->db->idate($this->tms)."',";
260 $sql .= " datep='".$this->db->idate($this->datep)."',";
261 $sql .= " datev='".$this->db->idate($this->datev)."',";
262 $sql .= " amount=".price2num($this->amount).",";
263 $sql .= " label='".$this->db->escape($this->label)."',";
264 $sql .= " note='".$this->db->escape($this->note)."',";
265 $sql .= " fk_user_creat=".((int) $this->fk_user_creat).",";
266 $sql .= " fk_user_modif=".((int) ($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id));
267 $sql .= " WHERE rowid=".((int) $this->id);
268
269 dol_syslog(get_class($this)."::update", LOG_DEBUG);
270 $resql = $this->db->query($sql);
271 if (!$resql) {
272 $this->error = "Error ".$this->db->lasterror();
273 $error++;
274 }
275
276 if (!$error && !$notrigger) {
277 // Call trigger
278 $result = $this->call_trigger('TVA_MODIFY', $user);
279 if ($result < 0) {
280 $error++;
281 }
282 // End call triggers
283 }
284
285 if (!$error) {
286 $this->db->commit();
287 return 1;
288 } else {
289 $this->db->rollback();
290 return -1;
291 }
292 }
293
300 public function setPaid($user)
301 {
302 // phpcs:enable
303 $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
304 $sql .= " paye = 1";
305 $sql .= " WHERE rowid = ".((int) $this->id);
306 $resql = $this->db->query($sql);
307 if ($resql) {
308 return 1;
309 } else {
310 return -1;
311 }
312 }
313
320 public function setUnpaid($user)
321 {
322 // phpcs:enable
323 $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET";
324 $sql .= " paye = 0";
325 $sql .= " WHERE rowid = ".((int) $this->id);
326 $resql = $this->db->query($sql);
327 if ($resql) {
328 return 1;
329 } else {
330 return -1;
331 }
332 }
333
334
342 public function fetch($id, $ref = '')
343 {
344 $sql = "SELECT";
345 $sql .= " t.rowid,";
346 $sql .= " t.tms,";
347 $sql .= " t.datep,";
348 $sql .= " t.datev,";
349 $sql .= " t.amount,";
350 $sql .= " t.fk_typepayment,";
351 $sql .= " t.num_payment,";
352 $sql .= " t.label,";
353 $sql .= " t.note,";
354 $sql .= " t.paye,";
355 $sql .= " t.fk_user_creat,";
356 $sql .= " t.fk_user_modif,";
357 $sql .= " t.fk_account";
358 $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
359 $sql .= " WHERE t.rowid = ".((int) $id);
360
361 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
362
363 $resql = $this->db->query($sql);
364 if ($resql) {
365 if ($this->db->num_rows($resql)) {
366 $obj = $this->db->fetch_object($resql);
367
368 $this->id = $obj->rowid;
369 $this->ref = $obj->rowid;
370 $this->tms = $this->db->jdate($obj->tms);
371 $this->datep = $this->db->jdate($obj->datep);
372 $this->datev = $this->db->jdate($obj->datev);
373 $this->amount = $obj->amount;
374 $this->type_payment = $obj->fk_typepayment;
375 $this->num_payment = $obj->num_payment;
376 $this->label = $obj->label;
377 $this->paye = $obj->paye;
378 $this->note = $obj->note;
379 $this->fk_user_creat = $obj->fk_user_creat;
380 $this->fk_user_modif = $obj->fk_user_modif;
381 $this->fk_account = $obj->fk_account;
382 $this->fk_type = empty($obj->fk_type) ? "" : $obj->fk_type;
383 $this->rappro = empty($obj->rappro) ? "" : $obj->rappro;
384 }
385 $this->db->free($resql);
386
387 return 1;
388 } else {
389 $this->error = "Error ".$this->db->lasterror();
390 return -1;
391 }
392 }
393
394
401 public function delete($user)
402 {
403 global $conf, $langs;
404
405 $error = 0;
406
407 // Call trigger
408 $result = $this->call_trigger('TVA_DELETE', $user);
409 if ($result < 0) {
410 return -1;
411 }
412 // End call triggers
413
414 $sql = "DELETE FROM ".MAIN_DB_PREFIX."tva";
415 $sql .= " WHERE rowid=".((int) $this->id);
416
417 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
418 $resql = $this->db->query($sql);
419 if (!$resql) {
420 $this->error = "Error ".$this->db->lasterror();
421 return -1;
422 }
423
424
425 return 1;
426 }
427
428
436 public function initAsSpecimen()
437 {
438 $this->id = 0;
439
440 $this->tms = dol_now();
441 $this->datep = dol_now();
442 $this->datev = dol_now();
443 $this->amount = 100.0;
444 $this->label = '';
445 $this->note = '';
446 $this->fk_bank = 0;
447 $this->fk_user_creat = 0;
448 $this->fk_user_modif = 0;
449
450 return 1;
451 }
452
453
460 public function solde($year = 0)
461 {
462 $reglee = $this->tva_sum_reglee($year);
463
464 $payee = $this->tva_sum_payee($year);
465 $collectee = $this->tva_sum_collectee($year);
466
467 $solde = $reglee - ($collectee - $payee);
468
469 return $solde;
470 }
471
472 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
479 public function tva_sum_collectee($year = 0)
480 {
481 // phpcs:enable
482
483 $sql = "SELECT sum(f.total_tva) as amount";
484 $sql .= " FROM ".MAIN_DB_PREFIX."facture as f WHERE f.paye = 1";
485 if ($year) {
486 $sql .= " AND f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' ";
487 }
488
489 $result = $this->db->query($sql);
490 if ($result) {
491 if ($this->db->num_rows($result)) {
492 $obj = $this->db->fetch_object($result);
493 $ret = $obj->amount;
494 $this->db->free($result);
495 return $ret;
496 } else {
497 $this->db->free($result);
498 return 0;
499 }
500 } else {
501 print $this->db->lasterror();
502 return -1;
503 }
504 }
505
506 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
513 public function tva_sum_payee($year = 0)
514 {
515 // phpcs:enable
516
517 $sql = "SELECT sum(f.total_tva) as total_tva";
518 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f";
519 if ($year) {
520 $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' ";
521 }
522
523 $result = $this->db->query($sql);
524 if ($result) {
525 if ($this->db->num_rows($result)) {
526 $obj = $this->db->fetch_object($result);
527 $ret = $obj->total_tva;
528 $this->db->free($result);
529 return $ret;
530 } else {
531 $this->db->free($result);
532 return 0;
533 }
534 } else {
535 print $this->db->lasterror();
536 return -1;
537 }
538 }
539
540
541 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
548 public function tva_sum_reglee($year = 0)
549 {
550 // phpcs:enable
551
552 $sql = "SELECT sum(f.amount) as amount";
553 $sql .= " FROM ".MAIN_DB_PREFIX."tva as f";
554
555 if ($year) {
556 $sql .= " WHERE f.datev >= '".$this->db->escape($year)."-01-01' AND f.datev <= '".$this->db->escape($year)."-12-31' ";
557 }
558
559 $result = $this->db->query($sql);
560 if ($result) {
561 if ($this->db->num_rows($result)) {
562 $obj = $this->db->fetch_object($result);
563 $ret = $obj->amount;
564 $this->db->free($result);
565 return $ret;
566 } else {
567 $this->db->free($result);
568 return 0;
569 }
570 } else {
571 print $this->db->lasterror();
572 return -1;
573 }
574 }
575
576
583 public function addPayment($user)
584 {
585 global $conf, $langs;
586
587 $this->db->begin();
588
589 // Clean parameters
590 $this->amount = (float) price2num($this->amount);
591 $this->label = trim($this->label);
592 $this->note = trim($this->note);
593 $this->num_payment = trim($this->num_payment);
594 $this->fk_bank = (int) $this->fk_bank;
595 $this->fk_user_creat = (int) $this->fk_user_creat;
596 $this->fk_user_modif = (int) $this->fk_user_modif;
597 if (empty($this->datec)) {
598 $this->datec = dol_now();
599 }
600
601 // Check parameters
602 if (!$this->label) {
603 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
604 return -3;
605 }
606 if ($this->amount == '') {
607 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
608 return -4;
609 }
610 if (isModEnabled("bank") && (empty($this->accountid) || $this->accountid <= 0)) {
611 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("BankAccount"));
612 return -5;
613 }
614 if (isModEnabled("bank") && (empty($this->type_payment) || $this->type_payment <= 0)) {
615 $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
616 return -5;
617 }
618
619 // Insert into llx_tva
620 $sql = "INSERT INTO ".MAIN_DB_PREFIX."tva (";
621 $sql .= "datec";
622 $sql .= ", datep";
623 $sql .= ", datev";
624 $sql .= ", amount";
625 $sql .= ", fk_typepayment";
626 $sql .= ", num_payment";
627 if ($this->note) {
628 $sql .= ", note";
629 }
630 if ($this->label) {
631 $sql .= ", label";
632 }
633 $sql .= ", fk_user_creat";
634 $sql .= ", fk_bank";
635 $sql .= ", entity";
636 $sql .= ") ";
637 $sql .= " VALUES (";
638 $sql .= " '".$this->db->idate($this->datec)."'";
639 $sql .= ", '".$this->db->idate($this->datep)."'";
640 $sql .= ", '".$this->db->idate($this->datev)."'";
641 $sql .= ", ".((float) $this->amount);
642 $sql .= ", '".$this->db->escape($this->type_payment)."'";
643 $sql .= ", '".$this->db->escape($this->num_payment)."'";
644 if ($this->note) {
645 $sql .= ", '".$this->db->escape($this->note)."'";
646 }
647 if ($this->label) {
648 $sql .= ", '".$this->db->escape($this->label)."'";
649 }
650 $sql .= ", '".$this->db->escape($user->id)."'";
651 $sql .= ", NULL";
652 $sql .= ", ".((int) $conf->entity);
653 $sql .= ")";
654
655 dol_syslog(get_class($this)."::addPayment", LOG_DEBUG);
656 $result = $this->db->query($sql);
657 if ($result) {
658 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."tva"); // TODO should be called 'payment_vat'
659
660 // Call trigger
661 //XXX: Should be done just before commit no ?
662 $result = $this->call_trigger('TVA_ADDPAYMENT', $user);
663 if ($result < 0) {
664 $this->id = 0;
665 $ok = 0;
666 }
667 // End call triggers
668
669 if ($this->id > 0) {
670 $ok = 1;
671 if (isModEnabled("bank") && !empty($this->amount)) {
672 // Insert into llx_bank
673 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
674
675 $acc = new Account($this->db);
676 $result = $acc->fetch($this->accountid);
677 if ($result <= 0) {
678 dol_print_error($this->db);
679 }
680
681 if ($this->amount > 0) {
682 $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, -abs((float) $this->amount), $this->num_payment, 0, $user);
683 } else {
684 $bank_line_id = $acc->addline($this->datep, $this->type_payment, $this->label, abs((float) $this->amount), $this->num_payment, 0, $user);
685 }
686
687 // Update fk_bank into llx_tva. So we know vat line used to generate bank transaction
688 if ($bank_line_id > 0) {
689 $this->update_fk_bank($bank_line_id);
690 } else {
691 $this->error = $acc->error;
692 $ok = 0;
693 }
694
695 // Update links
696 $result = $acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', "(VATPayment)", "payment_vat");
697 if ($result < 0) {
698 $this->error = $acc->error;
699 $ok = 0;
700 }
701 }
702
703 if ($ok) {
704 $this->db->commit();
705 return $this->id;
706 } else {
707 $this->db->rollback();
708 return -3;
709 }
710 } else {
711 $this->db->rollback();
712 return -2;
713 }
714 } else {
715 $this->error = $this->db->error();
716 $this->db->rollback();
717 return -1;
718 }
719 }
720
721 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
728 public function update_fk_bank($id_bank)
729 {
730 // phpcs:enable
731 $sql = 'UPDATE '.MAIN_DB_PREFIX.'tva SET fk_bank = '.(int) $id_bank;
732 $sql .= ' WHERE rowid = '.(int) $this->id;
733 $result = $this->db->query($sql);
734 if ($result) {
735 return 1;
736 } else {
737 dol_print_error($this->db);
738 return -1;
739 }
740 }
741
752 public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
753 {
754 global $langs, $conf;
755
756 if (!empty($conf->dol_no_mouse_hover)) {
757 $notooltip = 1; // Force disable tooltips
758 }
759
760 $result = '';
761
762 $label = '<u>'.$langs->trans("ShowVatPayment").'</u>';
763 $label .= '<br>';
764 $label .= '<b>'.$langs->trans('Ref').':</b> '.$this->ref;
765 if (!empty($this->label)) {
766 $label .= '<br><b>'.$langs->trans('Label').':</b> '.$this->label;
767 }
768
769 $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id;
770
771 if ($option != 'nolink') {
772 // Add param to save lastsearch_values or not
773 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
774 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
775 $add_save_lastsearch_values = 1;
776 }
777 if ($add_save_lastsearch_values) {
778 $url .= '&save_lastsearch_values=1';
779 }
780 }
781
782 $linkclose = '';
783 if (empty($notooltip)) {
784 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
785 $label = $langs->trans("ShowMyObject");
786 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
787 }
788 $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
789 $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
790 } else {
791 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
792 }
793
794 $linkstart = '<a href="'.$url.'"';
795 $linkstart .= $linkclose.'>';
796 $linkend = '</a>';
797
798 $picto = 'payment';
799
800 $result .= $linkstart;
801 if ($withpicto) {
802 $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);
803 }
804 if ($withpicto != 2) {
805 $result .= $this->ref;
806 }
807 $result .= $linkend;
808
809 return $result;
810 }
811
817 public function getSommePaiement()
818 {
819 $table = 'payment_vat';
820 $field = 'fk_tva';
821
822 $sql = 'SELECT sum(amount) as amount';
823 $sql .= ' FROM '.MAIN_DB_PREFIX.$table;
824 $sql .= " WHERE ".$field." = ".((int) $this->id);
825
826 dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
827 $resql = $this->db->query($sql);
828 if ($resql) {
829 $amount = 0;
830
831 $obj = $this->db->fetch_object($resql);
832 if ($obj) {
833 $amount = $obj->amount ? $obj->amount : 0;
834 }
835
836 $this->db->free($resql);
837 return $amount;
838 } else {
839 return -1;
840 }
841 }
842
849 public function info($id)
850 {
851 $sql = "SELECT t.rowid, t.tms, t.fk_user_modif, t.datec, t.fk_user_creat";
852 $sql .= " FROM ".MAIN_DB_PREFIX."tva as t";
853 $sql .= " WHERE t.rowid = ".(int) $id;
854
855 dol_syslog(get_class($this)."::info", LOG_DEBUG);
856 $result = $this->db->query($sql);
857 if ($result) {
858 if ($this->db->num_rows($result)) {
859 $obj = $this->db->fetch_object($result);
860
861 $this->id = $obj->rowid;
862
863 $this->user_creation_id = $obj->fk_user_creat;
864 $this->user_modification_id = $obj->fk_user_modif;
865 $this->date_creation = $this->db->jdate($obj->datec);
866 $this->date_modification = $this->db->jdate($obj->tms);
867 }
868
869 $this->db->free($result);
870 } else {
871 dol_print_error($this->db);
872 }
873 }
874
882 public function getLibStatut($mode = 0, $alreadypaid = -1)
883 {
884 return $this->LibStatut($this->paye, $mode, $alreadypaid);
885 }
886
887 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
896 public function LibStatut($status, $mode = 0, $alreadypaid = -1)
897 {
898 // phpcs:enable
899 global $langs;
900
901 // Load translation files required by the page
902 $langs->loadLangs(array("customers", "bills"));
903
904 // We reinit status array to force to redefine them because label may change according to properties values.
905 $this->labelStatus = array();
906 $this->labelStatusShort = array();
907
908 if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
909 global $langs;
910 //$langs->load("mymodule");
911 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid');
912 $this->labelStatus[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid');
913 if ($status == self::STATUS_UNPAID && $alreadypaid != 0) {
914 $this->labelStatus[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
915 }
916 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv('BillStatusNotPaid');
917 $this->labelStatusShort[self::STATUS_PAID] = $langs->transnoentitiesnoconv('BillStatusPaid');
918 if ($status == self::STATUS_UNPAID && $alreadypaid != 0) {
919 $this->labelStatusShort[self::STATUS_UNPAID] = $langs->transnoentitiesnoconv("BillStatusStarted");
920 }
921 }
922
923 $statusType = 'status1';
924 if ($status == 0 && $alreadypaid != 0) {
925 $statusType = 'status3';
926 }
927 if ($status == 1) {
928 $statusType = 'status6';
929 }
930
931 return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
932 }
933
941 public function getKanbanView($option = '', $arraydata = null)
942 {
943 global $langs;
944
945 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
946
947 $return = '<div class="box-flex-item box-flex-grow-zero">';
948 $return .= '<div class="info-box info-box-sm">';
949 $return .= '<span class="info-box-icon bg-infobox-action">';
950 $return .= img_picto('', $this->picto);
951 //$return .= '<i class="fa fa-dol-action"></i>'; // Can be image
952 $return .= '</span>';
953 $return .= '<div class="info-box-content">';
954 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
955 if ($selected >= 0) {
956 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
957 }
958 if (property_exists($this, 'amount')) {
959 $return .= ' | <span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->amount).'</span>';
960 }
961 if (property_exists($this, 'type_payment')) {
962 $return .= '<br><span class="opacitymedium">'.$langs->trans("Payement").'</span> : <span class="info-box-label">'.$this->type_payment.'</span>';
963 }
964 if (property_exists($this, 'datev')) {
965 $return .= '<br><span class="opacitymedium">'.$langs->trans("DateEnd").'</span> : <span class="info-box-label" >'.dol_print_date($this->datev).'</span>';
966 }
967 if (method_exists($this, 'LibStatut')) {
968 $return .= '<br><div class="info-box-status margintoponly">'.$this->getLibStatut(3, $this->alreadypaid).'</div>';
969 }
970 $return .= '</div>';
971 $return .= '</div>';
972 $return .= '</div>';
973 return $return;
974 }
975}
$object ref
Definition info.php:89
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.
Class to manage VAT - Value-added tax (also known in French as TVA - Taxe sur la valeur ajoutée)
Definition tva.class.php:38
getKanbanView($option='', $arraydata=null)
Return clickable 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 paid.
setUnpaid($user)
Remove tag paid 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 clickable (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 paid completely.
initAsSpecimen()
Initialise an instance with random values.
info($id)
Information of vat payment object.
create($user)
Create in database.
tva_sum_reglee($year=0)
Total of the VAT paid.
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 a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79