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,
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');
303 $resteapayeraffiche = $resteapayer;
305 if ($type ==
'bank-transfer') {
307 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
308 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
310 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
311 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
314 $absolute_discount =
$object->thirdparty->getAvailableDiscounts(
null, $filterabsolutediscount, 0, 1);
315 $absolute_creditnote =
$object->thirdparty->getAvailableDiscounts(
null, $filtercreditnote, 0, 1);
316 $absolute_discount =
price2num($absolute_discount,
'MT');
317 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
320 $filterabsolutediscount =
"fk_facture_source IS NULL";
321 $filtercreditnote =
"fk_facture_source IS NOT NULL";
323 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
324 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
327 $absolute_discount =
$object->thirdparty->getAvailableDiscounts(
null, $filterabsolutediscount);
328 $absolute_creditnote =
$object->thirdparty->getAvailableDiscounts(
null, $filtercreditnote);
329 $absolute_discount =
price2num($absolute_discount,
'MT');
330 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
333 $author =
new User($db);
334 if (!empty(
$object->user_creation_id)) {
335 $author->fetch(
$object->user_creation_id);
336 } elseif (!empty(
$object->fk_user_author)) {
337 $author->fetch(
$object->fk_user_author);
340 if ($type ==
'bank-transfer') {
352 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
353 $sql .=
" , pfd.date_traite as date_traite";
354 $sql .=
" , pfd.amount";
355 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
356 if ($type ==
'bank-transfer') {
357 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
359 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
361 $sql .=
" AND pfd.traite = 0";
362 $sql .=
" AND pfd.type = 'ban'";
363 $sql .=
" ORDER BY pfd.date_demande DESC";
365 $resql = $db->query($sql);
367 $num = $db->num_rows($resql);
374 print
dol_get_fiche_head($head,
'standingorders', $title, -1, ($type ==
'bank-transfer' ?
'supplier_invoice' :
'bill'));
377 if ($type ==
'bank-transfer') {
378 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
380 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
383 $morehtmlref =
'<div class="refidno">';
385 if ($type ==
'bank-transfer') {
386 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, 0,
'string',
'', 0, 1);
387 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, 0,
'string',
'',
null,
null,
'', 1);
389 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_customer,
$object, 0,
'string',
'', 0, 1);
390 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client',
$object->ref_customer,
$object, 0,
'string',
'',
null,
null,
'', 1);
393 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
394 if ($type ==
'bank-transfer') {
396 $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>';
400 $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>';
404 if (isModEnabled(
'project')) {
405 $langs->load(
"projects");
406 $morehtmlref .=
'<br>';
408 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
409 if ($action !=
'classify') {
410 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
412 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
414 if (!empty(
$object->fk_project)) {
416 $proj->fetch(
$object->fk_project);
417 $morehtmlref .= $proj->getNomUrl(1);
419 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
424 $morehtmlref .=
'</div>';
426 $object->totalpaid = $totalpaid;
428 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $moreparam, 0,
'',
'');
430 print
'<div class="fichecenter">';
431 print
'<div class="fichehalfleft">';
432 print
'<div class="underbanner clearboth"></div>';
434 print
'<table class="border centpercent tableforfield">';
437 print
'<tr><td class="titlefield fieldname_type">'.$langs->trans(
'Type').
'</td><td colspan="3">';
438 print
'<span class="badgeneutral">';
441 if (!empty(
$object->module_source)) {
442 print
' <span class="opacitymediumbycolor paddingleft">('.$langs->trans(
"POS").
' '.
$object->module_source.
' - '.$langs->trans(
"Terminal").
' '.
$object->pos_source.
')</span>';
444 if (
$object->type == $object::TYPE_REPLACEMENT) {
445 if ($type ==
'bank-transfer') {
448 $facreplaced =
new Facture($db);
450 $facreplaced->fetch(
$object->fk_facture_source);
451 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
453 if (
$object->type == $object::TYPE_CREDIT_NOTE && !empty(
$object->fk_facture_source)) {
454 if ($type ==
'bank-transfer') {
459 $facusing->fetch(
$object->fk_facture_source);
460 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
463 $facidavoir =
$object->getListIdAvoirFromInvoice();
464 if (count($facidavoir) > 0) {
465 $invoicecredits = array();
466 foreach ($facidavoir as $facid) {
467 if ($type ==
'bank-transfer') {
472 $facavoir->fetch($facid);
473 $invoicecredits[] = $facavoir->getNomUrl(1);
475 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir");
476 print
' '. (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
489 print
'<!-- Discounts -->'.
"\n";
490 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining').
'</td><td colspan="3">';
492 if ($type ==
'bank-transfer') {
495 $thirdparty =
$object->thirdparty;
498 $thirdparty =
$object->thirdparty;
501 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id);
502 $cannotApplyDiscount = 1;
503 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
508 if ($type ==
'bank-transfer') {
510 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, 0).
'</td>';
511 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, 0).
'</td>';
517 print
'<table class="nobordernopadding centpercent"><tr><td>';
518 print $langs->trans(
'DateInvoice');
520 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editinvoicedate' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
521 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>';
523 print
'</tr></table>';
524 print
'</td><td colspan="3">';
526 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
527 if ($action ==
'editinvoicedate') {
528 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->date,
'invoicedate', 0, 0, 1, $type);
540 print
'<table class="nobordernopadding centpercent"><tr><td>';
541 print $langs->trans(
'PaymentConditionsShort');
543 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editconditions' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
544 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>';
546 print
'</tr></table>';
547 print
'</td><td colspan="3">';
548 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
549 if ($action ==
'editconditions') {
550 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 0, $type);
552 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none');
561 print
'<table class="nobordernopadding centpercent"><tr><td>';
562 print $langs->trans(
'DateMaxPayment');
564 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editpaymentterm' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
565 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>';
567 print
'</tr></table>';
568 print
'</td><td colspan="3">';
569 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
570 $duedate =
$object->date_lim_reglement;
571 if ($type ==
'bank-transfer') {
572 $duedate =
$object->date_echeance;
575 if ($action ==
'editpaymentterm') {
576 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $duedate,
'paymentterm', 0, 0, 1, $type);
590 print
'<table class="nobordernopadding centpercent"><tr><td>';
591 print $langs->trans(
'PaymentMode');
593 if ($action !=
'editmode' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
594 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>';
596 print
'</tr></table>';
597 print
'</td><td colspan="3">';
598 $filtertype =
'CRDT';
599 if ($type ==
'bank-transfer') {
600 $filtertype =
'DBIT';
602 if ($action ==
'editmode') {
603 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id', $filtertype, 1, 0, $type);
605 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
610 print
'<tr><td class="nowrap">';
611 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
612 print $langs->trans(
'BankAccount');
614 if (($action !=
'editbankaccount') && $user->hasRight(
'commande',
'creer') &&
$object->status == $object::STATUS_DRAFT) {
615 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>';
617 print
'</tr></table>';
618 print
'</td><td colspan="3">';
619 if ($action ==
'editbankaccount') {
620 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
622 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
629 print
'<div class="fichehalfright">';
630 print
'<!-- amounts -->'.
"\n";
631 print
'<div class="underbanner clearboth"></div>'.
"\n";
633 print
'<table class="border tableforfield centpercent">';
635 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_currency_amount.tpl.php';
643 print
'<td class="titlefieldmiddle">' . $langs->trans(
'AmountHT') .
'</td>';
644 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_ht, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
645 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
647 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_ht, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
653 print
'<td>' . $langs->trans(
'AmountVAT') .
'</td>';
654 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_tva, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
655 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
657 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_tva, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
662 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
664 print
'<td class="titlefieldmiddle">' . $langs->transcountry(
"AmountLT1", $mysoc->country_code) .
'</td>';
665 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_localtax1, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
666 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
669 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_localtax1, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
674 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
676 print
'<td>' . $langs->transcountry(
"AmountLT2", $mysoc->country_code) .
'</td>';
677 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_localtax2, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
678 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
681 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_localtax2, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
687 if ($selleruserevenustamp) {
689 print
'<table class="nobordernopadding centpercent"><tr><td>';
690 print $langs->trans(
'RevenueStamp');
692 if ($action !=
'editrevenuestamp' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
693 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>';
695 print
'</tr></table>';
696 print
'</td><td class="nowrap right">';
703 print
'<td>' . $langs->trans(
'AmountTTC') .
'</td>';
704 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->total_ttc, 0, $langs, 0, -1, -1,
$conf->currency) .
'</td>';
705 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
707 print
'<td class="nowrap amountcard right">' .
price($sign *
$object->multicurrency_total_ttc, 0, $langs, 0, -1, -1,
$object->multicurrency_code) .
'</td>';
712 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
715 $parameters = array(
'remaintopay' => $resteapayer);
716 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters,
$object, $action);
718 print $hookmanager->resPrint;
719 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
720 $resteapayer = $remaintopay;
725 print
'<tr><td>'.$langs->trans(
'RemainderToPay').
'</td><td class="nowrap right">'.
price($resteapayer, 1,
'', 1, - 1, - 1,
$conf->currency).
'</td>';
726 if (isModEnabled(
"multicurrency") && (
$object->multicurrency_code &&
$object->multicurrency_code !=
$conf->currency)) {
736 print
'<div class="clearboth"></div>';
744 $sql =
"SELECT SUM(pfd.amount) as amount";
745 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
746 if ($type ==
'bank-transfer') {
747 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
749 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
751 $sql .=
" AND pfd.traite = 0";
752 $sql .=
" AND pfd.type = 'ban'";
754 $resql = $db->query($sql);
756 $obj = $db->fetch_object($resql);
758 $pending = $obj->amount;
769 print
"\n".
'<div class="tabsAction">'.
"\n";
771 $buttonlabel = $langs->trans(
"MakeWithdrawRequest");
772 $user_perms = $user->hasRight(
'prelevement',
'bons',
'creer');
773 if ($type ==
'bank-transfer') {
774 $buttonlabel = $langs->trans(
"MakeBankTransferOrder");
775 $user_perms = $user->hasRight(
'paymentbybanktransfer',
'create');
779 if (
$object->status > $object::STATUS_DRAFT &&
$object->paid == 0 && $num == 0) {
780 if ($resteapayer > 0) {
782 $remaintopaylesspendingdebit = $resteapayer - $pending;
784 $title = $langs->trans(
"NewStandingOrder");
785 if ($type ==
'bank-transfer') {
786 $title = $langs->trans(
"NewPaymentByBankTransfer");
789 print
'<!-- form to select BAN -->';
790 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
791 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
792 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
793 print
'<input type="hidden" name="type" value="'.$type.
'" />';
794 print
'<input type="hidden" name="action" value="new" />';
796 print
'<div class="center formconsumeproduce">';
800 print $langs->trans(
'CustomerIBAN').
' ';
806 if (
$object->element ==
'invoice' &&
$object->fk_fac_rec_source) {
808 $facturerec->fetch(
$object->fk_fac_rec_source);
809 if ($facturerec->fk_societe_rib) {
811 $res = $companyBankAccount->fetch($facturerec->fk_societe_rib);
812 $selectedRib = $companyBankAccount->id;
816 $selectedRib = $form->selectRib($selectedRib,
'accountcustomerid',
'fk_soc='.
$object->socid, 1,
'', 1);
818 $defaultRibId =
$object->thirdparty->getDefaultRib();
821 $res = $companyBankAccount->fetch($defaultRibId);
822 if ($res > 0 && !$companyBankAccount->verif()) {
823 print
img_warning(
'Error on default bank number for IBAN : '.$langs->trans($companyBankAccount->error));
825 } elseif ($numopen || ($type !=
'bank-transfer' &&
$object->mode_reglement_code ==
'PRE') || ($type ==
'bank-transfer' &&
$object->mode_reglement_code ==
'VIR')) {
826 print
img_warning($langs->trans(
"NoDefaultIBANFound"));
833 print
' <label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
'</label>';
835 print
'<input type="text" class="right width75" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'">';
842 print
'<input type="submit" class="butAction small" value="'.$buttonlabel.
'" />';
853 $buttonlabel = $langs->trans(
"MakeWithdrawRequestStripe");
854 print
'<form method="POST" action="">';
855 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
856 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
857 print
'<input type="hidden" name="type" value="'.$type.
'" />';
858 print
'<input type="hidden" name="action" value="new" />';
859 print
'<input type="hidden" name="paymenservice" value="stripesepa" />';
860 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
861 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
862 print
'<input type="submit" class="butAction small" value="'.$buttonlabel.
'" />';
866 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$buttonlabel.
'</a>';
869 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AmountMustBePositive")).
'">'.$buttonlabel.
'</a>';
873 if (
$object->status > $object::STATUS_DRAFT) {
874 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AlreadyPaid")).
'">'.$buttonlabel.
'</a>';
876 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"Draft")).
'">'.$buttonlabel.
'</a>';
879 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"RequestAlreadyDone")).
'">'.$buttonlabel.
'</a>';
886 if ($type ==
'bank-transfer') {
887 print
'<div class="opacitymedium justify">'.$langs->trans(
"DoCreditTransferBeforePayments");
889 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
891 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
892 print
'</div><br><br>';
894 print
'<div class="opacitymedium justify">'.$langs->trans(
"DoStandingOrdersBeforePayments");
896 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
898 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
899 print
'</div><br><br>';
906 print
'<div class="div-table-responsive-no-min">';
907 print
'<table class="noborder centpercent">';
909 print
'<tr class="liste_titre">';
912 print
'<td> </td>';
914 print
'<td class="left">'.$langs->trans(
"DateRequest").
'</td>';
915 print
'<td>'.$langs->trans(
"User").
'</td>';
916 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
917 print
'<td class="center">'.$langs->trans(
"IBAN").
'</td>';
918 print
'<td class="center">'.$langs->trans(
"DateProcess").
'</td>';
919 if ($type ==
'bank-transfer') {
920 print
'<td class="">'.$langs->trans(
"BankTransferReceipt").
'</td>';
922 print
'<td class="">'.$langs->trans(
"WithdrawalReceipt").
'</td>';
924 print
'<td> </td>';
927 print
'<td> </td>';
931 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
932 $sql .=
" pfd.date_traite as date_traite, pfd.amount, pfd.fk_prelevement_bons,";
933 $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,";
934 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status,";
935 $sql .=
" sr.iban_prefix as iban, sr.bic as bic";
936 $sql .=
" FROM ".$db->prefix().
"prelevement_demande as pfd";
937 $sql .=
" LEFT JOIN ".$db->prefix().
"user as u on pfd.fk_user_demande = u.rowid";
938 $sql .=
" LEFT JOIN ".$db->prefix().
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
939 $sql .=
" LEFT JOIN ".$db->prefix().
"societe_rib as sr ON sr.rowid = pfd.fk_societe_rib";
940 if ($type ==
'bank-transfer') {
941 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
943 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
945 $sql .=
" AND pfd.traite = 0";
946 $sql .=
" AND pfd.type = 'ban'";
947 $sql .=
" ORDER BY pfd.date_demande DESC";
949 $resql = $db->query($sql);
955 $tmpuser =
new User($db);
957 $num = $db->num_rows($result);
959 $obj = $db->fetch_object($resql);
961 $tmpuser->id = $obj->user_id;
962 $tmpuser->login = $obj->login;
963 $tmpuser->ref = $obj->login;
964 $tmpuser->email = $obj->email;
965 $tmpuser->lastname = $obj->lastname;
966 $tmpuser->firstname = $obj->firstname;
967 $tmpuser->statut = $obj->user_status;
968 $tmpuser->status = $obj->user_status;
970 print
'<tr class="oddeven">';
974 print
'<td class="center">';
975 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
982 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'dayhour').
"</td>\n";
985 print
'<td class="tdoverflowmax125">';
986 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
990 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
993 print
'<td class="center"><span class="iban">';
995 if ($obj->iban && $obj->bic) {
999 print
'</span></td>';
1002 print
'<td class="center"><span class="opacitymedium">'.$langs->trans(
"OrderWaiting").
'</span></td>';
1005 print
'<td class="minwidth75">';
1006 if ($obj->fk_prelevement_bons > 0) {
1008 $withdrawreceipt->id = $obj->fk_prelevement_bons;
1009 $withdrawreceipt->ref = $obj->ref;
1010 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
1011 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
1012 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
1013 $withdrawreceipt->statut = $obj->status;
1014 $withdrawreceipt->status = $obj->status;
1015 $withdrawreceipt->amount = $obj->pb_amount;
1018 print $withdrawreceipt->getNomUrl(1);
1021 if ($type !=
'bank-transfer') {
1023 $langs->load(
"stripe");
1024 if ($obj->fk_prelevement_bons > 0) {
1027 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>';
1031 $langs->load(
"stripe");
1032 if ($obj->fk_prelevement_bons > 0) {
1035 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>';
1041 print
'<td class="">';
1047 print
'<td class="center">';
1048 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
1065 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
1066 $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,";
1067 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status, u.photo as user_photo,";
1068 $sql .=
" sr.iban_prefix as iban, sr.bic as bic";
1069 $sql .=
" FROM ".$db->prefix().
"prelevement_demande as pfd";
1070 $sql .=
" LEFT JOIN ".$db->prefix().
"user as u on pfd.fk_user_demande = u.rowid";
1071 $sql .=
" LEFT JOIN ".$db->prefix().
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
1072 $sql .=
" LEFT JOIN ".$db->prefix().
"societe_rib as sr ON sr.rowid = pfd.fk_societe_rib";
1073 if ($type ==
'bank-transfer') {
1074 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
1076 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
1078 $sql .=
" AND pfd.traite = 1";
1079 $sql .=
" AND pfd.type = 'ban'";
1080 $sql .=
" ORDER BY pfd.date_demande DESC";
1082 $resql = $db->query($sql);
1084 $num = $db->num_rows($resql);
1088 $tmpuser =
new User($db);
1091 $obj = $db->fetch_object($resql);
1093 $tmpuser->id = $obj->user_id;
1094 $tmpuser->login = $obj->login;
1095 $tmpuser->ref = $obj->login;
1096 $tmpuser->email = $obj->email;
1097 $tmpuser->lastname = $obj->lastname;
1098 $tmpuser->firstname = $obj->firstname;
1099 $tmpuser->statut = $obj->user_status;
1100 $tmpuser->status = $obj->user_status;
1101 $tmpuser->photo = $obj->user_photo;
1103 print
'<tr class="oddeven">';
1107 print
'<td> </td>';
1111 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'day').
"</td>\n";
1114 print
'<td class="tdoverflowmax125">';
1115 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
1119 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
1122 print
'<td class="center"><span class="iban">';
1124 if ($obj->iban && $obj->bic) {
1128 print
'</span></td>';
1131 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_traite),
'dayhour',
'tzuserrel').
"</td>\n";
1134 print
'<td class="minwidth75">';
1135 if ($obj->fk_prelevement_bons > 0) {
1137 $withdrawreceipt->id = $obj->fk_prelevement_bons;
1138 $withdrawreceipt->ref = $obj->ref;
1139 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
1140 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
1141 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
1142 $withdrawreceipt->statut = $obj->status;
1143 $withdrawreceipt->status = $obj->status;
1144 $withdrawreceipt->fk_bank_account = $obj->fk_bank_account;
1145 $withdrawreceipt->amount = $obj->pb_amount;
1148 print $withdrawreceipt->getNomUrl(1);
1150 print $withdrawreceipt->getLibStatut(2);
1153 $fk_bank_account = $withdrawreceipt->fk_bank_account;
1154 if (empty($fk_bank_account)) {
1155 $fk_bank_account = (
$object->type ==
'bank-transfer' ?
$conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT :
$conf->global->PRELEVEMENT_ID_BANKACCOUNT);
1157 if ($fk_bank_account > 0) {
1158 $bankaccount =
new Account($db);
1159 $result = $bankaccount->fetch($fk_bank_account);
1162 print $bankaccount->getNomUrl(1);
1169 print
'<td> </td>';
1173 print
'<td> </td>';
1180 if (!$numopen && !$numclosed) {
1181 print
'<tr class="oddeven"><td colspan="8"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
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 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_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete 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 '.
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.