38require
'../main.inc.php';
39require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
53$langs->loadLangs(array(
'companies',
'bills',
'banks',
'multicurrency'));
55$action =
GETPOST(
'action',
'alpha');
56$confirm =
GETPOST(
'confirm',
'alpha');
60$paymentnum =
GETPOST(
'num_paiement',
'alpha');
63$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
64$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
68$amountsresttopay = array();
71$multicurrency_amounts = array();
72$multicurrency_amountsresttopay = array();
75if ($user->socid > 0) {
76 $socid = $user->socid;
87$hookmanager->initHooks(array(
'paiementcard',
'globalcard'));
89$formquestion = array();
91$usercanissuepayment = $user->hasRight(
'facture',
'paiement');
103$parameters = array(
'socid' => $socid);
104$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
110if (empty($reshook)) {
111 if (($action ==
'add_paiement' || ($action ==
'confirm_paiement' && $confirm ==
'yes')) && $usercanissuepayment) {
114 $multicurrency_totalpayment = 0;
115 $atleastonepaymentnotnull = 0;
116 $formquestion = array();
120 $tmpinvoice =
new Facture($db);
121 foreach ($_POST as $key => $value) {
122 if (substr($key, 0, 7) ==
'amount_' &&
GETPOST($key) !=
'') {
123 $cursorfacid = substr($key, 7);
125 if (!empty($amounts[$cursorfacid])) {
126 $totalpayment += (float) $amounts[$cursorfacid];
127 $atleastonepaymentnotnull++;
129 $result = $tmpinvoice->fetch($cursorfacid);
133 $amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->total_ttc - $tmpinvoice->getSommePaiement(0));
134 if ($amounts[$cursorfacid]) {
136 if ($amounts[$cursorfacid] && (abs((
float) $amounts[$cursorfacid]) > abs((
float) $amountsresttopay[$cursorfacid]))) {
138 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
141 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
142 $langs->load(
"errors");
148 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOST($key));
149 } elseif (substr($key, 0, 21) ==
'multicurrency_amount_') {
150 $cursorfacid = substr($key, 21);
152 $multicurrency_totalpayment += (float) $multicurrency_amounts[$cursorfacid];
153 if (!empty($multicurrency_amounts[$cursorfacid])) {
154 $atleastonepaymentnotnull++;
156 $result = $tmpinvoice->fetch($cursorfacid);
160 $multicurrency_amountsresttopay[$cursorfacid] =
price2num($tmpinvoice->multicurrency_total_ttc - $tmpinvoice->getSommePaiement(1));
161 if ($multicurrency_amounts[$cursorfacid]) {
163 if ($multicurrency_amounts[$cursorfacid] && (abs((
float) $multicurrency_amounts[$cursorfacid]) > abs((
float) $multicurrency_amountsresttopay[$cursorfacid]))) {
165 $formquestion[
'text'] =
img_warning($langs->trans(
"PaymentHigherThanReminderToPay")).
' '.$langs->trans(
"HelpPaymentHigherThanReminderToPay");
168 if ($datepaye && ($datepaye < $tmpinvoice->date)) {
169 $langs->load(
"errors");
175 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' => $key,
'value' =>
GETPOSTINT($key));
180 if (!
GETPOST(
'paiementcode')) {
181 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'PaymentMode')),
null,
'errors');
185 if (isModEnabled(
"bank")) {
187 if (
GETPOST(
'accountid') <= 0) {
188 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
193 if (empty($totalpayment) && empty($multicurrency_totalpayment) && empty($atleastonepaymentnotnull)) {
194 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->trans(
'PaymentAmount')),
null,
'errors');
198 if (empty($datepaye)) {
199 setEventMessages($langs->transnoentities(
'ErrorFieldRequired', $langs->transnoentities(
'Date')),
null,
'errors');
204 if ($totalpayment > 0 && $multicurrency_totalpayment > 0) {
205 $langs->load(
"errors");
206 setEventMessages($langs->transnoentities(
'ErrorPaymentInBothCurrency'),
null,
'errors');
214 if ($action ==
'add_paiement') {
224 if ($action ==
'confirm_paiement' && $confirm ==
'yes' && $usercanissuepayment) {
229 $thirdparty =
new Societe($db);
231 $thirdparty->fetch($socid);
234 $multicurrency_code = array();
235 $multicurrency_tx = array();
238 foreach ($amounts as $key => $value) {
239 $tmpinvoice =
new Facture($db);
240 $tmpinvoice->fetch($key);
243 $amounts[$key] = - abs((
float) $newvalue);
245 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
246 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
249 foreach ($multicurrency_amounts as $key => $value) {
250 $tmpinvoice =
new Facture($db);
251 $tmpinvoice->fetch($key);
254 $multicurrency_amounts[$key] = - abs((
float) $newvalue);
256 $multicurrency_code[$key] = $tmpinvoice->multicurrency_code;
257 $multicurrency_tx[$key] = $tmpinvoice->multicurrency_tx;
260 if (isModEnabled(
"bank")) {
263 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'AccountToCredit')),
null,
'errors');
270 $paiement->datepaye = $datepaye;
271 $paiement->amounts = $amounts;
272 $paiement->multicurrency_amounts = $multicurrency_amounts;
273 $paiement->multicurrency_code = $multicurrency_code;
274 $paiement->multicurrency_tx = $multicurrency_tx;
276 $paiement->num_payment =
GETPOST(
'num_paiement',
'alpha');
277 $paiement->note_private =
GETPOST(
'comment',
'alpha');
278 $paiement->fk_account =
GETPOSTINT(
'accountid');
285 $paiement_id = $paiement->create($user, (
GETPOST(
'closepaidinvoices') ==
'on' ? 1 : 0), $thirdparty);
286 if ($paiement_id < 0) {
298 $label =
'(CustomerInvoicePayment)';
300 $label =
'(CustomerInvoicePaymentBack)';
303 $result = $paiement->addPaymentToBank($user,
'payment', $label,
GETPOSTINT(
'accountid'),
GETPOST(
'chqemetteur'),
GETPOST(
'chqbank'));
315 foreach ($paiement->amounts as $key => $amount) {
317 if (is_numeric($amount) && $amount != 0) {
318 if ($invoiceid != 0) {
325 if ($invoiceid > 0) {
326 $loc = DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$invoiceid;
328 $loc = DOL_URL_ROOT.
'/compta/paiement/card.php?id='.$paiement_id;
330 header(
'Location: '.$loc);
343$form =
new Form($db);
350if ($action ==
'create' || $action ==
'confirm_paiement' || $action ==
'add_paiement') {
352 $result = $facture->fetch($facid);
355 $facture->fetch_thirdparty();
359 $title .= $langs->trans(
"EnterPaymentReceivedFromCustomer");
362 $title .= $langs->trans(
"EnterPaymentDueToCustomer");
367 if ($action ==
'add_paiement') {
370 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'facid',
'value' => $facture->id);
371 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'socid',
'value' => $facture->socid);
372 $formquestion[$i++] = array(
'type' =>
'hidden',
'name' =>
'type',
'value' => $facture->type);
377 if (isModEnabled(
'paypalplus') &&
getDolGlobalString(
'PAYPAL_ENABLE_TRANSACTION_MANAGEMENT') && !empty($facture->ref_ext)) {
381 $paymentnum = $facture->ref_ext;
385 if (!empty(
$conf->use_javascript_ajax)) {
386 print
"\n".
'<script type="text/javascript">';
387 print
'$(document).ready(function () {
390 $("#selectpaiementcode").change(function() {
394 function setPaiementCode()
396 var code = $("#selectpaiementcode option:selected").val();
397 console.log("setPaiementCode code="+code);
399 if (code == \'CHQ\' || code == \'VIR\')
403 $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
405 if ($(\'#fieldchqemetteur\').val() == \'\')
408 $(\'#fieldchqemetteur\').val(emetteur);
413 $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
414 $(\'#fieldchqemetteur\').val(\'\');
418 function _elemToJson(selector)
421 $.map(selector.serializeArray(), function(n,i)
423 subJson[n["name"]] = n["value"];
428 function callForResult(imgId)
431 var form = $("#payment_form");
433 json["invoice_type"] = $("#invoice_type").val();
434 json["amountPayment"] = $("#amountpayment").attr("value");
435 json["amounts"] = _elemToJson(form.find("input.amount"));
436 json["remains"] = _elemToJson(form.find("input.remain"));
439 json["imgClicked"] = imgId;
442 $.post("'.DOL_URL_ROOT.
'/compta/ajaxpayment.php", json, function(data)
444 json = $.parseJSON(data);
448 for (var key in json)
450 if (key == "result") {
451 if (json["makeRed"]) {
452 $("#"+key).addClass("error");
454 $("#"+key).removeClass("error");
456 json[key]=json["label"]+" "+json[key];
457 $("#"+key).text(json[key]);
458 } else {console.log(key);
459 form.find("input[name*=\""+key+"\"]").each(function() {
460 $(this).attr("value", json[key]);
466 $("#payment_form").find("input.amount").change(function() {
469 $("#payment_form").find("input.amount").keyup(function() {
477 print
' $(document).ready(function () {';
478 print
' $(".AutoFillAmount").on(\'click touchstart\', function(){
479 $("input[name="+$(this).data(\'rowname\')+"]").val($(this).data("value")).trigger("change");
483 print
' </script>'.
"\n";
486 print
'<form id="payment_form" name="add_paiement" action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
487 print
'<input type="hidden" name="token" value="'.newToken().
'">';
488 print
'<input type="hidden" name="action" value="add_paiement">';
489 print
'<input type="hidden" name="facid" value="'.$facture->id.
'">';
490 print
'<input type="hidden" name="socid" value="'.$facture->socid.
'">';
491 print
'<input type="hidden" name="type" id="invoice_type" value="'.$facture->type.
'">';
492 print
'<input type="hidden" name="thirdpartylabel" id="thirdpartylabel" value="'.dol_escape_htmltag($facture->thirdparty->name).
'">';
493 print
'<input type="hidden" name="page_y" value="">';
497 print
'<table class="border centpercent">';
500 print
'<tr><td class="titlefieldcreate"><span class="fieldrequired">'.$langs->trans(
'Company').
'</span></td><td>'.$facture->thirdparty->getNomUrl(4).
"</td></tr>\n";
503 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'Date').
'</span></td><td>';
505 $datepayment = ($datepayment ==
'' ? (!
getDolGlobalString(
'MAIN_AUTOFILL_DATE') ? -1 :
'') : $datepayment);
506 print $form->selectDate($datepayment,
'', 0, 0, 0,
"add_paiement", 1, 1, 0,
'',
'', $facture->date);
510 print
'<tr><td><span class="fieldrequired">'.$langs->trans(
'PaymentMode').
'</span></td><td>';
511 $form->select_types_paiements((
GETPOST(
'paiementcode') ?
GETPOST(
'paiementcode') : $facture->mode_reglement_code),
'paiementcode',
'', 2);
517 if (isModEnabled(
"bank")) {
518 if ($facture->type != 2) {
519 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToCredit').
'</span></td>';
521 if ($facture->type == 2) {
522 print
'<td><span class="fieldrequired">'.$langs->trans(
'AccountToDebit').
'</span></td>';
526 print
img_picto(
'',
'bank_account',
'class="pictofixedwidth"');
527 print $form->select_comptes($accountid,
'accountid', 0,
'', 2,
'', (isModEnabled(
'multicurrency') ? 1 : 0),
'widthcentpercentminusx maxwidth500', 1);
530 print
'<td> </td>';
535 print
'<tr><td>'.$langs->trans(
'Numero');
536 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeOrTransferNumber").
')</em>';
538 print
'<td><input name="num_paiement" type="text" class="maxwidth200" value="'.$paymentnum.
'"></td></tr>';
541 print
'<tr><td class="'.(GETPOST(
'paiementcode') ==
'CHQ' ?
'fieldrequired ' :
'').
'fieldrequireddyn">'.$langs->trans(
'CheckTransmitter');
542 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeMaker").
')</em>';
544 print
'<td><input id="fieldchqemetteur" class="maxwidth300" name="chqemetteur" type="text" value="'.GETPOST(
'chqemetteur',
'alphanohtml').
'"></td></tr>';
547 print
'<tr><td>'.$langs->trans(
'Bank');
548 print
' <em class="opacitymedium">('.$langs->trans(
"ChequeBank").
')</em>';
550 print
'<td><input name="chqbank" class="maxwidth300" type="text" value="'.GETPOST(
'chqbank',
'alphanohtml').
'"></td></tr>';
553 print
'<tr><td>'.$langs->trans(
'Comments').
'</td>';
554 print
'<td class="tdtop">';
555 print
'<textarea name="comment" wrap="soft" class="quatrevingtpercent" rows="'.ROWS_3.
'">'.
GETPOST(
'comment',
'restricthtml').
'</textarea>';
559 if ($action !=
'add_paiement' &&
getDolGlobalString(
'FACTURE_PAYMENTS_SHOW_LINK_TO_INPUT_ORIGIN_IS_MORE_THAN')) {
560 print
'<tr><td></td>';
561 print
'<td class="tdtop right">';
562 print
'<a class="right" href="#amount_'.$facid.
'">'.$langs->trans(
"GoSourceInvoice").
'</a>';
575 $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,';
576 $sql .=
' f.datef as df, f.fk_soc as socid, f.date_lim_reglement as dlr';
577 $sql .=
' FROM '.MAIN_DB_PREFIX.
'facture as f';
578 $sql .=
' WHERE f.entity IN ('.getEntity(
'facture').
')';
579 $sql .=
' AND (f.fk_soc = '.((int) $facture->socid);
581 if (
getDolGlobalString(
'FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && !empty($facture->thirdparty->parent)) {
582 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int) $facture->thirdparty->parent).
')';
586 $sql .=
' OR f.fk_soc IN (SELECT rowid FROM '.MAIN_DB_PREFIX.
'societe WHERE parent = '.((int) $facture->thirdparty->id).
')';
588 $sql .=
') AND f.paye = 0';
589 $sql .=
' AND f.fk_statut = 1';
591 $sql .=
' AND type IN (0,1,3,5)';
593 $sql .=
' AND type = 2';
596 $sql .=
' ORDER BY f.datef ASC, f.ref ASC';
598 $resql = $db->query($sql);
600 $num = $db->num_rows($resql);
602 $arraytitle = $langs->trans(
'Invoice');
603 if ($facture->type == 2) {
604 $arraytitle = $langs->trans(
"CreditNotes");
606 $alreadypayedlabel = $langs->trans(
'Received');
607 $multicurrencyalreadypayedlabel = $langs->trans(
'MulticurrencyReceived');
608 if ($facture->type == 2) {
609 $alreadypayedlabel = $langs->trans(
"PaidBack");
610 $multicurrencyalreadypayedlabel = $langs->trans(
"MulticurrencyPaidBack");
612 $remaindertopay = $langs->trans(
'RemainderToTake');
613 $multicurrencyremaindertopay = $langs->trans(
'MulticurrencyRemainderToTake');
614 if ($facture->type == 2) {
615 $remaindertopay = $langs->trans(
"RemainderToPayBack");
616 $multicurrencyremaindertopay = $langs->trans(
"MulticurrencyRemainderToPayBack");
623 print
'<div class="div-table-responsive-no-min">';
624 print
'<table class="noborder centpercent">';
626 print
'<tr class="liste_titre">';
627 print
'<td>'.$arraytitle.
'</td>';
628 print
'<td class="center">'.$langs->trans(
'Date').
'</td>';
629 print
'<td class="center">'.$langs->trans(
'DateMaxPayment').
'</td>';
630 if (isModEnabled(
'multicurrency')) {
631 print
'<td>'.$langs->trans(
'Currency').
'</td>';
632 print
'<td class="right">'.$langs->trans(
'MulticurrencyAmountTTC').
'</td>';
633 print
'<td class="right">'.$multicurrencyalreadypayedlabel.
'</td>';
634 print
'<td class="right">'.$multicurrencyremaindertopay.
'</td>';
635 print
'<td class="right">'.$langs->trans(
'MulticurrencyPaymentAmount').
'</td>';
637 print
'<td class="right">'.$langs->trans(
'AmountTTC').
'</td>';
638 print
'<td class="right">'.$alreadypayedlabel.
'</td>';
639 print
'<td class="right">'.$remaindertopay.
'</td>';
640 print
'<td class="right">'.$langs->trans(
'PaymentAmount').
'</td>';
642 $parameters = array();
643 $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, $facture, $action);
645 print
'<td align="right"> </td>';
650 $totalrecucreditnote = 0;
651 $totalrecudeposits = 0;
655 $objp = $db->fetch_object($resql);
663 $soc->fetch($objp->socid);
666 $invoice->fetch($objp->facid);
667 $paiement = $invoice->getSommePaiement();
668 $creditnotes = $invoice->getSumCreditNotesUsed();
669 $deposits = $invoice->getSumDepositsUsed();
670 $alreadypayed =
price2num($paiement + $creditnotes + $deposits,
'MT');
671 $remaintopay =
price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,
'MT');
674 $tooltiponmulticurrencyfullamount =
'';
675 $multicurrency_remaintopay =
'';
676 $multicurrency_payment = 0;
677 $multicurrency_creditnotes = 0;
678 $multicurrency_deposits = 0;
679 if (isModEnabled(
'multicurrency')) {
680 $multicurrency_payment = $invoice->getSommePaiement(1);
681 $multicurrency_creditnotes = $invoice->getSumCreditNotesUsed(1);
682 $multicurrency_deposits = $invoice->getSumDepositsUsed(1);
683 $multicurrency_alreadypayed =
price2num($multicurrency_payment + $multicurrency_creditnotes + $multicurrency_deposits,
'MT');
684 $multicurrency_remaintopay =
price2num($invoice->multicurrency_total_ttc - $multicurrency_payment - $multicurrency_creditnotes - $multicurrency_deposits,
'MT');
686 $tooltiponmulticurrencyfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->multicurrency_total_ht, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
687 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->multicurrency_total_tva, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
688 $tooltiponmulticurrencyfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->multicurrency_total_ttc, 0, $langs, 0, -1, -1, $objp->multicurrency_code) .
"<br>";
692 $tooltiponfullamount = $langs->trans(
'AmountHT') .
": " .
price($objp->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
693 $tooltiponfullamount .= $langs->trans(
'AmountVAT') .
": " .
price($objp->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
694 $tooltiponfullamount .= $langs->trans(
'AmountTTC') .
": " .
price($objp->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
"<br>";
696 print
'<tr class="oddeven'.(($invoice->id == $facid) ?
' highlight' :
'').
'">';
698 print
'<td class="nowraponall">';
699 print $invoice->getNomUrl(1,
'');
700 if ($objp->socid != $facture->thirdparty->id) {
701 print
' - '.$soc->getNomUrl(1).
' ';
706 print
'<td class="center">'.dol_print_date($db->jdate($objp->df),
'day').
"</td>\n";
709 if ($objp->dlr > 0) {
710 print
'<td class="nowraponall center">';
713 if ($invoice->hasDelay()) {
719 print
'<td align="center"></td>';
723 if (isModEnabled(
'multicurrency')) {
724 print
'<td class="center">'.$objp->multicurrency_code.
"</td>\n";
728 if (isModEnabled(
'multicurrency')) {
729 print
'<td class="right">';
730 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
731 print
'<span class="amount classfortooltip" title="'.$tooltiponmulticurrencyfullamount.
'">' .
price($sign * $objp->multicurrency_total_ttc);
733 print
'</span></td>';
736 print
'<td class="right">';
737 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
738 print
price($sign * $multicurrency_payment);
739 if ($multicurrency_creditnotes) {
740 print
'+'.price($multicurrency_creditnotes);
742 if ($multicurrency_deposits) {
743 print
'+'.price($multicurrency_deposits);
749 print
'<td class="right">';
750 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
751 print
price($sign * (
float) $multicurrency_remaintopay);
755 print
'<td class="right nowraponall">';
758 $namef =
'multicurrency_amount_'.$objp->facid;
759 $nameRemain =
'multicurrency_remain_'.$objp->facid;
761 if ($objp->multicurrency_code && $objp->multicurrency_code !=
$conf->currency) {
762 if ($action !=
'add_paiement') {
763 if (!empty(
$conf->use_javascript_ajax)) {
764 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowname='".$namef.
"' data-value='".($sign * (
float) $multicurrency_remaintopay).
"'");
766 print
'<input type="text" class="maxwidth75 multicurrency_amount" name="'.$namef.
'" value="'.(
GETPOST($namef) !=
'0' ?
GETPOST($namef) :
'').
'">';
767 print
'<input type="hidden" class="multicurrency_remain" name="'.$nameRemain.
'" value="'.$multicurrency_remaintopay.
'">';
769 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.(
GETPOST($namef) !=
'0' ?
GETPOST($namef) :
'').
'" disabled>';
770 print
'<input type="hidden" name="'.$namef.
'" value="'.
GETPOST($namef).
'">';
777 print
'<td class="right"><span class="amount classfortooltip" title="'.$tooltiponfullamount.
'">'.
price($sign * $objp->total_ttc).
'</span></td>';
780 print
'<td class="right"><span class="amount">'.price($sign * $paiement);
782 print
'<span class="opacitymedium">+'.price($creditnotes).
'</span>';
785 print
'<span class="opacitymedium">+'.price($deposits).
'</span>';
787 print
'</span></td>';
790 print
'<td class="right">';
791 print
price($sign * (
float) $remaintopay);
792 if (isModEnabled(
'prelevement')) {
793 $numdirectdebitopen = 0;
794 $totaldirectdebit = 0;
795 $sql =
"SELECT COUNT(pfd.rowid) as nb, SUM(pfd.amount) as amount";
796 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
797 $sql .=
" WHERE fk_facture = ".((int) $objp->facid);
798 $sql .=
" AND pfd.traite = 0";
799 $sql .=
" AND pfd.ext_payment_id IS NULL";
801 $result_sql = $db->query($sql);
803 $obj = $db->fetch_object($result_sql);
804 $numdirectdebitopen = $obj->nb;
805 $totaldirectdebit = $obj->amount;
809 if ($numdirectdebitopen) {
810 $langs->load(
"withdrawals");
811 print
img_warning($langs->trans(
"WarningSomeDirectDebitOrdersAlreadyExists", $numdirectdebitopen,
price(
price2num($totaldirectdebit,
'MT'), 0, $langs, 1, -1, -1,
$conf->currency)),
'',
'classfortooltip');
818 print
'<td class="right nowraponall">';
821 $namef =
'amount_'.$objp->facid;
822 $nameRemain =
'remain_'.$objp->facid;
824 if ($action !=
'add_paiement') {
825 if (!empty(
$conf->use_javascript_ajax)) {
826 print
img_picto(
"Auto fill",
'rightarrow',
"class='AutoFillAmount' data-rowname='".$namef.
"' data-value='".($sign * (
float) $remaintopay).
"'");
828 print
'<input type="text" class="maxwidth75 amount" id="'.$namef.
'" name="'.$namef.
'" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'">';
829 print
'<input type="hidden" class="remain" name="'.$nameRemain.
'" value="'.$remaintopay.
'">';
831 print
'<input type="text" class="maxwidth75" name="'.$namef.
'_disabled" value="'.
dol_escape_htmltag(
GETPOST($namef)).
'" disabled>';
836 $parameters = array();
837 $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, $objp, $action);
840 print
'<td align="center" width="16">';
842 if (!empty($amounts[$invoice->id]) && (abs((
float) $amounts[$invoice->id]) > abs((
float) $amountsresttopay[$invoice->id]))
843 || !empty($multicurrency_amounts[$invoice->id]) && (abs((
float) $multicurrency_amounts[$invoice->id]) > abs((
float) $multicurrency_amountsresttopay[$invoice->id]))) {
844 print
' '.img_warning($langs->trans(
"PaymentHigherThanReminderToPay"));
850 $total_ttc += $objp->total_ttc;
851 $totalrecu += $paiement;
852 $totalrecucreditnote += $creditnotes;
853 $totalrecudeposits += $deposits;
859 print
'<tr class="liste_total">';
860 print
'<td colspan="3" class="left">'.$langs->trans(
'TotalTTC').
'</td>';
861 if (isModEnabled(
'multicurrency')) {
866 print
'<td class="right" id="multicurrency_result" style="font-weight: bold;"></td>';
868 print
'<td class="right"><b>'.price($sign * $total_ttc).
'</b></td>';
869 print
'<td class="right"><b>'.price($sign * $totalrecu);
870 if ($totalrecucreditnote) {
871 print
'+'.price($totalrecucreditnote);
873 if ($totalrecudeposits) {
874 print
'+'.price($totalrecudeposits);
877 print
'<td class="right"><b>'.price($sign * (
float)
price2num($total_ttc - $totalrecu - $totalrecucreditnote - $totalrecudeposits,
'MT')).
'</b></td>';
878 print
'<td class="right" id="result" style="font-weight: bold;"></td>';
879 print
'<td align="center"> </td>';
893 if ($action !=
'add_paiement') {
894 $checkboxlabel = $langs->trans(
"ClosePaidInvoicesAutomatically");
896 $checkboxlabel = $langs->trans(
"ClosePaidCreditNotesAutomatically");
898 $buttontitle = $langs->trans(
'ToMakePayment');
900 $buttontitle = $langs->trans(
'ToMakePaymentBack');
903 print
'<br><div class="center">';
904 print
'<input type="checkbox" checked name="closepaidinvoices" id="closepaidinvoices"><label for="closepaidinvoices"> '.$checkboxlabel.
'</label>';
909 print
'<br><input type="submit" class="button reposition" value="'.dol_escape_htmltag($buttontitle).
'"><br><br>';
914 if ($action ==
'add_paiement') {
915 $preselectedchoice = $addwarning ?
'no' :
'yes';
919 if (!empty($totalpayment)) {
920 $text = $langs->trans(
'ConfirmCustomerPayment', $totalpayment, $langs->transnoentitiesnoconv(
"Currency".$conf->currency));
922 if (!empty($multicurrency_totalpayment)) {
923 $text .=
'<br>'.$langs->trans(
'ConfirmCustomerPayment', $multicurrency_totalpayment, $langs->transnoentitiesnoconv(
"paymentInInvoiceCurrency"));
925 if (
GETPOST(
'closepaidinvoices')) {
926 $text .=
'<br>'.$langs->trans(
"AllCompletelyPayedInvoiceWillBeClosed");
927 print
'<input type="hidden" name="closepaidinvoices" value="'.GETPOST(
'closepaidinvoices').
'">';
929 $formconfirm = $form->formconfirm($_SERVER[
'PHP_SELF'].
'?facid='.$facture->id.
'&socid='.$facture->socid.
'&type='.$facture->type, $langs->trans(
'ReceivedCustomersPayments'), $text,
'confirm_paiement', $formquestion, $preselectedchoice);
933 $parameters = array(
'formConfirm' => $formconfirm);
934 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
935 if (empty($reshook)) {
936 $formconfirm .= $hookmanager->resPrint;
937 } elseif ($reshook > 0) {
938 $formconfirm = $hookmanager->resPrint;
952if (!
GETPOST(
'action',
'aZ09')) {
953 if (empty($page) || $page == -1) {
957 $offset = $limit * $page;
963 $sortfield =
'p.datep';
966 $sql =
'SELECT p.datep as dp, p.amount, f.total_ttc as fa_amount, f.ref';
967 $sql .=
', f.rowid as facid, c.libelle as paiement_type, p.num_paiement as num_payment';
968 $sql .=
' FROM '.MAIN_DB_PREFIX.
'paiement as p LEFT JOIN '.MAIN_DB_PREFIX.
'c_paiement as c ON p.fk_paiement = c.id';
969 $sql .=
', '.MAIN_DB_PREFIX.
'facture as f';
970 $sql .=
' WHERE p.fk_facture = f.rowid';
971 $sql .=
' AND f.entity IN ('.getEntity(
'invoice').
')';
973 $sql .=
' AND f.fk_soc = '.((int) $socid);
976 $sql .= $db->order($sortfield, $sortorder);
977 $sql .= $db->plimit($limit + 1, $offset);
978 $resql = $db->query($sql);
981 $num = $db->num_rows($resql);
984 print_barre_liste($langs->trans(
'Payments'), $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', $num);
985 print
'<table class="noborder centpercent">';
986 print
'<tr class="liste_titre">';
990 print_liste_field_titre(
'Amount', $_SERVER[
"PHP_SELF"],
'p.amount',
'',
'',
'', $sortfield, $sortorder,
'right ');
994 while ($i < min($num, $limit)) {
995 $objp = $db->fetch_object($resql);
997 print
'<tr class="oddeven">';
998 print
'<td><a href="'.DOL_URL_ROOT.
'/compta/facture/card.php?facid='.$objp->facid.
'">'.$objp->ref.
"</a></td>\n";
999 print
'<td>'.dol_print_date($db->jdate($objp->dp)).
"</td>\n";
1000 print
'<td>'.$objp->paiement_type.
' '.$objp->num_payment.
"</td>\n";
1001 print
'<td class="right"><span class="amount">'.price($objp->amount).
'</span></td>';
1002 print
'<td> </td>';
1005 $parameters = array();
1006 $reshook = $hookmanager->executeHooks(
'printObjectLine', $parameters, $objp, $action);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
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 information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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 '.
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_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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a 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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.