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)) {
87$hookmanager->initHooks(array(
'directdebitcard',
'globalcard'));
89if ($type ==
'bank-transfer') {
90 $result =
restrictedArea($user,
'fournisseur',
$id,
'facture_fourn',
'facture',
'fk_soc', $fieldid, $isdraft);
91 if (!$user->hasRight(
'fournisseur',
'facture',
'lire')) {
95 $result =
restrictedArea($user,
'facture',
$id,
'',
'',
'fk_soc', $fieldid, $isdraft);
96 if (!$user->hasRight(
'facture',
'lire')) {
101if ($type ==
'bank-transfer') {
102 $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
104 $usercancreate = $user->hasRight(
'facture',
'creer');
112$parameters = array(
'socid' => $socid);
113$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
118if (empty($reshook)) {
119 if ($action ==
"new" && $usercancreate) {
124 $sourcetype =
'facture';
125 if ($type ==
'bank-transfer') {
126 $sourcetype =
'supplier_invoice';
127 $newtype =
'bank-transfer';
129 $paymentservice =
GETPOST(
'paymentservice');
133 $amount =
GETPOST(
'withdraw_request_amount',
'alpha');
134 $result =
$object->demande_prelevement($user, (
float)
price2num($amount), $newtype, $sourcetype, 0, $iban ?? 0);
148 if ($action ==
"delete" && $usercancreate) {
152 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id.
'&type='.$type);
159 if ($action ==
'sepastripedirectdebit' && $usercancreate) {
160 $result =
$object->makeStripeSepaRequest($user,
GETPOSTINT(
'did'),
'direct-debit',
'facture');
174 if ($action ==
'sepastripecredittransfer' && $usercancreate) {
175 $result =
$object->makeStripeSepaRequest($user,
GETPOSTINT(
'did'),
'bank-transfer',
'supplier_invoice');
189 if ($action ==
'setconditions' && $usercancreate) {
191 $object->cond_reglement_code = 0;
192 $object->cond_reglement_id = 0;
207 $old_date_echeance =
$object->date_echeance;
208 $new_date_echeance =
$object->calculate_date_lim_reglement();
209 if ($new_date_echeance > $old_date_echeance) {
210 $object->date_echeance = $new_date_echeance;
215 $result =
$object->update($user);
227 } elseif ($action ==
'setmode' && $usercancreate) {
230 } elseif ($action ==
'setdatef' && $usercancreate) {
234 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
236 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
241 $date_echence_calc =
$object->calculate_date_lim_reglement();
242 if (!empty(
$object->date_echeance) &&
$object->date_echeance < $date_echence_calc) {
243 $object->date_echeance = $date_echence_calc;
249 $result =
$object->update($user);
253 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
257 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
259 $result =
$object->update($user);
271$form =
new Form($db);
275if ($type ==
'bank-transfer') {
276 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'CreditTransfer');
279 $title = $langs->trans(
'InvoiceCustomer').
" - ".$langs->trans(
'StandingOrders');
280 $helpurl =
"EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
287 $selleruserevenustamp = $mysoc->useRevenueStamp();
289 $totalpaid =
$object->getSommePaiement();
290 $totalcreditnotes =
$object->getSumCreditNotesUsed();
291 $totaldeposits =
$object->getSumDepositsUsed();
298 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
304 if ($type ==
'bank-transfer') {
306 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
307 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
309 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
310 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
313 $absolute_discount =
$object->thirdparty->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
314 $absolute_creditnote =
$object->thirdparty->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
315 $absolute_discount =
price2num($absolute_discount,
'MT');
316 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
319 $filterabsolutediscount =
"fk_facture_source IS NULL";
320 $filtercreditnote =
"fk_facture_source IS NOT NULL";
322 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
323 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
326 $absolute_discount =
$object->thirdparty->getAvailableDiscounts(
null, $filterabsolutediscount);
327 $absolute_creditnote =
$object->thirdparty->getAvailableDiscounts(
null, $filtercreditnote);
328 $absolute_discount =
price2num($absolute_discount,
'MT');
329 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
332 $author =
new User($db);
333 if (!empty(
$object->user_creation_id)) {
334 $author->fetch(
$object->user_creation_id);
335 } elseif (!empty(
$object->fk_user_author)) {
336 $author->fetch(
$object->fk_user_author);
339 if ($type ==
'bank-transfer') {
350 $listofopendirectdebitorcredittransfer =
$object->getListOfOpenDirectDebitOrCreditTransfer($type);
351 $numopen = count($listofopendirectdebitorcredittransfer);
353 print
dol_get_fiche_head($head,
'standingorders', $title, -1, ($type ==
'bank-transfer' ?
'supplier_invoice' :
'bill'));
356 if ($type ==
'bank-transfer') {
357 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
359 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
362 $morehtmlref =
'<div class="refidno">';
364 if ($type ==
'bank-transfer') {
365 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, 0,
'string',
'', 0, 1);
366 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, 0,
'string',
'',
null,
null,
'', 1);
368 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_customer,
$object, 0,
'string',
'', 0, 1);
369 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client',
$object->ref_customer,
$object, 0,
'string',
'',
null,
null,
'', 1);
372 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
373 if ($type ==
'bank-transfer') {
375 $morehtmlref .=
' <div class="inline-block valignmiddle">(<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.
$object->thirdparty->id.
'&search_company='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)</div>';
379 $morehtmlref .=
' <div class="inline-block valignmiddle">(<a class="valignmiddle" href="'.DOL_URL_ROOT.
'/compta/facture/list.php?socid='.
$object->thirdparty->id.
'&search_company='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)</div>';
383 if (isModEnabled(
'project')) {
384 $langs->load(
"projects");
385 $morehtmlref .=
'<br>';
387 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
388 if ($action !=
'classify') {
389 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
391 $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');
393 if (!empty(
$object->fk_project)) {
395 $proj->fetch(
$object->fk_project);
396 $morehtmlref .= $proj->getNomUrl(1);
398 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
403 $morehtmlref .=
'</div>';
405 $object->totalpaid = $totalpaid;
407 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $moreparam, 0,
'',
'');
409 print
'<div class="fichecenter">';
410 print
'<div class="fichehalfleft">';
411 print
'<div class="underbanner clearboth"></div>';
413 print
'<table class="border centpercent tableforfield">';
416 print
'<tr><td class="titlefield fieldname_type">'.$langs->trans(
'Type').
'</td><td colspan="3">';
417 print
'<span class="badgeneutral">';
420 if (!empty(
$object->module_source)) {
421 print
' <span class="opacitymediumbycolor paddingleft">('.$langs->trans(
"POS").
' '.
$object->module_source.
' - '.$langs->trans(
"Terminal").
' '.
$object->pos_source.
')</span>';
423 if (
$object->type == $object::TYPE_REPLACEMENT) {
424 if ($type ==
'bank-transfer') {
427 $facreplaced =
new Facture($db);
429 $facreplaced->fetch(
$object->fk_facture_source);
430 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
432 if (
$object->type == $object::TYPE_CREDIT_NOTE && !empty(
$object->fk_facture_source)) {
433 if ($type ==
'bank-transfer') {
438 $facusing->fetch(
$object->fk_facture_source);
439 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
443 $object->getListIdAvoirFromInvoice();
445 if (!empty(
$object->creditnote_ids)) {
446 $invoicecredits = array();
447 foreach (
$object->creditnote_ids as $invoiceid) {
448 if ($type ==
'bank-transfer') {
451 $creditnote =
new Facture($db);
453 $creditnote->fetch($invoiceid);
454 $invoicecredits[] = $creditnote->getNomUrl(1);
456 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir");
457 print
' '. (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
470 print
'<!-- Discounts -->'.
"\n";
471 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining').
'</td><td colspan="3">';
473 if ($type ==
'bank-transfer') {
476 $thirdparty =
$object->thirdparty;
479 $thirdparty =
$object->thirdparty;
482 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id);
483 $cannotApplyDiscount = 1;
484 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
489 if ($type ==
'bank-transfer') {
491 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, 0).
'</td>';
492 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, 0).
'</td>';
498 print
'<table class="nobordernopadding centpercent"><tr><td>';
499 print $langs->trans(
'DateInvoice');
501 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editinvoicedate' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
502 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>';
504 print
'</tr></table>';
505 print
'</td><td colspan="3">';
507 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
508 if ($action ==
'editinvoicedate') {
509 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->date,
'invoicedate', 0, 0, 1, $type);
521 print
'<table class="nobordernopadding centpercent"><tr><td>';
522 print $langs->trans(
'PaymentConditionsShort');
524 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editconditions' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
525 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>';
527 print
'</tr></table>';
528 print
'</td><td colspan="3">';
529 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
530 if ($action ==
'editconditions') {
531 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'cond_reglement_id', 0, $type);
533 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->cond_reglement_id,
'none');
542 print
'<table class="nobordernopadding centpercent"><tr><td>';
543 print $langs->trans(
'DateMaxPayment');
545 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editpaymentterm' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
546 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>';
548 print
'</tr></table>';
549 print
'</td><td colspan="3">';
550 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
551 $duedate =
$object->date_lim_reglement;
552 if ($type ==
'bank-transfer') {
553 $duedate =
$object->date_echeance;
556 if ($action ==
'editpaymentterm') {
557 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $duedate,
'paymentterm', 0, 0, 1, $type);
571 print
'<table class="nobordernopadding centpercent"><tr><td>';
572 print $langs->trans(
'PaymentMode');
574 if ($action !=
'editmode' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
575 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>';
577 print
'</tr></table>';
578 print
'</td><td colspan="3">';
579 $filtertype =
'CRDT';
580 if ($type ==
'bank-transfer') {
581 $filtertype =
'DBIT';
583 if ($action ==
'editmode') {
584 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'mode_reglement_id', $filtertype, 1, 0, $type);
586 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->mode_reglement_id,
'none');
591 print
'<tr><td class="nowrap">';
592 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
593 print $langs->trans(
'BankAccount');
595 if (($action !=
'editbankaccount') && $user->hasRight(
'commande',
'creer') &&
$object->status == $object::STATUS_DRAFT) {
596 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>';
598 print
'</tr></table>';
599 print
'</td><td colspan="3">';
600 if ($action ==
'editbankaccount') {
601 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'fk_account', 1);
603 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, (
string)
$object->fk_account,
'none');
610 print
'<div class="fichehalfright">';
611 print
'<!-- amounts -->'.
"\n";
612 print
'<div class="underbanner clearboth"></div>'.
"\n";
614 print
'<table class="border tableforfield centpercent">';
616 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
624 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
625 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
626 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
628 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
634 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
635 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
636 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
638 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
643 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
645 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
646 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
647 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
650 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
655 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
657 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
658 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
659 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
662 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
668 if ($selleruserevenustamp) {
670 print
'<table class="nobordernopadding centpercent"><tr><td>';
671 print $langs->trans(
'RevenueStamp');
673 if ($action !=
'editrevenuestamp' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
674 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>';
676 print
'</tr></table>';
677 print
'</td><td class="nowrap right">';
684 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
685 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
686 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
688 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
693 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
696 $parameters = array(
'remaintopay' => $resteapayer);
697 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters,
$object, $action);
699 print $hookmanager->resPrint;
700 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
701 $resteapayer = $remaintopay;
706 print
'<tr><td>'.$langs->trans(
'RemainderToPay').
'</td><td class="nowrap right">'.
price($resteapayer, 1,
'', 1, - 1, - 1,
$conf->currency).
'</td>';
707 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
717 print
'<div class="clearboth"></div>';
730 $sql =
"SELECT SUM(pfd.amount) as amount";
731 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
732 if ($type ==
'bank-transfer') {
733 $sql .=
" WHERE pfd.fk_facture_fourn = ".((int)
$object->id);
735 $sql .=
" WHERE pfd.fk_facture = ".((int)
$object->id);
737 $sql .=
" AND pfd.traite = 0";
739 $resql = $db->query($sql);
741 $obj = $db->fetch_object($resql);
743 $pending += (float) $obj->amount;
749 $sqlPending =
"SELECT SUM(pl.amount) as amount";
750 $sqlPending .=
" FROM ".$db->prefix().
"prelevement_lignes as pl";
751 $sqlPending .=
" INNER JOIN ".$db->prefix().
"prelevement as p ON p.fk_prelevement_lignes = pl.rowid";
752 if ($type ==
'bank-transfer') {
753 $sqlPending .=
" WHERE p.fk_facture_fourn = ".((int)
$object->id);
755 $sqlPending .=
" WHERE p.fk_facture = ".((int)
$object->id);
757 $sqlPending .=
" AND (pl.statut IS NULL OR pl.statut = 0)";
758 $resPending = $db->query($sqlPending);
760 if ($objPending = $db->fetch_object($resPending)) {
761 $pending += (float) $objPending->amount;
764 $db->free($resPending);
792 print
"\n".
'<div class="tabsAction">'.
"\n";
794 $buttonlabel = $langs->trans(
"MakeWithdrawRequest");
795 $user_perms = $user->hasRight(
'prelevement',
'bons',
'creer');
796 if ($type ==
'bank-transfer') {
797 $buttonlabel = $langs->trans(
"MakeBankTransferOrder");
798 $user_perms = $user->hasRight(
'paymentbybanktransfer',
'create');
802 if (
$object->status > $object::STATUS_DRAFT &&
$object->paid == 0 && $numopen == 0) {
803 if ($resteapayer > 0) {
805 $remaintopaylesspendingdebit = $resteapayer - $pending;
807 $title = $langs->trans(
"NewStandingOrder");
808 if ($type ==
'bank-transfer') {
809 $title = $langs->trans(
"NewPaymentByBankTransfer");
812 print
'<!-- form to select BAN -->';
813 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
814 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
815 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
816 print
'<input type="hidden" name="type" value="'.$type.
'" />';
817 print
'<input type="hidden" name="action" value="new" />';
819 print
'<div class="center formconsumeproduce">';
821 print $langs->trans(
'CustomerIBAN').
' ';
825 if (
$object->element ==
'invoice' &&
$object->fk_fac_rec_source) {
827 $facturerec->fetch(
$object->fk_fac_rec_source);
828 if ($facturerec->fk_societe_rib) {
830 $res = $companyBankAccount->fetch($facturerec->fk_societe_rib);
831 $selectedRibId = $companyBankAccount->id;
834 $defaultRibId =
$object->thirdparty->getDefaultRib();
835 if (empty($selectedRibId)) $selectedRibId = (int) $defaultRibId;
837 $selectedRib = $form->selectRib($selectedRibId,
'accountcustomerid',
'fk_soc='.
$object->socid, 1,
'', 1);
841 $res = $companyBankAccount->fetch($defaultRibId);
842 if ($res > 0 && !$companyBankAccount->verif()) {
843 print
img_warning(
'Error on default bank number for IBAN : '.$langs->trans($companyBankAccount->error));
845 } elseif (($type !=
'bank-transfer' &&
$object->mode_reglement_code ==
'PRE') || ($type ==
'bank-transfer' &&
$object->mode_reglement_code ==
'VIR')) {
846 print
img_warning($langs->trans(
"NoDefaultIBANFound"));
851 print
' <label for="withdraw_request_amount">';
852 if ($type ==
'bank-transfer') {
853 print $langs->trans(
'BankTransferAmount');
855 print $langs->trans(
"WithdrawRequestAmount");
858 print
'<input type="text" class="right width75" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'">';
862 print
'<input type="submit" class="butAction small" value="'.$buttonlabel.
'" />';
873 $buttonlabel = $langs->trans(
"MakeWithdrawRequestStripe");
874 print
'<form method="POST" action="">';
875 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
876 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
877 print
'<input type="hidden" name="type" value="'.$type.
'" />';
878 print
'<input type="hidden" name="action" value="new" />';
879 print
'<input type="hidden" name="paymenservice" value="stripesepa" />';
880 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
881 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
882 print
'<input type="submit" class="butAction small" value="'.$buttonlabel.
'" />';
886 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$buttonlabel.
'</a>';
889 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AmountMustBePositive")).
'">'.$buttonlabel.
'</a>';
893 if (
$object->status > $object::STATUS_DRAFT) {
894 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AlreadyPaid")).
'">'.$buttonlabel.
'</a>';
896 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"Draft")).
'">'.$buttonlabel.
'</a>';
899 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"RequestAlreadyDone")).
'">'.$buttonlabel.
'</a>';
906 if ($type ==
'bank-transfer') {
907 print
'<div class="opacitymedium justify">'.$langs->trans(
"DoCreditTransferBeforePayments");
909 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
911 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
912 print
'</div><br><br>';
914 print
'<div class="opacitymedium justify">'.$langs->trans(
"DoStandingOrdersBeforePayments");
916 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
918 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
919 print
'</div><br><br>';
926 print
'<div class="div-table-responsive-no-min">';
927 print
'<table class="noborder centpercent">';
929 print
'<tr class="liste_titre">';
932 print
'<td> </td>';
934 print
'<td class="left">'.$langs->trans(
"DateRequest").
'</td>';
935 print
'<td>'.$langs->trans(
"User").
'</td>';
936 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
937 print
'<td class="center">'.$langs->trans(
"IBAN").
'</td>';
938 print
'<td class="center">'.$langs->trans(
"DateProcess").
'</td>';
939 if ($type ==
'bank-transfer') {
940 print
'<td class="">'.$langs->trans(
"BankTransferReceipt").
'</td>';
942 print
'<td class="">'.$langs->trans(
"WithdrawalReceipt").
'</td>';
944 print
'<td> </td>';
947 print
'<td> </td>';
951 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
952 $sql .=
" pfd.date_traite as date_traite, pfd.amount, pfd.fk_prelevement_bons,";
953 $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,";
954 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status,";
955 $sql .=
" sr.iban_prefix as iban, sr.bic as bic";
956 $sql .=
" FROM ".$db->prefix().
"prelevement_demande as pfd";
957 $sql .=
" LEFT JOIN ".$db->prefix().
"user as u on pfd.fk_user_demande = u.rowid";
958 $sql .=
" LEFT JOIN ".$db->prefix().
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
959 $sql .=
" LEFT JOIN ".$db->prefix().
"societe_rib as sr ON sr.rowid = pfd.fk_societe_rib";
960 if ($type ==
'bank-transfer') {
961 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
963 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
965 $sql .=
" AND pfd.traite = 0";
966 $sql .=
" AND pfd.type = 'ban'";
967 $sql .=
" ORDER BY pfd.date_demande DESC";
969 $resql = $db->query($sql);
975 $tmpuser =
new User($db);
977 $num = $db->num_rows($resql);
979 $obj = $db->fetch_object($resql);
981 $tmpuser->id = $obj->user_id;
982 $tmpuser->login = $obj->login;
983 $tmpuser->ref = $obj->login;
984 $tmpuser->email = $obj->email;
985 $tmpuser->lastname = $obj->lastname;
986 $tmpuser->firstname = $obj->firstname;
987 $tmpuser->statut = $obj->user_status;
988 $tmpuser->status = $obj->user_status;
990 print
'<tr class="oddeven">';
994 print
'<td class="center">';
995 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
1002 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'dayhour').
"</td>\n";
1005 print
'<td class="tdoverflowmax125">';
1006 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
1010 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
1013 print
'<td class="center"><span class="iban">';
1015 if ($obj->iban && $obj->bic) {
1019 print
'</span></td>';
1022 print
'<td class="center"><span class="opacitymedium">'.$langs->trans(
"OrderWaiting").
'</span></td>';
1025 print
'<td class="minwidth75">';
1026 if ($obj->fk_prelevement_bons > 0) {
1028 $withdrawreceipt->id = $obj->fk_prelevement_bons;
1029 $withdrawreceipt->ref = $obj->ref;
1030 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
1031 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
1032 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
1033 $withdrawreceipt->statut = $obj->status;
1034 $withdrawreceipt->status = $obj->status;
1035 $withdrawreceipt->amount = $obj->pb_amount;
1038 print $withdrawreceipt->getNomUrl(1);
1041 if ($type !=
'bank-transfer') {
1043 $langs->load(
"stripe");
1044 if ($obj->fk_prelevement_bons > 0) {
1047 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>';
1051 $langs->load(
"stripe");
1052 if ($obj->fk_prelevement_bons > 0) {
1055 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>';
1061 print
'<td class="">';
1067 print
'<td class="center">';
1068 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
1085 $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,";
1086 $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,";
1087 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status, u.photo as user_photo,";
1088 $sql .=
" sr.iban_prefix as iban, sr.bic as bic";
1089 $sql .=
" FROM ".$db->prefix().
"prelevement_demande as pfd";
1090 $sql .=
" LEFT JOIN ".$db->prefix().
"user as u on pfd.fk_user_demande = u.rowid";
1091 $sql .=
" LEFT JOIN ".$db->prefix().
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
1092 $sql .=
" LEFT JOIN ".$db->prefix().
"societe_rib as sr ON sr.rowid = pfd.fk_societe_rib";
1093 if ($type ==
'bank-transfer') {
1094 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
1096 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
1098 $sql .=
" AND pfd.traite = 1";
1099 $sql .=
" AND pfd.type = 'ban'";
1101 $sql .=
" ORDER BY pfd.date_demande DESC";
1103 $resql = $db->query($sql);
1105 $num = $db->num_rows($resql);
1109 $tmpuser =
new User($db);
1112 $obj = $db->fetch_object($resql);
1114 $tmpuser->id = $obj->user_id;
1115 $tmpuser->login = $obj->login;
1116 $tmpuser->ref = $obj->login;
1117 $tmpuser->email = $obj->email;
1118 $tmpuser->lastname = $obj->lastname;
1119 $tmpuser->firstname = $obj->firstname;
1120 $tmpuser->statut = $obj->user_status;
1121 $tmpuser->status = $obj->user_status;
1122 $tmpuser->photo = $obj->user_photo;
1124 print
'<tr class="oddeven">';
1128 print
'<td> </td>';
1132 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'day',
'tzuserrel').
"</td>\n";
1135 print
'<td class="tdoverflowmax125">';
1136 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
1140 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
1143 print
'<td class="center"><span class="iban">';
1145 if ($obj->iban && $obj->bic) {
1149 print
'</span></td>';
1152 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_traite),
'dayhour',
'tzuserrel').
"</td>\n";
1155 print
'<td class="minwidth75">';
1156 if ($obj->fk_prelevement_bons > 0) {
1158 $withdrawreceipt->id = $obj->fk_prelevement_bons;
1159 $withdrawreceipt->ref = $obj->ref;
1160 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
1161 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
1162 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
1163 $withdrawreceipt->statut = $obj->status;
1164 $withdrawreceipt->status = $obj->status;
1165 $withdrawreceipt->fk_bank_account = $obj->fk_bank_account;
1166 $withdrawreceipt->amount = $obj->pb_amount;
1169 print $withdrawreceipt->getNomUrl(1);
1171 print $withdrawreceipt->getLibStatut(2);
1174 $fk_bank_account = $withdrawreceipt->fk_bank_account;
1175 if (empty($fk_bank_account)) {
1178 if ($fk_bank_account > 0) {
1179 $bankaccount =
new Account($db);
1180 $result = $bankaccount->fetch($fk_bank_account);
1183 print $bankaccount->getNomUrl(1);
1186 if (!empty($obj->ext_payment_id) || !empty($obj->ext_payment_site)) {
1187 print
' - <span class="small opacitymedium">';
1188 print $obj->ext_payment_id.
'/'.$obj->ext_payment_site;
1195 print
'<td> </td>';
1199 print
'<td> </td>';
1206 if (!$numopen && !$numclosed) {
1207 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.