31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
41 $langs->loadLangs(array(
'banks',
'categories',
'withdrawals',
'companies',
'bills'));
43 $type =
GETPOST(
'type',
'aZ09');
46 $action =
GETPOST(
'action',
'aZ09');
47 $massaction =
GETPOST(
'massaction',
'alpha');
48 $toselect =
GETPOST(
'toselect',
'array');
50 $mode =
GETPOST(
'mode',
'alpha') ?
GETPOST(
'mode',
'alpha') :
'real';
51 $format =
GETPOST(
'format',
'aZ09');
52 $id_bankaccount =
GETPOST(
'id_bankaccount',
'int');
55 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
57 if (empty($page) || $page == -1) {
60 $offset = $limit * $page;
62 $hookmanager->initHooks(array(
'directdebitcreatecard',
'globalcard'));
65 $socid =
GETPOST(
'socid',
'int');
67 $socid = $user->socid;
69 if ($type ==
'bank-transfer') {
70 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
82 if (
GETPOST(
'cancel',
'alpha')) {
86 $parameters = array(
'mode' => $mode,
'format' => $format,
'limit' => $limit,
'page' => $page,
'offset' => $offset);
87 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
92 if (empty($reshook)) {
94 if ($action ==
'modify') {
95 for ($i = 1; $i < 9; $i++) {
99 if ($action ==
'create') {
100 $default_account = ($type ==
'bank-transfer' ?
'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' :
'PRELEVEMENT_ID_BANKACCOUNT');
104 if ($id_bankaccount != $conf->global->$default_account) {
105 $res =
dolibarr_set_const($db, $default_account, $id_bankaccount,
'chaine', 0,
'', $conf->entity);
108 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
110 $bank->fetch($conf->global->{$default_account});
115 if (empty($bank->ics) && $type !==
'bank-transfer') {
116 $errormessage = str_replace(
'{url}', $bank->getNomUrl(1,
'',
'', -1, 1), $langs->trans(
"ErrorICSmissing",
'{url}'));
127 $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
130 } elseif ($result == 0) {
131 $mesg = $langs->trans(
"NoInvoiceCouldBeWithdrawed", $format);
133 $mesg .=
'<br>'.
"\n";
134 foreach ($bprev->invoice_in_error as $key => $val) {
135 $mesg .=
'<span class="warning">'.$val.
"</span><br>\n";
138 if ($type !=
'bank-transfer') {
139 $texttoshow = $langs->trans(
"DirectDebitOrderCreated",
'{s}');
140 $texttoshow = str_replace(
'{s}', $bprev->getNomUrl(1), $texttoshow);
143 $texttoshow = $langs->trans(
"CreditTransferOrderCreated",
'{s}');
144 $texttoshow = str_replace(
'{s}', $bprev->getNomUrl(1), $texttoshow);
148 header(
"Location: ".DOL_URL_ROOT.
'/compta/prelevement/card.php?id='.urlencode($bprev->id).
'&type='.urlencode($type));
153 $objectclass =
"BonPrelevement";
154 if ($type ==
'bank-transfer') {
155 $uploaddir = $conf->paymentbybanktransfer->dir_output;
157 $uploaddir = $conf->prelevement->dir_output;
159 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
169 $thirdpartystatic =
new Societe($db);
170 if ($type !=
'bank-transfer') {
171 $invoicestatic =
new Facture($db);
176 $arrayofselected = is_array($toselect) ? $toselect : array();
178 $arrayofmassactions = array(
180 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
181 $arrayofmassactions = array();
183 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
185 llxHeader(
'', $langs->trans(
"NewStandingOrder"));
188 $langs->load(
"errors");
189 $modulenametoshow =
"Withdraw";
190 if ($type ==
'bank-transfer') {
191 $modulenametoshow =
"PaymentByBankTransfer";
193 setEventMessages($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv($modulenametoshow)),
null,
'errors');
207 $title = $langs->trans(
"NewStandingOrder");
208 if ($type ==
'bank-transfer') {
209 $title = $langs->trans(
"NewPaymentByBankTransfer");
216 $nb = $bprev->nbOfInvoiceToPay($type);
217 $pricetowithdraw = $bprev->SommeAPrelever($type);
221 print
'<table class="border centpercent tableforfield">';
223 $title = $langs->trans(
"NbOfInvoiceToWithdraw");
224 if ($type ==
'bank-transfer') {
225 $title = $langs->trans(
"NbOfInvoiceToPayByBankTransfer");
228 print
'<tr><td class="titlefieldcreate">'.$title.
'</td>';
233 print
'<tr><td>'.$langs->trans(
"AmountTotal").
'</td>';
234 print
'<td class="amount">';
235 print
price($pricetowithdraw);
246 print
'<div class="tabsAction">'.
"\n";
248 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?action=create" method="POST">';
249 print
'<input type="hidden" name="token" value="'.newToken().
'">';
250 print
'<input type="hidden" name="type" value="'.$type.
'">';
252 if ($pricetowithdraw) {
253 $title = $langs->trans(
'BankToReceiveWithdraw').
': ';
254 if ($type ==
'bank-transfer') {
255 $title = $langs->trans(
'BankToPayCreditTransfer').
': ';
260 $default_account = ($type ==
'bank-transfer' ?
'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' :
'PRELEVEMENT_ID_BANKACCOUNT');
262 print
$form->select_comptes($conf->global->$default_account,
'id_bankaccount', 0,
"courant=1", 0,
'', 0,
'', 1);
265 if (empty($executiondate)) {
267 if ($type !=
'bank-transfer') {
268 $delayindays = $conf->global->PRELEVEMENT_ADDDAYS;
270 $delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
276 print $langs->trans(
'ExecutionDate').
' ';
277 $datere = $executiondate;
278 print
$form->selectDate($datere,
're');
281 if ($mysoc->isInEEC()) {
282 $title = $langs->trans(
"CreateForSepa");
283 if ($type ==
'bank-transfer') {
284 $title = $langs->trans(
"CreateSepaFileForPaymentByBankTransfer");
287 if ($type !=
'bank-transfer') {
288 print
'<select name="format">';
289 print
'<option value="FRST"'.($format ==
'FRST' ?
' selected="selected"' :
'').
'>'.$langs->trans(
'SEPAFRST').
'</option>';
290 print
'<option value="RCUR"'.($format ==
'RCUR' ?
' selected="selected"' :
'').
'>'.$langs->trans(
'SEPARCUR').
'</option>';
293 print
'<input type="submit" class="butAction" value="'.$title.
'"/>';
295 $title = $langs->trans(
"CreateAll");
296 if ($type ==
'bank-transfer') {
297 $title = $langs->trans(
"CreateFileForPaymentByBankTransfer");
299 print
'<input type="hidden" name="format" value="ALL">'.
"\n";
300 print
'<input type="submit" class="butAction" value="'.$title.
'">'.
"\n";
303 if ($mysoc->isInEEC()) {
304 $title = $langs->trans(
"CreateForSepaFRST");
305 if ($type ==
'bank-transfer') {
306 $title = $langs->trans(
"CreateSepaFileForPaymentByBankTransfer");
308 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"AmountMustBePositive").
'">'.$title.
"</a>\n";
310 if ($type !=
'bank-transfer') {
311 $title = $langs->trans(
"CreateForSepaRCUR");
312 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"AmountMustBePositive").
'">'.$title.
"</a>\n";
315 $title = $langs->trans(
"CreateAll");
316 if ($type ==
'bank-transfer') {
317 $title = $langs->trans(
"CreateFileForPaymentByBankTransfer");
319 print
'<a class="butActionRefused classfortooltip" href="#">'.$title.
"</a>\n";
323 $titlefortab = $langs->transnoentitiesnoconv(
"StandingOrders");
324 $title = $langs->trans(
"CreateAll");
325 if ($type ==
'bank-transfer') {
326 $titlefortab = $langs->transnoentitiesnoconv(
"PaymentByBankTransfers");
327 $title = $langs->trans(
"CreateFileForPaymentByBankTransfer");
329 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NoInvoiceToWithdraw", $titlefortab, $titlefortab)).
'">'.$title.
"</a>\n";
343 $sql =
"SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,";
344 $sql .=
" pfd.rowid as request_row_id, pfd.date_demande, pfd.amount";
345 if ($type ==
'bank-transfer') {
346 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
348 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
350 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
351 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_demande as pfd";
352 $sql .=
" WHERE s.rowid = f.fk_soc";
353 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
354 if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
355 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
358 $sql .=
" AND f.total_ttc > 0";
359 $sql .=
" AND pfd.traite = 0";
360 $sql .=
" AND pfd.ext_payment_id IS NULL";
361 if ($type ==
'bank-transfer') {
362 $sql .=
" AND pfd.fk_facture_fourn = f.rowid";
364 $sql .=
" AND pfd.fk_facture = f.rowid";
367 $sql .=
" AND f.fk_soc = ".((int) $socid);
371 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
372 $result = $db->query($sql);
381 $sql .= $db->plimit($limit + 1, $offset);
383 $resql = $db->query($sql);
385 $num = $db->num_rows(
$resql);
389 if ($limit > 0 && $limit != $conf->liste_limit) {
390 $param .=
'&limit='.urlencode($limit);
393 $param .=
'&socid='.urlencode($socid);
396 $param .=
"&option=".urlencode($option);
399 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
400 print
'<input type="hidden" name="token" value="'.newToken().
'">';
401 print
'<input type="hidden" name="page" value="'.$page.
'">';
402 if (!empty($limit)) {
403 print
'<input type="hidden" name="limit" value="'.$limit.
'"/>';
406 print
'<input type="hidden" name="type" value="'.$type.
'">';
409 $title = $langs->trans(
"InvoiceWaitingWithdraw");
410 if ($type ==
'bank-transfer') {
411 $title = $langs->trans(
"InvoiceWaitingPaymentByBankTransfer");
413 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $param,
'',
'', $massactionbutton, $num,
$nbtotalofrecords,
'bill', 0,
'',
'', $limit);
415 $tradinvoice =
"Invoice";
416 if ($type ==
'bank-transfer') {
417 $tradinvoice =
"SupplierInvoice";
420 print
'<table class="noborder centpercent">';
421 print
'<tr class="liste_titre">';
422 print
'<td>'.$langs->trans($tradinvoice).
'</td>';
423 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
424 print
'<td>'.$langs->trans(
"RIB").
'</td>';
425 print
'<td>'.$langs->trans(
"RUM").
'</td>';
426 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
427 print
'<td class="right">'.$langs->trans(
"DateRequest").
'</td>';
428 if ($massactionbutton || $massaction) {
429 print
'<td align="center">'.$form->showCheckAddButtons(
'checkforselect', 1).
'</td>';
434 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
437 while ($i < $num && $i < $limit) {
438 $obj = $db->fetch_object(
$resql);
440 $bac->fetch(0, $obj->socid);
442 print
'<tr class="oddeven">';
446 $invoicestatic->id = $obj->rowid;
447 $invoicestatic->ref = $obj->ref;
448 print $invoicestatic->getNomUrl(1,
'withdraw');
453 $thirdpartystatic->fetch($obj->socid);
454 print $thirdpartystatic->getNomUrl(1,
'ban');
460 if (!empty($bac->iban) || !empty($bac->bic)) {
461 print $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
462 if ($bac->verif() <= 0) {
463 print
img_warning(
'Error on default bank number for IBAN : '.$langs->trans($bac->error_message));
466 print
img_warning($langs->trans(
"IBANNotDefined"));
469 print
img_warning($langs->trans(
"NoBankAccountDefined"));
475 $rumtoshow = $thirdpartystatic->display_rib(
'rum');
478 $format = $thirdpartystatic->display_rib(
'format');
479 if ($type !=
'bank-transfer') {
481 print
' ('.$format.
')';
485 print
img_warning($langs->trans(
"NoBankAccountDefined"));
489 print
'<td class="right amount">';
490 print
price($obj->amount, 0, $langs, 0, 0, -1, $conf->currency);
493 print
'<td class="right">';
497 if ($massactionbutton || $massaction) {
498 print
'<td class="nowrap center">';
500 if (in_array($obj->request_row_id, $arrayofselected)) {
503 print
'<input id="cb'.$obj->request_row_id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->request_row_id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
510 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
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.
Class to manage third parties objects (customers, suppliers, prospects...)
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
prelevement_check_config($type='direct-debit')
Check need data to create standigns orders receipt file.
$nbtotalofrecords
Count total nb of records.
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.