37require
'../main.inc.php';
38require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
44$langs->loadLangs(array(
'companies',
'bills',
'banks',
'multicurrency'));
46$action =
GETPOST(
'action',
'alpha');
47$confirm =
GETPOST(
'confirm',
'alpha');
49$facid =
GETPOST(
'facid',
'int');
50$accountid =
GETPOST(
'accountid',
'int');
51$paymentnum =
GETPOST(
'num_paiement',
'alpha');
52$socid =
GETPOST(
'socid',
'int');
54$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
55$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
56$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
59$amountsresttopay = array();
62$multicurrency_amounts = array();
63$multicurrency_amountsresttopay = array();
66if ($user->socid > 0) {
67 $socid = $user->socid;
74 $ret = $object->fetch($facid);
78$hookmanager->initHooks(array(
'paiementcard',
'globalcard'));
80$formquestion = array();
82$usercanissuepayment = $user->hasRight(
'facture',
'paiement');
86$result =
restrictedArea($user,
'facture', $object->id,
'',
'',
'fk_soc', $fieldid, $isdraft);
93$parameters = array(
'socid'=>$socid);
94$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
100 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $usercanissuepayment) {
106 $multicurrency_totalpayment = 0;
107 $atleastonepaymentnotnull = 0;
108 $formquestion = array();
112 $tmpinvoice =
new Facture($db);
113 foreach ($_POST as $key => $value) {
114 if (substr($key, 0, 7) ==
'amount_' &&
GETPOST($key) !=
'') {
115 $cursorfacid = substr($key, 7);
117 $totalpayment = $totalpayment + $amounts[$cursorfacid];
118 if (!empty($amounts[$cursorfacid])) {
119 $atleastonepaymentnotnull++;
121 $result = $tmpinvoice->fetch($cursorfacid);
125 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement());
126 if ($amounts[$cursorfacid]) {
128 if ($amounts[$cursorfacid] && (abs($amounts[$cursorfacid]) > abs($amountsresttopay[$cursorfacid]))) {
130 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
133 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
134 $langs->load(
"errors");
140 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
141 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
142 $cursorfacid = substr($key, 21);
144 $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid];
145 if (!empty($multicurrency_amounts[$cursorfacid])) {
146 $atleastonepaymentnotnull++;
148 $result = $tmpinvoice->fetch($cursorfacid);
152 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
153 if ($multicurrency_amounts[$cursorfacid]) {
155 if ($multicurrency_amounts[$cursorfacid] && (abs($multicurrency_amounts[$cursorfacid]) > abs($multicurrency_amountsresttopay[$cursorfacid]))) {
157 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
160 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
161 $langs->load(
"errors");
167 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key,
'int'));
172 if (!
GETPOST(
'paiementcode')) {
173 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
177 if (isModEnabled(
"banque")) {
179 if (
GETPOST(
'accountid') <= 0) {
180 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
185 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
186 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
190 if (empty($datepaye)) {
191 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
196 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
197 $langs->load(
"errors");
198 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
206 if ($action ==
'add_paiement') {
216 if ($action ==
'confirm_paiement' && $confirm ==
'yes' && $usercanissuepayment) {
223 $thirdparty =
new Societe($db);
225 $thirdparty->fetch($socid);
228 $multicurrency_code = array();
229 $multicurrency_tx = array();
232 foreach ($amounts as $key => $value) {
233 $tmpinvoice =
new Facture($db);
234 $tmpinvoice->fetch($key);
237 $amounts[$key] = - abs($newvalue);
239 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
240 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
243 foreach ($multicurrency_amounts as $key => $value) {
244 $tmpinvoice =
new Facture($db);
245 $tmpinvoice->fetch($key);
248 $multicurrency_amounts[$key] = - abs($newvalue);
250 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
251 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
254 if (isModEnabled(
"banque")) {
256 if (
GETPOST(
'accountid',
'int') <= 0) {
257 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
264 $paiement->datepaye = $datepaye;
265 $paiement->amounts = $amounts;
266 $paiement->multicurrency_amounts = $multicurrency_amounts;
267 $paiement->multicurrency_code = $multicurrency_code;
268 $paiement->multicurrency_tx = $multicurrency_tx;
270 $paiement->num_payment =
GETPOST(
'num_paiement',
'alpha');
271 $paiement->note_private =
GETPOST(
'comment',
'alpha');
272 $paiement->fk_account =
GETPOST(
'accountid',
'int');
278 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
279 if ($paiement_id < 0) {
286 $label =
'(CustomerInvoicePayment)';
288 $label =
'(CustomerInvoicePaymentBack)';
290 $result = $paiement->addPaymentToBank($user,
'payment', $label,
GETPOST(
'accountid',
'int'),
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
302 foreach ($paiement->amounts as $key => $amount) {
304 if (is_numeric($amount) && $amount != 0) {
305 if ($invoiceid != 0) {
312 if ($invoiceid > 0) {
313 $loc = DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$invoiceid;
315 $loc = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$paiement_id;
317 header(
'Location: '.$loc);
330$form =
new Form($db);
337if ($action ==
'create' || $action ==
'confirm_paiement' || $action ==
'add_paiement') {
339 $result = $facture->fetch($facid);
342 $facture->fetch_thirdparty();
346 $title .= $langs->trans(
"EnterPaymentReceivedFromCustomer");
349 $title .= $langs->trans(
"EnterPaymentDueToCustomer");
354 if ($action ==
'add_paiement') {
357 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'facid',
'value' => $facture->id);
358 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'socid',
'value' => $facture->socid);
359 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'type',
'value' => $facture->type);
364 if (isModEnabled(
'paypalplus') && $conf->global->PAYPAL_ENABLE_TRANSACTION_MANAGEMENT && !empty($facture->ref_ext)) {
366 $accountid = $conf->global->PAYPAL_BANK_ACCOUNT;
368 $paymentnum = $facture->ref_ext;
372 if (!empty($conf->use_javascript_ajax)) {
373 print
"\n".
'<script type="text/javascript">';
374 print
'$(document).ready(function () {
377 $("#selectpaiementcode").change(function() {
381 function setPaiementCode()
383 var code = $("#selectpaiementcode option:selected").val();
384 console.log("setPaiementCode code="+code);
386 if (code == \'CHQ\' || code == \'VIR\')
390 $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
392 if ($(\'#fieldchqemetteur\').val() == \'\')
395 $(\'#fieldchqemetteur\').val(emetteur);
400 $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
401 $(\'#fieldchqemetteur\').val(\'\');
405 function _elemToJson(selector)
408 $.map(selector.serializeArray(), function(n,i)
410 subJson[n["name"]] = n["value"];
415 function callForResult(imgId)
418 var form = $("#payment_form");
420 json["invoice_type"] = $("#invoice_type").val();
421 json["amountPayment"] = $("#amountpayment").attr("value");
422 json["amounts"] = _elemToJson(form.find("input.amount"));
423 json["remains"] = _elemToJson(form.find("input.remain"));
426 json["imgClicked"] = imgId;
429 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
431 json = $.parseJSON(data);
435 for (var key in json)
437 if (key == "result") {
438 if (json["makeRed"]) {
439 $("#"+key).addClass("error");
441 $("#"+key).removeClass("error");
443 json[key]=json["label"]+" "+json[key];
444 $("#"+key).text(json[key]);
445 } else {console.log(key);
446 form.find("input[name*=\""+key+"\"]").each(function() {
447 $(this).attr("value", json[key]);
453 $("#payment_form").find("input.amount").change(function() {
456 $("#payment_form").find("input.amount").keyup(function() {
464 print
' $(document).ready(function () {';
465 print
' $(".AutoFillAmout").on(\'click touchstart\', function(){
466 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
470 print
' </script>'.
"\n";
473 print
'<form id="payment_form" name="add_paiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
474 print
'<input type="hidden" name="token" value="'.newToken().
'">';
475 print
'<input type="hidden" name="action" value="add_paiement">';
476 print
'<input type="hidden" name="facid" value="'.$facture->id.
'">';
477 print
'<input type="hidden" name="socid" value="'.$facture->socid.
'">';
478 print
'<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.
'">';
479 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).
'">';
480 print
'<input type="hidden" name="page_y" value="">';
484 print
'<table class="border centpercent">';
487 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
'Company').
'</span></td><td>'.$facture->thirdparty->getNomUrl(4).
"</td></tr>\n";
490 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Date').
'</span></td><td>';
492 $datepayment = ($datepayment ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datepayment);
493 print $form->selectDate($datepayment,
'',
'',
'', 0,
"add_paiement", 1, 1, 0,
'',
'', $facture->date);
497 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</span></td><td>';
498 $form->select_types_paiements((
GETPOST(
'paiementcode') ?
GETPOST(
'paiementcode') : $facture->mode_reglement_code),
'paiementcode',
'', 2);
504 if (isModEnabled(
"banque")) {
505 if ($facture->type != 2) {
506 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</span></td>';
508 if ($facture->type == 2) {
509 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</span></td>';
514 print $form->select_comptes($accountid,
'accountid', 0,
'', 2,
'', 0,
'widthcentpercentminusx maxwidth500', 1);
517 print
'<td> </td>';
522 print
'<tr><td>'.$langs->trans(
'Numero');
523 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
525 print
'<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.
'"></td></tr>';
528 print
'<tr><td class="'.(GETPOST(
'paiementcode') ==
'CHQ' ?
'fieldrequired ' :
'').
'fieldrequireddyn">'.$langs->trans(
'CheckTransmitter');
529 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeMaker").
')</em>';
531 print
'<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST(
'chqemetteur',
'alphanohtml').
'"></td></tr>';
534 print
'<tr><td>'.$langs->trans(
'Bank');
535 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeBank").
')</em>';
537 print
'<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST(
'chqbank',
'alphanohtml').
'"></td></tr>';
540 print
'<tr><td>'.$langs->trans(
'Comments').
'</td>';
541 print
'<td class="tdtop">';
542 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
GETPOST(
'comment',
'restricthtml').
'</textarea>';
546 if ($action !=
'add_paiement' &&
getDolGlobalString(
'FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) {
547 print
'<tr><td></td>';
548 print
'<td class="tdtop right">';
549 print
'<a class="right" href="#amount_'.$facid.
'">'.$langs->trans(
"GoSourceInvoice").
'</a>';
562 $sql =
'SELECT f.rowid as facid, f.ref, f.total_ht, f.total_tva, f.total_ttc, f.multicurrency_code, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc, f.type,';
563 $sql .=
' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
564 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture as f';
565 $sql .=
' WHERE f.entity IN ('.getEntity(
'facture').
')';
566 $sql .=
' AND (f.fk_soc = '.((int) $facture->socid);
568 if (
getDolGlobalString(
'FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) {
569 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int) $facture->thirdparty->parent).
')';
573 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int) $facture->thirdparty->id).
')';
575 $sql .=
') AND f.paye = 0';
576 $sql .=
' AND f.fk_statut = 1';
578 $sql .=
' AND type IN (0,1,3,5)';
580 $sql .=
' AND type = 2';
583 $sql .=
' ORDER BY f.datef ASC, f.ref ASC';
585 $resql = $db->query($sql);
587 $num = $db->num_rows($resql);
589 $arraytitle = $langs->trans(
'Invoice');
590 if ($facture->type == 2) {
591 $arraytitle = $langs->trans(
"CreditNotes");
593 $alreadypayedlabel = $langs->trans(
'Received');
594 $multicurrencyalreadypayedlabel = $langs->trans(
'MulticurrencyReceived');
595 if ($facture->type == 2) {
596 $alreadypayedlabel = $langs->trans(
"PaidBack");
597 $multicurrencyalreadypayedlabel = $langs->trans(
"MulticurrencyPaidBack");
599 $remaindertopay = $langs->trans(
'RemainderToTake');
600 $multicurrencyremaindertopay = $langs->trans(
'MulticurrencyRemainderToTake');
601 if ($facture->type == 2) {
602 $remaindertopay = $langs->trans(
"RemainderToPayBack");
603 $multicurrencyremaindertopay = $langs->trans(
"MulticurrencyRemainderToPayBack");
610 print
'<div class="div-table-responsive-no-min">';
611 print
'<table class="noborder centpercent">';
613 print
'<tr class="liste_titre">';
614 print
'<td>'.$arraytitle.
'</td>';
615 print
'<td class="center">'.$langs->trans(
'Date').
'</td>';
616 print
'<td class="center">'.$langs->trans(
'DateMaxPayment').
'</td>';
617 if (isModEnabled(
'multicurrency')) {
618 print
'<td>'.$langs->trans(
'Currency').
'</td>';
619 print
'<td class="right">'.$langs->trans(
'MulticurrencyAmountTTC').
'</td>';
620 print
'<td class="right">'.$multicurrencyalreadypayedlabel.
'</td>';
621 print
'<td class="right">'.$multicurrencyremaindertopay.
'</td>';
622 print
'<td class="right">'.$langs->trans(
'MulticurrencyPaymentAmount').
'</td>';
624 print
'<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
625 print
'<td class="right">'.$alreadypayedlabel.
'</td>';
626 print
'<td class="right">'.$remaindertopay.
'</td>';
627 print
'<td class="right">'.$langs->trans(
'PaymentAmount').
'</td>';
629 $parameters = array();
630 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $facture, $action);
632 print
'<td align="right"> </td>';
637 $totalrecucreditnote = 0;
638 $totalrecudeposits = 0;
641 $objp = $db->fetch_object($resql);
649 $soc->fetch($objp->socid);
652 $invoice->fetch($objp->facid);
653 $paiement = $invoice->getSommePaiement();
654 $creditnotes = $invoice->getSumCreditNotesUsed();
655 $deposits = $invoice->getSumDepositsUsed();
656 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
657 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
660 if (isModEnabled(
'multicurrency')) {
661 $multicurrency_payment = $invoice->getSommePaiement(1);
662 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
663 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
664 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
665 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
667 $tootltiponmulticurrencyfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
668 $tootltiponmulticurrencyfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
669 $tootltiponmulticurrencyfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
673 $tootltiponfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->total_ht, 0, $langs, 0, -1, -1, $conf->currency) .
"<br>";
674 $tootltiponfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->total_tva, 0, $langs, 0, -1, -1, $conf->currency) .
"<br>";
675 $tootltiponfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->total_ttc, 0, $langs, 0, -1, -1, $conf->currency) .
"<br>";
677 print
'<tr class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
679 print
'<td class="nowraponall">';
680 print $invoice->getNomUrl(1,
'');
681 if ($objp->socid != $facture->thirdparty->id) {
682 print
' - '.$soc->getNomUrl(1).
' ';
687 print
'<td class="center">'.dol_print_date($db->jdate($objp->df),
'day').
"</td>\n";
690 if ($objp->dlr > 0) {
691 print
'<td class="nowraponall center">';
694 if ($invoice->hasDelay()) {
700 print
'<td align="center"></td>';
704 if (isModEnabled(
'multicurrency')) {
705 print
'<td class="center">'.$objp->multicurrency_code.
"</td>\n";
709 if (isModEnabled(
'multicurrency')) {
710 print
'<td class="right">';
711 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
712 print
'<span class="amount classfortooltip" title="'.$tootltiponmulticurrencyfullamount.
'">' .
price($sign * $objp->multicurrency_total_ttc);
714 print
'</span></td>';
717 print
'<td class="right">';
718 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
719 print
price($sign * $multicurrency_payment);
720 if ($multicurrency_creditnotes) {
721 print
'+'.price($multicurrency_creditnotes);
723 if ($multicurrency_deposits) {
724 print
'+'.price($multicurrency_deposits);
730 print
'<td class="right">';
731 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
732 print
price($sign * $multicurrency_remaintopay);
736 print
'<td class="right nowraponall">';
739 $namef =
'multicurrency_amount_'.$objp->facid;
740 $nameRemain =
'multicurrency_remain_'.$objp->facid;
742 if ($objp->multicurrency_code && $objp->multicurrency_code != $conf->currency) {
743 if ($action !=
'add_paiement') {
744 if (!empty($conf->use_javascript_ajax)) {
745 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmout' data-rowname='".$namef.
"' data-value='".($sign * $multicurrency_remaintopay).
"'");
747 print
'<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
748 print
'<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
750 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.
GETPOST($namef).
'" disabled>';
751 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
758 print
'<td class="right"><span class="amount classfortooltip" title="'.$tootltiponfullamount.
'">'.
price($sign * $objp->total_ttc).
'</span></td>';
761 print
'<td class="right"><span class="amount">'.price($sign * $paiement);
763 print
'<span class="opacitymedium">+'.price($creditnotes).
'</span>';
766 print
'<span class="opacitymedium">+'.price($deposits).
'</span>';
768 print
'</span></td>';
771 print
'<td class="right">';
772 print
price($sign * $remaintopay);
773 if (isModEnabled(
'prelevement')) {
774 $numdirectdebitopen = 0;
775 $totaldirectdebit = 0;
776 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
777 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
778 $sql .=
" WHERE fk_facture = ".((int) $objp->facid);
779 $sql .=
" AND pfd.traite = 0";
780 $sql .=
" AND pfd.ext_payment_id IS NULL";
782 $result_sql = $db->query($sql);
784 $obj = $db->fetch_object($result_sql);
785 $numdirectdebitopen = $obj->nb;
786 $totaldirectdebit = $obj->amount;
790 if ($numdirectdebitopen) {
791 $langs->load(
"withdrawals");
792 print
img_warning($langs->trans(
"WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1, $conf->currency)),
'',
'classfortooltip');
799 print
'<td class="right nowraponall">';
802 $namef =
'amount_'.$objp->facid;
803 $nameRemain =
'remain_'.$objp->facid;
805 if ($action !=
'add_paiement') {
806 if (!empty($conf->use_javascript_ajax)) {
807 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmout' data-rowname='".$namef.
"' data-value='".($sign * $remaintopay).
"'");
809 print
'<input type="text" class="maxwidth75 amount" id="'.$namef.
'" name="'.$namef.
'" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'">';
810 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
812 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
817 $parameters = array();
818 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
821 print
'<td align="center" width="16">';
823 if (!empty($amounts[$invoice->id]) && (abs($amounts[$invoice->id]) > abs($amountsresttopay[$invoice->id]))
824 || !empty($multicurrency_amounts[$invoice->id]) && (abs($multicurrency_amounts[$invoice->id]) > abs($multicurrency_amountsresttopay[$invoice->id]))) {
825 print
' '.img_warning($langs->trans(
"PaymentHigherThanReminderToPay"));
831 $total_ttc += $objp->total_ttc;
832 $totalrecu += $paiement;
833 $totalrecucreditnote += $creditnotes;
834 $totalrecudeposits += $deposits;
840 print
'<tr class="liste_total">';
841 print
'<td colspan="3" class="left">'.$langs->trans(
'TotalTTC').
'</td>';
842 if (isModEnabled(
'multicurrency')) {
847 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
849 print
'<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
850 print
'<td class="right"><b>'.price($sign * $totalrecu);
851 if ($totalrecucreditnote) {
852 print
'+'.price($totalrecucreditnote);
854 if ($totalrecudeposits) {
855 print
'+'.price($totalrecudeposits);
858 print
'<td class="right"><b>'.price($sign *
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
859 print
'<td class="right" id="result" style="font-weight: bold;"></td>';
860 print
'<td align="center"> </td>';
874 if ($action !=
'add_paiement') {
875 $checkboxlabel = $langs->trans(
"ClosePaidInvoicesAutomatically");
877 $checkboxlabel = $langs->trans(
"ClosePaidCreditNotesAutomatically");
879 $buttontitle = $langs->trans(
'ToMakePayment');
881 $buttontitle = $langs->trans(
'ToMakePaymentBack');
884 print
'<br><div class="center">';
885 print
'<input type="checkbox" checked name="closepaidinvoices"> '.$checkboxlabel;
890 print
'<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).
'"><br><br>';
895 if ($action ==
'add_paiement') {
896 $preselectedchoice = $addwarning ?
'no' :
'yes';
899 if (!empty($totalpayment)) {
900 $text = $langs->trans(
'ConfirmCustomerPayment', $totalpayment, $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
902 if (!empty($multicurrency_totalpayment)) {
903 $text .=
'<br>'.$langs->trans(
'ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
905 if (
GETPOST(
'closepaidinvoices')) {
906 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
907 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
909 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.$facture->id.
'&socid='.$facture->socid.
'&type='.$facture->type, $langs->trans(
'ReceivedCustomersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
913 $parameters = array(
'formConfirm' => $formconfirm);
914 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
915 if (empty($reshook)) {
916 $formconfirm .= $hookmanager->resPrint;
917 } elseif ($reshook > 0) {
918 $formconfirm = $hookmanager->resPrint;
932if (!
GETPOST(
'action',
'aZ09')) {
933 if (empty($page) || $page == -1) {
936 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
937 $offset = $limit * $page;
943 $sortfield =
'p.datep';
946 $sql =
'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
947 $sql .=
', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment';
948 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
949 $sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
950 $sql .=
' WHERE p.fk_facture = f.rowid';
951 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
953 $sql .=
' AND f.fk_soc = '.((int) $socid);
956 $sql .= $db->order($sortfield, $sortorder);
957 $sql .= $db->plimit($limit + 1, $offset);
958 $resql = $db->query($sql);
961 $num = $db->num_rows($resql);
964 print_barre_liste($langs->trans(
'Payments'), $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', $num);
965 print
'<table class="noborder centpercent">';
966 print
'<tr class="liste_titre">';
970 print_liste_field_titre(
'Amount', $_SERVER[
"PHP_SELF"],
'p.amount',
'',
'',
'', $sortfield, $sortorder,
'right ');
974 while ($i < min($num, $limit)) {
975 $objp = $db->fetch_object($resql);
977 print
'<tr class="oddeven">';
978 print
'<td><a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$objp->facid.
'">'.$objp->ref.
"</a></td>\n";
979 print
'<td>'.dol_print_date($db->jdate($objp->dp)).
"</td>\n";
980 print
'<td>'.$objp->paiement_type.
' '.$objp->num_payment.
"</td>\n";
981 print
'<td class="right"><span class="amount">'.price($objp->amount).
'</span></td>';
982 print
'<td> </td>';
985 $parameters = array();
986 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $objp, $action);
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage payments of customer invoices.
Class to manage third parties objects (customers, suppliers, prospects...)
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...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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...
currentToken()
Return the value of token currently saved into session with name 'token'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
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).
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_escape_js($stringtoescape, $mode=0, $noescapebackslashn=0)
Returns text escaped for inclusion into javascript code.
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.