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