34 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
46 public $element =
'payment';
51 public $table_element =
'paiement';
56 public $picto =
'payment';
75 public $multicurrency_amount;
76 public $amounts = array();
77 public $multicurrency_amounts = array();
78 public $multicurrency_code = array();
80 public $pos_change = 0;
101 public $num_paiement;
111 public $ext_payment_id;
116 public $id_prelevement;
121 public $num_prelevement;
126 public $ext_payment_site;
133 public $bank_account;
176 public function fetch($id, $ref =
'', $fk_bank =
'')
178 $sql =
'SELECT p.rowid, p.ref, p.ref_ext, p.datep as dp, p.amount, p.statut, p.ext_payment_id, p.ext_payment_site, p.fk_bank, p.multicurrency_amount,';
179 $sql .=
' c.code as type_code, c.libelle as type_label,';
180 $sql .=
' p.num_paiement as num_payment, p.note,';
181 $sql .=
' b.fk_account';
182 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
183 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
184 $sql .=
' WHERE p.entity IN ('.getEntity(
'invoice').
')';
186 $sql .=
' AND p.rowid = '.((int) $id);
188 $sql .=
" AND p.ref = '".$this->db->escape($ref).
"'";
189 } elseif ($fk_bank) {
190 $sql .=
' AND p.fk_bank = '.((int) $fk_bank);
193 $resql = $this->
db->query(
$sql);
195 if ($this->
db->num_rows($resql)) {
196 $obj = $this->
db->fetch_object($resql);
198 $this->
id = $obj->rowid;
199 $this->
ref = $obj->ref ? $obj->ref : $obj->rowid;
200 $this->ref_ext = $obj->ref_ext;
201 $this->date = $this->
db->jdate($obj->dp);
202 $this->datepaye = $this->
db->jdate($obj->dp);
203 $this->num_payment = $obj->num_payment;
204 $this->montant = $obj->amount;
205 $this->amount = $obj->amount;
206 $this->multicurrency_amount = $obj->multicurrency_amount;
207 $this->note = $obj->note;
208 $this->note_private = $obj->note;
209 $this->type_label = $obj->type_label;
210 $this->type_code = $obj->type_code;
211 $this->statut = $obj->statut;
212 $this->ext_payment_id = $obj->ext_payment_id;
213 $this->ext_payment_site = $obj->ext_payment_site;
215 $this->bank_account = $obj->fk_account;
216 $this->fk_account = $obj->fk_account;
217 $this->bank_line = $obj->fk_bank;
219 $this->
db->free($resql);
222 $this->
db->free($resql);
241 public function create($user, $closepaidinvoices = 0, $thirdparty =
null)
243 global $conf, $langs;
252 $totalamount_converted = 0;
253 $atleastonepaymentnotnull = 0;
255 if ($way ==
'dolibarr') {
256 $amounts = &$this->amounts;
257 $amounts_to_update = &$this->multicurrency_amounts;
259 $amounts = &$this->multicurrency_amounts;
260 $amounts_to_update = &$this->amounts;
263 $currencyofpayment =
'';
265 foreach ($amounts as $key => $value) {
270 $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value, $way);
272 if ($value_converted ===
false) {
274 $this->error =
'FailedToFoundTheConversionRateForInvoice';
277 if (empty($currencyofpayment)) {
278 $currencyofpayment = $this->multicurrency_code[$key];
280 if ($currencyofpayment != $this->multicurrency_code[$key]) {
282 $this->error =
'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment';
286 $totalamount_converted += $value_converted;
287 $amounts_to_update[$key] =
price2num($value_converted,
'MT');
290 $amounts[$key] = $newvalue;
291 $totalamount += $newvalue;
292 if (!empty($newvalue)) {
293 $atleastonepaymentnotnull++;
297 if (!empty($currencyofpayment)) {
300 $bankaccount->fetch($this->fk_account);
301 $bankcurrencycode = empty($bankaccount->currency_code) ? $conf->currency : $bankaccount->currency_code;
302 if ($currencyofpayment != $bankcurrencycode && $currencyofpayment != $conf->currency && $bankcurrencycode != $conf->currency) {
303 $langs->load(
"errors");
304 $this->error = $langs->trans(
'ErrorYouTryToPayInvoicesInACurrencyFromBankWithAnotherCurrency', $currencyofpayment, $bankcurrencycode);
311 $totalamount_converted =
price2num($totalamount_converted);
314 if (empty($totalamount) && empty($atleastonepaymentnotnull)) {
315 $this->errors[] =
'TotalAmountEmpty';
316 $this->error =
'TotalAmountEmpty';
320 dol_syslog(get_class($this).
"::create insert paiement", LOG_DEBUG);
324 $this->
ref = $this->
getNextNumRef(is_object($thirdparty) ? $thirdparty :
'');
326 if (empty($this->ref_ext)) {
330 if ($way ==
'dolibarr') {
332 $mtotal = $totalamount_converted;
334 $total = $totalamount_converted;
335 $mtotal = $totalamount;
338 $num_payment = $this->num_payment;
341 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"paiement (entity, ref, ref_ext, datec, datep, amount, multicurrency_amount, fk_paiement, num_paiement, note, ext_payment_id, ext_payment_site, fk_user_creat, pos_change)";
342 $sql .=
" VALUES (".((int) $conf->entity).
", '".$this->
db->escape($this->
ref).
"', '".$this->
db->escape($this->ref_ext).
"', '".$this->
db->idate($now).
"', '".$this->
db->idate($this->datepaye).
"', ".((
float)
$total).
", ".((
float) $mtotal).
", ".((int) $this->paiementid).
", ";
343 $sql .=
"'".$this->db->escape($num_payment).
"', '".$this->
db->escape(
$note).
"', ".($this->ext_payment_id ?
"'".$this->db->escape($this->ext_payment_id).
"'" :
"null").
", ".($this->ext_payment_site ?
"'".$this->
db->escape($this->ext_payment_site).
"'" :
"null").
", ".((
int) $user->id).
", ".((
float) $this->pos_change).
")";
345 $resql = $this->
db->query(
$sql);
347 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
'paiement');
350 foreach ($this->amounts as $key => $amount) {
352 if (is_numeric($amount) && $amount <> 0) {
354 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)";
356 $sql .=
" VALUES (".((int) $facid).
", ".((int) $this->
id).
", ".((
float) $amount).
", ".((
float) $this->multicurrency_amounts[$key]).
")";
358 dol_syslog(get_class($this).
'::create Amount line '.$key.
' insert paiement_facture', LOG_DEBUG);
359 $resql = $this->
db->query(
$sql);
362 $invoice->fetch($facid);
365 if ($closepaidinvoices) {
366 $paiement = $invoice->getSommePaiement();
367 $creditnotes = $invoice->getSumCreditNotesUsed();
368 $deposits = $invoice->getSumDepositsUsed();
369 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
370 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
375 $affected_types = array(
383 if (!in_array($invoice->type, $affected_types)) {
384 dol_syslog(
"Invoice ".$facid.
" is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more.");
385 } elseif ($remaintopay) {
386 dol_syslog(
"Remain to pay for invoice ".$facid.
" not null. We do nothing more.");
391 $amount_ht = $amount_tva = $amount_ttc = array();
392 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
396 $discount->fetch(
'', $invoice->id);
397 if (empty($discount->id)) {
398 $discount->description =
'(DEPOSIT)';
399 $discount->fk_soc = $invoice->socid;
400 $discount->fk_facture_source = $invoice->id;
404 foreach ($invoice->lines as $line) {
405 if ($line->total_ht != 0) {
406 $amount_ht[$line->tva_tx] += $line->total_ht;
407 $amount_tva[$line->tva_tx] += $line->total_tva;
408 $amount_ttc[$line->tva_tx] += $line->total_ttc;
409 $multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht;
410 $multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva;
411 $multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc;
416 foreach ($amount_ht as $tva_tx => $xxx) {
417 $discount->amount_ht = abs($amount_ht[$tva_tx]);
418 $discount->amount_tva = abs($amount_tva[$tva_tx]);
419 $discount->amount_ttc = abs($amount_ttc[$tva_tx]);
420 $discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]);
421 $discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]);
422 $discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]);
423 $discount->tva_tx = abs($tva_tx);
425 $result = $discount->create($user);
434 $this->error = $discount->error;
435 $this->errors = $discount->errors;
442 $result = $invoice->setPaid($user,
'',
'');
444 $this->error = $invoice->error;
445 $this->errors = $invoice->errors;
453 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
454 dol_syslog(get_class($this).
'::create Regenerate the document after inserting payment for thirdparty default_lang='.(is_object($invoice->thirdparty) ? $invoice->thirdparty->default_lang :
'null'), LOG_DEBUG);
457 $outputlangs = $langs;
459 $invoice->fetch_thirdparty();
460 $newlang = $invoice->thirdparty->default_lang;
462 if (!empty($newlang)) {
464 $outputlangs->setDefaultLang($newlang);
467 $hidedetails = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0;
468 $hidedesc = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0;
469 $hideref = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0;
471 $ret = $invoice->fetch($facid);
473 $result = $invoice->generateDocument($invoice->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
476 $this->error = $invoice->error;
477 $this->errors = $invoice->errors;
482 $this->error = $this->
db->lasterror();
486 dol_syslog(get_class($this).
'::Create Amount line '.$key.
' not a number. We discard it.');
492 $result = $this->
call_trigger(
'PAYMENT_CUSTOMER_CREATE', $user);
499 $this->error = $this->
db->lasterror();
506 $this->multicurrency_amount = $mtotal;
510 $this->
db->rollback();
524 public function delete($notrigger = 0)
526 global $conf, $user, $langs;
530 $bank_line_id = $this->bank_line;
537 if (is_array($billsarray)) {
538 if (count($billsarray)) {
539 $this->error =
"ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible";
540 $this->
db->rollback();
544 $this->
db->rollback();
549 if ($bank_line_id > 0) {
552 $result = $accline->fetch($bank_line_id);
554 $accline->id = $accline->rowid = $bank_line_id;
558 $result = $accline->delete_urls($user);
560 $this->error = $accline->error;
561 $this->
db->rollback();
566 $result = $accline->delete($user);
568 $this->error = $accline->error;
569 $this->
db->rollback();
576 $result = $this->
call_trigger(
'PAYMENT_CUSTOMER_DELETE', $user);
578 $this->
db->rollback();
585 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.
'paiement_facture';
586 $sql .=
' WHERE fk_paiement = '.((int) $this->
id);
588 $result = $this->
db->query(
$sql);
590 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.
'paiement';
591 $sql .=
" WHERE rowid = ".((int) $this->
id);
593 $result = $this->
db->query(
$sql);
595 $this->error = $this->
db->lasterror();
596 $this->
db->rollback();
603 $this->error = $this->
db->error;
604 $this->
db->rollback();
624 public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0, $accountancycode =
'')
626 global $conf, $langs, $user;
632 if ($accountid <= 0) {
633 $this->error =
'Bad value for parameter accountid='.$accountid;
634 dol_syslog(get_class($this).
'::addPaymentToBank '.$this->error, LOG_ERR);
638 $this->fk_account = $accountid;
640 dol_syslog(
"addPaymentToBank ".$user->id.
", ".$mode.
", ".$label.
", ".$this->fk_account.
", ".$emetteur_nom.
", ".$emetteur_banque);
642 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
644 $result = $acc->fetch($this->fk_account);
646 $this->error = $acc->error;
647 $this->errors = $acc->errors;
654 $totalamount = $this->amount;
655 $totalamount_main_currency =
null;
656 if (empty($totalamount)) {
661 if (
isModEnabled(
'multicurrency') && $conf->currency != $acc->currency_code) {
662 $totalamount = $this->multicurrency_amount;
663 $totalamount_main_currency = $this->amount;
666 if ($mode ==
'payment_supplier') {
667 $totalamount = -$totalamount;
668 if (isset($totalamount_main_currency)) {
669 $totalamount_main_currency = -$totalamount_main_currency;
674 $bank_line_id = $acc->addline(
676 $this->paiementcode ? $this->paiementcode : $this->paiementid,
687 $totalamount_main_currency
692 if ($bank_line_id > 0) {
702 if ($mode ==
'payment') {
703 $url = DOL_URL_ROOT.
'/compta/paiement/card.php?id=';
705 if ($mode ==
'payment_supplier') {
706 $url = DOL_URL_ROOT.
'/fourn/paiement/card.php?id=';
709 $result = $acc->add_url_line($bank_line_id, $this->
id, $url,
'(paiement)', $mode);
720 $linkaddedforthirdparty = array();
721 foreach ($this->amounts as $key => $value) {
722 if ($mode ==
'payment') {
725 $fac->fetch_thirdparty();
726 if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) {
727 $result = $acc->add_url_line(
729 $fac->thirdparty->id,
730 DOL_URL_ROOT.
'/comm/card.php?socid=',
731 $fac->thirdparty->name,
735 dol_syslog(get_class($this).
'::addPaymentToBank '.$this->
db->lasterror());
737 $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id;
740 if ($mode ==
'payment_supplier') {
743 $fac->fetch_thirdparty();
744 if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) {
745 $result = $acc->add_url_line(
747 $fac->thirdparty->id,
748 DOL_URL_ROOT.
'/fourn/card.php?socid=',
749 $fac->thirdparty->name,
753 dol_syslog(get_class($this).
'::addPaymentToBank '.$this->
db->lasterror());
755 $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id;
762 if (!$error && $label ==
'(WithdrawalPayment)') {
763 $result = $acc->add_url_line(
765 $this->id_prelevement,
766 DOL_URL_ROOT.
'/compta/prelevement/card.php?id=',
773 if (!$error && $label ==
'(InvoiceRefused)') {
774 $result=$acc->add_url_line(
776 $this->id_prelevement,
777 DOL_URL_ROOT.
'/compta/prelevement/card.php?id=',
778 $this->num_prelevement,
783 if (!$error && !$notrigger) {
785 $result = $this->
call_trigger(
'PAYMENT_ADD_TO_BANK', $user);
792 $this->error = $acc->error;
793 $this->errors = $acc->errors;
800 $this->
db->rollback();
805 return $bank_line_id;
822 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' set fk_bank = '.((int) $id_bank);
823 $sql .=
" WHERE rowid = ".((int) $this->
id);
825 dol_syslog(get_class($this).
'::update_fk_bank', LOG_DEBUG);
826 $result = $this->
db->query(
$sql);
830 $this->error = $this->
db->lasterror();
831 dol_syslog(get_class($this).
'::update_fk_bank '.$this->error);
848 if (!empty($date) && $this->statut != 1) {
851 dol_syslog(get_class($this).
"::update_date with date = ".$date, LOG_DEBUG);
853 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
854 $sql .=
" SET datep = '".$this->db->idate($date).
"'";
855 $sql .=
" WHERE rowid = ".((int) $this->
id);
857 $result = $this->
db->query(
$sql);
860 $this->error =
'Error -1 '.$this->db->error();
863 $type = $this->element;
865 $sql =
"UPDATE ".MAIN_DB_PREFIX.
'bank';
866 $sql .=
" SET dateo = '".$this->db->idate($date).
"', datev = '".$this->
db->idate($date).
"'";
867 $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).
")";
868 $sql .=
" AND rappro = 0";
870 $result = $this->
db->query(
$sql);
873 $this->error =
'Error -1 '.$this->db->error();
880 $this->datepaye = $date;
886 $this->
db->rollback();
903 if (!empty($num) && $this->statut != 1) {
904 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
905 $sql .=
" SET num_paiement = '".$this->db->escape($num).
"'";
906 $sql .=
" WHERE rowid = ".((int) $this->
id);
908 dol_syslog(get_class($this).
"::update_num", LOG_DEBUG);
909 $result = $this->
db->query(
$sql);
911 $this->num_payment = $this->
db->escape($num);
914 $this->error =
'Error -1 '.$this->db->error();
941 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET statut = 1 WHERE rowid = '.((int) $this->
id);
943 dol_syslog(get_class($this).
'::valide', LOG_DEBUG);
944 $result = $this->
db->query(
$sql);
948 $this->error = $this->
db->lasterror();
949 dol_syslog(get_class($this).
'::valide '.$this->error);
962 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET statut = 2 WHERE rowid = '.((int) $this->
id);
964 dol_syslog(get_class($this).
'::reject', LOG_DEBUG);
965 $result = $this->
db->query(
$sql);
969 $this->error = $this->
db->lasterror();
970 dol_syslog(get_class($this).
'::reject '.$this->error);
983 $sql =
'SELECT p.rowid, p.datec, p.fk_user_creat, p.fk_user_modif, p.tms';
984 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p';
985 $sql .=
' WHERE p.rowid = '.((int) $id);
987 dol_syslog(get_class($this).
'::info', LOG_DEBUG);
988 $result = $this->
db->query(
$sql);
991 if ($this->
db->num_rows($result)) {
992 $obj = $this->
db->fetch_object($result);
993 $this->
id = $obj->rowid;
994 if ($obj->fk_user_creat) {
995 $cuser =
new User($this->
db);
996 $cuser->fetch($obj->fk_user_creat);
997 $this->user_creation = $cuser;
999 if ($obj->fk_user_modif) {
1000 $muser =
new User($this->
db);
1001 $muser->fetch($obj->fk_user_modif);
1002 $this->user_modification = $muser;
1004 $this->date_creation = $this->
db->jdate($obj->datec);
1005 $this->date_modification = $this->
db->jdate($obj->tms);
1007 $this->
db->free($result);
1022 $sql =
'SELECT pf.fk_facture';
1023 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf, '.MAIN_DB_PREFIX.
'facture as f';
1024 $sql .=
' WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = '.((int) $this->
id);
1026 $sql .=
' AND '.$filter;
1028 $resql = $this->
db->query(
$sql);
1031 $num = $this->
db->num_rows($resql);
1032 $billsarray = array();
1035 $obj = $this->
db->fetch_object($resql);
1036 $billsarray[$i] = $obj->fk_facture;
1042 $this->error = $this->
db->error();
1043 dol_syslog(get_class($this).
'::getBillsArray Error '.$this->error.
' -', LOG_DEBUG);
1056 $sql =
'SELECT pf.fk_facture, pf.amount';
1057 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf';
1058 $sql .=
' WHERE pf.fk_paiement = '.((int) $this->
id);
1059 $resql = $this->
db->query(
$sql);
1062 $num = $this->
db->num_rows($resql);
1066 $obj = $this->
db->fetch_object($resql);
1067 $amounts[$obj->fk_facture] = $obj->amount;
1073 $this->error = $this->
db->error();
1074 dol_syslog(get_class($this).
'::getAmountsArray Error '.$this->error.
' -', LOG_DEBUG);
1089 global $conf, $db, $langs;
1090 $langs->load(
"bills");
1093 if (empty($conf->global->PAYMENT_ADDON)) {
1094 $conf->global->PAYMENT_ADDON =
'mod_payment_cicada';
1095 } elseif ($conf->global->PAYMENT_ADDON ==
'ant') {
1096 $conf->global->PAYMENT_ADDON =
'mod_payment_ant';
1097 } elseif ($conf->global->PAYMENT_ADDON ==
'cicada') {
1098 $conf->global->PAYMENT_ADDON =
'mod_payment_cicada';
1101 if (!empty($conf->global->PAYMENT_ADDON)) {
1104 $file = $conf->global->PAYMENT_ADDON.
".php";
1105 $classname = $conf->global->PAYMENT_ADDON;
1108 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1110 foreach ($dirmodels as $reldir) {
1114 if (is_file($dir.$file) && is_readable($dir.$file)) {
1115 $mybool |= include_once $dir.$file;
1121 $file = $conf->global->PAYMENT_ADDON.
".php";
1122 $classname =
"mod_payment_".$conf->global->PAYMENT_ADDON;
1123 $classname = preg_replace(
'/\-.*$/',
'', $classname);
1125 foreach ($conf->file->dol_document_root as $dirroot) {
1126 $dir = $dirroot.
"/core/modules/payment/";
1129 if (is_file($dir.$file) && is_readable($dir.$file)) {
1130 $mybool |= include_once $dir.$file;
1140 $obj =
new $classname();
1142 $numref = $obj->getNextValue($soc, $this);
1148 if ($mode !=
'last' && !$numref) {
1155 $langs->load(
"errors");
1156 print $langs->trans(
"Error").
" ".$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Invoice"));
1172 foreach ($this->multicurrency_amounts as $value) {
1173 if (!empty($value)) {
1193 global $user, $langs, $conf;
1197 $nownotime =
dol_mktime(0, 0, 0, $arraynow[
'mon'], $arraynow[
'mday'], $arraynow[
'year']);
1201 $this->
ref =
'SPECIMEN';
1202 $this->specimen = 1;
1204 $this->datepaye = $nownotime;
1218 public function getNomUrl($withpicto = 0, $option =
'', $mode =
'withlistofinvoices', $notooltip = 0, $morecss =
'')
1220 global $conf, $langs, $hookmanager;
1222 if (!empty($conf->dol_no_mouse_hover)) {
1228 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Payment").
'</u><br>';
1229 $label .=
'<strong>'.$langs->trans(
"Ref").
':</strong> '.$this->ref;
1230 $dateofpayment = ($this->datepaye ? $this->datepaye : $this->date);
1231 if ($dateofpayment) {
1232 $label .=
'<br><strong>'.$langs->trans(
"Date").
':</strong> ';
1234 if ($tmparray[
'seconds'] == 0 && $tmparray[
'minutes'] == 0 && ($tmparray[
'hours'] == 0 || $tmparray[
'hours'] == 12)) {
1240 if ($this->amount) {
1241 $label .=
'<br><strong>'.$langs->trans(
"Amount").
':</strong> '.
price($this->amount, 0, $langs, 1, -1, -1, $conf->currency);
1243 if ($mode ==
'withlistofinvoices') {
1245 if (is_array($arraybill) && count($arraybill) > 0) {
1246 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1247 $facturestatic =
new Facture($this->
db);
1248 foreach ($arraybill as $billid) {
1249 $facturestatic->fetch($billid);
1250 $label .=
'<br> '.$facturestatic->getNomUrl(1,
'', 0, 0,
'', 1).
' '.$facturestatic->getLibStatut(2, 1);
1256 if (empty($notooltip)) {
1257 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1258 $label = $langs->trans(
"Payment");
1259 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1261 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1262 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1264 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1267 $url = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$this->id;
1269 $linkstart =
'<a href="'.$url.
'"';
1270 $linkstart .= $linkclose.
'>';
1273 $result .= $linkstart;
1275 $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);
1277 if ($withpicto && $withpicto != 2) {
1278 $result .= ($this->
ref ? $this->
ref : $this->id);
1280 $result .= $linkend;
1282 $hookmanager->initHooks(array($this->element .
'dao'));
1283 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1284 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1286 $result = $hookmanager->resPrint;
1288 $result .= $hookmanager->resPrint;
1301 return $this->
LibStatut($this->statut, $mode);
1317 $langs->load(
'compta');
1367 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1369 if (empty($force_thirdparty_id)) {
1371 if (!empty($billsarray)) {
1373 if ($invoice->fetch($billsarray[0]) > 0) {
1374 $force_thirdparty_id = $invoice->socid;
1379 return parent::fetch_thirdparty($force_thirdparty_id);