32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/invoice.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/fourn.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture-rec.class.php';
43require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
56$langs->loadLangs(array(
'bills',
'banks',
'withdrawals',
'companies'));
61$action =
GETPOST(
'action',
'aZ09');
64$fieldid = (!empty($ref) ?
'ref' :
'rowid');
66 $socid = $user->socid;
70if ($type ==
'bank-transfer') {
72 $moreparam =
'&type='.$type;
79if (
$id > 0 || !empty($ref)) {
89$hookmanager->initHooks(array(
'directdebitcard',
'globalcard'));
91if ($type ==
'bank-transfer') {
92 $result =
restrictedArea($user,
'fournisseur',
$id,
'facture_fourn',
'facture',
'fk_soc', $fieldid, $isdraft);
93 if (!$user->hasRight(
'fournisseur',
'facture',
'lire')) {
97 $result =
restrictedArea($user,
'facture',
$id,
'',
'',
'fk_soc', $fieldid, $isdraft);
98 if (!$user->hasRight(
'facture',
'lire')) {
103if ($type ==
'bank-transfer') {
104 $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
106 $usercancreate = $user->hasRight(
'facture',
'creer');
114$parameters = array(
'socid' => $socid);
115$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
120if (empty($reshook)) {
121 if ($action ==
"new" && $usercancreate) {
126 $sourcetype =
'facture';
127 if ($type ==
'bank-transfer') {
128 $sourcetype =
'supplier_invoice';
129 $newtype =
'bank-transfer';
131 $paymentservice =
GETPOST(
'paymentservice');
135 $amount =
GETPOST(
'withdraw_request_amount',
'alpha');
136 $result =
$object->demande_prelevement($user, (
float)
price2num($amount), $newtype, $sourcetype, 0, $iban ?? 0);
150 if ($action ==
"delete" && $usercancreate) {
154 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id.
'&type='.$type);
161 if ($action ==
'sepastripedirectdebit' && $usercancreate) {
162 $result =
$object->makeStripeSepaRequest($user,
GETPOSTINT(
'did'),
'direct-debit',
'facture');
176 if ($action ==
'sepastripecredittransfer' && $usercancreate) {
177 $result =
$object->makeStripeSepaRequest($user,
GETPOSTINT(
'did'),
'bank-transfer',
'supplier_invoice');
191 if ($action ==
'setconditions' && $usercancreate) {
193 $object->cond_reglement_code = 0;
194 $object->cond_reglement_id = 0;
209 $old_date_echeance =
$object->date_echeance;
210 $new_date_echeance =
$object->calculate_date_lim_reglement();
211 if ($new_date_echeance > $old_date_echeance) {
212 $object->date_echeance = $new_date_echeance;
217 $result =
$object->update($user);
229 } elseif ($action ==
'setmode' && $usercancreate) {
232 } elseif ($action ==
'setdatef' && $usercancreate) {
236 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
238 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
243 $date_echence_calc =
$object->calculate_date_lim_reglement();
244 if (!empty(
$object->date_echeance) &&
$object->date_echeance < $date_echence_calc) {
245 $object->date_echeance = $date_echence_calc;
251 $result =
$object->update($user);
255 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
259 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
261 $result =
$object->update($user);
273$form =
new Form($db);
277if ($type ==
'bank-transfer') {
278 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'CreditTransfer');
281 $title = $langs->trans(
'InvoiceCustomer').
" - ".$langs->trans(
'StandingOrders');
282 $helpurl =
"EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
289 $selleruserevenustamp = $mysoc->useRevenueStamp();
291 $totalpaid =
$object->getSommePaiement();
292 $totalcreditnotes =
$object->getSumCreditNotesUsed();
293 $totaldeposits =
$object->getSumDepositsUsed();
300 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
306 if ($type ==
'bank-transfer') {
308 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
309 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
311 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
312 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
315 $absolute_discount =
$object->thirdparty->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
316 $absolute_creditnote =
$object->thirdparty->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
317 $absolute_discount =
price2num($absolute_discount,
'MT');
318 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
321 $filterabsolutediscount =
"fk_facture_source IS NULL";
322 $filtercreditnote =
"fk_facture_source IS NOT NULL";
324 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
325 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
328 $absolute_discount =
$object->thirdparty->getAvailableDiscounts(
null, $filterabsolutediscount);
329 $absolute_creditnote =
$object->thirdparty->getAvailableDiscounts(
null, $filtercreditnote);
330 $absolute_discount =
price2num($absolute_discount,
'MT');
331 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
334 $author =
new User($db);
335 if (!empty(
$object->user_creation_id)) {
336 $author->fetch(
$object->user_creation_id);
337 } elseif (!empty(
$object->fk_user_author)) {
338 $author->fetch(
$object->fk_user_author);
341 if ($type ==
'bank-transfer') {
352 $listofopendirectdebitorcredittransfer =
$object->getListOfOpenDirectDebitOrCreditTransfer($type);
353 $numopen = count($listofopendirectdebitorcredittransfer);
355 print
dol_get_fiche_head($head,
'standingorders', $title, -1, ($type ==
'bank-transfer' ?
'supplier_invoice' :
'bill'));
358 if ($type ==
'bank-transfer') {
359 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
361 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
364 $morehtmlref =
'<div class="refidno">';
366 if ($type ==
'bank-transfer') {
367 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, 0,
'string',
'', 0, 1);
368 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, 0,
'string',
'',
null,
null,
'', 1);
370 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_customer,
$object, 0,
'string',
'', 0, 1);
371 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client',
$object->ref_customer,
$object, 0,
'string',
'',
null,
null,
'', 1);
374 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
375 if ($type ==
'bank-transfer') {
377 $morehtmlref .=
' <div class="inline-block valignmiddle">(<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.((int)
$object->thirdparty->id).
'">'.$langs->trans(
"OtherBills").
'</a>)</div>';
381 $morehtmlref .=
' <div class="inline-block valignmiddle">(<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/compta/facture/list.php?socid='.((int)
$object->thirdparty->id).
'">'.$langs->trans(
"OtherBills").
'</a>)</div>';
385 if (isModEnabled(
'project')) {
386 $langs->load(
"projects");
387 $morehtmlref .=
'<br>';
389 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
390 if ($action !=
'classify') {
391 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.((int)
$object->id).
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
393 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid, (
string)
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
395 if (!empty(
$object->fk_project)) {
397 $proj->fetch(
$object->fk_project);
398 $morehtmlref .= $proj->getNomUrl(1);
400 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
405 $morehtmlref .=
'</div>';
407 $object->totalpaid = $totalpaid;
409 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $moreparam, 0,
'',
'');
411 print
'<div class="fichecenter">';
412 print
'<div class="fichehalfleft">';
413 print
'<div class="underbanner clearboth"></div>';
415 print
'<table class="border centpercent tableforfield">';
418 print
'<tr><td class="titlefield fieldname_type">'.$langs->trans(
'Type').
'</td><td colspan="3">';
419 print
'<span class="badgeneutral">';
422 if (!empty(
$object->module_source)) {
423 print
' <span class="opacitymediumbycolor paddingleft">('.$langs->trans(
"POS").
' '.
$object->module_source.
' - '.$langs->trans(
"Terminal").
' '.
$object->pos_source.
')</span>';
425 if (
$object->type == $object::TYPE_REPLACEMENT) {
426 if ($type ==
'bank-transfer') {
429 $facreplaced =
new Facture($db);
431 $facreplaced->fetch(
$object->fk_facture_source);
432 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
434 if (
$object->type == $object::TYPE_CREDIT_NOTE && !empty(
$object->fk_facture_source)) {
435 if ($type ==
'bank-transfer') {
440 $facusing->fetch(
$object->fk_facture_source);
441 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
445 $object->getListIdAvoirFromInvoice();
447 if (!empty(
$object->creditnote_ids)) {
448 $invoicecredits = array();
449 foreach (
$object->creditnote_ids as $invoiceid) {
450 if ($type ==
'bank-transfer') {
453 $creditnote =
new Facture($db);
455 $creditnote->fetch($invoiceid);
456 $invoicecredits[] = $creditnote->getNomUrl(1);
458 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir");
459 print
' '. (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
472 print
'<!-- Discounts -->'.
"\n";
473 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining').
'</td><td colspan="3">';
475 if ($type ==
'bank-transfer') {
478 $thirdparty =
$object->thirdparty;
481 $thirdparty =
$object->thirdparty;
484 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id);
485 $cannotApplyDiscount = 1;
486 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
491 if ($type ==
'bank-transfer') {
493 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, 0).
'</td>';
494 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, 0).
'</td>';
500 print
'<table class="nobordernopadding centpercent"><tr><td>';
501 print $langs->trans(
'DateInvoice');
503 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editinvoicedate' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
504 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editinvoicedate&token='.
newToken().
'&id='.
$object->id.
'&type='.urlencode($type).
'">'.
img_edit($langs->trans(
'SetDate'), 1).
'</a></td>';
506 print
'</tr></table>';
507 print
'</td><td colspan="3">';
509 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
510 if ($action ==
'editinvoicedate') {
511 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->date,
'invoicedate', 0, 0, 1, $type);
523 print
'<table class="nobordernopadding centpercent"><tr><td>';
524 print $langs->trans(
'PaymentConditionsShort');
526 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editconditions' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
527 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editconditions&token='.
newToken().
'&id='.
$object->id.
'&type='.urlencode($type).
'">'.
img_edit($langs->trans(
'SetConditions'), 1).
'</a></td>';
529 print
'</tr></table>';
530 print
'</td><td colspan="3">';
531 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
532 if ($action ==
'editconditions') {
533 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 0, $type);
535 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none');
544 print
'<table class="nobordernopadding centpercent"><tr><td>';
545 print $langs->trans(
'DateMaxPayment');
547 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editpaymentterm' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
548 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editpaymentterm&token='.
newToken().
'&id='.
$object->id.
'&type='.urlencode($type).
'">'.
img_edit($langs->trans(
'SetDate'), 1).
'</a></td>';
550 print
'</tr></table>';
551 print
'</td><td colspan="3">';
552 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
553 $duedate =
$object->date_lim_reglement;
554 if ($type ==
'bank-transfer') {
555 $duedate =
$object->date_echeance;
558 if ($action ==
'editpaymentterm') {
559 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $duedate,
'paymentterm', 0, 0, 1, $type);
573 print
'<table class="nobordernopadding centpercent"><tr><td>';
574 print $langs->trans(
'PaymentMode');
576 if ($action !=
'editmode' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
577 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editmode&token='.
newToken().
'&id='.
$object->id.
'&type='.urlencode($type).
'">'.
img_edit($langs->trans(
'SetMode'), 1).
'</a></td>';
579 print
'</tr></table>';
580 print
'</td><td colspan="3">';
581 $filtertype =
'CRDT';
582 if ($type ==
'bank-transfer') {
583 $filtertype =
'DBIT';
585 if ($action ==
'editmode') {
586 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id', $filtertype, 1, 0, $type);
588 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
593 print
'<tr><td class="nowrap">';
594 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
595 print $langs->trans(
'BankAccount');
597 if (($action !=
'editbankaccount') && $user->hasRight(
'commande',
'creer') &&
$object->status == $object::STATUS_DRAFT) {
598 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbankaccount&token='.
newToken().
'&id='.
$object->id.
'&type='.urlencode($type).
'">'.
img_edit($langs->trans(
'SetBankAccount'), 1).
'</a></td>';
600 print
'</tr></table>';
601 print
'</td><td colspan="3">';
602 if ($action ==
'editbankaccount') {
603 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
605 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
612 print
'<div class="fichehalfright">';
613 print
'<!-- amounts -->'.
"\n";
614 print
'<div class="underbanner clearboth"></div>'.
"\n";
616 print
'<table class="border tableforfield centpercent">';
618 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
626 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
627 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
628 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
630 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
636 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
637 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
638 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
640 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
645 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
647 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
648 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
649 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
652 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
657 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
659 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
660 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
661 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
664 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
670 if ($selleruserevenustamp) {
672 print
'<table class="nobordernopadding centpercent"><tr><td>';
673 print $langs->trans(
'RevenueStamp');
675 if ($action !=
'editrevenuestamp' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
676 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editrevenuestamp&token='.
newToken().
'&facid='.
$object->id.
'">'.
img_edit($langs->trans(
'SetRevenuStamp'), 1).
'</a></td>';
678 print
'</tr></table>';
679 print
'</td><td class="nowrap right">';
686 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
687 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
688 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
690 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
695 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
698 $parameters = array(
'remaintopay' => $resteapayer);
699 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters,
$object, $action);
701 print $hookmanager->resPrint;
702 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
703 $resteapayer = $remaintopay;
708 print
'<tr><td>'.$langs->trans(
'RemainderToPay').
'</td><td class="nowrap right">'.
price($resteapayer, 1,
'', 1, - 1, - 1,
$conf->currency).
'</td>';
709 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
719 print
'<div class="clearboth"></div>';
732 $sql =
"SELECT SUM(pfd.amount) as amount";
733 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
734 if ($type ==
'bank-transfer') {
735 $sql .=
" WHERE pfd.fk_facture_fourn = ".((int)
$object->id);
737 $sql .=
" WHERE pfd.fk_facture = ".((int)
$object->id);
739 $sql .=
" AND pfd.traite = 0";
741 $resql = $db->query($sql);
743 $obj = $db->fetch_object($resql);
745 $pending += (float) $obj->amount;
751 $sqlPending =
"SELECT SUM(pl.amount) as amount";
752 $sqlPending .=
" FROM ".$db->prefix().
"prelevement_lignes as pl";
753 $sqlPending .=
" INNER JOIN ".$db->prefix().
"prelevement as p ON p.fk_prelevement_lignes = pl.rowid";
754 if ($type ==
'bank-transfer') {
755 $sqlPending .=
" WHERE p.fk_facture_fourn = ".((int)
$object->id);
757 $sqlPending .=
" WHERE p.fk_facture = ".((int)
$object->id);
759 $sqlPending .=
" AND (pl.statut IS NULL OR pl.statut = 0)";
760 $resPending = $db->query($sqlPending);
762 if ($objPending = $db->fetch_object($resPending)) {
763 $pending += (float) $objPending->amount;
766 $db->free($resPending);
794 print
"\n".
'<div class="tabsAction">'.
"\n";
796 $buttonlabel = $langs->trans(
"MakeWithdrawRequest");
797 $user_perms = $user->hasRight(
'prelevement',
'bons',
'creer');
798 if ($type ==
'bank-transfer') {
799 $buttonlabel = $langs->trans(
"MakeBankTransferOrder");
800 $user_perms = $user->hasRight(
'paymentbybanktransfer',
'create');
804 if (
$object->status > $object::STATUS_DRAFT &&
$object->paid == 0 && $numopen == 0) {
805 if ($resteapayer > 0) {
807 $remaintopaylesspendingdebit = $resteapayer - $pending;
809 $title = $langs->trans(
"NewStandingOrder");
810 if ($type ==
'bank-transfer') {
811 $title = $langs->trans(
"NewPaymentByBankTransfer");
814 print
'<!-- form to select BAN -->';
815 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
816 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
817 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
818 print
'<input type="hidden" name="type" value="'.$type.
'" />';
819 print
'<input type="hidden" name="action" value="new" />';
821 print
'<div class="center formconsumeproduce">';
823 print $langs->trans(
'CustomerIBAN').
' ';
827 if (
$object->element ==
'invoice' &&
$object->fk_fac_rec_source) {
829 $facturerec->fetch(
$object->fk_fac_rec_source);
830 if ($facturerec->fk_societe_rib) {
832 $res = $companyBankAccount->fetch($facturerec->fk_societe_rib);
833 $selectedRibId = $companyBankAccount->id;
836 $defaultRibId =
$object->thirdparty->getDefaultRib();
837 if (empty($selectedRibId)) $selectedRibId = (int) $defaultRibId;
839 $selectedRib = $form->selectRib($selectedRibId,
'accountcustomerid',
'fk_soc='.
$object->socid, 1,
'', 1);
843 $res = $companyBankAccount->fetch($defaultRibId);
844 if ($res > 0 && !$companyBankAccount->verif()) {
845 print
img_warning(
'Error on default bank number for IBAN : '.$langs->trans($companyBankAccount->error));
847 } elseif (($type !=
'bank-transfer' &&
$object->mode_reglement_code ==
'PRE') || ($type ==
'bank-transfer' &&
$object->mode_reglement_code ==
'VIR')) {
848 print
img_warning($langs->trans(
"NoDefaultIBANFound"));
853 print
' <label for="withdraw_request_amount">';
854 if ($type ==
'bank-transfer') {
855 print $langs->trans(
'BankTransferAmount');
857 print $langs->trans(
"WithdrawRequestAmount");
860 print
'<input type="text" class="right width75" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'">';
864 print
'<input type="submit" class="butAction small" value="'.$buttonlabel.
'" />';
875 $buttonlabel = $langs->trans(
"MakeWithdrawRequestStripe");
876 print
'<form method="POST" action="">';
877 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
878 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
879 print
'<input type="hidden" name="type" value="'.$type.
'" />';
880 print
'<input type="hidden" name="action" value="new" />';
881 print
'<input type="hidden" name="paymenservice" value="stripesepa" />';
882 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
883 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
884 print
'<input type="submit" class="butAction small" value="'.$buttonlabel.
'" />';
888 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$buttonlabel.
'</a>';
891 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AmountMustBePositive")).
'">'.$buttonlabel.
'</a>';
895 if (
$object->status > $object::STATUS_DRAFT) {
896 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AlreadyPaid")).
'">'.$buttonlabel.
'</a>';
898 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"Draft")).
'">'.$buttonlabel.
'</a>';
901 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"RequestAlreadyDone")).
'">'.$buttonlabel.
'</a>';
908 if ($type ==
'bank-transfer') {
909 print
'<div class="opacitymedium justify">'.$langs->trans(
"DoCreditTransferBeforePayments");
911 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
913 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
914 print
'</div><br><br>';
916 print
'<div class="opacitymedium justify">'.$langs->trans(
"DoStandingOrdersBeforePayments");
918 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
920 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
921 print
'</div><br><br>';
928 print
'<div class="div-table-responsive-no-min">';
929 print
'<table class="noborder centpercent">';
931 print
'<tr class="liste_titre">';
934 print
'<td> </td>';
936 print
'<td class="left">'.$langs->trans(
"DateRequest").
'</td>';
937 print
'<td>'.$langs->trans(
"User").
'</td>';
938 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
939 print
'<td class="center">'.$langs->trans(
"IBAN").
'</td>';
940 print
'<td class="center">'.$langs->trans(
"DateProcess").
'</td>';
941 if ($type ==
'bank-transfer') {
942 print
'<td class="">'.$langs->trans(
"BankTransferReceipt").
'</td>';
944 print
'<td class="">'.$langs->trans(
"WithdrawalReceipt").
'</td>';
946 print
'<td> </td>';
949 print
'<td> </td>';
953 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
954 $sql .=
" pfd.date_traite as date_traite, pfd.amount, pfd.fk_prelevement_bons,";
955 $sql .=
" pb.ref, pb.date_trans, pb.method_trans, pb.credite, pb.date_credit, pb.datec, pb.statut as status, pb.amount as pb_amount,";
956 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status,";
957 $sql .=
" sr.iban_prefix as iban, sr.bic as bic";
958 $sql .=
" FROM ".$db->prefix().
"prelevement_demande as pfd";
959 $sql .=
" LEFT JOIN ".$db->prefix().
"user as u on pfd.fk_user_demande = u.rowid";
960 $sql .=
" LEFT JOIN ".$db->prefix().
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
961 $sql .=
" LEFT JOIN ".$db->prefix().
"societe_rib as sr ON sr.rowid = pfd.fk_societe_rib";
962 if ($type ==
'bank-transfer') {
963 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
965 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
967 $sql .=
" AND pfd.traite = 0";
968 $sql .=
" AND pfd.type = 'ban'";
969 $sql .=
" ORDER BY pfd.date_demande DESC";
971 $resql = $db->query($sql);
977 $tmpuser =
new User($db);
979 $num = $db->num_rows($resql);
981 $obj = $db->fetch_object($resql);
983 $tmpuser->id = $obj->user_id;
984 $tmpuser->login = $obj->login;
985 $tmpuser->ref = $obj->login;
986 $tmpuser->email = $obj->email;
987 $tmpuser->lastname = $obj->lastname;
988 $tmpuser->firstname = $obj->firstname;
989 $tmpuser->statut = $obj->user_status;
990 $tmpuser->status = $obj->user_status;
992 print
'<tr class="oddeven">';
996 print
'<td class="center">';
997 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
1004 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'dayhour').
"</td>\n";
1007 print
'<td class="tdoverflowmax125">';
1008 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
1012 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
1015 print
'<td class="center"><span class="iban">';
1017 if ($obj->iban && $obj->bic) {
1021 print
'</span></td>';
1024 print
'<td class="center"><span class="opacitymedium">'.$langs->trans(
"OrderWaiting").
'</span></td>';
1027 print
'<td class="minwidth75">';
1028 if ($obj->fk_prelevement_bons > 0) {
1030 $withdrawreceipt->id = $obj->fk_prelevement_bons;
1031 $withdrawreceipt->ref = $obj->ref;
1032 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
1033 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
1034 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
1035 $withdrawreceipt->statut = $obj->status;
1036 $withdrawreceipt->status = $obj->status;
1037 $withdrawreceipt->amount = $obj->pb_amount;
1040 print $withdrawreceipt->getNomUrl(1);
1043 if ($type !=
'bank-transfer') {
1045 $langs->load(
"stripe");
1046 if ($obj->fk_prelevement_bons > 0) {
1049 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=sepastripedirectdebit&paymentservice=stripesepa&token='.
newToken().
'&did='.$obj->rowid.
'&id='.
$object->id.
'&type='.urlencode($type).
'">'.
img_picto(
'',
'stripe',
'class="pictofixedwidth"').$langs->trans(
"RequestDirectDebitWithStripe").
'</a>';
1053 $langs->load(
"stripe");
1054 if ($obj->fk_prelevement_bons > 0) {
1057 print
'<a href="'.$_SERVER[
"PHP_SELF"].
'?action=sepastripecredittransfer&paymentservice=stripesepa&token='.
newToken().
'&did='.$obj->rowid.
'&id='.
$object->id.
'&type='.urlencode($type).
'">'.
img_picto(
'',
'stripe',
'class="pictofixedwidth"').$langs->trans(
"RequestDirectDebitWithStripe").
'</a>';
1063 print
'<td class="">';
1069 print
'<td class="center">';
1070 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
1087 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount, pfd.fk_societe_rib, pfd.ext_payment_id, pfd.ext_payment_site,";
1088 $sql .=
" pb.ref, pb.date_trans, pb.method_trans, pb.credite, pb.date_credit, pb.datec, pb.statut as status, pb.fk_bank_account, pb.amount as pb_amount,";
1089 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status, u.photo as user_photo,";
1090 $sql .=
" sr.iban_prefix as iban, sr.bic as bic";
1091 $sql .=
" FROM ".$db->prefix().
"prelevement_demande as pfd";
1092 $sql .=
" LEFT JOIN ".$db->prefix().
"user as u on pfd.fk_user_demande = u.rowid";
1093 $sql .=
" LEFT JOIN ".$db->prefix().
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
1094 $sql .=
" LEFT JOIN ".$db->prefix().
"societe_rib as sr ON sr.rowid = pfd.fk_societe_rib";
1095 if ($type ==
'bank-transfer') {
1096 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
1098 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
1100 $sql .=
" AND pfd.traite = 1";
1101 $sql .=
" AND pfd.type = 'ban'";
1103 $sql .=
" ORDER BY pfd.date_demande DESC";
1105 $resql = $db->query($sql);
1107 $num = $db->num_rows($resql);
1111 $tmpuser =
new User($db);
1114 $obj = $db->fetch_object($resql);
1116 $tmpuser->id = $obj->user_id;
1117 $tmpuser->login = $obj->login;
1118 $tmpuser->ref = $obj->login;
1119 $tmpuser->email = $obj->email;
1120 $tmpuser->lastname = $obj->lastname;
1121 $tmpuser->firstname = $obj->firstname;
1122 $tmpuser->statut = $obj->user_status;
1123 $tmpuser->status = $obj->user_status;
1124 $tmpuser->photo = $obj->user_photo;
1126 print
'<tr class="oddeven">';
1130 print
'<td> </td>';
1134 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'day',
'tzuserrel').
"</td>\n";
1137 print
'<td class="tdoverflowmax125">';
1138 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
1142 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
1145 print
'<td class="center"><span class="iban">';
1147 if ($obj->iban && $obj->bic) {
1151 print
'</span></td>';
1154 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_traite),
'dayhour',
'tzuserrel').
"</td>\n";
1157 print
'<td class="minwidth75">';
1158 if ($obj->fk_prelevement_bons > 0) {
1160 $withdrawreceipt->id = $obj->fk_prelevement_bons;
1161 $withdrawreceipt->ref = $obj->ref;
1162 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
1163 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
1164 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
1165 $withdrawreceipt->statut = $obj->status;
1166 $withdrawreceipt->status = $obj->status;
1167 $withdrawreceipt->fk_bank_account = $obj->fk_bank_account;
1168 $withdrawreceipt->amount = $obj->pb_amount;
1171 print $withdrawreceipt->getNomUrl(1);
1173 print $withdrawreceipt->getLibStatut(2);
1176 $fk_bank_account = $withdrawreceipt->fk_bank_account;
1177 if (empty($fk_bank_account)) {
1180 if ($fk_bank_account > 0) {
1181 $bankaccount =
new Account($db);
1182 $result = $bankaccount->fetch($fk_bank_account);
1185 print $bankaccount->getNomUrl(1);
1188 if (!empty($obj->ext_payment_id) || !empty($obj->ext_payment_site)) {
1189 print
' - <span class="small opacitymedium">';
1190 print $obj->ext_payment_id.
'/'.$obj->ext_payment_site;
1197 print
'<td> </td>';
1201 print
'<td> </td>';
1208 if (!$numopen && !$numclosed) {
1209 print
'<tr class="oddeven"><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
$id
Support class for third parties, contacts, members, users or resources.
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
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 bank accounts.
Class to manage withdrawal receipts.
Class to manage bank accounts description of third parties.
Class to manage suppliers invoices.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
Class to manage invoice templates.
Class to manage projects.
Class to manage Dolibarr users.
facturefourn_prepare_head(FactureFournisseur $object)
Prepare array with list of tabs.
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...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
facture_prepare_head($object)
Initialize the array of tabs for customer invoice.
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.
dolDecrypt($chain, $key='')
Decode a string with a symmetric encryption.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.