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';
44$langs->loadLangs(array(
'bills',
'banks',
'withdrawals',
'companies'));
49$action =
GETPOST(
'action',
'aZ09');
52$fieldid = (!empty($ref) ?
'ref' :
'rowid');
54 $socid = $user->socid;
58if ($type ==
'bank-transfer') {
60 $moreparam =
'&type='.$type;
66if (
$id > 0 || !empty($ref)) {
74$hookmanager->initHooks(array(
'directdebitcard',
'globalcard'));
76if ($type ==
'bank-transfer') {
77 $result =
restrictedArea($user,
'fournisseur',
$id,
'facture_fourn',
'facture',
'fk_soc', $fieldid, $isdraft);
78 if (!$user->hasRight(
'fournisseur',
'facture',
'lire')) {
82 $result =
restrictedArea($user,
'facture',
$id,
'',
'',
'fk_soc', $fieldid, $isdraft);
83 if (!$user->hasRight(
'facture',
'lire')) {
88if ($type ==
'bank-transfer') {
89 $usercancreate = ($user->rights->fournisseur->facture->creer || $user->rights->supplier_invoice->creer);
91 $usercancreate = $user->hasRight(
'facture',
'creer');
99$parameters = array(
'socid' => $socid);
100$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
105if (empty($reshook)) {
106 if ($action ==
"new" && $usercancreate) {
111 $sourcetype =
'facture';
112 if ($type ==
'bank-transfer') {
113 $sourcetype =
'supplier_invoice';
114 $newtype =
'bank-transfer';
116 $paymentservice =
GETPOST(
'paymentservice');
119 $iban = explode(
" / ",
GETPOST(
'ribList'))[0];
120 $sql =
"SELECT rowid FROM ".$db->prefix().
"societe_rib WHERE iban_prefix = '".$db->escape($iban).
"'" ;
121 $resql =
$object->db->query($sql);
123 if ($resql->num_rows) {
124 $selectedRibObj =
$object->db->fetch_object($resql);
127 $amount =
GETPOST(
'withdraw_request_amount',
'alpha');
128 $result =
$object->demande_prelevement($user,
price2num($amount), $newtype, $sourcetype, 0, $selectedRibObj->rowid ?? 0);
142 if ($action ==
"delete" && $usercancreate) {
146 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id.
'&type='.$type);
153 if ($action ==
'sepastripedirectdebit' && $usercancreate) {
154 $result =
$object->makeStripeSepaRequest($user,
GETPOSTINT(
'did'),
'direct-debit',
'facture');
168 if ($action ==
'sepastripecredittransfer' && $usercancreate) {
169 $result =
$object->makeStripeSepaRequest($user,
GETPOSTINT(
'did'),
'bank-transfer',
'supplier_invoice');
183 if ($action ==
'setconditions' && $usercancreate) {
185 $object->cond_reglement_code = 0;
186 $object->cond_reglement_id = 0;
201 $old_date_echeance =
$object->date_echeance;
202 $new_date_echeance =
$object->calculate_date_lim_reglement();
203 if ($new_date_echeance > $old_date_echeance) {
204 $object->date_echeance = $new_date_echeance;
209 $result =
$object->update($user);
221 } elseif ($action ==
'setmode' && $usercancreate) {
224 } elseif ($action ==
'setdatef' && $usercancreate) {
228 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
230 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
235 $date_echence_calc =
$object->calculate_date_lim_reglement();
236 if (!empty(
$object->date_echeance) &&
$object->date_echeance < $date_echence_calc) {
237 $object->date_echeance = $date_echence_calc;
243 $result =
$object->update($user);
247 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
251 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
253 $result =
$object->update($user);
265$form =
new Form($db);
269if ($type ==
'bank-transfer') {
270 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'CreditTransfer');
273 $title = $langs->trans(
'InvoiceCustomer').
" - ".$langs->trans(
'StandingOrders');
274 $helpurl =
"EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
281 $selleruserevenustamp = $mysoc->useRevenueStamp();
283 $totalpaid =
$object->getSommePaiement();
284 $totalcreditnotes =
$object->getSumCreditNotesUsed();
285 $totaldeposits =
$object->getSumDepositsUsed();
292 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
297 $resteapayeraffiche = $resteapayer;
299 if ($type ==
'bank-transfer') {
301 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
302 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
304 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
305 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
308 $absolute_discount =
$object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount, 0, 1);
309 $absolute_creditnote =
$object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote, 0, 1);
310 $absolute_discount =
price2num($absolute_discount,
'MT');
311 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
314 $filterabsolutediscount =
"fk_facture_source IS NULL";
315 $filtercreditnote =
"fk_facture_source IS NOT NULL";
317 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
318 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
321 $absolute_discount =
$object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount);
322 $absolute_creditnote =
$object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote);
323 $absolute_discount =
price2num($absolute_discount,
'MT');
324 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
327 $author =
new User($db);
328 if (!empty(
$object->user_creation_id)) {
329 $author->fetch(
$object->user_creation_id);
330 } elseif (!empty(
$object->fk_user_author)) {
331 $author->fetch(
$object->fk_user_author);
334 if ($type ==
'bank-transfer') {
346 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
347 $sql .=
" , pfd.date_traite as date_traite";
348 $sql .=
" , pfd.amount";
349 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
350 if ($type ==
'bank-transfer') {
351 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
353 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
355 $sql .=
" AND pfd.traite = 0";
356 $sql .=
" AND pfd.type = 'ban'";
357 $sql .=
" ORDER BY pfd.date_demande DESC";
359 $resql = $db->query($sql);
361 $num = $db->num_rows($resql);
368 print
dol_get_fiche_head($head,
'standingorders', $title, -1, ($type ==
'bank-transfer' ?
'supplier_invoice' :
'bill'));
371 if ($type ==
'bank-transfer') {
372 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
374 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
377 $morehtmlref =
'<div class="refidno">';
379 if ($type ==
'bank-transfer') {
380 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, 0,
'string',
'', 0, 1);
381 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, 0,
'string',
'',
null,
null,
'', 1);
383 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_customer,
$object, 0,
'string',
'', 0, 1);
384 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client',
$object->ref_customer,
$object, 0,
'string',
'',
null,
null,
'', 1);
387 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
388 if ($type ==
'bank-transfer') {
390 $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>';
394 $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>';
398 if (isModEnabled(
'project')) {
399 $langs->load(
"projects");
400 $morehtmlref .=
'<br>';
402 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
403 if ($action !=
'classify') {
404 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
406 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
408 if (!empty(
$object->fk_project)) {
410 $proj->fetch(
$object->fk_project);
411 $morehtmlref .= $proj->getNomUrl(1);
413 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
418 $morehtmlref .=
'</div>';
420 $object->totalpaid = $totalpaid;
422 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $moreparam, 0,
'',
'');
424 print
'<div class="fichecenter">';
425 print
'<div class="fichehalfleft">';
426 print
'<div class="underbanner clearboth"></div>';
428 print
'<table class="border centpercent tableforfield">';
431 print
'<tr><td class="titlefield fieldname_type">'.$langs->trans(
'Type').
'</td><td colspan="3">';
432 print
'<span class="badgeneutral">';
435 if (!empty(
$object->module_source)) {
436 print
' <span class="opacitymediumbycolor paddingleft">('.$langs->trans(
"POS").
' '.
$object->module_source.
' - '.$langs->trans(
"Terminal").
' '.
$object->pos_source.
')</span>';
438 if (
$object->type == $object::TYPE_REPLACEMENT) {
439 if ($type ==
'bank-transfer') {
442 $facreplaced =
new Facture($db);
444 $facreplaced->fetch(
$object->fk_facture_source);
445 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
447 if (
$object->type == $object::TYPE_CREDIT_NOTE && !empty(
$object->fk_facture_source)) {
448 if ($type ==
'bank-transfer') {
453 $facusing->fetch(
$object->fk_facture_source);
454 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
457 $facidavoir =
$object->getListIdAvoirFromInvoice();
458 if (count($facidavoir) > 0) {
459 $invoicecredits = array();
460 foreach ($facidavoir as $facid) {
461 if ($type ==
'bank-transfer') {
466 $facavoir->fetch($facid);
467 $invoicecredits[] = $facavoir->getNomUrl(1);
469 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir");
470 print
' '. (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
483 print
'<!-- Discounts -->'.
"\n";
484 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining').
'</td><td colspan="3">';
486 if ($type ==
'bank-transfer') {
489 $thirdparty =
$object->thirdparty;
492 $thirdparty =
$object->thirdparty;
495 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id);
496 $cannotApplyDiscount = 1;
497 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
502 if ($type ==
'bank-transfer') {
504 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, 0).
'</td>';
505 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, 0).
'</td>';
511 print
'<table class="nobordernopadding centpercent"><tr><td>';
512 print $langs->trans(
'DateInvoice');
514 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editinvoicedate' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
515 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>';
517 print
'</tr></table>';
518 print
'</td><td colspan="3">';
520 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
521 if ($action ==
'editinvoicedate') {
522 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->date,
'invoicedate', 0, 0, 1, $type);
534 print
'<table class="nobordernopadding centpercent"><tr><td>';
535 print $langs->trans(
'PaymentConditionsShort');
537 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editconditions' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
538 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>';
540 print
'</tr></table>';
541 print
'</td><td colspan="3">';
542 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
543 if ($action ==
'editconditions') {
544 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 0, $type);
546 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none');
555 print
'<table class="nobordernopadding centpercent"><tr><td>';
556 print $langs->trans(
'DateMaxPayment');
558 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editpaymentterm' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
559 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>';
561 print
'</tr></table>';
562 print
'</td><td colspan="3">';
563 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
564 $duedate =
$object->date_lim_reglement;
565 if ($type ==
'bank-transfer') {
566 $duedate =
$object->date_echeance;
569 if ($action ==
'editpaymentterm') {
570 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $duedate,
'paymentterm', 0, 0, 1, $type);
584 print
'<table class="nobordernopadding centpercent"><tr><td>';
585 print $langs->trans(
'PaymentMode');
587 if ($action !=
'editmode' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
588 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>';
590 print
'</tr></table>';
591 print
'</td><td colspan="3">';
592 $filtertype =
'CRDT';
593 if ($type ==
'bank-transfer') {
594 $filtertype =
'DBIT';
596 if ($action ==
'editmode') {
597 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id', $filtertype, 1, 0, $type);
599 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
604 print
'<tr><td class="nowrap">';
605 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
606 print $langs->trans(
'BankAccount');
608 if (($action !=
'editbankaccount') && $user->hasRight(
'commande',
'creer') &&
$object->status == $object::STATUS_DRAFT) {
609 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>';
611 print
'</tr></table>';
612 print
'</td><td colspan="3">';
613 if ($action ==
'editbankaccount') {
614 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
616 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
623 print
'<div class="fichehalfright">';
624 print
'<div class="underbanner clearboth"></div>';
626 print
'<table class="border centpercent tableforfield">';
628 if (isModEnabled(
'multicurrency') && (
$object->multicurrency_code != $conf->currency)) {
630 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT',
'multicurrency_total_ht',
'',
$object, 0).
'</td>';
631 print
'<td class="nowrap">'.price(
$object->multicurrency_total_ht, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency)).
'</td>';
635 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT',
'multicurrency_total_tva',
'',
$object, 0).
'</td>';
636 print
'<td class="nowrap">'.price(
$object->multicurrency_total_tva, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency)).
'</td>';
640 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountTTC',
'multicurrency_total_ttc',
'',
$object, 0).
'</td>';
641 print
'<td class="nowrap">'.price(
$object->multicurrency_total_ttc, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency)).
'</td>';
646 print
'<tr><td class="titlefield">'.$langs->trans(
'AmountHT').
'</td>';
647 print
'<td class="nowrap right">'.price(
$object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
650 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td class="nowrap right">'.
price(
$object->total_tva, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
654 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
655 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
656 print
'<td class="nowrap right">'.price(
$object->total_localtax1, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
658 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
659 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
660 print
'<td class=nowrap right">'.price(
$object->total_localtax2, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
664 if ($selleruserevenustamp) {
666 print
'<table class="nobordernopadding centpercent"><tr><td>';
667 print $langs->trans(
'RevenueStamp');
669 if ($action !=
'editrevenuestamp' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
670 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>';
672 print
'</tr></table>';
673 print
'</td><td class="nowrap right">';
674 print
price(
$object->revenuestamp, 1,
'', 1, - 1, - 1, $conf->currency);
679 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td class="nowrap right">'.
price(
$object->total_ttc, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
681 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
684 $parameters = array(
'remaintopay' => $resteapayer);
685 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters,
$object, $action);
687 print $hookmanager->resPrint;
688 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
689 $resteapayer = $remaintopay;
694 print
'<tr><td>'.$langs->trans(
'RemainderToPay').
'</td><td class="nowrap right">'.
price($resteapayer, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
701 print
'<div class="clearboth"></div>';
709 $sql =
"SELECT SUM(pfd.amount) as amount";
710 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
711 if ($type ==
'bank-transfer') {
712 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
714 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
716 $sql .=
" AND pfd.traite = 0";
717 $sql .=
" AND pfd.type = 'ban'";
719 $resql = $db->query($sql);
721 $obj = $db->fetch_object($resql);
723 $pending = $obj->amount;
734 print
"\n".
'<div class="tabsAction">'.
"\n";
736 $buttonlabel = $langs->trans(
"MakeWithdrawRequest");
737 $user_perms = $user->hasRight(
'prelevement',
'bons',
'creer');
738 if ($type ==
'bank-transfer') {
739 $buttonlabel = $langs->trans(
"MakeBankTransferOrder");
740 $user_perms = $user->hasRight(
'paymentbybanktransfer',
'create');
744 if (
$object->status > $object::STATUS_DRAFT &&
$object->paid == 0 && $num == 0) {
745 if ($resteapayer > 0) {
747 $remaintopaylesspendingdebit = $resteapayer - $pending;
751 $title = $langs->trans(
"NewStandingOrder");
752 if ($type ==
'bank-transfer') {
753 $title = $langs->trans(
"NewPaymentByBankTransfer");
758 print
'<table class="border centpercent tableforfield">';
759 print
'<form method="POST" action="">';
760 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
761 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
762 print
'<input type="hidden" name="type" value="'.$type.
'" />';
763 print
'<input type="hidden" name="action" value="new" />';
764 print
'<tr><td class="titlefield">'.$langs->trans(
'CustomerIBAN').
'</td>';
765 print
'<td class="nowraponall">';
767 $ribList =
$object->thirdparty->get_all_rib();
768 $ribForSelection = [];
770 foreach ($ribList as $rib) {
771 $ribString = $rib->iban . (($rib->iban && $rib->bic) ?
' / ' :
'') . $rib->bic;
772 $ribForSelection[$rib->id] = $ribString;
773 if ($rib->default_rib == 1) {
774 $defaultRib = $ribString;
778 $selectedRib= $defaultRib;
779 $listeOfRibs =
GETPOST(
'ribList');
780 $selectedRib = $form->formIban(!empty($listeOfRibs) ? $listeOfRibs: $defaultRib,
'ribList', 0, $type, 0, $ribForSelection);
782 if (!empty($rib->iban)) {
783 if (!$rib->verif()) {
784 print
img_warning(
'Error on default bank number for IBAN : '.$langs->trans($rib->error));
786 } elseif ($numopen || ($type !=
'bank-transfer' &&
$object->mode_reglement_code ==
'PRE') || ($type ==
'bank-transfer' &&
$object->mode_reglement_code ==
'VIR')) {
787 print
img_warning($langs->trans(
"NoDefaultIBANFound"));
793 print
'<tr><td class="nowrap">';
794 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
795 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
796 print
'</td></tr></table>';
797 print
'</td><td colspan="3">';
798 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
804 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
813 $buttonlabel = $langs->trans(
"MakeWithdrawRequestStripe");
814 print
'<form method="POST" action="">';
815 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
816 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
817 print
'<input type="hidden" name="type" value="'.$type.
'" />';
818 print
'<input type="hidden" name="action" value="new" />';
819 print
'<input type="hidden" name="paymenservice" value="stripesepa" />';
820 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
821 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
822 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
825 print
'<div class="fichecenter">';
827 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$buttonlabel.
'</a>';
830 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AmountMustBePositive")).
'">'.$buttonlabel.
'</a>';
834 if (
$object->status > $object::STATUS_DRAFT) {
835 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AlreadyPaid")).
'">'.$buttonlabel.
'</a>';
837 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"Draft")).
'">'.$buttonlabel.
'</a>';
840 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"RequestAlreadyDone")).
'">'.$buttonlabel.
'</a>';
847 if ($type ==
'bank-transfer') {
848 print
'<div class="opacitymedium justify">'.$langs->trans(
"DoCreditTransferBeforePayments");
850 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
852 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
855 print
'<div class="opacitymedium justify">'.$langs->trans(
"DoStandingOrdersBeforePayments");
857 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
859 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
867 print
'<div class="div-table-responsive-no-min">';
868 print
'<table class="noborder centpercent">';
870 print
'<tr class="liste_titre">';
873 print
'<td> </td>';
875 print
'<td class="left">'.$langs->trans(
"DateRequest").
'</td>';
876 print
'<td>'.$langs->trans(
"User").
'</td>';
877 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
878 print
'<td class="center">'.$langs->trans(
"DateProcess").
'</td>';
879 print
'<td class="center">'.$langs->trans(
"CustomerIBAN").
'</td>';
880 if ($type ==
'bank-transfer') {
881 print
'<td class="center">'.$langs->trans(
"BankTransferReceipt").
'</td>';
883 print
'<td class="center">'.$langs->trans(
"WithdrawalReceipt").
'</td>';
885 print
'<td> </td>';
888 print
'<td> </td>';
892 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
893 $sql .=
" pfd.date_traite as date_traite, pfd.amount, pfd.fk_prelevement_bons,";
894 $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,";
895 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status,";
896 $sql .=
" sr.iban_prefix as iban, sr.bic as bic";
897 $sql .=
" FROM ".$db->prefix().
"prelevement_demande as pfd";
898 $sql .=
" LEFT JOIN ".$db->prefix().
"user as u on pfd.fk_user_demande = u.rowid";
899 $sql .=
" LEFT JOIN ".$db->prefix().
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
900 $sql .=
" LEFT JOIN ".$db->prefix().
"societe_rib as sr ON sr.rowid = pfd.fk_societe_rib";
901 if ($type ==
'bank-transfer') {
902 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
904 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
906 $sql .=
" AND pfd.traite = 0";
907 $sql .=
" AND pfd.type = 'ban'";
908 $sql .=
" ORDER BY pfd.date_demande DESC";
910 $resql = $db->query($sql);
916 $tmpuser =
new User($db);
918 $num = $db->num_rows($result);
920 $obj = $db->fetch_object($resql);
922 $tmpuser->id = $obj->user_id;
923 $tmpuser->login = $obj->login;
924 $tmpuser->ref = $obj->login;
925 $tmpuser->email = $obj->email;
926 $tmpuser->lastname = $obj->lastname;
927 $tmpuser->firstname = $obj->firstname;
928 $tmpuser->statut = $obj->user_status;
929 $tmpuser->status = $obj->user_status;
931 print
'<tr class="oddeven">';
935 print
'<td class="center">';
936 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
943 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'dayhour').
"</td>\n";
946 print
'<td class="tdoverflowmax125">';
947 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
951 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
954 print
'<td class="center"><span class="opacitymedium">'.$langs->trans(
"OrderWaiting").
'</span></td>';
957 print
'<td class="center"><span class="iban">' . $obj->iban.
" / ".$obj->bic .
'</span></td>';
960 print
'<td class="minwidth75">';
961 if ($obj->fk_prelevement_bons > 0) {
963 $withdrawreceipt->id = $obj->fk_prelevement_bons;
964 $withdrawreceipt->ref = $obj->ref;
965 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
966 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
967 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
968 $withdrawreceipt->statut = $obj->status;
969 $withdrawreceipt->status = $obj->status;
970 $withdrawreceipt->amount = $obj->pb_amount;
973 print $withdrawreceipt->getNomUrl(1);
976 if ($type !=
'bank-transfer') {
978 $langs->load(
"stripe");
979 if ($obj->fk_prelevement_bons > 0) {
982 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>';
986 $langs->load(
"stripe");
987 if ($obj->fk_prelevement_bons > 0) {
990 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>';
996 print
'<td class="center">-</td>';
1000 print
'<td class="center">';
1001 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
1018 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
1019 $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,";
1020 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status, u.photo as user_photo,";
1021 $sql .=
" sr.iban_prefix as iban, sr.bic as bic";
1022 $sql .=
" FROM ".$db->prefix().
"prelevement_demande as pfd";
1023 $sql .=
" LEFT JOIN ".$db->prefix().
"user as u on pfd.fk_user_demande = u.rowid";
1024 $sql .=
" LEFT JOIN ".$db->prefix().
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
1025 $sql .=
" LEFT JOIN ".$db->prefix().
"societe_rib as sr ON sr.rowid = pfd.fk_societe_rib";
1026 if ($type ==
'bank-transfer') {
1027 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
1029 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
1031 $sql .=
" AND pfd.traite = 1";
1032 $sql .=
" AND pfd.type = 'ban'";
1033 $sql .=
" ORDER BY pfd.date_demande DESC";
1035 $resql = $db->query($sql);
1037 $num = $db->num_rows($resql);
1041 $tmpuser =
new User($db);
1044 $obj = $db->fetch_object($resql);
1046 $tmpuser->id = $obj->user_id;
1047 $tmpuser->login = $obj->login;
1048 $tmpuser->ref = $obj->login;
1049 $tmpuser->email = $obj->email;
1050 $tmpuser->lastname = $obj->lastname;
1051 $tmpuser->firstname = $obj->firstname;
1052 $tmpuser->statut = $obj->user_status;
1053 $tmpuser->status = $obj->user_status;
1054 $tmpuser->photo = $obj->user_photo;
1056 print
'<tr class="oddeven">';
1060 print
'<td> </td>';
1064 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'day').
"</td>\n";
1067 print
'<td class="tdoverflowmax125">';
1068 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
1072 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
1075 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_traite),
'dayhour',
'tzuserrel').
"</td>\n";
1078 print
'<td class="center"><span class="iban">' . $obj->iban.
" / ".$obj->bic .
'</span></td>';
1081 print
'<td class="center minwidth75">';
1082 if ($obj->fk_prelevement_bons > 0) {
1084 $withdrawreceipt->id = $obj->fk_prelevement_bons;
1085 $withdrawreceipt->ref = $obj->ref;
1086 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
1087 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
1088 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
1089 $withdrawreceipt->statut = $obj->status;
1090 $withdrawreceipt->status = $obj->status;
1091 $withdrawreceipt->fk_bank_account = $obj->fk_bank_account;
1092 $withdrawreceipt->amount = $obj->pb_amount;
1095 print $withdrawreceipt->getNomUrl(1);
1097 print $withdrawreceipt->getLibStatut(2);
1100 $fk_bank_account = $withdrawreceipt->fk_bank_account;
1101 if (empty($fk_bank_account)) {
1102 $fk_bank_account = (
$object->type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
1104 if ($fk_bank_account > 0) {
1105 $bankaccount =
new Account($db);
1106 $result = $bankaccount->fetch($fk_bank_account);
1109 print $bankaccount->getNomUrl(1);
1116 print
'<td> </td>';
1120 print
'<td> </td>';
1127 if (!$numopen && !$numclosed) {
1128 print
'<tr class="oddeven"><td colspan="7"><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 suppliers invoices.
Class to manage invoices.
const STATUS_DRAFT
Draft status.
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.