dolibarr 19.0.3
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 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
26// Put here all includes required by your class file
27require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
28require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
29
30
35{
39 public $element = 'payment_salary';
40
44 public $table_element = 'payment_salary';
45
49 public $picto = 'payment';
50
56 public $chid;
57
61 public $fk_salary;
62
63 public $datec = '';
64 public $tms = '';
65
71 public $datepaye = '';
72
76 public $datep = '';
77
82 public $total;
83
84 public $amount; // Total amount of payment
85 public $amounts = array(); // Array of amounts
86
90 public $fk_typepayment;
91
96 public $num_paiement;
97
101 public $num_payment;
102
106 public $fk_bank;
107
111 public $bank_line;
112
116 public $fk_user_author;
117
121 public $fk_user_modif;
122
126 public $type_code;
127
131 public $type_label;
132
136 public $bank_account;
137
141 public $datev = '';
142
146 public $fields = array(
147 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'index'=>1, 'position'=>1, 'comment'=>'Id'),
148 );
149
155 public function __construct($db)
156 {
157 $this->db = $db;
158 }
159
168 public function create($user, $closepaidcontrib = 0)
169 {
170 global $conf;
171
172 $error = 0;
173
174 $now = dol_now();
175
176 dol_syslog(get_class($this)."::create", LOG_DEBUG);
177
178 //deprecatd
179 if (!empty($this->datepaye) && empty($this->datep)) {
180 dol_syslog(__METHOD__.": using datepaye is deprecated, please use datep instead", LOG_WARNING);
181 $this->datep = $this->datepaye;
182 }
183
184 // Validate parametres
185 if (empty($this->datep)) {
186 $this->error = 'ErrorBadValueForParameterCreatePaymentSalary';
187 return -1;
188 }
189
190 // Clean parameters
191 if (isset($this->fk_salary)) {
192 $this->fk_salary = (int) $this->fk_salary;
193 }
194 if (isset($this->amount)) {
195 $this->amount = trim($this->amount);
196 }
197 if (isset($this->fk_typepayment)) {
198 $this->fk_typepayment = (int) $this->fk_typepayment;
199 }
200 if (isset($this->num_paiement)) {
201 $this->num_paiement = trim($this->num_paiement);
202 } // deprecated
203 if (isset($this->num_payment)) {
204 $this->num_payment = trim($this->num_payment);
205 }
206 if (isset($this->note)) {
207 $this->note = trim($this->note);
208 }
209 if (isset($this->fk_bank)) {
210 $this->fk_bank = (int) $this->fk_bank;
211 }
212 if (isset($this->fk_user_author)) {
213 $this->fk_user_author = (int) $this->fk_user_author;
214 }
215 if (isset($this->fk_user_modif)) {
216 $this->fk_user_modif = (int) $this->fk_user_modif;
217 }
218
219 $totalamount = 0;
220 foreach ($this->amounts as $key => $value) { // How payment is dispatch
221 $newvalue = price2num($value, 'MT');
222 $this->amounts[$key] = $newvalue;
223 $totalamount += $newvalue;
224 }
225 $totalamount = price2num($totalamount);
226
227 // Check parameters
228 if ($totalamount == 0) {
229 return -1;
230 } // On accepte les montants negatifs pour les rejets de prelevement mais pas null
231
232
233 $this->db->begin();
234
235 if ($totalamount != 0) {
236 // Insert array of amounts
237 foreach ($this->amounts as $key => $amount) {
238 $salary_id = $key;
239 $amount = price2num($amount);
240 if (is_numeric($amount) && !empty($amount)) {
241 // 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).
242 $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (entity, fk_salary, datec, datep, amount,";
243 $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)";
244 $sql .= " VALUES (".((int) $conf->entity).", ".((int) $salary_id).", '".$this->db->idate($now)."',";
245 $sql .= " '".$this->db->idate($this->datep)."',";
246 $sql .= " ".price2num($amount).",";
247 $sql .= " ".((int) $this->fk_typepayment).", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".((int) $user->id).",";
248 $sql .= " 0)";
249
250 $resql = $this->db->query($sql);
251 if ($resql) {
252 $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
253 }
254
255 // If we want to closed payed invoices
256 if ($closepaidcontrib) {
257 $tmpsalary = new Salary($this->db);
258 $tmpsalary->fetch($salary_id);
259 $paiement = $tmpsalary->getSommePaiement();
260 //$creditnotes=$tmpsalary->getSumCreditNotesUsed();
261 $creditnotes = 0;
262 //$deposits=$tmpsalary->getSumDepositsUsed();
263 $deposits = 0;
264 $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT');
265 $remaintopay = price2num($tmpsalary->amount - $paiement - $creditnotes - $deposits, 'MT');
266 if ($remaintopay == 0) {
267 $result = $tmpsalary->setPaid($user);
268 } else {
269 dol_syslog("Remain to pay for salary id=".$salary_id." not null. We do nothing.");
270 }
271 }
272 }
273 }
274 }
275
276 $result = $this->call_trigger('PAYMENTSALARY_CREATE', $user);
277 if ($result < 0) {
278 $error++;
279 }
280
281 if ($totalamount != 0 && !$error) {
282 $this->amount = $totalamount;
283 $this->total = $totalamount; // deprecated
284 $this->db->commit();
285 return $this->id; // id of the last payment inserted
286 } else {
287 $this->error = $this->db->error();
288 $this->db->rollback();
289 return -1;
290 }
291 }
292
299 public function fetch($id)
300 {
301 global $langs;
302 $sql = "SELECT";
303 $sql .= " t.rowid,";
304 $sql .= " t.fk_salary,";
305 $sql .= " t.datec,";
306 $sql .= " t.tms,";
307 $sql .= " t.datep,";
308 $sql .= " t.amount,";
309 $sql .= " t.fk_typepayment,";
310 $sql .= " t.num_payment as num_payment,";
311 $sql .= " t.note,";
312 $sql .= " t.fk_bank,";
313 $sql .= " t.fk_user_author,";
314 $sql .= " t.fk_user_modif,";
315 $sql .= " pt.code as type_code, pt.libelle as type_label,";
316 $sql .= ' b.fk_account';
317 $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepayment = pt.id";
318 $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid';
319 $sql .= " WHERE t.rowid = ".((int) $id);
320 // TODO link on entity of tax;
321
322 dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
323 $resql = $this->db->query($sql);
324 if ($resql) {
325 if ($this->db->num_rows($resql)) {
326 $obj = $this->db->fetch_object($resql);
327
328 $this->id = $obj->rowid;
329 $this->ref = $obj->rowid;
330
331 $this->fk_salary = $obj->fk_salary;
332 $this->datec = $this->db->jdate($obj->datec);
333 $this->tms = $this->db->jdate($obj->tms);
334 $this->datepaye = $this->db->jdate($obj->datep);
335 $this->amount = $obj->amount;
336 $this->fk_typepayment = $obj->fk_typepayment;
337 $this->num_paiement = $obj->num_payment;
338 $this->num_payment = $obj->num_payment;
339 $this->note = $obj->note;
340 $this->note_private = $obj->note;
341 $this->fk_bank = $obj->fk_bank;
342 $this->fk_user_author = $obj->fk_user_author;
343 $this->fk_user_modif = $obj->fk_user_modif;
344
345 $this->type_code = $obj->type_code;
346 $this->type_label = $obj->type_label;
347
348 $this->bank_account = $obj->fk_account;
349 $this->bank_line = $obj->fk_bank;
350 }
351 $this->db->free($resql);
352
353 return 1;
354 } else {
355 $this->error = "Error ".$this->db->lasterror();
356 return -1;
357 }
358 }
359
360
368 public function update($user = null, $notrigger = 0)
369 {
370 global $conf, $langs;
371 $error = 0;
372
373 // Clean parameters
374
375 if (isset($this->fk_salary)) {
376 $this->fk_salary = (int) $this->fk_salary;
377 }
378 if (isset($this->amount)) {
379 $this->amount = trim($this->amount);
380 }
381 if (isset($this->fk_typepayment)) {
382 $this->fk_typepayment = (int) $this->fk_typepayment;
383 }
384 if (isset($this->num_paiement)) {
385 $this->num_paiement = trim($this->num_paiement);
386 } // deprecated
387 if (isset($this->num_payment)) {
388 $this->num_payment = trim($this->num_payment);
389 }
390 if (isset($this->note)) {
391 $this->note = trim($this->note);
392 }
393 if (isset($this->fk_bank)) {
394 $this->fk_bank = (int) $this->fk_bank;
395 }
396 if (isset($this->fk_user_author)) {
397 $this->fk_user_author = (int) $this->fk_user_author;
398 }
399 if (isset($this->fk_user_modif)) {
400 $this->fk_user_modif = (int) $this->fk_user_modif;
401 }
402
403 // Check parameters
404 // Put here code to add control on parameters values
405
406 // Update request
407 $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET";
408 $sql .= " fk_salary=".(isset($this->fk_salary) ? $this->fk_salary : "null").",";
409 $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').",";
410 $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').",";
411 $sql .= " datep=".(dol_strlen($this->datepaye) != 0 ? "'".$this->db->idate($this->datepaye)."'" : 'null').",";
412 $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").",";
413 $sql .= " fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment : "null").",";
414 $sql .= " num_payment=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").",";
415 $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").",";
416 $sql .= " fk_bank=".(isset($this->fk_bank) ? ((int) $this->fk_bank) : "null").",";
417 $sql .= " fk_user_author=".(isset($this->fk_user_author) ? ((int) $this->fk_user_author) : "null").",";
418 $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? ((int) $this->fk_user_modif) : "null");
419 $sql .= " WHERE rowid=".((int) $this->id);
420
421 $this->db->begin();
422
423 dol_syslog(get_class($this)."::update", LOG_DEBUG);
424 $resql = $this->db->query($sql);
425 if (!$resql) {
426 $error++;
427 $this->errors[] = "Error ".$this->db->lasterror();
428 }
429
430 // Commit or rollback
431 if ($error) {
432 foreach ($this->errors as $errmsg) {
433 dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
434 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
435 }
436 $this->db->rollback();
437 return -1 * $error;
438 } else {
439 $this->db->commit();
440 return 1;
441 }
442 }
443
444
452 public function delete($user, $notrigger = 0)
453 {
454 $error = 0;
455
456 dol_syslog(get_class($this)."::delete");
457
458 $this->db->begin();
459
460 if ($this->bank_line > 0) {
461 $accline = new AccountLine($this->db);
462 $accline->fetch($this->bank_line);
463 $result = $accline->delete($user);
464 if ($result < 0) {
465 $this->errors[] = $accline->error;
466 $error++;
467 }
468 }
469
470 if (!$error) {
471 $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary";
472 $sql .= " WHERE rowid=".((int) $this->id);
473
474 dol_syslog(get_class($this)."::delete", LOG_DEBUG);
475 $resql = $this->db->query($sql);
476 if (!$resql) {
477 $error++;
478 $this->errors[] = "Error ".$this->db->lasterror();
479 }
480 }
481
482 // Commit or rollback
483 if ($error) {
484 foreach ($this->errors as $errmsg) {
485 dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
486 $this->error .= ($this->error ? ', '.$errmsg : $errmsg);
487 }
488 $this->db->rollback();
489 return -1 * $error;
490 } else {
491 $this->db->commit();
492 return 1;
493 }
494 }
495
496
497
505 public function createFromClone(User $user, $fromid)
506 {
507 $error = 0;
508
509 $object = new PaymentSalary($this->db);
510
511 $this->db->begin();
512
513 // Load source object
514 $object->fetch($fromid);
515 $object->id = 0;
516 $object->statut = 0;
517
518 // Clear fields
519 // ...
520
521 // Create clone
522 $object->context['createfromclone'] = 'createfromclone';
523 $result = $object->create($user);
524
525 // Other options
526 if ($result < 0) {
527 $this->error = $object->error;
528 $error++;
529 }
530
531 unset($object->context['createfromclone']);
532
533 // End
534 if (!$error) {
535 $this->db->commit();
536 return $object->id;
537 } else {
538 $this->db->rollback();
539 return -1;
540 }
541 }
542
543
551 public function initAsSpecimen()
552 {
553 $this->id = 0;
554
555 $this->fk_salary = '';
556 $this->datec = '';
557 $this->tms = '';
558 $this->datepaye = '';
559 $this->amount = '';
560 $this->fk_typepayment = '';
561 $this->num_payment = '';
562 $this->note_private = '';
563 $this->note_public = '';
564 $this->fk_bank = '';
565 $this->fk_user_author = '';
566 $this->fk_user_modif = '';
567 }
568
569
582 public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
583 {
584 global $langs;
585
586 // Clean data
587 $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement);
588
589 $error = 0;
590
591 if (isModEnabled("banque")) {
592 include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
593
594 $acc = new Account($this->db);
595 $acc->fetch($accountid);
596
597 $total = $this->amount;
598
599 // Insert payment into llx_bank
600 $bank_line_id = $acc->addline(
601 $this->datep,
602 $this->fk_typepayment, // Payment mode id or code ("CHQ or VIR for example")
603 $label,
604 -$total,
605 $this->num_payment,
606 '',
607 $user,
608 $emetteur_nom,
609 $emetteur_banque,
610 '',
611 $this->datev
612 );
613
614 // Update fk_bank into llx_paiement_salary.
615 // so we know the payment that was used to generated the bank entry.
616 if ($bank_line_id > 0) {
617 $result = $this->update_fk_bank($bank_line_id);
618 if ($result <= 0) {
619 $error++;
620 dol_print_error($this->db);
621 }
622
623 // Add link 'payment_salary' in bank_url between payment and bank transaction
624 $url = '';
625 if ($mode == 'payment_salary') {
626 $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id=';
627 }
628
629 if ($url) {
630 $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
631 if ($result <= 0) {
632 $error++;
633 dol_print_error($this->db);
634 }
635 }
636
637 // Add link 'user' in bank_url between user and bank transaction
638 foreach ($this->amounts as $key => $value) {
639 if (!$error) {
640 if ($mode == 'payment_salary') {
641 $salary = new Salary($this->db);
642 $salary->fetch($key);
643 $salary->fetch_user($salary->fk_user);
644
645 $fuser = $salary->user;
646
647 if ($fuser->id > 0) {
648 $result = $acc->add_url_line(
649 $bank_line_id,
650 $fuser->id,
651 DOL_URL_ROOT.'/user/card.php?id=',
652 $fuser->getFullName($langs),
653 'user'
654 );
655 }
656 if ($result <= 0) {
657 $this->error = $this->db->lasterror();
658 dol_syslog(get_class($this) . '::addPaymentToBank ' . $this->error);
659 $error++;
660 }
661 }
662 }
663 }
664 } else {
665 $this->error = $acc->error;
666 $error++;
667 }
668 }
669
670 if (!$error) {
671 return 1;
672 } else {
673 return -1;
674 }
675 }
676
677
678 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
685 public function update_fk_bank($id_bank)
686 {
687 // phpcs:enable
688 $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET fk_bank = ".((int) $id_bank)." WHERE rowid = ".((int) $this->id);
689
690 dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG);
691 $result = $this->db->query($sql);
692 if ($result) {
693 return 1;
694 } else {
695 $this->error = $this->db->error();
696 return 0;
697 }
698 }
699
707 public function updatePaymentDate($date)
708 {
709 $error = 0;
710
711 if (!empty($date)) {
712 $this->db->begin();
713
714 dol_syslog(get_class($this)."::updatePaymentDate with date = ".$date, LOG_DEBUG);
715
716 $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element;
717 $sql .= " SET datep = '".$this->db->idate($date)."'";
718 $sql .= " WHERE rowid = ".((int) $this->id);
719
720 $result = $this->db->query($sql);
721 if (!$result) {
722 $error++;
723 $this->error = 'Error -1 '.$this->db->error();
724 }
725
726 $type = $this->element;
727
728 $sql = "UPDATE ".MAIN_DB_PREFIX.'bank';
729 $sql .= " SET dateo = '".$this->db->idate($date)."', datev = '".$this->db->idate($date)."'";
730 $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).")";
731 $sql .= " AND rappro = 0";
732
733 $result = $this->db->query($sql);
734 if (!$result) {
735 $error++;
736 $this->error = 'Error -1 '.$this->db->error();
737 }
738
739 if (!$error) {
740 }
741
742 if (!$error) {
743 $this->datepaye = $date;
744
745 $this->db->commit();
746 return 0;
747 } else {
748 $this->db->rollback();
749 return -2;
750 }
751 }
752 return -1; //no date given or already validated
753 }
754
761 public function getLibStatut($mode = 0)
762 {
763 return $this->LibStatut($this->statut, $mode);
764 }
765
766 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
774 public function LibStatut($status, $mode = 0)
775 {
776 // phpcs:enable
777 global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage
778
779 $langs->load('compta');
780 /*if ($mode == 0)
781 {
782 if ($status == 0) return $langs->trans('ToValidate');
783 if ($status == 1) return $langs->trans('Validated');
784 }
785 if ($mode == 1)
786 {
787 if ($status == 0) return $langs->trans('ToValidate');
788 if ($status == 1) return $langs->trans('Validated');
789 }
790 if ($mode == 2)
791 {
792 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
793 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
794 }
795 if ($mode == 3)
796 {
797 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
798 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
799 }
800 if ($mode == 4)
801 {
802 if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
803 if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
804 }
805 if ($mode == 5)
806 {
807 if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
808 if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
809 }
810 if ($mode == 6)
811 {
812 if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
813 if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
814 }*/
815 return '';
816 }
817
828 public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
829 {
830 global $conf, $langs, $hookmanager;
831
832 $option = '';
833
834 if (!empty($conf->dol_no_mouse_hover)) {
835 $notooltip = 1; // Force disable tooltips
836 }
837
838 $result = '';
839 $params = [
840 'id' => $this->id,
841 'objecttype' => $this->element.($this->module ? '@'.$this->module : ''),
842 //'option' => $option,
843 ];
844 $classfortooltip = 'classfortooltip';
845 $dataparams = '';
846 if (getDolGlobalInt('MAIN_ENABLE_AJAX_TOOLTIP')) {
847 $classfortooltip = 'classforajaxtooltip';
848 $dataparams = ' data-params="'.dol_escape_htmltag(json_encode($params)).'"';
849 $label = '';
850 } else {
851 $label = implode($this->getTooltipContentArray($params));
852 }
853
854 $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$this->id;
855
856 if ($option !== 'nolink') {
857 // Add param to save lastsearch_values or not
858 $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
859 if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
860 $add_save_lastsearch_values = 1;
861 }
862 if ($url && $add_save_lastsearch_values) {
863 $url .= '&save_lastsearch_values=1';
864 }
865 }
866
867 $linkclose = '';
868 if (empty($notooltip)) {
869 if (getDolGlobalInt('MAIN_OPTIMIZEFORTEXTBROWSER')) {
870 $label = $langs->trans("SalaryPayment");
871 $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
872 }
873 $linkclose .= ($label ? ' title="'.dol_escape_htmltag($label, 1).'"' : ' title="tocomplete"');
874 $linkclose .= $dataparams.' class="'.$classfortooltip.($morecss ? ' '.$morecss : '').'"';
875 } else {
876 $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
877 }
878
879 if ($option == 'nolink' || empty($url)) {
880 $linkstart = '<span';
881 } else {
882 $linkstart = '<a href="'.$url.'"';
883 }
884 $linkstart .= $linkclose.'>';
885 if ($option == 'nolink' || empty($url)) {
886 $linkend = '</span>';
887 } else {
888 $linkend = '</a>';
889 }
890
891 $result .= $linkstart;
892
893 if (empty($this->showphoto_on_popup)) {
894 if ($withpicto) {
895 $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), (($withpicto != 2) ? 'class="paddingright"' : ''), 0, 0, $notooltip ? 0 : 1);
896 }
897 }
898
899 if ($withpicto != 2) {
900 $result .= $this->ref;
901 }
902
903 $result .= $linkend;
904 //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
905
906 global $action, $hookmanager;
907 $hookmanager->initHooks(array($this->element.'dao'));
908 $parameters = array('id' => $this->id, 'getnomurl' => &$result);
909 $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
910 if ($reshook > 0) {
911 $result = $hookmanager->resPrint;
912 } else {
913 $result .= $hookmanager->resPrint;
914 }
915
916 return $result;
917 }
918
925 public function getTooltipContentArray($params)
926 {
927 global $conf, $langs, $user;
928
929 $langs->load('salaries');
930 $datas = [];
931
932 if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) {
933 return ['optimize' => $langs->trans("SalaryPayment")];
934 }
935
936 if ($user->hasRight('salaries', 'read')) {
937 $datas['picto'] = img_picto('', $this->picto).' <u class="paddingrightonly">'.$langs->trans("SalaryPayment").'</u>';
938 if (isset($this->status)) {
939 $datas['status'] = ' '.$this->getLibStatut(5);
940 }
941 $datas['Ref'] = '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
942 if (!empty($this->total_ttc)) {
943 $datas['AmountTTC'] = '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
944 }
945 if (!empty($this->datep)) {
946 $datas['Date'] = '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datep, 'dayhour', 'tzuserrel');
947 } elseif (!empty($this->datepaye)) {
948 $datas['Date'] = '<br><b>'.$langs->trans('Date').':</b> '.dol_print_date($this->datepaye, 'dayhour', 'tzuserrel');
949 }
950 }
951
952 return $datas;
953 }
954
962 public function getKanbanView($option = '', $arraydata = null)
963 {
964 global $langs;
965
966 $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']);
967
968 $return = '<div class="box-flex-item box-flex-grow-zero">';
969 $return .= '<div class="info-box info-box-sm">';
970 $return .= '<span class="info-box-icon bg-infobox-action">';
971 $return .= img_picto('', $this->picto);
972 $return .= '</span>';
973 $return .= '<div class="info-box-content">';
974 $return .= '<span class="info-box-ref inline-block tdoverflowmax150 valignmiddle">'.(method_exists($this, 'getNomUrl') ? $this->getNomUrl(1) : $this->ref).'</span>';
975 if ($selected >= 0) {
976 $return .= '<input id="cb'.$this->id.'" class="flat checkforselect fright" type="checkbox" name="toselect[]" value="'.$this->id.'"'.($selected ? ' checked="checked"' : '').'>';
977 }
978 if (property_exists($this, 'fk_bank')) {
979 $return .= ' | <span class="info-box-label">'.$this->fk_bank.'</span>';
980 }
981 if (property_exists($this, 'fk_user_author')) {
982 $return .= '<br><span class="info-box-status">'.$this->fk_user_author.'</span>';
983 }
984
985 if (property_exists($this, 'fk_typepayment')) {
986 $return .= '<br><span class="opacitymedium">'.$langs->trans("PaymentMode").'</span> : <span class="info-box-label">'.$this->fk_typepayment.'</span>';
987 }
988 if (property_exists($this, 'amount')) {
989 $return .= '<br><span class="opacitymedium">'.$langs->trans("Amount").'</span> : <span class="info-box-label amount">'.price($this->amount).'</span>';
990 }
991 $return .= '</div>';
992 $return .= '</div>';
993 $return .= '</div>';
994 return $return;
995 }
996}
print $langs trans("AuditedSecurityEvents").'</strong >< span class="opacitymedium"></span >< br > status
Definition security.php:604
$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.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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.
publicphonebutton2 phonegreen basiclayout basiclayout TotalHT VATCode TotalVAT TotalLT1 TotalLT2 TotalTTC TotalHT clearboth nowraponall right right takeposterminal SELECT e e e e e statut
Definition invoice.php:1907