33 require_once DOL_DOCUMENT_ROOT.
'/core/class/commonobject.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/multicurrency/class/multicurrency.class.php';
45 public $element =
'payment';
50 public $table_element =
'paiement';
55 public $picto =
'payment';
73 public $multicurrency_amount;
74 public $amounts = array();
75 public $multicurrency_amounts = array();
77 public $pos_change = 0;
108 public $ext_payment_id;
113 public $ext_payment_site;
120 public $bank_account;
162 public function fetch($id, $ref =
'', $fk_bank =
'')
164 $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,';
165 $sql .=
' c.code as type_code, c.libelle as type_label,';
166 $sql .=
' p.num_paiement as num_payment, p.note,';
167 $sql .=
' b.fk_account';
168 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
169 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'bank as b ON p.fk_bank = b.rowid';
170 $sql .=
' WHERE p.entity IN ('.getEntity(
'invoice').
')';
172 $sql .=
' AND p.rowid = '.$id;
174 $sql .=
" AND p.ref = '".$ref.
"'";
176 $sql .=
' AND p.fk_bank = '.$fk_bank;
183 $obj = $this->
db->fetch_object(
$resql);
185 $this->
id = $obj->rowid;
186 $this->ref = $obj->ref ? $obj->ref : $obj->rowid;
187 $this->ref_ext = $obj->ref_ext;
188 $this->date = $this->
db->jdate($obj->dp);
189 $this->datepaye = $this->
db->jdate($obj->dp);
190 $this->num_payment = $obj->num_payment;
191 $this->montant = $obj->amount;
192 $this->amount = $obj->amount;
193 $this->multicurrency_amount = $obj->multicurrency_amount;
194 $this->
note = $obj->note;
195 $this->type_label = $obj->type_label;
196 $this->type_code = $obj->type_code;
197 $this->
statut = $obj->statut;
198 $this->ext_payment_id = $obj->ext_payment_id;
199 $this->ext_payment_site = $obj->ext_payment_site;
201 $this->bank_account = $obj->fk_account;
202 $this->fk_account = $obj->fk_account;
203 $this->bank_line = $obj->fk_bank;
227 public function create($user, $closepaidinvoices = 0, $thirdparty = null)
229 global $conf, $langs;
238 $totalamount_converted = 0;
239 $atleastonepaymentnotnull = 0;
241 if ($way ==
'dolibarr')
243 $amounts = &$this->amounts;
244 $amounts_to_update = &$this->multicurrency_amounts;
246 $amounts = &$this->multicurrency_amounts;
247 $amounts_to_update = &$this->amounts;
250 foreach ($amounts as $key => $value)
252 $value_converted = Multicurrency::getAmountConversionFromInvoiceRate($key, $value, $way);
253 $totalamount_converted += $value_converted;
254 $amounts_to_update[$key] =
price2num($value_converted,
'MT');
257 $amounts[$key] = $newvalue;
258 $totalamount += $newvalue;
259 if (!empty($newvalue)) $atleastonepaymentnotnull++;
263 $totalamount_converted =
price2num($totalamount_converted);
266 if (empty($totalamount) && empty($atleastonepaymentnotnull))
268 $this->errors[] =
'TotalAmountEmpty';
269 $this->error =
'TotalAmountEmpty';
273 dol_syslog(get_class($this).
"::create insert paiement", LOG_DEBUG);
277 $this->ref = $this->
getNextNumRef(is_object($thirdparty) ? $thirdparty :
'');
279 if (empty($this->ref_ext)) {
283 if ($way ==
'dolibarr')
286 $mtotal = $totalamount_converted;
288 $total = $totalamount_converted;
289 $mtotal = $totalamount;
292 $num_payment = $this->num_payment;
295 $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)";
296 $sql .=
" VALUES (".$conf->entity.
", '".$this->
db->escape($this->ref).
"', '".$this->
db->escape($this->ref_ext).
"', '".$this->
db->idate($now).
"', '".$this->
db->idate($this->datepaye).
"', ".
$total.
", ".$mtotal.
", ".$this->paiementid.
", ";
297 $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").
", ".$user->id.
", ".((
float) $this->pos_change).
")";
302 $this->
id = $this->
db->last_insert_id(MAIN_DB_PREFIX.
'paiement');
305 foreach ($this->amounts as $key => $amount)
308 if (is_numeric($amount) && $amount <> 0)
311 $sql =
'INSERT INTO '.MAIN_DB_PREFIX.
'paiement_facture (fk_facture, fk_paiement, amount, multicurrency_amount)';
312 $sql .=
' VALUES ('.$facid.
', '.$this->
id.
', \''.$amount.
'\', \
''.$this->multicurrency_amounts[$key].
'\')
';
314 dol_syslog(get_class($this).'::create Amount line
'.$key.' insert paiement_facture
', LOG_DEBUG);
315 $resql = $this->db->query($sql);
318 $invoice = new Facture($this->db);
319 $invoice->fetch($facid);
321 // If we want to closed payed invoices
322 if ($closepaidinvoices)
324 $paiement = $invoice->getSommePaiement();
325 $creditnotes = $invoice->getSumCreditNotesUsed();
326 $deposits = $invoice->getSumDepositsUsed();
327 $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT
');
328 $remaintopay = price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits, 'MT
');
330 //var_dump($invoice->total_ttc.' -
'.$paiement.' -
'.$creditnotes.' -
'.$deposits.' -
'.$remaintopay);exit;
332 //Invoice types that are eligible for changing status to paid
333 $affected_types = array(
334 Facture::TYPE_STANDARD,
335 Facture::TYPE_REPLACEMENT,
336 Facture::TYPE_CREDIT_NOTE,
337 Facture::TYPE_DEPOSIT,
338 Facture::TYPE_SITUATION
341 if (!in_array($invoice->type, $affected_types)) dol_syslog("Invoice ".$facid." is not a standard, nor replacement invoice, nor credit note, nor deposit invoice, nor situation invoice. We do nothing more.");
342 elseif ($remaintopay) dol_syslog("Remain to pay for invoice ".$facid." not null. We do nothing more.");
343 //else if ($mustwait) dol_syslog("There is ".$mustwait." differed payment to process, we do nothing more.");
345 // If invoice is a down payment, we also convert down payment to discount
346 if ($invoice->type == Facture::TYPE_DEPOSIT)
348 $amount_ht = $amount_tva = $amount_ttc = array();
349 $multicurrency_amount_ht = $multicurrency_amount_tva = $multicurrency_amount_ttc = array();
351 // Insert one discount by VAT rate category
352 $discount = new DiscountAbsolute($this->db);
353 $discount->fetch('', $invoice->id);
354 if (empty($discount->id)) { // If the invoice was not yet converted into a discount (this may have been done manually before we come here)
355 $discount->description = '(DEPOSIT)
';
356 $discount->fk_soc = $invoice->socid;
357 $discount->fk_facture_source = $invoice->id;
359 // Loop on each vat rate
361 foreach ($invoice->lines as $line) {
362 if ($line->total_ht != 0) { // no need to create discount if amount is null
363 $amount_ht[$line->tva_tx] += $line->total_ht;
364 $amount_tva[$line->tva_tx] += $line->total_tva;
365 $amount_ttc[$line->tva_tx] += $line->total_ttc;
366 $multicurrency_amount_ht[$line->tva_tx] += $line->multicurrency_total_ht;
367 $multicurrency_amount_tva[$line->tva_tx] += $line->multicurrency_total_tva;
368 $multicurrency_amount_ttc[$line->tva_tx] += $line->multicurrency_total_ttc;
373 foreach ($amount_ht as $tva_tx => $xxx) {
374 $discount->amount_ht = abs($amount_ht[$tva_tx]);
375 $discount->amount_tva = abs($amount_tva[$tva_tx]);
376 $discount->amount_ttc = abs($amount_ttc[$tva_tx]);
377 $discount->multicurrency_amount_ht = abs($multicurrency_amount_ht[$tva_tx]);
378 $discount->multicurrency_amount_tva = abs($multicurrency_amount_tva[$tva_tx]);
379 $discount->multicurrency_amount_ttc = abs($multicurrency_amount_ttc[$tva_tx]);
380 $discount->tva_tx = abs($tva_tx);
382 $result = $discount->create($user);
392 setEventMessages($discount->error, $discount->errors, 'errors
');
397 // Set invoice to paid
400 $result = $invoice->set_paid($user, '', '');
403 $this->error = $invoice->error;
404 $this->errors = $invoice->errors;
411 // Regenerate documents of invoices
412 if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
414 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);
417 $outputlangs = $langs;
418 if ($conf->global->MAIN_MULTILANGS && empty($newlang)) {
419 $invoice->fetch_thirdparty();
420 $newlang = $invoice->thirdparty->default_lang;
422 if (!empty($newlang)) {
423 $outputlangs = new Translate("", $conf);
424 $outputlangs->setDefaultLang($newlang);
426 $ret = $invoice->fetch($facid); // Reload to get new records
427 $result = $invoice->generateDocument($invoice->modelpdf, $outputlangs);
429 setEventMessages($invoice->error, $invoice->errors, 'errors
');
434 $this->error = $this->db->lasterror();
438 dol_syslog(get_class($this).'::Create Amount line
'.$key.' not a number. We discard it.
');
442 if (!$error) // All payments into $this->amounts were recorded without errors
444 // Appel des triggers
445 $result = $this->call_trigger('PAYMENT_CUSTOMER_CREATE
', $user);
446 if ($result < 0) { $error++; }
447 // Fin appel triggers
450 $this->error = $this->db->lasterror();
456 $this->amount = $total;
457 $this->total = $total; // deprecated
458 $this->multicurrency_amount = $mtotal;
462 $this->db->rollback();
476 public function delete($notrigger = 0)
478 global $conf, $user, $langs;
482 $bank_line_id = $this->bank_line;
486 // Verifier si paiement porte pas sur une facture classee
487 // Si c'est le cas, on refuse la suppression
488 $billsarray = $this->getBillsArray(
'fk_statut > 1');
489 if (is_array($billsarray))
491 if (count($billsarray))
493 $this->error =
"ErrorDeletePaymentLinkedToAClosedInvoiceNotPossible";
494 $this->
db->rollback();
498 $this->
db->rollback();
503 if ($bank_line_id > 0)
507 $result = $accline->fetch($bank_line_id);
509 $accline->id = $accline->rowid = $bank_line_id;
513 $result = $accline->delete_urls($user);
516 $this->error = $accline->error;
517 $this->
db->rollback();
522 $result = $accline->delete($user);
525 $this->error = $accline->error;
526 $this->
db->rollback();
534 $result = $this->
call_trigger(
'PAYMENT_CUSTOMER_DELETE', $user);
537 $this->
db->rollback();
544 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.
'paiement_facture';
545 $sql .=
' WHERE fk_paiement = '.$this->id;
547 $result = $this->
db->query($sql);
550 $sql =
'DELETE FROM '.MAIN_DB_PREFIX.
'paiement';
551 $sql .=
' WHERE rowid = '.$this->id;
553 $result = $this->
db->query($sql);
556 $this->error = $this->
db->lasterror();
557 $this->
db->rollback();
564 $this->error = $this->
db->error;
565 $this->
db->rollback();
585 public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque, $notrigger = 0, $accountancycode =
'')
587 global $conf, $langs, $user;
592 if (!empty($conf->banque->enabled))
596 $this->error =
'Bad value for parameter accountid='.$accountid;
597 dol_syslog(get_class($this).
'::addPaymentToBank '.$this->error, LOG_ERR);
603 $this->fk_account = $accountid;
605 include_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
607 dol_syslog(
"$user->id, $mode, $label, $this->fk_account, $emetteur_nom, $emetteur_banque");
610 $result = $acc->fetch($this->fk_account);
612 $totalamount = $this->amount;
616 if (!empty($conf->multicurrency->enabled) && $conf->currency != $acc->currency_code) $totalamount = $this->multicurrency_amount;
618 if ($mode ==
'payment_supplier') $totalamount = -$totalamount;
621 $bank_line_id = $acc->addline(
636 if ($bank_line_id > 0)
649 if ($mode ==
'payment') $url = DOL_URL_ROOT.
'/compta/paiement/card.php?id=';
650 if ($mode ==
'payment_supplier') $url = DOL_URL_ROOT.
'/fourn/paiement/card.php?id=';
653 $result = $acc->add_url_line($bank_line_id, $this->
id, $url,
'(paiement)', $mode);
666 $linkaddedforthirdparty = array();
667 foreach ($this->amounts as $key => $value)
669 if ($mode ==
'payment')
673 $fac->fetch_thirdparty();
674 if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty))
676 $result = $acc->add_url_line(
678 $fac->thirdparty->id,
679 DOL_URL_ROOT.
'/comm/card.php?socid=',
680 $fac->thirdparty->name,
683 if ($result <= 0)
dol_syslog(get_class($this).
'::addPaymentToBank '.$this->
db->lasterror());
684 $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id;
687 if ($mode ==
'payment_supplier')
691 $fac->fetch_thirdparty();
692 if (!in_array($fac->thirdparty->id, $linkaddedforthirdparty))
694 $result = $acc->add_url_line(
696 $fac->thirdparty->id,
697 DOL_URL_ROOT.
'/fourn/card.php?socid=',
698 $fac->thirdparty->name,
701 if ($result <= 0)
dol_syslog(get_class($this).
'::addPaymentToBank '.$this->
db->lasterror());
702 $linkaddedforthirdparty[$fac->thirdparty->id] = $fac->thirdparty->id;
709 if (!$error && $label ==
'(WithdrawalPayment)') {
710 $result = $acc->add_url_line(
712 $this->id_prelevement,
713 DOL_URL_ROOT.
'/compta/prelevement/card.php?id=',
719 if (!$error && !$notrigger)
722 $result = $this->
call_trigger(
'PAYMENT_ADD_TO_BANK', $user);
723 if ($result < 0) { $error++; }
727 $this->error = $acc->error;
735 $this->
db->rollback();
741 return $bank_line_id;
758 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' set fk_bank = '.$id_bank;
759 $sql .=
' WHERE rowid = '.$this->id;
761 dol_syslog(get_class($this).
'::update_fk_bank', LOG_DEBUG);
762 $result = $this->
db->query($sql);
767 $this->error = $this->
db->lasterror();
768 dol_syslog(get_class($this).
'::update_fk_bank '.$this->error);
785 if (!empty($date) && $this->
statut != 1)
789 dol_syslog(get_class($this).
"::update_date with date = ".$date, LOG_DEBUG);
791 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
792 $sql .=
" SET datep = '".$this->db->idate($date).
"'";
793 $sql .=
" WHERE rowid = ".$this->id;
795 $result = $this->
db->query($sql);
799 $this->error =
'Error -1 '.$this->db->error();
802 $type = $this->element;
804 $sql =
"UPDATE ".MAIN_DB_PREFIX.
'bank';
805 $sql .=
" SET dateo = '".$this->db->idate($date).
"', datev = '".$this->
db->idate($date).
"'";
806 $sql .=
" WHERE rowid IN (SELECT fk_bank FROM ".MAIN_DB_PREFIX.
"bank_url WHERE type = '".$this->
db->escape($type).
"' AND url_id = ".$this->
id.
")";
807 $sql .=
" AND rappro = 0";
809 $result = $this->
db->query($sql);
813 $this->error =
'Error -1 '.$this->db->error();
822 $this->datepaye = $date;
828 $this->
db->rollback();
845 if (!empty($num) && $this->
statut != 1) {
846 $sql =
"UPDATE ".MAIN_DB_PREFIX.$this->table_element;
847 $sql .=
" SET num_paiement = '".$this->db->escape($num).
"'";
848 $sql .=
" WHERE rowid = ".$this->id;
850 dol_syslog(get_class($this).
"::update_num", LOG_DEBUG);
851 $result = $this->
db->query($sql);
854 $this->num_payment = $this->
db->escape($num);
857 $this->error =
'Error -1 '.$this->db->error();
884 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET statut = 1 WHERE rowid = '.$this->id;
886 dol_syslog(get_class($this).
'::valide', LOG_DEBUG);
887 $result = $this->
db->query($sql);
892 $this->error = $this->
db->lasterror();
893 dol_syslog(get_class($this).
'::valide '.$this->error);
906 $sql =
'UPDATE '.MAIN_DB_PREFIX.$this->table_element.
' SET statut = 2 WHERE rowid = '.$this->id;
908 dol_syslog(get_class($this).
'::reject', LOG_DEBUG);
909 $result = $this->
db->query($sql);
914 $this->error = $this->
db->lasterror();
915 dol_syslog(get_class($this).
'::reject '.$this->error);
928 $sql =
'SELECT p.rowid, p.datec, p.fk_user_creat, p.fk_user_modif, p.tms';
929 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p';
930 $sql .=
' WHERE p.rowid = '.$id;
932 dol_syslog(get_class($this).
'::info', LOG_DEBUG);
933 $result = $this->
db->query($sql);
937 if ($this->
db->num_rows($result))
939 $obj = $this->
db->fetch_object($result);
940 $this->
id = $obj->rowid;
941 if ($obj->fk_user_creat)
943 $cuser =
new User($this->
db);
944 $cuser->fetch($obj->fk_user_creat);
945 $this->user_creation = $cuser;
947 if ($obj->fk_user_modif)
949 $muser =
new User($this->
db);
950 $muser->fetch($obj->fk_user_modif);
951 $this->user_modification = $muser;
953 $this->date_creation = $this->
db->jdate($obj->datec);
954 $this->date_modification = $this->
db->jdate($obj->tms);
956 $this->
db->free($result);
970 $sql =
'SELECT pf.fk_facture';
971 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf, '.MAIN_DB_PREFIX.
'facture as f';
972 $sql .=
' WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = '.$this->id;
973 if ($filter) $sql .=
' AND '.$filter;
979 $billsarray = array();
983 $obj = $this->
db->fetch_object(
$resql);
984 $billsarray[$i] = $obj->fk_facture;
990 $this->error = $this->
db->error();
991 dol_syslog(get_class($this).
'::getBillsArray Error '.$this->error.
' -', LOG_DEBUG);
1003 $sql =
'SELECT pf.fk_facture, pf.amount';
1004 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement_facture as pf';
1005 $sql .=
' WHERE pf.fk_paiement = '.$this->id;
1010 $num = $this->
db->num_rows(
$resql);
1015 $obj = $this->
db->fetch_object(
$resql);
1016 $amounts[$obj->fk_facture] = $obj->amount;
1022 $this->error = $this->
db->error();
1023 dol_syslog(get_class($this).
'::getAmountsArray Error '.$this->error.
' -', LOG_DEBUG);
1038 global $conf, $db, $langs;
1039 $langs->load(
"bills");
1042 if (empty($conf->global->PAYMENT_ADDON)) $conf->global->PAYMENT_ADDON =
'mod_payment_cicada';
1043 elseif ($conf->global->PAYMENT_ADDON ==
'ant') $conf->global->PAYMENT_ADDON =
'mod_payment_ant';
1044 elseif ($conf->global->PAYMENT_ADDON ==
'cicada') $conf->global->PAYMENT_ADDON =
'mod_payment_cicada';
1046 if (!empty($conf->global->PAYMENT_ADDON))
1050 $file = $conf->global->PAYMENT_ADDON.
".php";
1051 $classname = $conf->global->PAYMENT_ADDON;
1054 $dirmodels = array_merge(array(
'/'), (array) $conf->modules_parts[
'models']);
1056 foreach ($dirmodels as $reldir) {
1060 if (is_file($dir.$file) && is_readable($dir.$file))
1062 $mybool |= include_once $dir.$file;
1069 $file = $conf->global->PAYMENT_ADDON.
".php";
1070 $classname =
"mod_payment_".$conf->global->PAYMENT_ADDON;
1071 $classname = preg_replace(
'/\-.*$/',
'', $classname);
1073 foreach ($conf->file->dol_document_root as $dirroot)
1075 $dir = $dirroot.
"/core/modules/payment/";
1078 if (is_file($dir.$file) && is_readable($dir.$file)) {
1079 $mybool |= include_once $dir.$file;
1090 $obj =
new $classname();
1092 $numref = $obj->getNextValue($soc, $this);
1098 if ($mode !=
'last' && !$numref) {
1105 $langs->load(
"errors");
1106 print $langs->trans(
"Error").
" ".$langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Invoice"));
1121 if (!empty($conf->multicurrency->enabled))
1123 foreach ($this->multicurrency_amounts as $value)
1146 global $user, $langs, $conf;
1150 $nownotime =
dol_mktime(0, 0, 0, $arraynow[
'mon'], $arraynow[
'mday'], $arraynow[
'year']);
1154 $this->ref =
'SPECIMEN';
1155 $this->specimen = 1;
1157 $this->datepaye = $nownotime;
1170 public function getNomUrl($withpicto = 0, $option =
'', $mode =
'withlistofinvoices', $notooltip = 0)
1172 global $conf, $langs;
1174 if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1;
1178 $label =
img_picto(
'', $this->picto).
' <u>'.$langs->trans(
"Payment").
'</u><br>';
1179 $label .=
'<strong>'.$langs->trans(
"Ref").
':</strong> '.$this->ref;
1180 $dateofpayment = ($this->datepaye ? $this->datepaye : $this->date);
1181 if ($dateofpayment) {
1182 $label .=
'<br><strong>'.$langs->trans(
"Date").
':</strong> ';
1184 if ($tmparray[
'seconds'] == 0 && $tmparray[
'minutes'] == 0 && ($tmparray[
'hours'] == 0 || $tmparray[
'hours'] == 12)) {
1190 if ($mode ==
'withlistofinvoices')
1193 if (is_array($arraybill) && count($arraybill) > 0)
1195 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1196 $facturestatic =
new Facture($this->
db);
1197 foreach ($arraybill as $billid)
1199 $facturestatic->fetch($billid);
1200 $label .=
'<br> '.$facturestatic->getNomUrl(1,
'', 0, 0,
'', 1).
' '.$facturestatic->getLibStatut(2, 1);
1206 if (empty($notooltip))
1208 if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
1210 $label = $langs->trans(
"ShowMyObject");
1211 $linkclose .=
' alt="'.dol_escape_htmltag($label, 1).
'"';
1213 $linkclose .=
' title="'.dol_escape_htmltag($label, 1).
'"';
1214 $linkclose .=
' class="classfortooltip'.($morecss ?
' '.$morecss :
'').
'"';
1215 }
else $linkclose = ($morecss ?
' class="'.$morecss.
'"' :
'');
1217 $url = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$this->id;
1219 $linkstart =
'<a href="'.$url.
'"';
1220 $linkstart .= $linkclose.
'>';
1223 $result .= $linkstart;
1224 if ($withpicto) $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);
1225 if ($withpicto && $withpicto != 2) $result .= ($this->ref ? $this->ref : $this->id);
1226 $result .= $linkend;
1255 $langs->load(
'compta');
1305 include_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
1307 if (empty($force_thirdparty_id))
1310 if (!empty($billsarray))
1313 if ($invoice->fetch($billsarray[0]) > 0)
1315 $force_thirdparty_id = $invoice->socid;
1320 return parent::fetch_thirdparty($force_thirdparty_id);
getBillsArray($filter= '')
Return list of invoices the payment is related to.
getAmountsArray()
Return list of amounts of payments.
create($user, $closepaidinvoices=0, $thirdparty=null)
Create payment of invoices into database.
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...
if(!empty($arrayfields['u.datec']['checked'])) print_liste_field_titre("DateCreationShort"u if(!empty($arrayfields['u.tms']['checked'])) print_liste_field_titre("DateModificationShort"u if(!empty($arrayfields['u.statut']['checked'])) print_liste_field_titre("Status"u statut
dol_now($mode= 'auto')
Return date for now.
Class to manage Dolibarr users.
__construct($db)
Constructor.
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...
Class to manage bank transaction lines.
reject(User $user=null)
Reject payment.
Class to manage suppliers invoices.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
$conf db
API class for accounts.
Class to manage bank accounts.
info($id)
Information sur l'objet.
initAsSpecimen($option= '')
Initialise an instance with random values.
update_fk_bank($id_bank)
Mise a jour du lien entre le paiement et la ligne generee dans llx_bank.
update_date($date)
Updates the payment date.
fetch_thirdparty($force_thirdparty_id=0)
Load the third party of object, from id into this->thirdparty.
fetch($id, $ref= '', $fk_bank= '')
Load payment from database.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
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_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
Class to manage payments of customer invoices.
getLibStatut($mode=0)
Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) ...
dol_getdate($timestamp, $fast=false, $forcetimezone= '')
Return an array with locale date info.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
valide(User $user=null)
Validate payment.
update_num($num)
Updates the payment number.
validate(User $user=null)
Validate payment.
getWay()
get the right way of payment
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
call_trigger($triggerName, $user)
Call trigger based on this instance.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
LibStatut($status, $mode=0)
Renvoi le libelle d'un statut donne.
Class to manage invoices.
Parent class of all other business classes (invoices, contracts, proposals, orders, ...)
if(!empty($search_group)) natural_search(array("g.nom"g note
getNextNumRef($soc, $mode= 'next')
Return next reference of customer invoice not already used (or last reference) according to numbering...
getNomUrl($withpicto=0, $option= '', $mode= 'withlistofinvoices', $notooltip=0)
Return clicable name (with picto eventually)