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