dolibarr 20.0.0
paymentsalary.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
3 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
4 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
5 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Put here all includes required by your class file
29require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
30require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
31
32
37{
41 public $element = 'payment_salary';
42
46 public $table_element = 'payment_salary';
47
51 public $picto = 'payment';
52
58 public $chid;
59
63 public $fk_salary;
64
68 public $datec = '';
69
75 public $datepaye = '';
76
80 public $datep = '';
81
86 public $total;
87
91 public $amount;
92
96 public $amounts = array();
97
101 public $fk_typepayment;
102
107 public $num_paiement;
108
113 public $num_payment;
114
118 public $fk_bank;
119
123 public $bank_line;
124
128 public $fk_user_author;
129
133 public $fk_user_modif;
134
138 public $type_code;
139
143 public $type_label;
144
148 public $bank_account;
149
153 public $datev = '';
154
158 public $fields = array(
159 'rowid' => array('type' => 'integer', 'label' => 'TechnicalID', 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'index' => 1, 'position' => 1, 'comment' => 'Id'),
160 );
161
167 public function __construct($db)
168 {
169 $this->db = $db;
170 }
171
180 public function create($user, $closepaidcontrib = 0)
181 {
182 global $conf;
183
184 $error = 0;
185
186 $now = dol_now();
187
188 dol_syslog(get_class($this)."::create", LOG_DEBUG);
189
190 //deprecatd
191 if (!empty($this->datepaye) && empty($this->datep)) {
192 dol_syslog(__METHOD__.": using datepaye is deprecated, please use datep instead", LOG_WARNING);
193 $this->datep = $this->datepaye;
194 }
195
196 // Validate parameters
197 if (empty($this->datep)) {
198 $this->error = 'ErrorBadValueForParameterCreatePaymentSalary';
199 return -1;
200 }
201
202 // Clean parameters
203 if (isset($this->fk_salary)) {
204 $this->fk_salary = (int) $this->fk_salary;
205 }
206 if (isset($this->amount)) {
207 $this->amount = (float) $this->amount;
208 }
209 if (isset($this->fk_typepayment)) {
210 $this->fk_typepayment = (int) $this->fk_typepayment;
211 }
212 if (isset($this->num_paiement)) {
213 $this->num_paiement = trim($this->num_paiement);
214 } // deprecated
215 if (isset($this->num_payment)) {
216 $this->num_payment = trim($this->num_payment);
217 }
218 if (isset($this->note)) {
219 $this->note = trim($this->note);
220 }
221 if (isset($this->fk_bank)) {
222 $this->fk_bank = (int) $this->fk_bank;
223 }
224 if (isset($this->fk_user_author)) {
225 $this->fk_user_author = (int) $this->fk_user_author;
226 }
227 if (isset($this->fk_user_modif)) {
228 $this->fk_user_modif = (int) $this->fk_user_modif;
229 }
230
231 $totalamount = 0;
232 foreach ($this->amounts as $key => $value) { // How payment is dispatch
233 $newvalue = (float) price2num($value, 'MT');
234 $this->amounts[$key] = $newvalue;
235 $totalamount += $newvalue;
236 }
237
238 // Check parameters
239 $totalamount = (float) price2num($totalamount, 'MT'); // this is to ensure the following test is no biaised by a potential float equal to 0.0000000000001
240 if ($totalamount == 0) {
241 return -1;
242 } // On accepte les montants negatifs pour les rejets de prelevement mais pas null
243
244
245 $this->db->begin();
246
247 if ($totalamount != 0) {
248 // Insert array of amounts
249 foreach ($this->amounts as $key => $amount) {
250 $salary_id = $key;
251 if (is_numeric($amount) && !empty($amount)) {
252 // We can have n payments for 1 salary but we can't have 1 payments for n salaries (for invoices link is n-n, not for salaries).
253 $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (entity, fk_salary, datec, datep, amount,";
254 $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)";
255 $sql .= " VALUES (".((int) $conf->entity).", ".((int) $salary_id).", '".$this->db->idate($now)."',";
256 $sql .= " '".$this->db->idate($this->datep)."',";
257 $sql .= " ".((float) $amount).",";
258 $sql .= " ".((int) $this->fk_typepayment).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).",";
259 $sql .= " 0)";
260
261 $resql = $this->db->query($sql);
262 if ($resql) {
263 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
264 }
265
266 // If we want to closed paid invoices
267 if ($closepaidcontrib) {
268 $tmpsalary = new Salary($this->db);
269 $tmpsalary->fetch($salary_id);
270 $paiement = $tmpsalary->getSommePaiement();
271 //$creditnotes=$tmpsalary->getSumCreditNotesUsed();
272 $creditnotes = 0;
273 //$deposits=$tmpsalary->getSumDepositsUsed();
274 $deposits = 0;
275 $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
276 $remaintopay = price2num($tmpsalary->amount - $paiement - $creditnotes - $deposits, 'MT');
277 if ($remaintopay == 0) {
278 $result = $tmpsalary->setPaid($user);
279 } else {
280 dol_syslog("Remain to pay for salary id=".$salary_id." not null. We do nothing.");
281 }
282 }
283 }
284 }
285 }
286
287 $result = $this->call_trigger('PAYMENTSALARY_CREATE', $user);
288 if ($result < 0) {
289 $error++;
290 }
291
292 if ($totalamount != 0 && !$error) {
293 $this->amount = $totalamount;
294 $this->total = $totalamount; // deprecated
295 $this->db->commit();
296 return $this->id; // id of the last payment inserted
297 } else {
298 $this->error = $this->db->error();
299 $this->db->rollback();
300 return -1;
301 }
302 }
303
310 public function fetch($id)
311 {
312 global $langs;
313 $sql = "SELECT";
314 $sql .= " t.rowid,";
315 $sql .= " t.fk_salary,";
316 $sql .= " t.datec,";
317 $sql .= " t.tms,";
318 $sql .= " t.datep,";
319 $sql .= " t.amount,";
320 $sql .= " t.fk_typepayment,";
321 $sql .= " t.num_payment as num_payment,";
322 $sql .= " t.note,";
323 $sql .= " t.fk_bank,";
324 $sql .= " t.fk_user_author,";
325 $sql .= " t.fk_user_modif,";
326 $sql .= " pt.code as type_code, pt.libelle as type_label,";
327 $sql .= ' b.fk_account';
328 $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id";
329 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
330 $sql .= " WHERE t.rowid = ".((int) $id);
331 // TODO link on entity of tax;
332
333 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
334 $resql = $this->db->query($sql);
335 if ($resql) {
336 if ($this->db->num_rows($resql)) {
337 $obj = $this->db->fetch_object($resql);
338
339 $this->id = $obj->rowid;
340 $this->ref = $obj->rowid;
341
342 $this->fk_salary = $obj->fk_salary;
343 $this->datec = $this->db->jdate($obj->datec);
344 $this->tms = $this->db->jdate($obj->tms);
345 $this->datepaye = $this->db->jdate($obj->datep);
346 $this->amount = $obj->amount;
347 $this->fk_typepayment = $obj->fk_typepayment;
348 $this->num_paiement = $obj->num_payment;
349 $this->num_payment = $obj->num_payment;
350 $this->note = $obj->note;
351 $this->note_private = $obj->note;
352 $this->fk_bank = $obj->fk_bank;
353 $this->fk_user_author = $obj->fk_user_author;
354 $this->fk_user_modif = $obj->fk_user_modif;
355
356 $this->type_code = $obj->type_code;
357 $this->type_label = $obj->type_label;
358
359 $this->bank_account = $obj->fk_account;
360 $this->bank_line = $obj->fk_bank;
361 }
362 $this->db->free($resql);
363
364 return 1;
365 } else {
366 $this->error = "Error ".$this->db->lasterror();
367 return -1;
368 }
369 }
370
371
379 public function update($user = null, $notrigger = 0)
380 {
381 global $conf, $langs;
382 $error = 0;
383
384 // Clean parameters
385
386 if (isset($this->fk_salary)) {
387 $this->fk_salary = (int) $this->fk_salary;
388 }
389 if (isset($this->amount)) {
390 $this->amount = (float) $this->amount;
391 }
392 if (isset($this->fk_typepayment)) {
393 $this->fk_typepayment = (int) $this->fk_typepayment;
394 }
395 if (isset($this->num_paiement)) {
396 $this->num_paiement = trim($this->num_paiement);
397 } // deprecated
398 if (isset($this->num_payment)) {
399 $this->num_payment = trim($this->num_payment);
400 }
401 if (isset($this->note)) {
402 $this->note = trim($this->note);
403 }
404 if (isset($this->fk_bank)) {
405 $this->fk_bank = (int) $this->fk_bank;
406 }
407 if (isset($this->fk_user_author)) {
408 $this->fk_user_author = (int) $this->fk_user_author;
409 }
410 if (isset($this->fk_user_modif)) {
411 $this->fk_user_modif = (int) $this->fk_user_modif;
412 }
413
414 // Check parameters
415 // Put here code to add control on parameters values
416
417 // Update request
418 $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET";
419 $sql .= " fk_salary=".(isset($this->fk_salary) ? $this->fk_salary : "null").",";
420 $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
421 $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
422 $sql .= " datep=".(dol_strlen($this->datepaye) != 0 ? "'".$this->db->idate($this->datepaye)."'" : 'null').",";
423 $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
424 $sql .= " fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment : "null").",";
425 $sql .= " num_payment=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
426 $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
427 $sql .= " fk_bank=".(isset($this->fk_bank) ? ((int) $this->fk_bank) : "null").",";
428 $sql .= " fk_user_author=".(isset($this->fk_user_author) ? ((int) $this->fk_user_author) : "null").",";
429 $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? ((int) $this->fk_user_modif) : "null");
430 $sql .= " WHERE rowid=".((int) $this->id);
431
432 $this->db->begin();
433
434 dol_syslog(get_class($this)."::update", LOG_DEBUG);
435 $resql = $this->db->query($sql);
436 if (!$resql) {
437 $error++;
438 $this->errors[] = "Error ".$this->db->lasterror();
439 }
440
441 // Commit or rollback
442 if ($error) {
443 foreach ($this->errors as $errmsg) {
444 dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
445 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
446 }
447 $this->db->rollback();
448 return -1 * $error;
449 } else {
450 $this->db->commit();
451 return 1;
452 }
453 }
454
455
463 public function delete($user, $notrigger = 0)
464 {
465 $error = 0;
466
467 dol_syslog(get_class($this)."::delete");
468
469 $this->db->begin();
470
471 if ($this->bank_line > 0) {
472 $accline = new AccountLine($this->db);
473 $accline->fetch($this->bank_line);
474 $result = $accline->delete($user);
475 if ($result < 0) {
476 $this->errors[] = $accline->error;
477 $error++;
478 }
479 }
480
481 if (!$error) {
482 $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary";
483 $sql .= " WHERE rowid=".((int) $this->id);
484
485 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
486 $resql = $this->db->query($sql);
487 if (!$resql) {
488 $error++;
489 $this->errors[] = "Error ".$this->db->lasterror();
490 }
491 }
492
493 // Commit or rollback
494 if ($error) {
495 foreach ($this->errors as $errmsg) {
496 dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
497 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
498 }
499 $this->db->rollback();
500 return -1 * $error;
501 } else {
502 $this->db->commit();
503 return 1;
504 }
505 }
506
507
508
516 public function createFromClone(User $user, $fromid)
517 {
518 $error = 0;
519
520 $object = new PaymentSalary($this->db);
521
522 $this->db->begin();
523
524 // Load source object
525 $object->fetch($fromid);
526 $object->id = 0;
527 $object->statut = 0;
528
529 // Clear fields
530 // ...
531
532 // Create clone
533 $object->context['createfromclone'] = 'createfromclone';
534 $result = $object->create($user);
535
536 // Other options
537 if ($result < 0) {
538 $this->error = $object->error;
539 $error++;
540 }
541
542 unset($object->context['createfromclone']);
543
544 // End
545 if (!$error) {
546 $this->db->commit();
547 return $object->id;
548 } else {
549 $this->db->rollback();
550 return -1;
551 }
552 }
553
554
562 public function initAsSpecimen()
563 {
564 $this->id = 0;
565 $this->fk_salary = 0;
566 $this->datec = '';
567 $this->tms = dol_now();
568 $this->datepaye = dol_now();
569 $this->amount = 0.0;
570 $this->fk_typepayment = 0;
571 $this->num_payment = '';
572 $this->note_private = '';
573 $this->note_public = '';
574 $this->fk_bank = 0;
575 $this->fk_user_author = 0;
576 $this->fk_user_modif = 0;
577
578 return 1;
579 }
580
581
594 public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
595 {
596 global $langs;
597
598 // Clean data
599 $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement);
600
601 $error = 0;
602
603 if (isModEnabled("bank")) {
604 include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
605
606 $acc = new Account($this->db);
607 $acc->fetch($accountid);
608
609 $total = $this->amount;
610
611 // Insert payment into llx_bank
612 $bank_line_id = $acc->addline(
613 $this->datep,
614 $this->fk_typepayment, // Payment mode id or code ("CHQ or VIR for example")
615 $label,
616 -$total,
617 $this->num_payment,
618 '',
619 $user,
620 $emetteur_nom,
621 $emetteur_banque,
622 '',
623 $this->datev
624 );
625
626 // Update fk_bank into llx_paiement_salary.
627 // so we know the payment that was used to generated the bank entry.
628 if ($bank_line_id > 0) {
629 $result = $this->update_fk_bank($bank_line_id);
630 if ($result <= 0) {
631 $error++;
632 dol_print_error($this->db);
633 }
634
635 // Add link 'payment_salary' in bank_url between payment and bank transaction
636 $url = '';
637 if ($mode == 'payment_salary') {
638 $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id=';
639 }
640
641 if ($url) {
642 $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
643 if ($result <= 0) {
644 $error++;
645 dol_print_error($this->db);
646 }
647 }
648
649 // Add link 'user' in bank_url between user and bank transaction
650 foreach ($this->amounts as $key => $value) {
651 if (!$error) {
652 if ($mode == 'payment_salary') {
653 $salary = new Salary($this->db);
654 $salary->fetch($key);
655 $salary->fetch_user($salary->fk_user);
656
657 $fuser = $salary->user;
658
659 if ($fuser->id > 0) {
660 $result = $acc->add_url_line(
661 $bank_line_id,
662 $fuser->id,
663 DOL_URL_ROOT.'/user/card.php?id=',
664 $fuser->getFullName($langs),
665 'user'
666 );
667 }
668 if ($result <= 0) {
669 $this->error = $this->db->lasterror();
670 dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->error);
671 $error++;
672 }
673 }
674 }
675 }
676 } else {
677 $this->error = $acc->error;
678 $error++;
679 }
680 }
681
682 if (!$error) {
683 return 1;
684 } else {
685 return -1;
686 }
687 }
688
689
690 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
697 public function update_fk_bank($id_bank)
698 {
699 // phpcs:enable
700 $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id);
701
702 dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
703 $result = $this->db->query($sql);
704 if ($result) {
705 return 1;
706 } else {
707 $this->error = $this->db->error();
708 return 0;
709 }
710 }
711
719 public function updatePaymentDate($date)
720 {
721 $error = 0;
722
723 if (!empty($date)) {
724 $this->db->begin();
725
726 dol_syslog(get_class($this)."::updatePaymentDate with date = ".$date, LOG_DEBUG);
727
728 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
729 $sql .= " SET datep = '".$this->db->idate($date)."'";
730 $sql .= " WHERE rowid = ".((int) $this->id);
731
732 $result = $this->db->query($sql);
733 if (!$result) {
734 $error++;
735 $this->error = 'Error -1 '.$this->db->error();
736 }
737
738 $type = $this->element;
739
740 $sql = "UPDATE ".MAIN_DB_PREFIX.'bank';
741 $sql .= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'";
742 $sql .= " WHERE rowid IN (SELECT fk_bank FROM ".MAIN_DB_PREFIX."bank_url WHERE type = '".$this->db->escape($type)."' AND url_id = ".((int) $this->id).")";
743 $sql .= " AND rappro = 0";
744
745 $result = $this->db->query($sql);
746 if (!$result) {
747 $error++;
748 $this->error = 'Error -1 '.$this->db->error();
749 }
750
751 if (!$error) {
752 }
753
754 if (!$error) {
755 $this->datepaye = $date;
756
757 $this->db->commit();
758 return 0;
759 } else {
760 $this->db->rollback();
761 return -2;
762 }
763 }
764 return -1; //no date given or already validated
765 }
766
773 public function getLibStatut($mode = 0)
774 {
775 return $this->LibStatut($this->statut, $mode);
776 }
777
778 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
786 public function LibStatut($status, $mode = 0)
787 {
788 // phpcs:enable
789 global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
790
791 $langs->load('compta');
792 /*if ($mode == 0)
793 {
794 if ($status == 0) return $langs->trans('ToValidate');
795 if ($status == 1) return $langs->trans('Validated');
796 }
797 if ($mode == 1)
798 {
799 if ($status == 0) return $langs->trans('ToValidate');
800 if ($status == 1) return $langs->trans('Validated');
801 }
802 if ($mode == 2)
803 {
804 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
805 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
806 }
807 if ($mode == 3)
808 {
809 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
810 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
811 }
812 if ($mode == 4)
813 {
814 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
815 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
816 }
817 if ($mode == 5)
818 {
819 if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
820 if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
821 }
822 if ($mode == 6)
823 {
824 if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
825 if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
826 }*/
827 return '';
828 }
829
840 public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
841 {
842 global $conf, $langs, $hookmanager;
843
844 $option = '';
845
846 if (!empty($conf->dol_no_mouse_hover)) {
847 $notooltip = 1; // Force disable tooltips
848 }
849
850 $result = '';
851 $params = [
852 'id' => $this->id,
853 'objecttype' => $this->element.($this->module ? '@'.$this->module : ''),
854 //'option' => $option,
855 ];
856 $classfortooltip = 'classfortooltip';
857 $dataparams = '';
858 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
859 $classfortooltip = 'classforajaxtooltip';
860 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
861 $label = '';
862 } else {
863 $label = implode($this->getTooltipContentArray($params));
864 }
865
866 $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$this->id;
867
868 if ($option !== 'nolink') {
869 // Add param to save lastsearch_values or not
870 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
871 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
872 $add_save_lastsearch_values = 1;
873 }
874 if ($url && $add_save_lastsearch_values) {
875 $url .= '&save_lastsearch_values=1';
876 }
877 }
878
879 $linkclose = '';
880 if (empty($notooltip)) {
881 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
882 $label = $langs->trans("SalaryPayment");
883 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
884 }
885 $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
886 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
887 } else {
888 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
889 }
890
891 if ($option == 'nolink' || empty($url)) {
892 $linkstart = '<span';
893 } else {
894 $linkstart = '<a href="'.$url.'"';
895 }
896 $linkstart .= $linkclose.'>';
897 if ($option == 'nolink' || empty($url)) {
898 $linkend = '</span>';
899 } else {
900 $linkend = '</a>';
901 }
902
903 $result .= $linkstart;
904
905 if (empty($this->showphoto_on_popup)) {
906 if ($withpicto) {
907 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
908 }
909 }
910
911 if ($withpicto != 2) {
912 $result .= $this->ref;
913 }
914
915 $result .= $linkend;
916 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
917
918 global $action, $hookmanager;
919 $hookmanager->initHooks(array($this->element.'dao'));
920 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
921 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
922 if ($reshook > 0) {
923 $result = $hookmanager->resPrint;
924 } else {
925 $result .= $hookmanager->resPrint;
926 }
927
928 return $result;
929 }
930
937 public function getTooltipContentArray($params)
938 {
939 global $conf, $langs, $user;
940
941 $langs->load('salaries');
942 $datas = [];
943
944 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
945 return ['optimize' => $langs->trans("SalaryPayment")];
946 }
947
948 if ($user->hasRight('salaries', 'read')) {
949 $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("SalaryPayment").'</u>';
950 if (isset($this->status)) {
951 $datas['status'] = ' '.$this->getLibStatut(5);
952 }
953 $datas['Ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
954 if (!empty($this->total_ttc)) {
955 $datas['AmountTTC'] = '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
956 }
957 if (!empty($this->datep)) {
958 $datas['Date'] = '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datep, 'dayhour', 'tzuserrel');
959 } elseif (!empty($this->datepaye)) {
960 $datas['Date'] = '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datepaye, 'dayhour', 'tzuserrel');
961 }
962 }
963
964 return $datas;
965 }
966
974 public function getKanbanView($option = '', $arraydata = null)
975 {
976 global $langs;
977
978 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
979
980 $return = '<div class="box-flex-item box-flex-grow-zero">';
981 $return .= '<div class="info-box info-box-sm">';
982 $return .= '<span class="info-box-icon bg-infobox-action">';
983 $return .= img_picto('', $this->picto);
984 $return .= '</span>';
985 $return .= '<div class="info-box-content">';
986 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
987 if ($selected >= 0) {
988 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
989 }
990 if (property_exists($this, 'fk_bank') && is_numeric($this->fk_bank)) {
991 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
992 $account = new AccountLine($this->db);
993 $account->fetch($this->fk_bank);
994 $return .= ' | <span class="info-box-label">'.$account->getNomUrl(1).'</span>';
995 }
996 if (property_exists($this, 'fk_user_author') && is_numeric($this->fk_user_author)) {
997 $userstatic = new User($this->db);
998 $userstatic->fetch($this->fk_user_author);
999 $return .= '<br><span class="info-box-status">'.$userstatic->getNomUrl(1).'</span>';
1000 }
1001
1002 if (property_exists($this, 'fk_typepayment')) {
1003 $return .= '<br><span class="opacitymedium">'.$langs->trans("PaymentMode").'</span> : <span class="info-box-label">'.$this->fk_typepayment.'</span>';
1004 }
1005 if (property_exists($this, 'amount')) {
1006 $return .= '<br><span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->amount).'</span>';
1007 }
1008 $return .= '</div>';
1009 $return .= '</div>';
1010 $return .= '</div>';
1011 return $return;
1012 }
1013}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Or an array listing all the potential status of the object: array: int of the status => translated la...
Definition security.php:636
$object ref
Definition info.php:79
Class to manage bank accounts.
Class to manage bank transaction lines.
Parent class of all other business classes (invoices, contracts, proposals, orders,...
call_trigger($triggerName, $user)
Call trigger based on this instance.
Class to manage payments of salaries.
LibStatut($status, $mode=0)
Return the status.
update_fk_bank($id_bank)
Mise a jour du lien entre le paiement de salaire et la ligne dans llx_bank generee.
updatePaymentDate($date)
Updates the payment date.
getLibStatut($mode=0)
Return the label of the status.
initAsSpecimen()
Initialise an instance with random values.
getNomUrl($withpicto=0, $maxlen=0, $notooltip=0, $morecss='', $save_lastsearch_value=-1)
Return clicable name (with picto eventually)
create($user, $closepaidcontrib=0)
Create payment of salary into database.
__construct($db)
Constructor.
update($user=null, $notrigger=0)
Update database.
getTooltipContentArray($params)
getTooltipContentArray
addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
Add record into bank for payment with links between this bank record and invoices of payment.
getKanbanView($option='', $arraydata=null)
Return clicable link of object (with eventually picto)
fetch($id)
Load object in memory from database.
createFromClone(User $user, $fromid)
Load an object from its id and create a new one in database.
Class to manage salary payments.
Class to manage Dolibarr users.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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).
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.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall TAKEPOS_SHOW_SUBPRICE right right right takeposterminal SELECT e e e e e statut
Definition invoice.php:1991