dolibarr 22.0.5
virement_request.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (C) 2005-2015 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2015 Charlie BENKE <charlie@patas-monkey.com>
5 * Copyright (C) 2017-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
6 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
7 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
34require_once DOL_DOCUMENT_ROOT.'/salaries/class/salary.class.php';
35require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
36require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
39require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
40require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
41require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
42
43require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
44require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
45require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
46
47require_once DOL_DOCUMENT_ROOT.'/core/lib/invoice.lib.php';
48require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php';
49require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
50require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.php';
51require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
52require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
53require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
54require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
55require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
56if (isModEnabled('project')) {
57 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
58 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
59}
60
70// Load translation files required by the page
71$langs->loadLangs(array("compta", "bills", "users", "salaries", "hrm", "withdrawals"));
72
73$id = GETPOSTINT('id');
74$ref = GETPOST('ref', 'alpha');
75$action = GETPOST('action', 'aZ09');
76$type = 'salaire';
77
78$label = GETPOST('label', 'alphanohtml');
79$projectid = (GETPOSTINT('projectid') ? GETPOSTINT('projectid') : GETPOSTINT('fk_project'));
80
81// Security check
82$socid = GETPOSTINT('socid');
83if ($user->socid) {
84 $socid = $user->socid;
85}
86
87
88$object = new Salary($db);
89$extrafields = new ExtraFields($db);
90
91$childids = $user->getAllChildIds(1);
92
93// fetch optionals attributes and labels
94$extrafields->fetch_name_optionals_label($object->table_element);
95
96// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
97$hookmanager->initHooks(array('salaryinfo', 'globalcard'));
98
99$object = new Salary($db);
100if ($id > 0) {
101 $object->fetch($id);
102
103 // Check current user can read this salary
104 $canread = 0;
105 if ($user->hasRight('salaries', 'readall')) {
106 $canread = 1;
107 }
108 if ($user->hasRight('salaries', 'read') && $object->fk_user > 0 && in_array($object->fk_user, $childids)) {
109 $canread = 1;
110 }
111 if (!$canread) {
113 }
114}
115
116$permissiontoread = $user->hasRight('salaries', 'read');
117$permissiontoadd = $user->hasRight('salaries', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_linkedfiles
118$permissiontodelete = $user->hasRight('salaries', 'delete') || ($permissiontoadd && isset($object->status) && $object->status == $object::STATUS_UNPAID);
119
120$moreparam = '';
121if ($type == 'bank-transfer') {
122 $obj = new FactureFournisseur($db);
123 $moreparam = '&type='.$type;
124} else {
125 $obj = new Facture($db);
126}
127
128// Load object
129if ($id > 0) {
130 $ret = $object->fetch($id);
131 $isdraft = (($obj->status == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
132 if ($ret > 0) {
133 $object->fetch_thirdparty();
134 }
135}
136
137$hookmanager->initHooks(array('directdebitcard', 'globalcard'));
138
139restrictedArea($user, 'salaries', $object->id, 'salary', '');
140
141
142/*
143 * Actions
144 */
145
146// Link to a project
147if ($action == 'classin' && $user->hasRight('banque', 'modifier')) {
148 $object->fetch($id);
149 $object->setProject($projectid);
150}
151
152// set label
153if ($action == 'setlabel' && $user->hasRight('salaries', 'write')) {
154 $object->fetch($id);
155 $object->label = $label;
156 $object->update($user);
157}
158
159$parameters = array('socid' => $socid);
160$reshook = $hookmanager->executeHooks('doActions', $parameters, $obj, $action); // Note that $action and $object may have been modified by some hooks
161if ($reshook < 0) {
162 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
163}
164
165// payment mode
166if ($action == 'setmode' && $permissiontoadd) {
167 $object->fetch($id);
168 $result = $object->setPaymentMethods(GETPOSTINT('mode_reglement_id'));
169 if ($result < 0) {
170 setEventMessages($object->error, $object->errors, 'errors');
171 }
172}
173
174// bank account
175if ($action == 'setbankaccount' && $permissiontoadd) {
176 $object->fetch($id);
177 $result = $object->setBankAccount(GETPOSTINT('fk_account'));
178 if ($result < 0) {
179 setEventMessages($object->error, $object->errors, 'errors');
180 }
181}
182
183if ($action == "add" && $permissiontoadd) {
184 //var_dump($object);exit;
185 if ($object->id > 0) {
186 $db->begin();
187
188 $sourcetype = 'salaire';
189 $newtype = 'salaire';
190
191 $paymentservice = GETPOST('paymentservice'); // value can be 'stripesepa'. not used yet.
192
193 $result = $object->demande_prelevement($user, GETPOSTFLOAT('request_transfer'), $newtype, $sourcetype);
194
195 if ($result > 0) {
196 $db->commit();
197
198 setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
199 } else {
200 dol_print_error($db, $error);
201 $db->rollback();
202 setEventMessages($obj->error, $obj->errors, 'errors');
203 }
204 }
205 $action = '';
206}
207
208if ($action == "delete" && $permissiontodelete) {
209 if ($object->id > 0) {
210 $result = $object->demande_prelevement_delete($user, GETPOSTINT('did'));
211 if ($result == 0) {
212 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
213 exit;
214 }
215 }
216}
217
218
219/*
220 * View
221 */
222
223$form = new Form($db);
224
225$title = $langs->trans('Salary')." - ".$langs->trans('Info');
226$help_url = "";
227llxHeader("", $title, $help_url);
228
229$object->fetch($id);
230$object->info($id);
231
232$head = salaries_prepare_head($object);
233
234print dol_get_fiche_head($head, 'request_virement', $langs->trans("SalaryPayment"), -1, 'salary');
235
236$linkback = '<a href="'.DOL_URL_ROOT.'/salaries/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
237
238$morehtmlref = '<div class="refidno">';
239
240$userstatic = new User($db);
241$userstatic->fetch($object->fk_user);
242
243
244// Label
245if ($action != 'editlabel') {
246 $morehtmlref .= $form->editfieldkey("Label", 'label', $object->label, $object, $user->hasRight('salaries', 'write'), 'string', '', 0, 1);
247 $morehtmlref .= $object->label;
248} else {
249 $morehtmlref .= $langs->trans('Label').' :&nbsp;';
250 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
251 $morehtmlref .= '<input type="hidden" name="action" value="setlabel">';
252 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
253 $morehtmlref .= '<input type="text" name="label" value="'.$object->label.'"/>';
254 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
255 $morehtmlref .= '</form>';
256}
257
258$morehtmlref .= '<br>'.$langs->trans('Employee').' : '.$userstatic->getNomUrl(-1);
259
260$usercancreate = $permissiontoadd;
261
262// Project
263if (isModEnabled('project')) {
264 $langs->load("projects");
265 $morehtmlref .= '<br>';
266 if ($usercancreate) {
267 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
268 if ($action != 'classify') {
269 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
270 }
271 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
272 } else {
273 if (!empty($object->fk_project)) {
274 $proj = new Project($db);
275 $proj->fetch($object->fk_project);
276 $morehtmlref .= $proj->getNomUrl(1);
277 if ($proj->title) {
278 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
279 }
280 }
281 }
282}
283
284$morehtmlref .= '</div>';
285
286dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', '');
287
288print '<div class="fichecenter">';
289print '<div class="fichehalfleft">';
290
291print '<div class="underbanner clearboth"></div>';
292
293
294print '<table class="border centpercent tableforfield">';
295
296if ($action == 'edit') {
297 print '<tr><td class="titlefieldmiddle">'.$langs->trans("DateStartPeriod")."</td><td>";
298 print $form->selectDate($object->datesp, 'datesp', 0, 0, 0, 'datesp', 1);
299 print "</td></tr>";
300} else {
301 print "<tr>";
302 print '<td class="titlefieldmiddle">' . $langs->trans("DateStartPeriod") . '</td><td>';
303 print dol_print_date($object->datesp, 'day');
304 print '</td></tr>';
305}
306
307if ($action == 'edit') {
308 print '<tr><td>'.$langs->trans("DateEndPeriod")."</td><td>";
309 print $form->selectDate($object->dateep, 'dateep', 0, 0, 0, 'dateep', 1);
310 print "</td></tr>";
311} else {
312 print "<tr>";
313 print '<td>' . $langs->trans("DateEndPeriod") . '</td><td>';
314 print dol_print_date($object->dateep, 'day');
315 print '</td></tr>';
316}
317if ($action == 'edit') {
318 print '<tr><td class="fieldrequired">' . $langs->trans("Amount") . '</td><td><input name="amount" size="10" value="' . price($object->amount) . '"></td></tr>';
319} else {
320 print '<tr><td>' . $langs->trans("Amount") . '</td><td><span class="amount">' . price($object->amount, 0, $langs, 1, -1, -1, $conf->currency) . '</span></td></tr>';
321}
322
323// Default mode of payment
324print '<tr><td>';
325print '<table class="nobordernopadding" width="100%"><tr><td>';
326print $langs->trans('DefaultPaymentMode');
327print '</td>';
328if ($action != 'editmode') {
329 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editmode&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetMode'), 1).'</a></td>';
330}
331print '</tr></table>';
332print '</td><td>';
333
334if ($action == 'editmode') {
335 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->type_payment, 'mode_reglement_id');
336} else {
337 $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->type_payment, 'none');
338}
339print '</td></tr>';
340
341// Default Bank Account
342if (isModEnabled("bank")) {
343 print '<tr><td class="nowrap">';
344 print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
345 print $langs->trans('DefaultBankAccount');
346 print '<td>';
347 if ($action != 'editbankaccount' && $user->hasRight('salaries', 'write')) {
348 print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editbankaccount&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'</a></td>';
349 }
350 print '</tr></table>';
351 print '</td><td>';
352 if ($action == 'editbankaccount') {
353 $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->fk_account, 'fk_account', 1);
354 } else {
355 $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, (string) $object->fk_account, 'none');
356 }
357 print '</td>';
358 print '</tr>';
359}
360
361// Other attributes
362include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
363
364print '</table>';
365print '</div>';
366
367$user_perms = $user->hasRight('virement', 'bons', 'creer');
368$buttonlabel = $langs->trans("MakeTransferRequest");
369$user_perms = $user->hasRight('paymentbybanktransfer', 'create');
370
371print '<div class="fichehalfright">';
372/*
373 * Payments
374 */
375$sql = "SELECT p.rowid, p.num_payment as num_payment, p.datep as dp, p.amount,";
376$sql .= " c.code as type_code,c.libelle as paiement_type,";
377$sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal';
378$sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p";
379$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid';
380$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid';
381$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepayment = c.id";
382$sql .= ", ".MAIN_DB_PREFIX."salary as s";
383$sql .= " WHERE p.fk_salary = ".((int) $id);
384$sql .= " AND p.fk_salary = s.rowid";
385$sql .= " AND s.entity IN (".getEntity('tax').")";
386$sql .= " ORDER BY dp DESC";
387
388$resteapayer = 0;
389//print $sql;
390$resql = $db->query($sql);
391if ($resql) {
392 $totalpaid = 0;
393
394 $num = $db->num_rows($resql);
395
396 $i = 0;
397 $total = 0;
398
399 print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you don't need reserved height for your table
400 print '<table class="noborder paymenttable">';
401 print '<tr class="liste_titre">';
402 print '<td>'.$langs->trans("RefPayment").'</td>';
403 print '<td>'.$langs->trans("Date").'</td>';
404 print '<td>'.$langs->trans("Type").'</td>';
405 if (isModEnabled("bank")) {
406 print '<td class="liste_titre right">'.$langs->trans('BankAccount').'</td>';
407 }
408 print '<td class="right">'.$langs->trans("Amount").'</td>';
409 print '</tr>';
410
411 if ($num > 0) {
412 $bankaccountstatic = new Account($db);
413 while ($i < $num) {
414 $objp = $db->fetch_object($resql);
415
416 print '<tr class="oddeven"><td>';
417 print '<a href="'.DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='.$objp->rowid.'">'.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.'</a></td>';
418 print '<td>'.dol_print_date($db->jdate($objp->dp), 'dayhour', 'tzuserrel')."</td>\n";
419 $labeltype = $langs->trans("PaymentType".$objp->type_code) != "PaymentType".$objp->type_code ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type;
420 print "<td>".$labeltype.' '.$objp->num_payment."</td>\n";
421 if (isModEnabled("bank")) {
422 $bankaccountstatic->id = $objp->baid;
423 $bankaccountstatic->ref = $objp->baref;
424 $bankaccountstatic->label = $objp->baref;
425 $bankaccountstatic->number = $objp->banumber;
426 $bankaccountstatic->currency_code = $objp->bacurrency_code;
427
428 if (isModEnabled('accounting')) {
429 $bankaccountstatic->account_number = $objp->account_number;
430
431 $accountingjournal = new AccountingJournal($db);
432 $accountingjournal->fetch($objp->fk_accountancy_journal);
433 $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1);
434 }
435
436 print '<td class="right">';
437 if ($bankaccountstatic->id) {
438 print $bankaccountstatic->getNomUrl(1, 'transactions');
439 }
440 print '</td>';
441 }
442 print '<td class="right nowrap amountcard">'.price($objp->amount)."</td>\n";
443 print "</tr>";
444 $totalpaid += $objp->amount;
445 $i++;
446 }
447 } else {
448 print '<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
449 print '<td></td><td></td><td></td><td></td>';
450 print '</tr>';
451 }
452
453 // print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("AlreadyPaid").' :</td><td class="right nowrap amountcard">'.price($totalpaid)."</td></tr>\n";
454 // print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("AmountExpected").' :</td><td class="right nowrap amountcard">'.price($object->amount)."</td></tr>\n";
455
456 $resteapayer = (float) $object->amount - $totalpaid;
457 // $cssforamountpaymentcomplete = 'amountpaymentcomplete';
458
459 // print '<tr><td colspan="'.$nbcols.'" class="right">'.$langs->trans("RemainderToPay")." :</td>";
460 // print '<td class="right nowrap'.($resteapayer ? ' amountremaintopay' : (' '.$cssforamountpaymentcomplete)).'">'.price($resteapayer)."</td></tr>\n";
461
462 print "</table>";
463 print '</div>';
464
465 $db->free($resql);
466} else {
467 dol_print_error($db);
468}
469print '</div>';
470print '</div>';
471print '<div class="clearboth"></div>';
472
473
475
477print '<div class="tabsAction">'."\n";
478
479$sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
480$sql .= " pfd.date_traite as date_traite, pfd.amount, pfd.fk_prelevement_bons,";
481$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,";
482$sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
483$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
484$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid";
485$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
486if ($type == 'salaire') {
487 $sql .= " WHERE pfd.fk_salary = ".((int) $object->id);
488} else {
489 $sql .= " WHERE fk_facture = ".((int) $object->id);
490}
491$sql .= " AND pfd.traite = 0";
492$sql .= " AND pfd.type = 'ban'";
493$sql .= " ORDER BY pfd.date_demande DESC";
494$resql = $db->query($sql);
495
496$hadRequest = $db->num_rows($resql);
497if ($object->paye == 0 && $hadRequest == 0) {
498 if ($resteapayer > 0) {
499 if ($user_perms) {
500 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
501 print '<input type="hidden" name="token" value="'.newToken().'" />';
502 print '<input type="hidden" name="id" value="'.$object->id.'" />';
503 print '<input type="hidden" name="type" value="'.$type.'" />';
504 print '<input type="hidden" name="action" value="add" />';
505 print '<label for="withdraw_request_amount">'.$langs->trans('BankTransferAmount').' </label>';
506 print '<input type="text" id="withdraw_request_amount" name="request_transfer" value="'.price($resteapayer, 0, $langs, 1, -1, -1).'" size="9" />';
507 print '<input type="submit" class="butAction" value="'.$buttonlabel.'" />';
508 print '</form>';
509
510 if (getDolGlobalString('STRIPE_SEPA_DIRECT_DEBIT_SHOW_OLD_BUTTON')) { // This is hidden, prefer to use mode enabled with STRIPE_SEPA_DIRECT_DEBIT
511 // TODO Replace this with a checkbox for each payment mode: "Send request to XXX immediately..."
512 print "<br>";
513 //add stripe sepa button
514 $buttonlabel = $langs->trans("MakeWithdrawRequestStripe");
515 print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
516 print '<input type="hidden" name="token" value="'.newToken().'" />';
517 print '<input type="hidden" name="id" value="'.$object->id.'" />';
518 print '<input type="hidden" name="type" value="'.$type.'" />';
519 print '<input type="hidden" name="action" value="add" />';
520 print '<input type="hidden" name="paymenservice" value="stripesepa" />';
521 print '<label for="withdraw_request_amount">'.$langs->trans('BankTransferAmount').' </label>';
522 print '<input type="text" id="withdraw_request_amount" name="request_transfer" value="'.price($resteapayer, 0, $langs, 1, -1, -1).'" size="9" />';
523 print '<input type="submit" class="butAction" value="'.$buttonlabel.'" />';
524 print '</form>';
525 }
526 } else {
527 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$buttonlabel.'</a>';
528 }
529 } else {
530 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("AmountMustBePositive")).'">'.$buttonlabel.'</a>';
531 }
532} else {
533 if ($hadRequest == 0) {
534 if ($object->paye > 0) {
535 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("AlreadyPaid")).'">'.$buttonlabel.'</a>';
536 } else {
537 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("Draft")).'">'.$buttonlabel.'</a>';
538 }
539 } else {
540 print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("RequestAlreadyDone")).'">'.$buttonlabel.'</a>';
541 }
542}
543
544print '</div>';
545
546print '<div>';
547
548
549$bprev = new BonPrelevement($db);
550
551
552print '<div class="div-table-responsive-no-min">';
553print '<table class="noborder centpercent">';
554
555print '<tr class="liste_titre">';
556// Action column
557if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
558 print '<td>&nbsp;</td>';
559}
560print '<td class="left">'.$langs->trans("DateRequest").'</td>';
561print '<td>'.$langs->trans("User").'</td>';
562print '<td class="center">'.$langs->trans("Amount").'</td>';
563print '<td class="center">'.$langs->trans("DateProcess").'</td>';
564if ($type == 'bank-transfer') {
565 print '<td class="center">'.$langs->trans("BankTransferReceipt").'</td>';
566} else {
567 print '<td class="center">'.$langs->trans("WithdrawalReceipt").'</td>';
568}
569print '<td>&nbsp;</td>';
570// Action column
571if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
572 print '<td>&nbsp;</td>';
573}
574print '</tr>';
575
576$num = 0;
577if ($resql) {
578 $i = 0;
579
580 $tmpuser = new User($db);
581
582 $num = $db->num_rows($resql);
583 if ($num > 0) {
584 while ($i < $num) {
585 $obj = $db->fetch_object($resql);
586
587 $tmpuser->id = $obj->user_id;
588 $tmpuser->login = $obj->login;
589 $tmpuser->ref = $obj->login;
590 $tmpuser->email = $obj->email;
591 $tmpuser->lastname = $obj->lastname;
592 $tmpuser->firstname = $obj->firstname;
593 $tmpuser->statut = $obj->user_status;
594 $tmpuser->status = $obj->user_status;
595
596 print '<tr class="oddeven">';
597
598 // Action column
599 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
600 print '<td class="right">';
601 print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().'&did='.$obj->rowid.'&type='.urlencode($type).'">';
603 print '</a></td>';
604 }
605
606 // Date
607 print '<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande), 'dayhour')."</td>\n";
608
609 // User
610 print '<td class="tdoverflowmax125">';
611 print $tmpuser->getNomUrl(-1, '', 0, 0, 0, 0, 'login');
612 print '</td>';
613
614 // Amount
615 print '<td class="center"><span class="amount">'.price($obj->amount).'</span></td>';
616
617 // Date process
618 print '<td class="center"><span class="opacitymedium">'.$langs->trans("OrderWaiting").'</span></td>';
619
620 // Link to make payment now
621 print '<td class="minwidth75">';
622 if ($obj->fk_prelevement_bons > 0) {
623 $withdrawreceipt = new BonPrelevement($db);
624 $withdrawreceipt->id = $obj->fk_prelevement_bons;
625 $withdrawreceipt->ref = $obj->ref;
626 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
627 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
628 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
629 $withdrawreceipt->statut = $obj->status;
630 $withdrawreceipt->status = $obj->status;
631 $withdrawreceipt->amount = $obj->pb_amount;
632 //$withdrawreceipt->credite = $db->jdate($obj->credite);
633
634 print $withdrawreceipt->getNomUrl(1);
635 }
636
637 if (!in_array($type, array('bank-transfer', 'salaire', 'salary'))) {
638 if (getDolGlobalString('STRIPE_SEPA_DIRECT_DEBIT')) {
639 $langs->load("stripe");
640 if ($obj->fk_prelevement_bons > 0) {
641 print ' &nbsp; ';
642 }
643 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>';
644 }
645 } else {
646 if (getDolGlobalString('STRIPE_SEPA_CREDIT_TRANSFER')) {
647 $langs->load("stripe");
648 if ($obj->fk_prelevement_bons > 0) {
649 print ' &nbsp; ';
650 }
651 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("RequesCreditTransferWithStripe").'</a>';
652 }
653 }
654 print '</td>';
655
656 //
657 print '<td class="center">-</td>';
658
659 // Action column
660 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
661 print '<td class="right">';
662 print '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=delete&token='.newToken().'&did='.$obj->rowid.'&type='.urlencode($type).'">';
664 print '</a></td>';
665 }
666
667 print "</tr>\n";
668 $i++;
669 }
670 }
671
672 $db->free($resql);
673} else {
674 dol_print_error($db);
675}
676
677// Past requests when bon prelevement
678
679$sql = "SELECT pfd.rowid, pfd.traite, pfd.date_demande as date_demande,";
680$sql .= " pfd.date_traite as date_traite, pfd.amount, pfd.fk_prelevement_bons,";
681$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,";
682$sql .= " u.rowid as user_id, u.email, u.lastname, u.firstname, u.login, u.statut as user_status";
683$sql .= " FROM ".MAIN_DB_PREFIX."prelevement_demande as pfd";
684$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on pfd.fk_user_demande = u.rowid";
685$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."prelevement_bons as pb ON pb.rowid = pfd.fk_prelevement_bons";
686if ($type == 'salaire') {
687 $sql .= " WHERE pfd.fk_salary = ".((int) $object->id);
688} else {
689 $sql .= " WHERE fk_facture = ".((int) $object->id);
690}
691$sql .= " AND pfd.traite = 1";
692$sql .= " AND pfd.type = 'ban'";
693$sql .= " ORDER BY pfd.date_demande DESC";
694
695$numOfBp = 0;
696$resql = $db->query($sql);
697if ($resql) {
698 $numOfBp = $db->num_rows($resql);
699 $i = 0;
700 $tmpuser = new User($db);
701 if ($numOfBp > 0) {
702 while ($i < $numOfBp) {
703 $obj = $db->fetch_object($resql);
704
705 $tmpuser->id = $obj->user_id;
706 $tmpuser->login = $obj->login;
707 $tmpuser->ref = $obj->login;
708 $tmpuser->email = $obj->email;
709 $tmpuser->lastname = $obj->lastname;
710 $tmpuser->firstname = $obj->firstname;
711 $tmpuser->statut = $obj->user_status;
712 $tmpuser->status = $obj->user_status;
713
714 print '<tr class="oddeven">';
715
716 // Action column
717 if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
718 print '<td>&nbsp;</td>';
719 }
720
721 // Date
722 print '<td class="nowraponall">'.dol_print_date($db->jdate($obj->date_demande), 'dayhour')."</td>\n";
723
724 // User
725 print '<td class="tdoverflowmax125">';
726 print $tmpuser->getNomUrl(-1, '', 0, 0, 0, 0, 'login');
727 print '</td>';
728
729 // Amount
730 print '<td class="center"><span class="amount">'.price($obj->amount).'</span></td>';
731
732 // Date process
733 print '<td class="center nowraponall">'.dol_print_date($db->jdate($obj->date_traite), 'dayhour', 'tzuserrel')."</td>\n";
734
735 // Link to payment request done
736 print '<td class="center minwidth75">';
737 if ($obj->fk_prelevement_bons > 0) {
738 $withdrawreceipt = new BonPrelevement($db);
739 $withdrawreceipt->id = $obj->fk_prelevement_bons;
740 $withdrawreceipt->ref = $obj->ref;
741 $withdrawreceipt->date_trans = $db->jdate($obj->date_trans);
742 $withdrawreceipt->date_credit = $db->jdate($obj->date_credit);
743 $withdrawreceipt->date_creation = $db->jdate($obj->datec);
744 $withdrawreceipt->statut = $obj->status;
745 $withdrawreceipt->status = $obj->status;
746 $withdrawreceipt->fk_bank_account = $obj->fk_bank_account;
747 $withdrawreceipt->amount = $obj->pb_amount;
748 //$withdrawreceipt->credite = $db->jdate($obj->credite);
749
750 print $withdrawreceipt->getNomUrl(1);
751 print ' ';
752 print $withdrawreceipt->getLibStatut(2);
753
754 // Show the bank account
755 $fk_bank_account = $withdrawreceipt->fk_bank_account;
756 if (empty($fk_bank_account)) {
757 $fk_bank_account = ($object->type == 'bank-transfer' ? $conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT : $conf->global->PRELEVEMENT_ID_BANKACCOUNT);
758 }
759 if ($fk_bank_account > 0) {
760 $bankaccount = new Account($db);
761 $result = $bankaccount->fetch($fk_bank_account);
762 if ($result > 0) {
763 print ' - ';
764 print $bankaccount->getNomUrl(1);
765 }
766 }
767 }
768 print "</td>\n";
769
770 //
771 print '<td>&nbsp;</td>';
772
773 // Action column
774 if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
775 print '<td>&nbsp;</td>';
776 }
777
778 print "</tr>\n";
779 $i++;
780 }
781 }
782 $db->free($resql);
783} else {
784 dol_print_error($db);
785}
786
787if ($num == 0 && $numOfBp == 0) {
788 print '<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
789}
790
791print "</table>";
792print '</div>';
793
794// End of page
795llxFooter();
796$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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.
Definition wrapper.php:73
Class to manage bank accounts.
Class to manage accounting journals.
Class to manage withdrawal receipts.
Class to manage standard extra fields.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage generation of HTML components Only common components must be here.
Class to manage projects.
Class to manage salary payments.
Class to manage Dolibarr users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $allowothertags=array())
Show a picto called object_picto (generic function)
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=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.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.
print
button