dolibarr 20.0.2
paymentsalary.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2011-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
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->datep = $this->db->jdate($obj->datep);
347 $this->amount = $obj->amount;
348 $this->fk_typepayment = $obj->fk_typepayment;
349 $this->num_paiement = $obj->num_payment;
350 $this->num_payment = $obj->num_payment;
351 $this->note = $obj->note;
352 $this->note_private = $obj->note;
353 $this->fk_bank = $obj->fk_bank;
354 $this->fk_user_author = $obj->fk_user_author;
355 $this->fk_user_modif = $obj->fk_user_modif;
356
357 $this->type_code = $obj->type_code;
358 $this->type_label = $obj->type_label;
359
360 $this->bank_account = $obj->fk_account;
361 $this->bank_line = $obj->fk_bank;
362 }
363 $this->db->free($resql);
364
365 return 1;
366 } else {
367 $this->error = "Error ".$this->db->lasterror();
368 return -1;
369 }
370 }
371
372
380 public function update($user = null, $notrigger = 0)
381 {
382 global $conf, $langs;
383 $error = 0;
384
385 // Clean parameters
386
387 if (isset($this->fk_salary)) {
388 $this->fk_salary = (int) $this->fk_salary;
389 }
390 if (isset($this->amount)) {
391 $this->amount = (float) $this->amount;
392 }
393 if (isset($this->fk_typepayment)) {
394 $this->fk_typepayment = (int) $this->fk_typepayment;
395 }
396 if (isset($this->num_paiement)) {
397 $this->num_paiement = trim($this->num_paiement);
398 } // deprecated
399 if (isset($this->num_payment)) {
400 $this->num_payment = trim($this->num_payment);
401 }
402 if (isset($this->note)) {
403 $this->note = trim($this->note);
404 }
405 if (isset($this->fk_bank)) {
406 $this->fk_bank = (int) $this->fk_bank;
407 }
408 if (isset($this->fk_user_author)) {
409 $this->fk_user_author = (int) $this->fk_user_author;
410 }
411 if (isset($this->fk_user_modif)) {
412 $this->fk_user_modif = (int) $this->fk_user_modif;
413 }
414
415 // Check parameters
416 // Put here code to add control on parameters values
417
418 // Update request
419 $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET";
420 $sql .= " fk_salary=".(isset($this->fk_salary) ? $this->fk_salary : "null").",";
421 $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
422 $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
423 $sql .= " datep=".(dol_strlen($this->datepaye) != 0 ? "'".$this->db->idate($this->datepaye)."'" : 'null').",";
424 $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
425 $sql .= " fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment : "null").",";
426 $sql .= " num_payment=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
427 $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
428 $sql .= " fk_bank=".(isset($this->fk_bank) ? ((int) $this->fk_bank) : "null").",";
429 $sql .= " fk_user_author=".(isset($this->fk_user_author) ? ((int) $this->fk_user_author) : "null").",";
430 $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? ((int) $this->fk_user_modif) : "null");
431 $sql .= " WHERE rowid=".((int) $this->id);
432
433 $this->db->begin();
434
435 dol_syslog(get_class($this)."::update", LOG_DEBUG);
436 $resql = $this->db->query($sql);
437 if (!$resql) {
438 $error++;
439 $this->errors[] = "Error ".$this->db->lasterror();
440 }
441
442 // Commit or rollback
443 if ($error) {
444 foreach ($this->errors as $errmsg) {
445 dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
446 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
447 }
448 $this->db->rollback();
449 return -1 * $error;
450 } else {
451 $this->db->commit();
452 return 1;
453 }
454 }
455
456
464 public function delete($user, $notrigger = 0)
465 {
466 $error = 0;
467
468 dol_syslog(get_class($this)."::delete");
469
470 $this->db->begin();
471
472 if ($this->bank_line > 0) {
473 $accline = new AccountLine($this->db);
474 $accline->fetch($this->bank_line);
475 $result = $accline->delete($user);
476 if ($result < 0) {
477 $this->errors[] = $accline->error;
478 $error++;
479 }
480 }
481
482 if (!$error) {
483 $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary";
484 $sql .= " WHERE rowid=".((int) $this->id);
485
486 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
487 $resql = $this->db->query($sql);
488 if (!$resql) {
489 $error++;
490 $this->errors[] = "Error ".$this->db->lasterror();
491 }
492 }
493
494 // Commit or rollback
495 if ($error) {
496 foreach ($this->errors as $errmsg) {
497 dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
498 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
499 }
500 $this->db->rollback();
501 return -1 * $error;
502 } else {
503 $this->db->commit();
504 return 1;
505 }
506 }
507
508
509
517 public function createFromClone(User $user, $fromid)
518 {
519 $error = 0;
520
521 $object = new PaymentSalary($this->db);
522
523 $this->db->begin();
524
525 // Load source object
526 $object->fetch($fromid);
527 $object->id = 0;
528 $object->statut = 0;
529
530 // Clear fields
531 // ...
532
533 // Create clone
534 $object->context['createfromclone'] = 'createfromclone';
535 $result = $object->create($user);
536
537 // Other options
538 if ($result < 0) {
539 $this->error = $object->error;
540 $error++;
541 }
542
543 unset($object->context['createfromclone']);
544
545 // End
546 if (!$error) {
547 $this->db->commit();
548 return $object->id;
549 } else {
550 $this->db->rollback();
551 return -1;
552 }
553 }
554
555
563 public function initAsSpecimen()
564 {
565 $this->id = 0;
566 $this->fk_salary = 0;
567 $this->datec = '';
568 $this->tms = dol_now();
569 $this->datepaye = dol_now();
570 $this->amount = 0.0;
571 $this->fk_typepayment = 0;
572 $this->num_payment = '';
573 $this->note_private = '';
574 $this->note_public = '';
575 $this->fk_bank = 0;
576 $this->fk_user_author = 0;
577 $this->fk_user_modif = 0;
578
579 return 1;
580 }
581
582
595 public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
596 {
597 global $langs;
598
599 // Clean data
600 $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement);
601
602 $error = 0;
603
604 if (isModEnabled("bank")) {
605 include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
606
607 $acc = new Account($this->db);
608 $acc->fetch($accountid);
609
610 $total = $this->amount;
611
612 // Insert payment into llx_bank
613 $bank_line_id = $acc->addline(
614 $this->datep,
615 $this->fk_typepayment, // Payment mode id or code ("CHQ or VIR for example")
616 $label,
617 -$total,
618 $this->num_payment,
619 '',
620 $user,
621 $emetteur_nom,
622 $emetteur_banque,
623 '',
624 $this->datev
625 );
626
627 // Update fk_bank into llx_paiement_salary.
628 // so we know the payment that was used to generated the bank entry.
629 if ($bank_line_id > 0) {
630 $result = $this->update_fk_bank($bank_line_id);
631 if ($result <= 0) {
632 $error++;
633 dol_print_error($this->db);
634 }
635
636 // Add link 'payment_salary' in bank_url between payment and bank transaction
637 $url = '';
638 if ($mode == 'payment_salary') {
639 $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id=';
640 }
641
642 if ($url) {
643 $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
644 if ($result <= 0) {
645 $error++;
646 dol_print_error($this->db);
647 }
648 }
649
650 // Add link 'user' in bank_url between user and bank transaction
651 foreach ($this->amounts as $key => $value) {
652 if (!$error) {
653 if ($mode == 'payment_salary') {
654 $salary = new Salary($this->db);
655 $salary->fetch($key);
656 $salary->fetch_user($salary->fk_user);
657
658 $fuser = $salary->user;
659
660 if ($fuser->id > 0) {
661 $result = $acc->add_url_line(
662 $bank_line_id,
663 $fuser->id,
664 DOL_URL_ROOT.'/user/card.php?id=',
665 $fuser->getFullName($langs),
666 'user'
667 );
668 }
669 if ($result <= 0) {
670 $this->error = $this->db->lasterror();
671 dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->error);
672 $error++;
673 }
674 }
675 }
676 }
677 } else {
678 $this->error = $acc->error;
679 $error++;
680 }
681 }
682
683 if (!$error) {
684 return 1;
685 } else {
686 return -1;
687 }
688 }
689
690
691 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
698 public function update_fk_bank($id_bank)
699 {
700 // phpcs:enable
701 $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id);
702
703 dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
704 $result = $this->db->query($sql);
705 if ($result) {
706 return 1;
707 } else {
708 $this->error = $this->db->error();
709 return 0;
710 }
711 }
712
720 public function updatePaymentDate($date)
721 {
722 $error = 0;
723
724 if (!empty($date)) {
725 $this->db->begin();
726
727 dol_syslog(get_class($this)."::updatePaymentDate with date = ".$date, LOG_DEBUG);
728
729 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
730 $sql .= " SET datep = '".$this->db->idate($date)."'";
731 $sql .= " WHERE rowid = ".((int) $this->id);
732
733 $result = $this->db->query($sql);
734 if (!$result) {
735 $error++;
736 $this->error = 'Error -1 '.$this->db->error();
737 }
738
739 $type = $this->element;
740
741 $sql = "UPDATE ".MAIN_DB_PREFIX.'bank';
742 $sql .= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'";
743 $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).")";
744 $sql .= " AND rappro = 0";
745
746 $result = $this->db->query($sql);
747 if (!$result) {
748 $error++;
749 $this->error = 'Error -1 '.$this->db->error();
750 }
751
752 if (!$error) {
753 }
754
755 if (!$error) {
756 $this->datepaye = $date;
757
758 $this->db->commit();
759 return 0;
760 } else {
761 $this->db->rollback();
762 return -2;
763 }
764 }
765 return -1; //no date given or already validated
766 }
767
774 public function getLibStatut($mode = 0)
775 {
776 return $this->LibStatut($this->statut, $mode);
777 }
778
779 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
787 public function LibStatut($status, $mode = 0)
788 {
789 // phpcs:enable
790 global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
791
792 $langs->load('compta');
793 /*if ($mode == 0)
794 {
795 if ($status == 0) return $langs->trans('ToValidate');
796 if ($status == 1) return $langs->trans('Validated');
797 }
798 if ($mode == 1)
799 {
800 if ($status == 0) return $langs->trans('ToValidate');
801 if ($status == 1) return $langs->trans('Validated');
802 }
803 if ($mode == 2)
804 {
805 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
806 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
807 }
808 if ($mode == 3)
809 {
810 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
811 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
812 }
813 if ($mode == 4)
814 {
815 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
816 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
817 }
818 if ($mode == 5)
819 {
820 if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
821 if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
822 }
823 if ($mode == 6)
824 {
825 if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
826 if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
827 }*/
828 return '';
829 }
830
841 public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
842 {
843 global $conf, $langs, $hookmanager;
844
845 $option = '';
846
847 if (!empty($conf->dol_no_mouse_hover)) {
848 $notooltip = 1; // Force disable tooltips
849 }
850
851 $result = '';
852 $params = [
853 'id' => $this->id,
854 'objecttype' => $this->element.($this->module ? '@'.$this->module : ''),
855 //'option' => $option,
856 ];
857 $classfortooltip = 'classfortooltip';
858 $dataparams = '';
859 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
860 $classfortooltip = 'classforajaxtooltip';
861 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
862 $label = '';
863 } else {
864 $label = implode($this->getTooltipContentArray($params));
865 }
866
867 $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$this->id;
868
869 if ($option !== 'nolink') {
870 // Add param to save lastsearch_values or not
871 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
872 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
873 $add_save_lastsearch_values = 1;
874 }
875 if ($url && $add_save_lastsearch_values) {
876 $url .= '&save_lastsearch_values=1';
877 }
878 }
879
880 $linkclose = '';
881 if (empty($notooltip)) {
882 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
883 $label = $langs->trans("SalaryPayment");
884 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
885 }
886 $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
887 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
888 } else {
889 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
890 }
891
892 if ($option == 'nolink' || empty($url)) {
893 $linkstart = '<span';
894 } else {
895 $linkstart = '<a href="'.$url.'"';
896 }
897 $linkstart .= $linkclose.'>';
898 if ($option == 'nolink' || empty($url)) {
899 $linkend = '</span>';
900 } else {
901 $linkend = '</a>';
902 }
903
904 $result .= $linkstart;
905
906 if (empty($this->showphoto_on_popup)) {
907 if ($withpicto) {
908 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
909 }
910 }
911
912 if ($withpicto != 2) {
913 $result .= $this->ref;
914 }
915
916 $result .= $linkend;
917 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
918
919 global $action, $hookmanager;
920 $hookmanager->initHooks(array($this->element.'dao'));
921 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
922 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
923 if ($reshook > 0) {
924 $result = $hookmanager->resPrint;
925 } else {
926 $result .= $hookmanager->resPrint;
927 }
928
929 return $result;
930 }
931
938 public function getTooltipContentArray($params)
939 {
940 global $conf, $langs, $user;
941
942 $langs->load('salaries');
943 $datas = [];
944
945 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
946 return ['optimize' => $langs->trans("SalaryPayment")];
947 }
948
949 if ($user->hasRight('salaries', 'read')) {
950 $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("SalaryPayment").'</u>';
951 if (isset($this->status)) {
952 $datas['status'] = ' '.$this->getLibStatut(5);
953 }
954 $datas['Ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
955 if (!empty($this->total_ttc)) {
956 $datas['AmountTTC'] = '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
957 }
958 if (!empty($this->datep)) {
959 $datas['Date'] = '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datep, 'dayhour', 'tzuserrel');
960 } elseif (!empty($this->datepaye)) {
961 $datas['Date'] = '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datepaye, 'dayhour', 'tzuserrel');
962 }
963 }
964
965 return $datas;
966 }
967
975 public function getKanbanView($option = '', $arraydata = null)
976 {
977 global $langs;
978
979 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
980
981 $return = '<div class="box-flex-item box-flex-grow-zero">';
982 $return .= '<div class="info-box info-box-sm">';
983 $return .= '<span class="info-box-icon bg-infobox-action">';
984 $return .= img_picto('', $this->picto);
985 $return .= '</span>';
986 $return .= '<div class="info-box-content">';
987 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
988 if ($selected >= 0) {
989 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
990 }
991 if (property_exists($this, 'fk_bank') && is_numeric($this->fk_bank)) {
992 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
993 $account = new AccountLine($this->db);
994 $account->fetch($this->fk_bank);
995 $return .= ' | <span class="info-box-label">'.$account->getNomUrl(1).'</span>';
996 }
997 if (property_exists($this, 'fk_user_author') && is_numeric($this->fk_user_author)) {
998 $userstatic = new User($this->db);
999 $userstatic->fetch($this->fk_user_author);
1000 $return .= '<br><span class="info-box-status">'.$userstatic->getNomUrl(1).'</span>';
1001 }
1002
1003 if (property_exists($this, 'fk_typepayment')) {
1004 $return .= '<br><span class="opacitymedium">'.$langs->trans("PaymentMode").'</span> : <span class="info-box-label">'.$this->fk_typepayment.'</span>';
1005 }
1006 if (property_exists($this, 'amount')) {
1007 $return .= '<br><span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->amount).'</span>';
1008 }
1009 $return .= '</div>';
1010 $return .= '</div>';
1011 $return .= '</div>';
1012 return $return;
1013 }
1014}
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:637
$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:2010