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