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'));
43 if ($user->socid) $socid = $user->socid;
46 $type =
GETPOST(
'type',
'aZ09');
49 $action =
GETPOST(
'action',
'aZ09');
50 $mode =
GETPOST(
'mode',
'alpha') ?
GETPOST(
'mode',
'alpha') :
'real';
51 $format =
GETPOST(
'format',
'aZ09');
52 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
54 if (empty($page) || $page == -1) { $page = 0; }
55 $offset = $limit * $page;
57 $hookmanager->initHooks(array(
'directdebitcreatecard',
'globalcard'));
64 $parameters = array(
'mode' => $mode,
'format' => $format,
'limit' => $limit,
'page' => $page,
'offset' => $offset);
65 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
66 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
71 if ($action ==
'modify')
73 for ($i = 1; $i < 9; $i++)
78 if ($action ==
'create')
81 if ($type !=
'bank-transfer') {
82 $conf->global->PRELEVEMENT_ADDDAYS;
84 $conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
90 $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
93 } elseif ($result == 0) {
94 $mesg = $langs->trans(
"NoInvoiceCouldBeWithdrawed", $format);
97 foreach ($bprev->invoice_in_error as $key => $val)
99 $mesg .=
'<span class="warning">'.$val.
"</span><br>\n";
102 if ($type !=
'bank-transfer') {
103 setEventMessages($langs->trans(
"DirectDebitOrderCreated", $bprev->getNomUrl(1)), null);
105 setEventMessages($langs->trans(
"CreditTransferOrderCreated", $bprev->getNomUrl(1)), null);
108 header(
"Location: ".DOL_URL_ROOT.
'/compta/prelevement/card.php?id='.$bprev->id);
119 $form =
new Form($db);
121 $thirdpartystatic =
new Societe($db);
122 if ($type !=
'bank-transfer') {
123 $invoicestatic =
new Facture($db);
129 llxHeader(
'', $langs->trans(
"NewStandingOrder"));
133 $langs->load(
"errors");
134 setEventMessages($langs->trans(
"ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv(
"Withdraw")), null,
'errors');
147 $title = $langs->trans(
"NewStandingOrder");
148 if ($type ==
'bank-transfer') {
149 $title = $langs->trans(
"NewPaymentByBankTransfer");
156 $nb = $bprev->nbOfInvoiceToPay($type);
157 $pricetowithdraw = $bprev->SommeAPrelever($type);
162 print '<table class="border centpercent tableforfield">';
164 $title = $langs->trans(
"NbOfInvoiceToWithdraw");
165 if ($type ==
'bank-transfer') {
166 $title = $langs->trans(
"NbOfInvoiceToPayByBankTransfer");
169 print '<tr><td class="titlefieldcreate">'.$title.
'</td>';
174 print '<tr><td>'.$langs->trans(
"AmountTotal").
'</td>';
183 if ($mesg)
print $mesg;
185 print '<div class="tabsAction">'.
"\n";
187 print '<form action="'.$_SERVER[
'PHP_SELF'].
'?action=create" method="POST">';
188 print '<input type="hidden" name="token" value="'.newToken().
'">';
189 print '<input type="hidden" name="type" value="'.$type.
'">';
191 if ($pricetowithdraw) {
192 print $langs->trans(
'ExecutionDate').
' ';
194 print $form->selectDate($datere,
're');
196 if ($mysoc->isInEEC()) {
197 $title = $langs->trans(
"CreateForSepa");
198 if ($type ==
'bank-transfer') {
199 $title = $langs->trans(
"CreateSepaFileForPaymentByBankTransfer");
202 if ($type !=
'bank-transfer') {
203 print '<select name="format">';
204 print '<option value="FRST"'.(GETPOST(
'format',
'aZ09') ==
'FRST' ?
' selected="selected"' :
'').
'>'.$langs->trans(
'SEPAFRST').
'</option>';
205 print '<option value="RCUR"'.(GETPOST(
'format',
'aZ09') ==
'RCUR' ?
' selected="selected"' :
'').
'>'.$langs->trans(
'SEPARCUR').
'</option>';
208 print '<input class="butAction" type="submit" value="'.$title.
'"/>';
210 $title = $langs->trans(
"CreateAll");
211 if ($type ==
'bank-transfer') {
212 $title = $langs->trans(
"CreateFileForPaymentByBankTransfer");
214 print '<a class="butAction" type="submit" href="create.php?action=create&format=ALL&type='.$type.
'">'.$title.
"</a>\n";
217 if ($mysoc->isInEEC())
219 $title = $langs->trans(
"CreateForSepaFRST");
220 if ($type ==
'bank-transfer') {
221 $title = $langs->trans(
"CreateSepaFileForPaymentByBankTransfer");
223 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"AmountMustBePositive").
'">'.$title.
"</a>\n";
225 if ($type !=
'bank-transfer') {
226 $title = $langs->trans(
"CreateForSepaRCUR");
227 print '<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"AmountMustBePositive").
'">'.$title.
"</a>\n";
230 $title = $langs->trans(
"CreateAll");
231 if ($type ==
'bank-transfer') {
232 $title = $langs->trans(
"CreateFileForPaymentByBankTransfer");
234 print '<a class="butActionRefused classfortooltip" href="#">'.$title.
"</a>\n";
238 $titlefortab = $langs->transnoentitiesnoconv(
"StandingOrders");
239 $title = $langs->trans(
"CreateAll");
240 if ($type ==
'bank-transfer') {
241 $titlefortab = $langs->transnoentitiesnoconv(
"PaymentByBankTransfers");
242 $title = $langs->trans(
"CreateFileForPaymentByBankTransfer");
244 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv(
"NoInvoiceToWithdraw", $titlefortab, $titlefortab)).
'">'.$title.
"</a>\n";
258 $sql =
"SELECT f.ref, f.rowid, f.total_ttc, s.nom as name, s.rowid as socid,";
259 $sql .=
" pfd.date_demande, pfd.amount";
260 if ($type ==
'bank-transfer') {
261 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn as f,";
263 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facture as f,";
265 $sql .=
" ".MAIN_DB_PREFIX.
"societe as s,";
266 $sql .=
" ".MAIN_DB_PREFIX.
"prelevement_facture_demande as pfd";
267 $sql .=
" WHERE s.rowid = f.fk_soc";
268 $sql .=
" AND f.entity IN (".getEntity(
'invoice').
")";
269 if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
271 $sql .=
" AND f.fk_statut = ".Facture::STATUS_VALIDATED;
274 $sql .=
" AND f.total_ttc > 0";
275 $sql .=
" AND pfd.traite = 0";
276 $sql .=
" AND pfd.ext_payment_id IS NULL";
277 if ($type ==
'bank-transfer') {
278 $sql .=
" AND pfd.fk_facture_fourn = f.rowid";
280 $sql .=
" AND pfd.fk_facture = f.rowid";
282 if ($socid > 0) $sql .=
" AND f.fk_soc = ".$socid;
284 $nbtotalofrecords =
'';
285 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
287 $result = $db->query($sql);
288 $nbtotalofrecords = $db->num_rows($result);
289 if (($page * $limit) > $nbtotalofrecords)
296 $sql .= $db->plimit($limit + 1, $offset);
298 $resql = $db->query($sql);
301 $num = $db->num_rows(
$resql);
305 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
306 if ($socid) $param .=
'&socid='.urlencode($socid);
307 if ($option) $param .=
"&option=".urlencode($option);
309 print '<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
310 print '<input type="hidden" name="token" value="'.newToken().
'">';
311 print '<input type="hidden" name="page" value="'.$page.
'">';
312 if (!empty($limit)) {
313 print '<input type="hidden" name="limit" value="'.$limit.
'"/>';
316 $title = $langs->trans(
"InvoiceWaitingWithdraw");
317 if ($type ==
'bank-transfer') {
318 $title = $langs->trans(
"InvoiceWaitingPaymentByBankTransfer");
320 print_barre_liste($title, $page,
$_SERVER[
'PHP_SELF'], $param,
'',
'',
'', $num, $nbtotalofrecords,
'bill', 0,
'',
'', $limit);
322 $tradinvoice =
"Invoice";
323 if ($type ==
'bank-transfer') {
324 $tradinvoice =
"SupplierInvoice";
327 print '<table class="noborder centpercent">';
328 print '<tr class="liste_titre">';
329 print '<td>'.$langs->trans($tradinvoice).
'</td>';
330 print '<td>'.$langs->trans(
"ThirdParty").
'</td>';
331 print '<td>'.$langs->trans(
"RIB").
'</td>';
332 print '<td>'.$langs->trans(
"RUM").
'</td>';
333 print '<td class="right">'.$langs->trans(
"AmountTTC").
'</td>';
334 print '<td class="right">'.$langs->trans(
"DateRequest").
'</td>';
339 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
342 while ($i < $num && $i < $limit)
344 $obj = $db->fetch_object(
$resql);
346 $bac->fetch(0, $obj->socid);
348 print '<tr class="oddeven">';
352 $invoicestatic->id = $obj->rowid;
353 $invoicestatic->ref = $obj->ref;
354 print $invoicestatic->getNomUrl(1,
'withdraw');
359 $thirdpartystatic->fetch($obj->socid);
360 print $thirdpartystatic->getNomUrl(1,
'ban');
365 print $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
366 if ($bac->verif() <= 0)
print img_warning(
'Error on default bank number for IBAN : '.$bac->error_message);
371 $rumtoshow = $thirdpartystatic->display_rib(
'rum');
374 $format = $thirdpartystatic->display_rib(
'format');
375 if ($type !=
'bank-transfer') {
376 if ($format)
print ' ('.$format.
')';
383 print '<td class="right">';
384 print price($obj->amount, 0, $langs, 0, 0, -1, $conf->currency);
387 print '<td class="right">';
394 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.
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...
prelevement_check_config()
Check need data to create standigns orders receipt file.
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).
Class to manage bank accounts description of third parties.
Class to manage suppliers invoices.
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.
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.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
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.