35 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
47 public $element =
'payment';
52 public $table_element =
'paiement';
57 public $picto =
'payment';
76 public $multicurrency_amount;
77 public $amounts = array();
78 public $multicurrency_amounts = array();
79 public $multicurrency_code = array();
81 public $pos_change = 0;
102 public $num_paiement;
112 public $ext_payment_id;
117 public $id_prelevement;
122 public $num_prelevement;
127 public $ext_payment_site;
134 public $bank_account;
177 public function fetch($id, $ref =
'', $fk_bank =
'')
179 $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,';
180 $sql .=
' c.code as type_code, c.libelle as type_label,';
181 $sql .=
' p.num_paiement as num_payment, p.note,';
182 $sql .=
' b.fk_account';
183 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
184 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
185 $sql .=
' WHERE p.entity IN ('.getEntity(
'invoice').
')';
187 $sql .=
' AND p.rowid = '.((int) $id);
189 $sql .=
" AND p.ref = '".$this->db->escape($ref).
"'";
190 } elseif ($fk_bank) {
191 $sql .=
' AND p.fk_bank = '.((int) $fk_bank);
197 $obj = $this->
db->fetch_object(
$resql);
199 $this->
id = $obj->rowid;
200 $this->
ref = $obj->ref ? $obj->ref : $obj->rowid;
201 $this->ref_ext = $obj->ref_ext;
202 $this->date = $this->
db->jdate($obj->dp);
203 $this->datepaye = $this->
db->jdate($obj->dp);
204 $this->num_payment = $obj->num_payment;
205 $this->montant = $obj->amount;
206 $this->amount = $obj->amount;
207 $this->multicurrency_amount = $obj->multicurrency_amount;
208 $this->note = $obj->note;
209 $this->note_private = $obj->note;
210 $this->type_label = $obj->type_label;
211 $this->type_code = $obj->type_code;
212 $this->statut = $obj->statut;
213 $this->ext_payment_id = $obj->ext_payment_id;
214 $this->ext_payment_site = $obj->ext_payment_site;
216 $this->bank_account = $obj->fk_account;
217 $this->fk_account = $obj->fk_account;
218 $this->bank_line = $obj->fk_bank;
242 public function create($user, $closepaidinvoices = 0, $thirdparty =
null)
244 global $conf, $langs;
253 $totalamount_converted = 0;
254 $atleastonepaymentnotnull = 0;
256 if ($way ==
'dolibarr') {
257 $amounts = &$this->amounts;
258 $amounts_to_update = &$this->multicurrency_amounts;
260 $amounts = &$this->multicurrency_amounts;
261 $amounts_to_update = &$this->amounts;
264 $currencyofpayment =
'';
266 foreach ($amounts as $key => $value) {
271 $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value, $way);
273 if ($value_converted ===
false) {
275 $this->error =
'FailedToFoundTheConversionRateForInvoice';
278 if (empty($currencyofpayment)) {
279 $currencyofpayment = $this->multicurrency_code[$key];
281 if ($currencyofpayment != $this->multicurrency_code[$key]) {
283 $this->error =
'ErrorYouTryToPayInvoicesWithDifferentCurrenciesInSamePayment';
287 $totalamount_converted += $value_converted;
288 $amounts_to_update[$key] =
price2num($value_converted,
'MT');
291 $amounts[$key] = $newvalue;
292 $totalamount += $newvalue;
293 if (!empty($newvalue)) {
294 $atleastonepaymentnotnull++;
298 if (!empty($currencyofpayment)) {
301 $bankaccount->fetch($this->fk_account);
302 $bankcurrencycode = empty($bankaccount->currency_code) ? $conf->currency : $bankaccount->currency_code;
303 if ($currencyofpayment != $bankcurrencycode && $currencyofpayment != $conf->currency && $bankcurrencycode != $conf->currency) {
304 $langs->load(
"errors");
305 $this->error = $langs->trans(
'ErrorYouTryToPayInvoicesInACurrencyFromBankWithAnotherCurrency', $currencyofpayment, $bankcurrencycode);
312 $totalamount_converted =
price2num($totalamount_converted);
315 if (empty($totalamount) && empty($atleastonepaymentnotnull)) {
316 $this->errors[] =
'TotalAmountEmpty';
317 $this->error =
'TotalAmountEmpty';
321 dol_syslog(get_class($this).
"::create insert paiement", LOG_DEBUG);
325 $this->
ref = $this->
getNextNumRef(is_object($thirdparty) ? $thirdparty :
'');
327 if (empty($this->ref_ext)) {
331 if ($way ==
'dolibarr') {
333 $mtotal = $totalamount_converted;
335 $total = $totalamount_converted;
336 $mtotal = $totalamount;
339 $num_payment = $this->num_payment;
342 $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)";
343 $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).
", ";
344 $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).
")";
348 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
'paiement');
351 foreach ($this->amounts as $key => $amount) {
353 if (is_numeric($amount) && $amount <> 0) {
355 $sql =
"INSERT INTO ".MAIN_DB_PREFIX.
"paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)";
357 $sql .=
" VALUES (".((int) $facid).
", ".((int) $this->
id).
", ".((
float) $amount).
", ".((
float) $this->multicurrency_amounts[$key]).
")";
359 dol_syslog(get_class($this).
'::create Amount line '.$key.
' insert paiement_facture', LOG_DEBUG);
363 $invoice->fetch($facid);
366 if ($closepaidinvoices) {
367 $paiement = $invoice->getSommePaiement();
368 $creditnotes = $invoice->getSumCreditNotesUsed();
369 $deposits = $invoice->getSumDepositsUsed();
370 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
371 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
376 $affected_types = array(
384 if (!in_array($invoice->type, $affected_types)) {
385 dol_syslog(
"Invoice ".$facid.
" is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more.");
386 } elseif ($remaintopay) {
389 $hookmanager->initHooks(array(
'paymentdao'));
390 $parameters = array(
'facid' => $facid,
'invoice' => $invoice,
'remaintopay' => $remaintopay);
391 $action =
'CLOSEPAIDINVOICE';
392 $reshook = $hookmanager->executeHooks(
'createPayment', $parameters, $this, $action);
394 $this->errors[] = $hookmanager->error;
395 $this->error = $hookmanager->error;
397 } elseif ($reshook == 0) {
398 dol_syslog(
"Remain to pay for invoice " . $facid .
" not null. We do nothing more.");
404 $amount_ht = $amount_tva = $amount_ttc = array();
405 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
409 $discount->fetch(
'', $invoice->id);
410 if (empty($discount->id)) {
411 $discount->description =
'(DEPOSIT)';
412 $discount->fk_soc = $invoice->socid;
413 $discount->fk_facture_source = $invoice->id;
417 foreach ($invoice->lines as $line) {
418 if ($line->total_ht != 0) {
419 $amount_ht[$line->tva_tx] += $line->total_ht;
420 $amount_tva[$line->tva_tx] += $line->total_tva;
421 $amount_ttc[$line->tva_tx] += $line->total_ttc;
422 $multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht;
423 $multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva;
424 $multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc;
429 foreach ($amount_ht as $tva_tx => $xxx) {
430 $discount->amount_ht = abs($amount_ht[$tva_tx]);
431 $discount->amount_tva = abs($amount_tva[$tva_tx]);
432 $discount->amount_ttc = abs($amount_ttc[$tva_tx]);
433 $discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]);
434 $discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]);
435 $discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]);
436 $discount->tva_tx = abs($tva_tx);
438 $result = $discount->create($user);
447 $this->error = $discount->error;
448 $this->errors = $discount->errors;
455 $result = $invoice->setPaid($user,
'',
'');
457 $this->error = $invoice->error;
458 $this->errors = $invoice->errors;
466 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) {
467 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);
470 $outputlangs = $langs;
472 $invoice->fetch_thirdparty();
473 $newlang = $invoice->thirdparty->default_lang;
475 if (!empty($newlang)) {
477 $outputlangs->setDefaultLang($newlang);
480 $hidedetails = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0;
481 $hidedesc = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0;
482 $hideref = !empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0;
484 $ret = $invoice->fetch($facid);
486 $result = $invoice->generateDocument($invoice->model_pdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
489 $this->error = $invoice->error;
490 $this->errors = $invoice->errors;
495 $this->error = $this->
db->lasterror();
499 dol_syslog(get_class($this).
'::Create Amount line '.$key.
' not a number. We discard it.');
505 $result = $this->
call_trigger(
'PAYMENT_CUSTOMER_CREATE', $user);
512 $this->error = $this->
db->lasterror();
519 $this->multicurrency_amount = $mtotal;
523 $this->
db->rollback();
537 public function delete($notrigger = 0)
539 global $conf, $user, $langs;
543 $bank_line_id = $this->bank_line;
550 if (is_array($billsarray)) {
551 if (count($billsarray)) {
552 $this->error =
"ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible";
553 $this->
db->rollback();
557 $this->
db->rollback();
562 if ($bank_line_id > 0) {
565 $result = $accline->fetch($bank_line_id);
567 $accline->id = $accline->rowid = $bank_line_id;
571 $result = $accline->delete_urls($user);
573 $this->error = $accline->error;
574 $this->
db->rollback();
579 $result = $accline->delete($user);
581 $this->error = $accline->error;
582 $this->
db->rollback();
589 $result = $this->
call_trigger(
'PAYMENT_CUSTOMER_DELETE', $user);
591 $this->
db->rollback();
598 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.
'paiement_facture';
599 $sql .=
' WHERE fk_paiement = '.((int) $this->
id);
601 $result = $this->
db->query($sql);
603 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.
'paiement';
604 $sql .=
" WHERE rowid = ".((int) $this->
id);
606 $result = $this->
db->query($sql);
608 $this->error = $this->
db->lasterror();
609 $this->
db->rollback();
616 $this->error = $this->
db->error;
617 $this->
db->rollback();
637 public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0, $accountancycode =
'')
639 global $conf, $langs, $user;
645 if ($accountid <= 0) {
646 $this->error =
'Bad value for parameter accountid='.$accountid;
647 dol_syslog(get_class($this).
'::addPaymentToBank '.$this->error, LOG_ERR);
651 $this->fk_account = $accountid;
653 dol_syslog(
"addPaymentToBank ".$user->id.
", ".$mode.
", ".$label.
", ".$this->fk_account.
", ".$emetteur_nom.
", ".$emetteur_banque);
655 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
657 $result = $acc->fetch($this->fk_account);
665 $totalamount = $this->amount;
666 $totalamount_main_currency =
null;
667 if (empty($totalamount)) {
672 if (
isModEnabled(
'multicurrency') && $conf->currency != $acc->currency_code) {
673 $totalamount = $this->multicurrency_amount;
674 $totalamount_main_currency = $this->amount;
677 if ($mode ==
'payment_supplier') {
678 $totalamount = -$totalamount;
679 if (isset($totalamount_main_currency)) {
680 $totalamount_main_currency = -$totalamount_main_currency;
685 $bank_line_id = $acc->addline(
687 $this->paiementcode ? $this->paiementcode : $this->paiementid,
698 $totalamount_main_currency
703 if ($bank_line_id > 0) {
713 if ($mode ==
'payment') {
714 $url = DOL_URL_ROOT.
'/compta/paiement/card.php?id=';
716 if ($mode ==
'payment_supplier') {
717 $url = DOL_URL_ROOT.
'/fourn/paiement/card.php?id=';
720 $result = $acc->add_url_line($bank_line_id, $this->
id, $url,
'(paiement)', $mode);
731 $linkaddedforthirdparty = array();
732 foreach ($this->amounts as $key => $value) {
733 if ($mode ==
'payment') {
736 $fac->fetch_thirdparty();
737 if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) {
738 $result = $acc->add_url_line(
740 $fac->thirdparty->id,
741 DOL_URL_ROOT.
'/comm/card.php?socid=',
742 $fac->thirdparty->name,
746 dol_syslog(get_class($this).
'::addPaymentToBank '.$this->
db->lasterror());
748 $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id;
751 if ($mode ==
'payment_supplier') {
754 $fac->fetch_thirdparty();
755 if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) {
756 $result = $acc->add_url_line(
758 $fac->thirdparty->id,
759 DOL_URL_ROOT.
'/fourn/card.php?socid=',
760 $fac->thirdparty->name,
764 dol_syslog(get_class($this).
'::addPaymentToBank '.$this->
db->lasterror());
766 $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id;
773 if (!$error && $label ==
'(WithdrawalPayment)') {
774 $result = $acc->add_url_line(
776 $this->id_prelevement,
777 DOL_URL_ROOT.
'/compta/prelevement/card.php?id=',
784 if (! $error && $label ==
'(InvoiceRefused)') {
785 $result=$acc->add_url_line(
787 $this->id_prelevement,
788 DOL_URL_ROOT.
'/compta/prelevement/card.php?id=',
789 $this->num_prelevement,
794 if (!$error && !$notrigger) {
796 $result = $this->
call_trigger(
'PAYMENT_ADD_TO_BANK', $user);
803 $this->error = $acc->error;
810 $this->
db->rollback();
815 return $bank_line_id;
832 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' set fk_bank = '.((int) $id_bank);
833 $sql .=
" WHERE rowid = ".((int) $this->
id);
835 dol_syslog(get_class($this).
'::update_fk_bank', LOG_DEBUG);
836 $result = $this->
db->query($sql);
840 $this->error = $this->
db->lasterror();
841 dol_syslog(get_class($this).
'::update_fk_bank '.$this->error);
858 if (!empty($date) && $this->statut != 1) {
861 dol_syslog(get_class($this).
"::update_date with date = ".$date, LOG_DEBUG);
863 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
864 $sql .=
" SET datep = '".$this->db->idate($date).
"'";
865 $sql .=
" WHERE rowid = ".((int) $this->
id);
867 $result = $this->
db->query($sql);
870 $this->error =
'Error -1 '.$this->db->error();
873 $type = $this->element;
875 $sql =
"UPDATE ".MAIN_DB_PREFIX.
'bank';
876 $sql .=
" SET dateo = '".$this->db->idate($date).
"', datev = '".$this->
db->idate($date).
"'";
877 $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).
")";
878 $sql .=
" AND rappro = 0";
880 $result = $this->
db->query($sql);
883 $this->error =
'Error -1 '.$this->db->error();
890 $this->datepaye = $date;
896 $this->
db->rollback();
913 if (!empty($num) && $this->statut != 1) {
914 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
915 $sql .=
" SET num_paiement = '".$this->db->escape($num).
"'";
916 $sql .=
" WHERE rowid = ".((int) $this->
id);
918 dol_syslog(get_class($this).
"::update_num", LOG_DEBUG);
919 $result = $this->
db->query($sql);
921 $this->num_payment = $this->
db->escape($num);
924 $this->error =
'Error -1 '.$this->db->error();
951 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET statut = 1 WHERE rowid = '.((int) $this->
id);
953 dol_syslog(get_class($this).
'::valide', LOG_DEBUG);
954 $result = $this->
db->query($sql);
958 $this->error = $this->
db->lasterror();
959 dol_syslog(get_class($this).
'::valide '.$this->error);
972 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET statut = 2 WHERE rowid = '.((int) $this->
id);
974 dol_syslog(get_class($this).
'::reject', LOG_DEBUG);
975 $result = $this->
db->query($sql);
979 $this->error = $this->
db->lasterror();
980 dol_syslog(get_class($this).
'::reject '.$this->error);
993 $sql =
'SELECT p.rowid, p.datec, p.fk_user_creat, p.fk_user_modif, p.tms';
994 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p';
995 $sql .=
' WHERE p.rowid = '.((int) $id);
997 dol_syslog(get_class($this).
'::info', LOG_DEBUG);
998 $result = $this->
db->query($sql);
1001 if ($this->
db->num_rows($result)) {
1002 $obj = $this->
db->fetch_object($result);
1003 $this->
id = $obj->rowid;
1004 if ($obj->fk_user_creat) {
1005 $cuser =
new User($this->
db);
1006 $cuser->fetch($obj->fk_user_creat);
1007 $this->user_creation = $cuser;
1009 if ($obj->fk_user_modif) {
1010 $muser =
new User($this->
db);
1011 $muser->fetch($obj->fk_user_modif);
1012 $this->user_modification = $muser;
1014 $this->date_creation = $this->
db->jdate($obj->datec);
1015 $this->date_modification = $this->
db->jdate($obj->tms);
1017 $this->
db->free($result);
1032 $sql =
'SELECT pf.fk_facture';
1033 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf, '.MAIN_DB_PREFIX.
'facture as f';
1034 $sql .=
' WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = '.((int) $this->
id);
1036 $sql .=
' AND '.$filter;
1041 $num = $this->
db->num_rows(
$resql);
1042 $billsarray = array();
1045 $obj = $this->
db->fetch_object(
$resql);
1046 $billsarray[$i] = $obj->fk_facture;
1052 $this->error = $this->
db->error();
1053 dol_syslog(get_class($this).
'::getBillsArray Error '.$this->error.
' -', LOG_DEBUG);
1066 $sql =
'SELECT pf.fk_facture, pf.amount';
1067 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf';
1068 $sql .=
' WHERE pf.fk_paiement = '.((int) $this->
id);
1072 $num = $this->
db->num_rows(
$resql);
1076 $obj = $this->
db->fetch_object(
$resql);
1077 $amounts[$obj->fk_facture] = $obj->amount;
1083 $this->error = $this->
db->error();
1084 dol_syslog(get_class($this).
'::getAmountsArray Error '.$this->error.
' -', LOG_DEBUG);
1099 global $conf, $db, $langs;
1100 $langs->load(
"bills");
1103 if (empty($conf->global->PAYMENT_ADDON)) {
1104 $conf->global->PAYMENT_ADDON =
'mod_payment_cicada';
1105 } elseif ($conf->global->PAYMENT_ADDON ==
'ant') {
1106 $conf->global->PAYMENT_ADDON =
'mod_payment_ant';
1107 } elseif ($conf->global->PAYMENT_ADDON ==
'cicada') {
1108 $conf->global->PAYMENT_ADDON =
'mod_payment_cicada';
1111 if (!empty($conf->global->PAYMENT_ADDON)) {
1114 $file = $conf->global->PAYMENT_ADDON.
".php";
1115 $classname = $conf->global->PAYMENT_ADDON;
1118 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1120 foreach ($dirmodels as $reldir) {
1124 if (is_file($dir.$file) && is_readable($dir.$file)) {
1125 $mybool |= include_once $dir.$file;
1131 $file = $conf->global->PAYMENT_ADDON.
".php";
1132 $classname =
"mod_payment_".$conf->global->PAYMENT_ADDON;
1133 $classname = preg_replace(
'/\-.*$/',
'', $classname);
1135 foreach ($conf->file->dol_document_root as $dirroot) {
1136 $dir = $dirroot.
"/core/modules/payment/";
1139 if (is_file($dir.$file) && is_readable($dir.$file)) {
1140 $mybool |= include_once $dir.$file;
1150 $obj =
new $classname();
1152 $numref = $obj->getNextValue($soc, $this);
1158 if ($mode !=
'last' && !$numref) {
1165 $langs->load(
"errors");
1166 print $langs->trans(
"Error").
" ".$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Invoice"));
1182 foreach ($this->multicurrency_amounts as $value) {
1183 if (!empty($value)) {
1203 global $user, $langs, $conf;
1207 $nownotime =
dol_mktime(0, 0, 0, $arraynow[
'mon'], $arraynow[
'mday'], $arraynow[
'year']);
1211 $this->
ref =
'SPECIMEN';
1212 $this->specimen = 1;
1214 $this->datepaye = $nownotime;
1228 public function getNomUrl($withpicto = 0, $option =
'', $mode =
'withlistofinvoices', $notooltip = 0, $morecss =
'')
1230 global $conf, $langs, $hookmanager;
1232 if (!empty($conf->dol_no_mouse_hover)) {
1238 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Payment").
'</u><br>';
1239 $label .=
'<strong>'.$langs->trans(
"Ref").
':</strong> '.$this->ref;
1240 $dateofpayment = ($this->datepaye ? $this->datepaye : $this->date);
1241 if ($dateofpayment) {
1242 $label .=
'<br><strong>'.$langs->trans(
"Date").
':</strong> ';
1244 if ($tmparray[
'seconds'] == 0 && $tmparray[
'minutes'] == 0 && ($tmparray[
'hours'] == 0 || $tmparray[
'hours'] == 12)) {
1250 if ($this->amount) {
1251 $label .=
'<br><strong>'.$langs->trans(
"Amount").
':</strong> '.
price($this->amount, 0, $langs, 1, -1, -1, $conf->currency);
1253 if ($mode ==
'withlistofinvoices') {
1255 if (is_array($arraybill) && count($arraybill) > 0) {
1256 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1257 $facturestatic =
new Facture($this->
db);
1258 foreach ($arraybill as $billid) {
1259 $facturestatic->fetch($billid);
1260 $label .=
'<br> '.$facturestatic->getNomUrl(1,
'', 0, 0,
'', 1).
' '.$facturestatic->getLibStatut(2, 1);
1266 if (empty($notooltip)) {
1267 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1268 $label = $langs->trans(
"Payment");
1269 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1271 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1272 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1274 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1277 $url = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$this->id;
1279 $linkstart =
'<a href="'.$url.
'"';
1280 $linkstart .= $linkclose.
'>';
1283 $result .= $linkstart;
1285 $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);
1287 if ($withpicto && $withpicto != 2) {
1288 $result .= ($this->
ref ? $this->
ref : $this->id);
1290 $result .= $linkend;
1292 $hookmanager->initHooks(array($this->element .
'dao'));
1293 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1294 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1296 $result = $hookmanager->resPrint;
1298 $result .= $hookmanager->resPrint;
1311 return $this->
LibStatut($this->statut, $mode);
1327 $langs->load(
'compta');
1377 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1379 if (empty($force_thirdparty_id)) {
1381 if (!empty($billsarray)) {
1383 if ($invoice->fetch($billsarray[0]) > 0) {
1384 $force_thirdparty_id = $invoice->socid;
1389 return parent::fetch_thirdparty($force_thirdparty_id);