30 require
'../../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.
'/compta/prelevement/class/bonprelevement.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/prelevement.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
40 $langs->loadLangs(array(
'banks',
'categories',
'withdrawals',
'companies',
'bills'));
42 $type =
GETPOST(
'type',
'aZ09');
45 $action =
GETPOST(
'action',
'aZ09');
46 $massaction =
GETPOST(
'massaction',
'alpha');
47 $toselect =
GETPOST(
'toselect',
'array');
49 $mode =
GETPOST(
'mode',
'alpha') ?
GETPOST(
'mode',
'alpha') :
'real';
50 $format =
GETPOST(
'format',
'aZ09');
51 $id_bankaccount =
GETPOST(
'id_bankaccount',
'int');
54 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
56 if (empty($page) || $page == -1) {
59 $offset = $limit * $page;
61 $hookmanager->initHooks(array(
'directdebitcreatecard',
'globalcard'));
65 $socid = $user->socid;
67 if ($type ==
'bank-transfer') {
68 $result =
restrictedArea($user,
'paymentbybanktransfer',
'',
'',
'');
80 if (
GETPOST(
'cancel',
'alpha')) {
84 $parameters = array(
'mode' => $mode,
'format' => $format,
'limit' => $limit,
'page' => $page,
'offset' => $offset);
85 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
90 if (empty($reshook)) {
92 if ($action ==
'modify') {
93 for ($i = 1; $i < 9; $i++) {
97 if ($action ==
'create') {
98 $default_account = ($type ==
'bank-transfer' ?
'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' :
'PRELEVEMENT_ID_BANKACCOUNT');
102 if ($id_bankaccount != $conf->global->$default_account) {
103 $res =
dolibarr_set_const($db, $default_account, $id_bankaccount,
'chaine', 0,
'', $conf->entity);
106 require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
108 $bank->fetch($conf->global->{$default_account});
113 if (empty($bank->ics) && $type !==
'bank-transfer') {
114 $errormessage = str_replace(
'{url}', $bank->getNomUrl(1,
'',
'', -1, 1), $langs->trans(
"ErrorICSmissing",
'{url}'));
125 $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
128 } elseif ($result == 0) {
129 $mesg = $langs->trans(
"NoInvoiceCouldBeWithdrawed", $format);
131 $mesg .=
'<br>'.
"\n";
132 foreach ($bprev->invoice_in_error as $key => $val) {
133 $mesg .=
'<span class="warning">'.$val.
"</span><br>\n";
136 if ($type !=
'bank-transfer') {
137 $texttoshow = $langs->trans(
"DirectDebitOrderCreated",
'{s}');
138 $texttoshow = str_replace(
'{s}', $bprev->getNomUrl(1), $texttoshow);
141 $texttoshow = $langs->trans(
"CreditTransferOrderCreated",
'{s}');
142 $texttoshow = str_replace(
'{s}', $bprev->getNomUrl(1), $texttoshow);
146 header(
"Location: ".DOL_URL_ROOT.
'/compta/prelevement/card.php?id='.urlencode($bprev->id).
'&type='.urlencode($type));
151 $objectclass =
"BonPrelevement";
152 if ($type ==
'bank-transfer') {
153 $uploaddir = $conf->paymentbybanktransfer->dir_output;
155 $uploaddir = $conf->prelevement->dir_output;
157 include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
167 $thirdpartystatic =
new Societe($db);
168 if ($type !=
'bank-transfer') {
169 $invoicestatic =
new Facture($db);
174 $arrayofselected = is_array($toselect) ? $toselect : array();
176 $arrayofmassactions = array(
178 if (
GETPOST(
'nomassaction',
'int') || in_array($massaction, array(
'presend',
'predelete'))) {
179 $arrayofmassactions = array();
181 $massactionbutton =
$form->selectMassAction(
'', $arrayofmassactions);
183 llxHeader(
'', $langs->trans(
"NewStandingOrder"));
186 $langs->load(
"errors");
187 $modulenametoshow =
"Withdraw";
188 if ($type ==
'bank-transfer') {
189 $modulenametoshow =
"PaymentByBankTransfer";
191 setEventMessages($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv($modulenametoshow)), null,
'errors');
205 $title = $langs->trans(
"NewStandingOrder");
206 if ($type ==
'bank-transfer') {
207 $title = $langs->trans(
"NewPaymentByBankTransfer");
214 $nb = $bprev->nbOfInvoiceToPay($type);
215 $pricetowithdraw = $bprev->SommeAPrelever($type);
219 print
'<table class="border centpercent tableforfield">';
221 $title = $langs->trans(
"NbOfInvoiceToWithdraw");
222 if ($type ==
'bank-transfer') {
223 $title = $langs->trans(
"NbOfInvoiceToPayByBankTransfer");
226 print
'<tr><td class="titlefieldcreate">'.$title.
'</td>';
231 print
'<tr><td>'.$langs->trans(
"AmountTotal").
'</td>';
232 print
'<td class="amount">';
233 print
price($pricetowithdraw);
244 print
'<div class="tabsAction">'.
"\n";
246 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?action=create" method="POST">';
247 print
'<input type="hidden" name="token" value="'.newToken().
'">';
248 print
'<input type="hidden" name="type" value="'.$type.
'">';
250 if ($pricetowithdraw) {
251 $title = $langs->trans(
'BankToReceiveWithdraw').
': ';
252 if ($type ==
'bank-transfer') {
253 $title = $langs->trans(
'BankToPayCreditTransfer').
': ';
258 $default_account = ($type ==
'bank-transfer' ?
'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT' :
'PRELEVEMENT_ID_BANKACCOUNT');
260 print
$form->select_comptes($conf->global->$default_account,
'id_bankaccount', 0,
"courant=1", 0,
'', 0,
'', 1);
263 if (empty($executiondate)) {
265 if ($type !=
'bank-transfer') {
266 $delayindays = $conf->global->PRELEVEMENT_ADDDAYS;
268 $delayindays = $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
274 print $langs->trans(
'ExecutionDate').
' ';
275 $datere = $executiondate;
276 print
$form->selectDate($datere,
're');
279 if ($mysoc->isInEEC()) {
280 $title = $langs->trans(
"CreateForSepa");
281 if ($type ==
'bank-transfer') {
282 $title = $langs->trans(
"CreateSepaFileForPaymentByBankTransfer");
285 if ($type !=
'bank-transfer') {
286 print
'<select name="format">';
287 print
'<option value="FRST"'.(GETPOST(
'format',
'aZ09') ==
'FRST' ?
' selected="selected"' :
'').
'>'.$langs->trans(
'SEPAFRST').
'</option>';
288 print
'<option value="RCUR"'.(GETPOST(
'format',
'aZ09') ==
'RCUR' ?
' selected="selected"' :
'').
'>'.$langs->trans(
'SEPARCUR').
'</option>';
291 print
'<input type="submit" class="butAction" value="'.$title.
'"/>';
293 $title = $langs->trans(
"CreateAll");
294 if ($type ==
'bank-transfer') {
295 $title = $langs->trans(
"CreateFileForPaymentByBankTransfer");
297 print
'<input type="hidden" name="format" value="ALL">'.
"\n";
298 print
'<input type="submit" class="butAction" value="'.$title.
'">'.
"\n";
301 if ($mysoc->isInEEC()) {
302 $title = $langs->trans(
"CreateForSepaFRST");
303 if ($type ==
'bank-transfer') {
304 $title = $langs->trans(
"CreateSepaFileForPaymentByBankTransfer");
306 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"AmountMustBePositive").
'">'.$title.
"</a>\n";
308 if ($type !=
'bank-transfer') {
309 $title = $langs->trans(
"CreateForSepaRCUR");
310 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"AmountMustBePositive").
'">'.$title.
"</a>\n";
313 $title = $langs->trans(
"CreateAll");
314 if ($type ==
'bank-transfer') {
315 $title = $langs->trans(
"CreateFileForPaymentByBankTransfer");
317 print
'<a class="butActionRefused classfortooltip" href="#">'.$title.
"</a>\n";
321 $titlefortab = $langs->transnoentitiesnoconv(
"StandingOrders");
322 $title = $langs->trans(
"CreateAll");
323 if ($type ==
'bank-transfer') {
324 $titlefortab = $langs->transnoentitiesnoconv(
"PaymentByBankTransfers");
325 $title = $langs->trans(
"CreateFileForPaymentByBankTransfer");
327 print
'<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NoInvoiceToWithdraw", $titlefortab, $titlefortab)).
'">'.$title.
"</a>\n";
341 $sql =
"SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,";
342 $sql .=
" pfd.rowid as request_row_id, pfd.date_demande, pfd.amount";
343 if ($type ==
'bank-transfer') {
344 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
346 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
348 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
349 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
350 $sql .=
" WHERE s.rowid = f.fk_soc";
351 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
352 if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS)) {
353 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
356 $sql .=
" AND f.total_ttc > 0";
357 $sql .=
" AND pfd.traite = 0";
358 $sql .=
" AND pfd.ext_payment_id IS NULL";
359 if ($type ==
'bank-transfer') {
360 $sql .=
" AND pfd.fk_facture_fourn = f.rowid";
362 $sql .=
" AND pfd.fk_facture = f.rowid";
365 $sql .=
" AND f.fk_soc = ".((int) $socid);
368 $nbtotalofrecords =
'';
369 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
370 $result = $db->query($sql);
371 $nbtotalofrecords = $db->num_rows($result);
372 if (($page * $limit) > $nbtotalofrecords) {
379 $sql .= $db->plimit($limit + 1, $offset);
381 $resql = $db->query($sql);
383 $num = $db->num_rows(
$resql);
387 if ($limit > 0 && $limit != $conf->liste_limit) {
388 $param .=
'&limit='.urlencode($limit);
391 $param .=
'&socid='.urlencode($socid);
394 $param .=
"&option=".urlencode($option);
397 print
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
398 print
'<input type="hidden" name="token" value="'.newToken().
'">';
399 print
'<input type="hidden" name="page" value="'.$page.
'">';
400 if (!empty($limit)) {
401 print
'<input type="hidden" name="limit" value="'.$limit.
'"/>';
404 $title = $langs->trans(
"InvoiceWaitingWithdraw");
405 if ($type ==
'bank-transfer') {
406 $title = $langs->trans(
"InvoiceWaitingPaymentByBankTransfer");
408 print_barre_liste($title, $page, $_SERVER[
'PHP_SELF'], $param,
'',
'', $massactionbutton, $num, $nbtotalofrecords,
'bill', 0,
'',
'', $limit);
410 $tradinvoice =
"Invoice";
411 if ($type ==
'bank-transfer') {
412 $tradinvoice =
"SupplierInvoice";
415 print
'<table class="noborder centpercent">';
416 print
'<tr class="liste_titre">';
417 print
'<td>'.$langs->trans($tradinvoice).
'</td>';
418 print
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
419 print
'<td>'.$langs->trans(
"RIB").
'</td>';
420 print
'<td>'.$langs->trans(
"RUM").
'</td>';
421 print
'<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
422 print
'<td class="right">'.$langs->trans(
"DateRequest").
'</td>';
423 if ($massactionbutton || $massaction) {
424 print
'<td align="center">'.$form->showCheckAddButtons(
'checkforselect', 1).
'</td>';
429 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
432 while ($i < $num && $i < $limit) {
433 $obj = $db->fetch_object(
$resql);
435 $bac->fetch(0, $obj->socid);
437 print
'<tr class="oddeven">';
441 $invoicestatic->id = $obj->rowid;
442 $invoicestatic->ref = $obj->ref;
443 print $invoicestatic->getNomUrl(1,
'withdraw');
448 $thirdpartystatic->fetch($obj->socid);
449 print $thirdpartystatic->getNomUrl(1,
'ban');
455 if (!empty($bac->iban) || !empty($bac->bic)) {
456 print $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
457 if ($bac->verif() <= 0) {
458 print
img_warning(
'Error on default bank number for IBAN : '.$langs->trans($bac->error_message));
461 print
img_warning($langs->trans(
"IBANNotDefined"));
464 print
img_warning($langs->trans(
"NoBankAccountDefined"));
470 $rumtoshow = $thirdpartystatic->display_rib(
'rum');
473 $format = $thirdpartystatic->display_rib(
'format');
474 if ($type !=
'bank-transfer') {
476 print
' ('.$format.
')';
480 print
img_warning($langs->trans(
"NoBankAccountDefined"));
484 print
'<td class="right amount">';
485 print
price($obj->amount, 0, $langs, 0, 0, -1, $conf->currency);
488 print
'<td class="right">';
492 if ($massactionbutton || $massaction) {
493 print
'<td class="nowrap center">';
495 if (in_array($obj->request_row_id, $arrayofselected)) {
498 print
'<input id="cb'.$obj->request_row_id.
'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->request_row_id.
'"'.($selected ?
' checked="checked"' :
'').
'>';
505 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
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...
dol_now($mode= 'auto')
Return date for now.
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('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage bank accounts description of third parties.
Class to manage suppliers invoices.
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Class to manage bank accounts.
img_warning($titlealt= 'default', $moreatt= '', $morecss= 'pictowarning')
Show warning logo.
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...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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...
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
Class to manage withdrawal receipts.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
restrictedArea($user, $features, $objectid=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.
if(isModEnabled('facture')&&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur')&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)&&$user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice')&&$user->rights->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->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
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_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage invoices.
prelevement_check_config($type= 'direct-debit')
Check need data to create standigns orders receipt file.