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);
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;
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).
")";
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);
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);
652 $totalamount = $this->amount;
653 $totalamount_main_currency =
null;
654 if (empty($totalamount)) {
659 if (
isModEnabled(
'multicurrency') && $conf->currency != $acc->currency_code) {
660 $totalamount = $this->multicurrency_amount;
661 $totalamount_main_currency = $this->amount;
664 if ($mode ==
'payment_supplier') {
665 $totalamount = -$totalamount;
666 if (isset($totalamount_main_currency)) {
667 $totalamount_main_currency = -$totalamount_main_currency;
672 $bank_line_id = $acc->addline(
674 $this->paiementcode ? $this->paiementcode : $this->paiementid,
685 $totalamount_main_currency
690 if ($bank_line_id > 0) {
700 if ($mode ==
'payment') {
701 $url = DOL_URL_ROOT.
'/compta/paiement/card.php?id=';
703 if ($mode ==
'payment_supplier') {
704 $url = DOL_URL_ROOT.
'/fourn/paiement/card.php?id=';
707 $result = $acc->add_url_line($bank_line_id, $this->
id, $url,
'(paiement)', $mode);
718 $linkaddedforthirdparty = array();
719 foreach ($this->amounts as $key => $value) {
720 if ($mode ==
'payment') {
723 $fac->fetch_thirdparty();
724 if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) {
725 $result = $acc->add_url_line(
727 $fac->thirdparty->id,
728 DOL_URL_ROOT.
'/comm/card.php?socid=',
729 $fac->thirdparty->name,
733 dol_syslog(get_class($this).
'::addPaymentToBank '.$this->
db->lasterror());
735 $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id;
738 if ($mode ==
'payment_supplier') {
741 $fac->fetch_thirdparty();
742 if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty)) {
743 $result = $acc->add_url_line(
745 $fac->thirdparty->id,
746 DOL_URL_ROOT.
'/fourn/card.php?socid=',
747 $fac->thirdparty->name,
751 dol_syslog(get_class($this).
'::addPaymentToBank '.$this->
db->lasterror());
753 $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id;
760 if (!$error && $label ==
'(WithdrawalPayment)') {
761 $result = $acc->add_url_line(
763 $this->id_prelevement,
764 DOL_URL_ROOT.
'/compta/prelevement/card.php?id=',
771 if (! $error && $label ==
'(InvoiceRefused)') {
772 $result=$acc->add_url_line(
774 $this->id_prelevement,
775 DOL_URL_ROOT.
'/compta/prelevement/card.php?id=',
776 $this->num_prelevement,
781 if (!$error && !$notrigger) {
783 $result = $this->
call_trigger(
'PAYMENT_ADD_TO_BANK', $user);
790 $this->error = $acc->error;
797 $this->
db->rollback();
802 return $bank_line_id;
819 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' set fk_bank = '.((int) $id_bank);
820 $sql .=
" WHERE rowid = ".((int) $this->
id);
822 dol_syslog(get_class($this).
'::update_fk_bank', LOG_DEBUG);
823 $result = $this->
db->query($sql);
827 $this->error = $this->
db->lasterror();
828 dol_syslog(get_class($this).
'::update_fk_bank '.$this->error);
845 if (!empty($date) && $this->statut != 1) {
848 dol_syslog(get_class($this).
"::update_date with date = ".$date, LOG_DEBUG);
850 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
851 $sql .=
" SET datep = '".$this->db->idate($date).
"'";
852 $sql .=
" WHERE rowid = ".((int) $this->
id);
854 $result = $this->
db->query($sql);
857 $this->error =
'Error -1 '.$this->db->error();
860 $type = $this->element;
862 $sql =
"UPDATE ".MAIN_DB_PREFIX.
'bank';
863 $sql .=
" SET dateo = '".$this->db->idate($date).
"', datev = '".$this->
db->idate($date).
"'";
864 $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).
")";
865 $sql .=
" AND rappro = 0";
867 $result = $this->
db->query($sql);
870 $this->error =
'Error -1 '.$this->db->error();
877 $this->datepaye = $date;
883 $this->
db->rollback();
900 if (!empty($num) && $this->statut != 1) {
901 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
902 $sql .=
" SET num_paiement = '".$this->db->escape($num).
"'";
903 $sql .=
" WHERE rowid = ".((int) $this->
id);
905 dol_syslog(get_class($this).
"::update_num", LOG_DEBUG);
906 $result = $this->
db->query($sql);
908 $this->num_payment = $this->
db->escape($num);
911 $this->error =
'Error -1 '.$this->db->error();
938 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET statut = 1 WHERE rowid = '.((int) $this->
id);
940 dol_syslog(get_class($this).
'::valide', LOG_DEBUG);
941 $result = $this->
db->query($sql);
945 $this->error = $this->
db->lasterror();
946 dol_syslog(get_class($this).
'::valide '.$this->error);
959 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET statut = 2 WHERE rowid = '.((int) $this->
id);
961 dol_syslog(get_class($this).
'::reject', LOG_DEBUG);
962 $result = $this->
db->query($sql);
966 $this->error = $this->
db->lasterror();
967 dol_syslog(get_class($this).
'::reject '.$this->error);
980 $sql =
'SELECT p.rowid, p.datec, p.fk_user_creat, p.fk_user_modif, p.tms';
981 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p';
982 $sql .=
' WHERE p.rowid = '.((int) $id);
984 dol_syslog(get_class($this).
'::info', LOG_DEBUG);
985 $result = $this->
db->query($sql);
988 if ($this->
db->num_rows($result)) {
989 $obj = $this->
db->fetch_object($result);
990 $this->
id = $obj->rowid;
991 if ($obj->fk_user_creat) {
992 $cuser =
new User($this->
db);
993 $cuser->fetch($obj->fk_user_creat);
994 $this->user_creation = $cuser;
996 if ($obj->fk_user_modif) {
997 $muser =
new User($this->
db);
998 $muser->fetch($obj->fk_user_modif);
999 $this->user_modification = $muser;
1001 $this->date_creation = $this->
db->jdate($obj->datec);
1002 $this->date_modification = $this->
db->jdate($obj->tms);
1004 $this->
db->free($result);
1019 $sql =
'SELECT pf.fk_facture';
1020 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf, '.MAIN_DB_PREFIX.
'facture as f';
1021 $sql .=
' WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = '.((int) $this->
id);
1023 $sql .=
' AND '.$filter;
1028 $num = $this->
db->num_rows(
$resql);
1029 $billsarray = array();
1032 $obj = $this->
db->fetch_object(
$resql);
1033 $billsarray[$i] = $obj->fk_facture;
1039 $this->error = $this->
db->error();
1040 dol_syslog(get_class($this).
'::getBillsArray Error '.$this->error.
' -', LOG_DEBUG);
1053 $sql =
'SELECT pf.fk_facture, pf.amount';
1054 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf';
1055 $sql .=
' WHERE pf.fk_paiement = '.((int) $this->
id);
1059 $num = $this->
db->num_rows(
$resql);
1063 $obj = $this->
db->fetch_object(
$resql);
1064 $amounts[$obj->fk_facture] = $obj->amount;
1070 $this->error = $this->
db->error();
1071 dol_syslog(get_class($this).
'::getAmountsArray Error '.$this->error.
' -', LOG_DEBUG);
1086 global $conf, $db, $langs;
1087 $langs->load(
"bills");
1090 if (empty($conf->global->PAYMENT_ADDON)) {
1091 $conf->global->PAYMENT_ADDON =
'mod_payment_cicada';
1092 } elseif ($conf->global->PAYMENT_ADDON ==
'ant') {
1093 $conf->global->PAYMENT_ADDON =
'mod_payment_ant';
1094 } elseif ($conf->global->PAYMENT_ADDON ==
'cicada') {
1095 $conf->global->PAYMENT_ADDON =
'mod_payment_cicada';
1098 if (!empty($conf->global->PAYMENT_ADDON)) {
1101 $file = $conf->global->PAYMENT_ADDON.
".php";
1102 $classname = $conf->global->PAYMENT_ADDON;
1105 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1107 foreach ($dirmodels as $reldir) {
1111 if (is_file($dir.$file) && is_readable($dir.$file)) {
1112 $mybool |= include_once $dir.$file;
1118 $file = $conf->global->PAYMENT_ADDON.
".php";
1119 $classname =
"mod_payment_".$conf->global->PAYMENT_ADDON;
1120 $classname = preg_replace(
'/\-.*$/',
'', $classname);
1122 foreach ($conf->file->dol_document_root as $dirroot) {
1123 $dir = $dirroot.
"/core/modules/payment/";
1126 if (is_file($dir.$file) && is_readable($dir.$file)) {
1127 $mybool |= include_once $dir.$file;
1137 $obj =
new $classname();
1139 $numref = $obj->getNextValue($soc, $this);
1145 if ($mode !=
'last' && !$numref) {
1152 $langs->load(
"errors");
1153 print $langs->trans(
"Error").
" ".$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Invoice"));
1169 foreach ($this->multicurrency_amounts as $value) {
1170 if (!empty($value)) {
1190 global $user, $langs, $conf;
1194 $nownotime =
dol_mktime(0, 0, 0, $arraynow[
'mon'], $arraynow[
'mday'], $arraynow[
'year']);
1198 $this->
ref =
'SPECIMEN';
1199 $this->specimen = 1;
1201 $this->datepaye = $nownotime;
1215 public function getNomUrl($withpicto = 0, $option =
'', $mode =
'withlistofinvoices', $notooltip = 0, $morecss =
'')
1217 global $conf, $langs, $hookmanager;
1219 if (!empty($conf->dol_no_mouse_hover)) {
1225 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Payment").
'</u><br>';
1226 $label .=
'<strong>'.$langs->trans(
"Ref").
':</strong> '.$this->ref;
1227 $dateofpayment = ($this->datepaye ? $this->datepaye : $this->date);
1228 if ($dateofpayment) {
1229 $label .=
'<br><strong>'.$langs->trans(
"Date").
':</strong> ';
1231 if ($tmparray[
'seconds'] == 0 && $tmparray[
'minutes'] == 0 && ($tmparray[
'hours'] == 0 || $tmparray[
'hours'] == 12)) {
1237 if ($this->amount) {
1238 $label .=
'<br><strong>'.$langs->trans(
"Amount").
':</strong> '.
price($this->amount, 0, $langs, 1, -1, -1, $conf->currency);
1240 if ($mode ==
'withlistofinvoices') {
1242 if (is_array($arraybill) && count($arraybill) > 0) {
1243 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1244 $facturestatic =
new Facture($this->
db);
1245 foreach ($arraybill as $billid) {
1246 $facturestatic->fetch($billid);
1247 $label .=
'<br> '.$facturestatic->getNomUrl(1,
'', 0, 0,
'', 1).
' '.$facturestatic->getLibStatut(2, 1);
1253 if (empty($notooltip)) {
1254 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
1255 $label = $langs->trans(
"Payment");
1256 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1258 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1259 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1261 $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1264 $url = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$this->id;
1266 $linkstart =
'<a href="'.$url.
'"';
1267 $linkstart .= $linkclose.
'>';
1270 $result .= $linkstart;
1272 $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);
1274 if ($withpicto && $withpicto != 2) {
1275 $result .= ($this->
ref ? $this->
ref : $this->id);
1277 $result .= $linkend;
1279 $hookmanager->initHooks(array($this->element .
'dao'));
1280 $parameters = array(
'id'=>$this->
id,
'getnomurl' => &$result);
1281 $reshook = $hookmanager->executeHooks(
'getNomUrl', $parameters, $this, $action);
1283 $result = $hookmanager->resPrint;
1285 $result .= $hookmanager->resPrint;
1298 return $this->
LibStatut($this->statut, $mode);
1314 $langs->load(
'compta');
1364 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1366 if (empty($force_thirdparty_id)) {
1368 if (!empty($billsarray)) {
1370 if ($invoice->fetch($billsarray[0]) > 0) {
1371 $force_thirdparty_id = $invoice->socid;
1376 return parent::fetch_thirdparty($force_thirdparty_id);
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 absolute discounts.
Class to manage suppliers invoices.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard invoice.
const TYPE_SITUATION
Situation invoice.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments of customer invoices.
addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger=0, $accountancycode='')
Add a record into bank for payment + links between this bank record and sources of payment.
__construct($db)
Constructor.
fetch_thirdparty($force_thirdparty_id=0)
Load the third party of object, from id into this->thirdparty.
create($user, $closepaidinvoices=0, $thirdparty=null)
Create payment of invoices into database.
validate(User $user=null)
Validate payment.
reject(User $user=null)
Reject payment.
getAmountsArray()
Return list of amounts of payments.
getNomUrl($withpicto=0, $option='', $mode='withlistofinvoices', $notooltip=0, $morecss='')
Return clicable name (with picto eventually)
update_num($num)
Updates the payment number.
update_fk_bank($id_bank)
Mise a jour du lien entre le paiement et la ligne generee dans llx_bank.
getWay()
get the right way of payment
valide(User $user=null)
Validate payment.
initAsSpecimen($option='')
Initialise an instance with random values.
fetch($id, $ref='', $fk_bank='')
Load payment from database.
LibStatut($status, $mode=0)
Renvoi le libelle d'un statut donne.
update_date($date)
Updates the payment date.
getNextNumRef($soc, $mode='next')
Return next reference of customer invoice not already used (or last reference) according to numbering...
getBillsArray($filter='')
Return list of invoices the payment is related to.
info($id)
Information sur l'objet.
getLibStatut($mode=0)
Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
Class to manage translations.
Class to manage Dolibarr users.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
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 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)
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
div float
Buy price without taxes.
$conf db
API class for accounts.