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)) {
67 $ret =
$object->fetch($id, $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');
118 $result =
$object->demande_prelevement($user,
price2num(
GETPOST(
'withdraw_request_amount',
'alpha')), $newtype, $sourcetype);
132 if ($action ==
"delete" && $usercancreate) {
136 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id.
'&type='.$type);
143 if ($action ==
'sepastripedirectdebit' && $usercancreate) {
144 $result =
$object->makeStripeSepaRequest($user,
GETPOSTINT(
'did'),
'direct-debit',
'facture');
149 $ret =
$object->fetch($id, $ref);
158 if ($action ==
'sepastripecredittransfer' && $usercancreate) {
159 $result =
$object->makeStripeSepaRequest($user,
GETPOSTINT(
'did'),
'bank-transfer',
'supplier_invoice');
164 $ret =
$object->fetch($id, $ref);
173 if ($action ==
'setconditions' && $usercancreate) {
175 $object->cond_reglement_code = 0;
176 $object->cond_reglement_id = 0;
191 $old_date_echeance =
$object->date_echeance;
192 $new_date_echeance =
$object->calculate_date_lim_reglement();
193 if ($new_date_echeance > $old_date_echeance) {
194 $object->date_echeance = $new_date_echeance;
199 $result =
$object->update($user);
211 } elseif ($action ==
'setmode' && $usercancreate) {
214 } elseif ($action ==
'setdatef' && $usercancreate) {
218 setEventMessages($langs->trans(
"WarningInvoiceDateInFuture"),
null,
'warnings');
220 setEventMessages($langs->trans(
"WarningInvoiceDateTooFarInFuture"),
null,
'warnings');
225 $date_echence_calc =
$object->calculate_date_lim_reglement();
226 if (!empty(
$object->date_echeance) &&
$object->date_echeance < $date_echence_calc) {
227 $object->date_echeance = $date_echence_calc;
233 $result =
$object->update($user);
237 } elseif ($action ==
'setdate_lim_reglement' && $usercancreate) {
241 setEventMessages($langs->trans(
"DatePaymentTermCantBeLowerThanObjectDate"),
null,
'warnings');
243 $result =
$object->update($user);
255$form =
new Form($db);
259if ($type ==
'bank-transfer') {
260 $title = $langs->trans(
'SupplierInvoice').
" - ".$langs->trans(
'CreditTransfer');
263 $title = $langs->trans(
'InvoiceCustomer').
" - ".$langs->trans(
'StandingOrders');
264 $helpurl =
"EN:Customers_Invoices|FR:Factures_Clients|ES:Facturas_a_clientes";
271 $selleruserevenustamp = $mysoc->useRevenueStamp();
273 $totalpaid =
$object->getSommePaiement();
274 $totalcreditnotes =
$object->getSumCreditNotesUsed();
275 $totaldeposits =
$object->getSumDepositsUsed();
282 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
287 $resteapayeraffiche = $resteapayer;
289 if ($type ==
'bank-transfer') {
291 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL";
292 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL";
294 $filterabsolutediscount =
"fk_invoice_supplier_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS PAID)%')";
295 $filtercreditnote =
"fk_invoice_supplier_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS PAID)%')";
298 $absolute_discount =
$object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount, 0, 1);
299 $absolute_creditnote =
$object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote, 0, 1);
300 $absolute_discount =
price2num($absolute_discount,
'MT');
301 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
304 $filterabsolutediscount =
"fk_facture_source IS NULL";
305 $filtercreditnote =
"fk_facture_source IS NOT NULL";
307 $filterabsolutediscount =
"fk_facture_source IS NULL OR (description LIKE '(DEPOSIT)%' AND description NOT LIKE '(EXCESS RECEIVED)%')";
308 $filtercreditnote =
"fk_facture_source IS NOT NULL AND (description NOT LIKE '(DEPOSIT)%' OR description LIKE '(EXCESS RECEIVED)%')";
311 $absolute_discount =
$object->thirdparty->getAvailableDiscounts(
'', $filterabsolutediscount);
312 $absolute_creditnote =
$object->thirdparty->getAvailableDiscounts(
'', $filtercreditnote);
313 $absolute_discount =
price2num($absolute_discount,
'MT');
314 $absolute_creditnote =
price2num($absolute_creditnote,
'MT');
317 $author =
new User($db);
318 if (!empty(
$object->user_creation_id)) {
319 $author->fetch(
$object->user_creation_id);
320 } elseif (!empty(
$object->fk_user_author)) {
321 $author->fetch(
$object->fk_user_author);
324 if ($type ==
'bank-transfer') {
336 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande";
337 $sql .=
" , pfd.date_traite as date_traite";
338 $sql .=
" , pfd.amount";
339 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
340 if ($type ==
'bank-transfer') {
341 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
343 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
345 $sql .=
" AND pfd.traite = 0";
346 $sql .=
" AND pfd.type = 'ban'";
347 $sql .=
" ORDER BY pfd.date_demande DESC";
349 $resql = $db->query($sql);
351 $num = $db->num_rows($resql);
358 print
dol_get_fiche_head($head,
'standingorders', $title, -1, ($type ==
'bank-transfer' ?
'supplier_invoice' :
'bill'));
361 if ($type ==
'bank-transfer') {
362 $linkback =
'<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
364 $linkback =
'<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?restore_lastsearch_values=1'.(!empty($socid) ?
'&socid='.$socid :
'').
'">'.$langs->trans(
"BackToList").
'</a>';
367 $morehtmlref =
'<div class="refidno">';
369 if ($type ==
'bank-transfer') {
370 $morehtmlref .= $form->editfieldkey(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, 0,
'string',
'', 0, 1);
371 $morehtmlref .= $form->editfieldval(
"RefSupplierBill",
'ref_supplier',
$object->ref_supplier,
$object, 0,
'string',
'',
null,
null,
'', 1);
373 $morehtmlref .= $form->editfieldkey(
"RefCustomer",
'ref_client',
$object->ref_customer,
$object, 0,
'string',
'', 0, 1);
374 $morehtmlref .= $form->editfieldval(
"RefCustomer",
'ref_client',
$object->ref_customer,
$object, 0,
'string',
'',
null,
null,
'', 1);
377 $morehtmlref .=
'<br>'.$object->thirdparty->getNomUrl(1);
378 if ($type ==
'bank-transfer') {
380 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/fourn/facture/list.php?socid='.
$object->thirdparty->id.
'&search_company='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
384 $morehtmlref .=
' (<a href="'.DOL_URL_ROOT.
'/compta/facture/list.php?socid='.
$object->thirdparty->id.
'&search_company='.urlencode(
$object->thirdparty->name).
'">'.$langs->trans(
"OtherBills").
'</a>)';
388 if (isModEnabled(
'project')) {
389 $langs->load(
"projects");
390 $morehtmlref .=
'<br>';
392 $morehtmlref .=
img_picto($langs->trans(
"Project"),
'project',
'class="pictofixedwidth"');
393 if ($action !=
'classify') {
394 $morehtmlref .=
'<a class="editfielda" href="'.$_SERVER[
'PHP_SELF'].
'?action=classify&token='.
newToken().
'&id='.
$object->id.
'">'.
img_edit($langs->transnoentitiesnoconv(
'SetProject')).
'</a> ';
396 $morehtmlref .= $form->form_project($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->socid,
$object->fk_project, ($action ==
'classify' ?
'projectid' :
'none'), 0, 0, 0, 1,
'',
'maxwidth300');
398 if (!empty(
$object->fk_project)) {
400 $proj->fetch(
$object->fk_project);
401 $morehtmlref .= $proj->getNomUrl(1);
403 $morehtmlref .=
'<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).
'</span>';
408 $morehtmlref .=
'</div>';
410 $object->totalpaid = $totalpaid;
412 dol_banner_tab(
$object,
'ref', $linkback, 1,
'ref',
'ref', $morehtmlref, $moreparam, 0,
'',
'');
414 print
'<div class="fichecenter">';
415 print
'<div class="fichehalfleft">';
416 print
'<div class="underbanner clearboth"></div>';
418 print
'<table class="border centpercent tableforfield">';
421 print
'<tr><td class="titlefield fieldname_type">'.$langs->trans(
'Type').
'</td><td colspan="3">';
422 print
'<span class="badgeneutral">';
425 if (!empty(
$object->module_source)) {
426 print
' <span class="opacitymediumbycolor paddingleft">('.$langs->trans(
"POS").
' '.
$object->module_source.
' - '.$langs->trans(
"Terminal").
' '.
$object->pos_source.
')</span>';
428 if (
$object->type == $object::TYPE_REPLACEMENT) {
429 if ($type ==
'bank-transfer') {
432 $facreplaced =
new Facture($db);
434 $facreplaced->fetch(
$object->fk_facture_source);
435 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"ReplaceInvoice", $facreplaced->getNomUrl(1)).
'</span>';
437 if (
$object->type == $object::TYPE_CREDIT_NOTE && !empty(
$object->fk_facture_source)) {
438 if ($type ==
'bank-transfer') {
443 $facusing->fetch(
$object->fk_facture_source);
444 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"CorrectInvoice", $facusing->getNomUrl(1)).
'</span>';
447 $facidavoir =
$object->getListIdAvoirFromInvoice();
448 if (count($facidavoir) > 0) {
449 $invoicecredits = array();
450 foreach ($facidavoir as $facid) {
451 if ($type ==
'bank-transfer') {
456 $facavoir->fetch($facid);
457 $invoicecredits[] = $facavoir->getNomUrl(1);
459 print
' <span class="opacitymediumbycolor paddingleft">'.$langs->transnoentities(
"InvoiceHasAvoir");
460 print
' '. (count($invoicecredits) ?
' ' :
'') . implode(
',', $invoicecredits);
473 print
'<!-- Discounts -->'.
"\n";
474 print
'<tr><td>'.$langs->trans(
'DiscountStillRemaining').
'</td><td colspan="3">';
476 if ($type ==
'bank-transfer') {
479 $thirdparty =
$object->thirdparty;
482 $thirdparty =
$object->thirdparty;
485 $backtopage = urlencode($_SERVER[
"PHP_SELF"].
'?facid='.
$object->id);
486 $cannotApplyDiscount = 1;
487 include DOL_DOCUMENT_ROOT.
'/core/tpl/object_discounts.tpl.php';
492 if ($type ==
'bank-transfer') {
494 print
'<td>'.$form->editfieldkey(
"Label",
'label',
$object->label,
$object, 0).
'</td>';
495 print
'<td>'.$form->editfieldval(
"Label",
'label',
$object->label,
$object, 0).
'</td>';
501 print
'<table class="nobordernopadding centpercent"><tr><td>';
502 print $langs->trans(
'DateInvoice');
504 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editinvoicedate' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
505 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>';
507 print
'</tr></table>';
508 print
'</td><td colspan="3">';
510 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
511 if ($action ==
'editinvoicedate') {
512 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->date,
'invoicedate', 0, 0, 1, $type);
524 print
'<table class="nobordernopadding centpercent"><tr><td>';
525 print $langs->trans(
'PaymentConditionsShort');
527 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editconditions' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
528 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>';
530 print
'</tr></table>';
531 print
'</td><td colspan="3">';
532 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
533 if ($action ==
'editconditions') {
534 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'cond_reglement_id', 0, $type);
536 $form->form_conditions_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->cond_reglement_id,
'none');
545 print
'<table class="nobordernopadding centpercent"><tr><td>';
546 print $langs->trans(
'DateMaxPayment');
548 if (
$object->type != $object::TYPE_CREDIT_NOTE && $action !=
'editpaymentterm' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
549 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>';
551 print
'</tr></table>';
552 print
'</td><td colspan="3">';
553 if (
$object->type != $object::TYPE_CREDIT_NOTE) {
554 $duedate =
$object->date_lim_reglement;
555 if ($type ==
'bank-transfer') {
556 $duedate =
$object->date_echeance;
559 if ($action ==
'editpaymentterm') {
560 print $form->form_date($_SERVER[
'PHP_SELF'].
'?id='.
$object->id, $duedate,
'paymentterm', 0, 0, 1, $type);
574 print
'<table class="nobordernopadding centpercent"><tr><td>';
575 print $langs->trans(
'PaymentMode');
577 if ($action !=
'editmode' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
578 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>';
580 print
'</tr></table>';
581 print
'</td><td colspan="3">';
582 $filtertype =
'CRDT';
583 if ($type ==
'bank-transfer') {
584 $filtertype =
'DBIT';
586 if ($action ==
'editmode') {
587 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'mode_reglement_id', $filtertype, 1, 0, $type);
589 $form->form_modes_reglement($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->mode_reglement_id,
'none');
594 print
'<tr><td class="nowrap">';
595 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
596 print $langs->trans(
'BankAccount');
598 if (($action !=
'editbankaccount') && $user->hasRight(
'commande',
'creer') &&
$object->status == $object::STATUS_DRAFT) {
599 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>';
601 print
'</tr></table>';
602 print
'</td><td colspan="3">';
603 if ($action ==
'editbankaccount') {
604 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'fk_account', 1);
606 $form->formSelectAccount($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->fk_account,
'none');
612 $title =
'CustomerIBAN';
613 if ($type ==
'bank-transfer') {
614 $title =
'SupplierIBAN';
616 print
'<tr><td>'.$langs->trans($title).
'</td><td colspan="3">';
620 $bac->fetch(0,
'',
$object->thirdparty->id);
622 print $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
623 if (!empty($bac->iban)) {
624 if ($bac->verif() <= 0) {
625 print
img_warning(
'Error on default bank number for IBAN : '.$bac->error);
628 if ($numopen || ($type !=
'bank-transfer' &&
$object->mode_reglement_code ==
'PRE') || ($type ==
'bank-transfer' &&
$object->mode_reglement_code ==
'VIR')) {
629 print
img_warning($langs->trans(
"NoDefaultIBANFound"));
638 print
'<div class="fichehalfright">';
639 print
'<div class="underbanner clearboth"></div>';
641 print
'<table class="border centpercent tableforfield">';
643 if (isModEnabled(
'multicurrency') && (
$object->multicurrency_code != $conf->currency)) {
645 print
'<tr><td class="titlefieldmiddle">'.$form->editfieldkey(
'MulticurrencyAmountHT',
'multicurrency_total_ht',
'',
$object, 0).
'</td>';
646 print
'<td class="nowrap">'.price(
$object->multicurrency_total_ht, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency)).
'</td>';
650 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountVAT',
'multicurrency_total_tva',
'',
$object, 0).
'</td>';
651 print
'<td class="nowrap">'.price(
$object->multicurrency_total_tva, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency)).
'</td>';
655 print
'<tr><td>'.$form->editfieldkey(
'MulticurrencyAmountTTC',
'multicurrency_total_ttc',
'',
$object, 0).
'</td>';
656 print
'<td class="nowrap">'.price(
$object->multicurrency_total_ttc, 0, $langs, 0, - 1, - 1, (!empty(
$object->multicurrency_code) ?
$object->multicurrency_code : $conf->currency)).
'</td>';
661 print
'<tr><td class="titlefield">'.$langs->trans(
'AmountHT').
'</td>';
662 print
'<td class="nowrap right">'.price(
$object->total_ht, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
665 print
'<tr><td>'.$langs->trans(
'AmountVAT').
'</td><td class="nowrap right">'.
price(
$object->total_tva, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
669 if (($mysoc->localtax1_assuj ==
"1" && $mysoc->useLocalTax(1)) ||
$object->total_localtax1 != 0) {
670 print
'<tr><td>'.$langs->transcountry(
"AmountLT1", $mysoc->country_code).
'</td>';
671 print
'<td class="nowrap right">'.price(
$object->total_localtax1, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
673 if (($mysoc->localtax2_assuj ==
"1" && $mysoc->useLocalTax(2)) ||
$object->total_localtax2 != 0) {
674 print
'<tr><td>'.$langs->transcountry(
"AmountLT2", $mysoc->country_code).
'</td>';
675 print
'<td class=nowrap right">'.price(
$object->total_localtax2, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
679 if ($selleruserevenustamp) {
681 print
'<table class="nobordernopadding centpercent"><tr><td>';
682 print $langs->trans(
'RevenueStamp');
684 if ($action !=
'editrevenuestamp' &&
$object->status == $object::STATUS_DRAFT && $user->hasRight(
'facture',
'creer')) {
685 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>';
687 print
'</tr></table>';
688 print
'</td><td class="nowrap right">';
689 print
price(
$object->revenuestamp, 1,
'', 1, - 1, - 1, $conf->currency);
694 print
'<tr><td>'.$langs->trans(
'AmountTTC').
'</td><td class="nowrap right">'.
price(
$object->total_ttc, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
696 $resteapayer =
price2num(
$object->total_ttc - $totalpaid - $totalcreditnotes - $totaldeposits,
'MT');
699 $parameters = array(
'remaintopay' => $resteapayer);
700 $reshook = $hookmanager->executeHooks(
'finalizeAmountOfInvoice', $parameters,
$object, $action);
702 print $hookmanager->resPrint;
703 if (!empty($remaintopay = $hookmanager->resArray[
'remaintopay'])) {
704 $resteapayer = $remaintopay;
709 print
'<tr><td>'.$langs->trans(
'RemainderToPay').
'</td><td class="nowrap right">'.
price($resteapayer, 1,
'', 1, - 1, - 1, $conf->currency).
'</td></tr>';
716 print
'<div class="clearboth"></div>';
724 $sql =
"SELECT SUM(pfd.amount) as amount";
725 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
726 if ($type ==
'bank-transfer') {
727 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
729 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
731 $sql .=
" AND pfd.traite = 0";
732 $sql .=
" AND pfd.type = 'ban'";
734 $resql = $db->query($sql);
736 $obj = $db->fetch_object($resql);
738 $pending = $obj->amount;
749 print
"\n".
'<div class="tabsAction">'.
"\n";
751 $buttonlabel = $langs->trans(
"MakeWithdrawRequest");
752 $user_perms = $user->hasRight(
'prelevement',
'bons',
'creer');
753 if ($type ==
'bank-transfer') {
754 $buttonlabel = $langs->trans(
"MakeBankTransferOrder");
755 $user_perms = $user->hasRight(
'paymentbybanktransfer',
'create');
759 if (
$object->status > $object::STATUS_DRAFT &&
$object->paid == 0 && $num == 0) {
760 if ($resteapayer > 0) {
762 $remaintopaylesspendingdebit = $resteapayer - $pending;
764 print
'<form method="POST" action="">';
765 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
766 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
767 print
'<input type="hidden" name="type" value="'.$type.
'" />';
768 print
'<input type="hidden" name="action" value="new" />';
769 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
770 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
771 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
778 $buttonlabel = $langs->trans(
"MakeWithdrawRequestStripe");
779 print
'<form method="POST" action="">';
780 print
'<input type="hidden" name="token" value="'.newToken().
'" />';
781 print
'<input type="hidden" name="id" value="'.$object->id.
'" />';
782 print
'<input type="hidden" name="type" value="'.$type.
'" />';
783 print
'<input type="hidden" name="action" value="new" />';
784 print
'<input type="hidden" name="paymenservice" value="stripesepa" />';
785 print
'<label for="withdraw_request_amount">'.$langs->trans(
'BankTransferAmount').
' </label>';
786 print
'<input type="text" id="withdraw_request_amount" name="withdraw_request_amount" value="'.$remaintopaylesspendingdebit.
'" size="9" />';
787 print
'<input type="submit" class="butAction" value="'.$buttonlabel.
'" />';
791 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"NotEnoughPermissions")).
'">'.$buttonlabel.
'</a>';
794 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AmountMustBePositive")).
'">'.$buttonlabel.
'</a>';
798 if (
$object->status > $object::STATUS_DRAFT) {
799 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"AlreadyPaid")).
'">'.$buttonlabel.
'</a>';
801 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"Draft")).
'">'.$buttonlabel.
'</a>';
804 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans(
"RequestAlreadyDone")).
'">'.$buttonlabel.
'</a>';
811 if ($type ==
'bank-transfer') {
812 print
'<div class="opacitymedium justify">'.$langs->trans(
"DoCreditTransferBeforePayments");
814 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
816 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
819 print
'<div class="opacitymedium justify">'.$langs->trans(
"DoStandingOrdersBeforePayments");
821 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments2");
823 print
' '.$langs->trans(
"DoStandingOrdersBeforePayments3");
831 print
'<div class="div-table-responsive-no-min">';
832 print
'<table class="noborder centpercent">';
834 print
'<tr class="liste_titre">';
837 print
'<td> </td>';
839 print
'<td class="left">'.$langs->trans(
"DateRequest").
'</td>';
840 print
'<td>'.$langs->trans(
"User").
'</td>';
841 print
'<td class="center">'.$langs->trans(
"Amount").
'</td>';
842 print
'<td class="center">'.$langs->trans(
"DateProcess").
'</td>';
843 if ($type ==
'bank-transfer') {
844 print
'<td class="center">'.$langs->trans(
"BankTransferReceipt").
'</td>';
846 print
'<td class="center">'.$langs->trans(
"WithdrawalReceipt").
'</td>';
848 print
'<td> </td>';
851 print
'<td> </td>';
855 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
856 $sql .=
" pfd.date_traite as date_traite, pfd.amount, pfd.fk_prelevement_bons,";
857 $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,";
858 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
859 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
860 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on pfd.fk_user_demande = u.rowid";
861 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
862 if ($type ==
'bank-transfer') {
863 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
865 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
867 $sql .=
" AND pfd.traite = 0";
868 $sql .=
" AND pfd.type = 'ban'";
869 $sql .=
" ORDER BY pfd.date_demande DESC";
871 $resql = $db->query($sql);
877 $tmpuser =
new User($db);
879 $num = $db->num_rows($result);
881 $obj = $db->fetch_object($resql);
883 $tmpuser->id = $obj->user_id;
884 $tmpuser->login = $obj->login;
885 $tmpuser->ref = $obj->login;
886 $tmpuser->email = $obj->email;
887 $tmpuser->lastname = $obj->lastname;
888 $tmpuser->firstname = $obj->firstname;
889 $tmpuser->statut = $obj->user_status;
890 $tmpuser->status = $obj->user_status;
892 print
'<tr class="oddeven">';
896 print
'<td class="center">';
897 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
904 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'dayhour').
"</td>\n";
907 print
'<td class="tdoverflowmax125">';
908 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
912 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
915 print
'<td class="center"><span class="opacitymedium">'.$langs->trans(
"OrderWaiting").
'</span></td>';
918 print
'<td class="minwidth75">';
919 if ($obj->fk_prelevement_bons > 0) {
921 $withdrawreceipt->id = $obj->fk_prelevement_bons;
922 $withdrawreceipt->ref = $obj->ref;
923 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
924 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
925 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
926 $withdrawreceipt->statut = $obj->status;
927 $withdrawreceipt->status = $obj->status;
928 $withdrawreceipt->amount = $obj->pb_amount;
931 print $withdrawreceipt->getNomUrl(1);
934 if ($type !=
'bank-transfer') {
936 $langs->load(
"stripe");
937 if ($obj->fk_prelevement_bons > 0) {
940 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>';
944 $langs->load(
"stripe");
945 if ($obj->fk_prelevement_bons > 0) {
948 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>';
954 print
'<td class="center">-</td>';
958 print
'<td class="center">';
959 print
'<a href="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&did='.$obj->rowid.
'&type='.urlencode($type).
'">';
976 $sql =
"SELECT pfd.rowid, pfd.traite, pfd.date_demande, pfd.date_traite, pfd.fk_prelevement_bons, pfd.amount,";
977 $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,";
978 $sql .=
" u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status, u.photo as user_photo";
979 $sql .=
" FROM ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
980 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on pfd.fk_user_demande = u.rowid";
981 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
982 if ($type ==
'bank-transfer') {
983 $sql .=
" WHERE fk_facture_fourn = ".((int)
$object->id);
985 $sql .=
" WHERE fk_facture = ".((int)
$object->id);
987 $sql .=
" AND pfd.traite = 1";
988 $sql .=
" AND pfd.type = 'ban'";
989 $sql .=
" ORDER BY pfd.date_demande DESC";
991 $resql = $db->query($sql);
993 $num = $db->num_rows($resql);
997 $tmpuser =
new User($db);
1000 $obj = $db->fetch_object($resql);
1002 $tmpuser->id = $obj->user_id;
1003 $tmpuser->login = $obj->login;
1004 $tmpuser->ref = $obj->login;
1005 $tmpuser->email = $obj->email;
1006 $tmpuser->lastname = $obj->lastname;
1007 $tmpuser->firstname = $obj->firstname;
1008 $tmpuser->statut = $obj->user_status;
1009 $tmpuser->status = $obj->user_status;
1010 $tmpuser->photo = $obj->user_photo;
1012 print
'<tr class="oddeven">';
1016 print
'<td> </td>';
1020 print
'<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande),
'day').
"</td>\n";
1023 print
'<td class="tdoverflowmax125">';
1024 print $tmpuser->getNomUrl(-1,
'', 0, 0, 0, 0,
'login');
1028 print
'<td class="center"><span class="amount">'.price($obj->amount).
'</span></td>';
1031 print
'<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_traite),
'dayhour',
'tzuserrel').
"</td>\n";
1034 print
'<td class="center minwidth75">';
1035 if ($obj->fk_prelevement_bons > 0) {
1037 $withdrawreceipt->id = $obj->fk_prelevement_bons;
1038 $withdrawreceipt->ref = $obj->ref;
1039 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
1040 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
1041 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
1042 $withdrawreceipt->statut = $obj->status;
1043 $withdrawreceipt->status = $obj->status;
1044 $withdrawreceipt->fk_bank_account = $obj->fk_bank_account;
1045 $withdrawreceipt->amount = $obj->pb_amount;
1048 print $withdrawreceipt->getNomUrl(1);
1050 print $withdrawreceipt->getLibStatut(2);
1053 $fk_bank_account = $withdrawreceipt->fk_bank_account;
1054 if (empty($fk_bank_account)) {
1055 $fk_bank_account = (
$object->type ==
'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
1057 if ($fk_bank_account > 0) {
1058 $bankaccount =
new Account($db);
1059 $result = $bankaccount->fetch($fk_bank_account);
1062 print $bankaccount->getNomUrl(1);
1069 print
'<td> </td>';
1073 print
'<td> </td>';
1080 if (!$numopen && !$numclosed) {
1081 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()
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 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...
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 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.