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