dolibarr 24.0.0-beta
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017-2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
3 * Copyright (C) 2018-2026 Frédéric France <frederic.france@free.fr>
4 * Copyright (C) 2023 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2023 Joachim Kueter <git-jk@bloxera.com>
6 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2026 Solution Libre SAS <contact@solution-libre.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';
31
41require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
42require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
43require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
44require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
45require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
46require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
47require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
48require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
49if (isModEnabled('project')) {
50 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
51 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
52}
53
54// Load translation files required by the page
55$langs->loadLangs(array("accountancy", "banks", "bills", "categories", "compta", "users"));
56
57// Get parameters
58$id = GETPOSTINT('id');
59$action = GETPOST('action', 'alpha');
60$confirm = GETPOST('confirm');
61$cancel = GETPOST('cancel', 'alpha');
62$backtopage = GETPOST('backtopage', 'alpha');
63
64$accountid = GETPOSTINT("accountid") > 0 ? GETPOSTINT("accountid") : 0;
65$label = GETPOST("label", "alpha");
66$sens = GETPOSTINT("sens");
67$amount = GETPOST("amount");
68$paymenttype = GETPOST("paymenttype", "aZ09");
69$accountancy_code = GETPOST("accountancy_code", "alpha");
70$projectid = GETPOSTINT('projectid') ? GETPOSTINT('projectid') : GETPOSTINT('fk_project');
71if (isModEnabled('accounting') && getDolGlobalString('ACCOUNTANCY_AUXACCOUNT_USE_SEARCH_TO_SELECT') > 0) {
72 $subledger_account = GETPOST("subledger_account", "alpha") > 0 ? GETPOST("subledger_account", "alpha") : '';
73} else {
74 $subledger_account = GETPOST("subledger_account", "alpha");
75}
76
77// Security check
78$socid = GETPOSTINT("socid");
79if ($user->socid) {
80 $socid = $user->socid;
81}
82
83// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
84$hookmanager->initHooks(array('variouscard', 'globalcard'));
85
86$result = restrictedArea($user, 'banque', '', '', '');
87
89
90$extrafields->fetch_name_optionals_label($object->table_element);
91
92$permissiontoadd = $user->hasRight('banque', 'modifier');
93$permissiontodelete = $user->hasRight('banque', 'modifier');
94
95
100$parameters = array();
101$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
102if ($reshook < 0) {
103 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
104}
105
106if (empty($reshook)) {
107 if ($cancel) {
108 if ($action != 'addlink' && $action != 'setaccountancy_code' && $action != 'setsubledger_account') {
109 $urltogo = $backtopage ? $backtopage : dol_buildpath('/compta/bank/various_payment/list.php', 1);
110 header("Location: ".$urltogo);
111 exit;
112 }
113 if ($id > 0) {
114 $ret = $object->fetch($id);
115 }
116 $action = '';
117 }
118
119 // Link to a project
120 if ($action == 'classin' && $permissiontoadd) {
121 $object->fetch($id);
122 $object->setProject(GETPOSTINT('projectid'));
123 }
124
125 if ($action == 'add' && $permissiontoadd) {
126 $error = 0;
127
128 $datep = dol_mktime(12, 0, 0, GETPOSTINT("datepmonth"), GETPOSTINT("datepday"), GETPOSTINT("datepyear"));
129 $datev = dol_mktime(12, 0, 0, GETPOSTINT("datevmonth"), GETPOSTINT("datevday"), GETPOSTINT("datevyear"));
130 if (empty($datev)) {
131 $datev = $datep;
132 }
133
134 $object->ref = ''; // TODO
135 $object->fk_account = GETPOSTINT("accountid") > 0 ? GETPOSTINT("accountid") : 0;
136 $object->accountid = $object->fk_account;
137 $object->datev = $datev;
138 $object->datep = $datep;
139 $object->amount = GETPOSTFLOAT("amount");
140 $object->label = GETPOST("label", 'restricthtml');
141 $object->note_private = GETPOST("note", 'restricthtml');
142 $object->note = $object->note_private;
143 $object->type_payment = dol_getIdFromCode($db, GETPOST('paymenttype'), 'c_paiement', 'code', 'id', 1);
144 $object->num_payment = GETPOST("num_payment", 'alpha');
145 $object->chqemetteur = GETPOST("chqemetteur", 'alpha');
146 $object->chqbank = GETPOST("chqbank", 'alpha');
147 $object->fk_user_author = $user->id;
148 $object->category_transaction = GETPOSTINT("category_transaction");
149
150 $object->accountancy_code = (GETPOST("accountancy_code") != '-1' ? GETPOST("accountancy_code", "alpha") : "");
151 $object->subledger_account = $subledger_account;
152
153 $object->sens = GETPOSTINT('sens');
154 $object->fk_project = GETPOSTINT('fk_project');
155
156 // Fill array 'array_options' with data from add form
157 $ret = $extrafields->setOptionalsFromPost(null, $object);
158 if ($ret < 0) {
159 $error++;
160 }
161
162 if (!checkGeneralAccountAllowsAuxiliary($db, $object->accountancy_code, $object->subledger_account)) {
163 setEventMessages($langs->trans("ErrorAccountNotCentralized"). ". " . $langs->trans("RemoveSubsidiaryAccountOrAdjustTheGeneralAccount"), null, 'errors');
164 $error++;
165 }
166 if (empty($datep) || empty($datev)) {
167 $langs->load('errors');
168 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
169 $error++;
170 }
171 if (empty($object->amount)) {
172 $langs->load('errors');
173 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
174 $error++;
175 }
176 if (isModEnabled("bank") && !$object->accountid > 0) {
177 $langs->load('errors');
178 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
179 $error++;
180 }
181 if (empty($object->type_payment) || $object->type_payment < 0) {
182 $langs->load('errors');
183 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
184 $error++;
185 }
186 if (isModEnabled('accounting') && !$object->accountancy_code) {
187 $langs->load('errors');
188 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors');
189 $error++;
190 }
191 if ($object->sens < 0) {
192 $langs->load('errors');
193 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Sens")), null, 'errors');
194 $error++;
195 }
196
197 $bankaccount = new Account($db);
198 if ($object->fk_account > 0) {
199 $bankaccount->fetch((int) $object->fk_account);
200 }
201
202 // Check currency
203 $currencyofpayment = $conf->currency; // The currency of various payment is not yet asked, so we suppose it is the main company currency
204
205 if (isModEnabled('multicurrency') && $currencyofpayment != $bankaccount->currency_code) {
206 // TODO Support this feature the same way we do it for invoice payment
207 // using the $value_converted = MultiCurrency::getAmountConversionFromInvoiceRate($key, $value, $way);
208 setEventMessages($langs->trans("ErrorVariousPaymentOnBankAccountWithADifferentCurrencyNotYetSupported"), null, 'errors');
209 $error++;
210 }
211
212 if (!$error) {
213 $db->begin();
214
215 $ret = $object->create($user);
216 if ($ret > 0) {
217 $db->commit();
218 $urltogo = ($backtopage ? $backtopage : dolBuildUrl(DOL_URL_ROOT.'/compta/bank/various_payment/list.php'));
219 header("Location: ".$urltogo);
220 exit;
221 } else {
222 $db->rollback();
223 setEventMessages($object->error, $object->errors, 'errors');
224 $action = "create";
225 }
226 }
227
228 $action = 'create';
229 }
230
231 if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) {
232 $result = $object->fetch($id);
233
234 if ($object->rappro == 0) {
235 $db->begin();
236
237 $ret = $object->delete($user);
238 if ($ret > 0) {
239 $accountline = null;
240 if ($object->fk_bank) {
241 $accountline = new AccountLine($db);
242 $result = $accountline->fetch($object->fk_bank);
243 if ($result > 0) {
244 $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
245 }
246 }
247
248 if ($result >= 0) {
249 $db->commit();
250 header("Location: ".dolBuildUrl(DOL_URL_ROOT.'/compta/bank/various_payment/list.php'));
251 exit;
252 } else {
253 $object->error = $accountline ? $accountline->error : 'No AccountLine';
254 $db->rollback();
255 setEventMessages($object->error, $object->errors, 'errors');
256 }
257 } else {
258 $db->rollback();
259 setEventMessages($object->error, $object->errors, 'errors');
260 }
261 } else {
262 setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors');
263 }
264 }
265
266 if ($action == 'setaccountancy_code' && $permissiontodelete) {
267 $db->begin();
268
269 $result = $object->fetch($id);
270
271 $object->accountancy_code = GETPOST('accountancy_code', 'alphanohtml');
272
273 $res = $object->update($user);
274 if ($res > 0) {
275 $db->commit();
276 } else {
277 $db->rollback();
278 setEventMessages($object->error, $object->errors, 'errors');
279 }
280 }
281
282 if ($action == 'setsubledger_account' && $permissiontodelete) {
283 $db->begin();
284
285 $result = $object->fetch($id);
286
287 $object->subledger_account = $subledger_account;
288
289 $res = $object->update($user);
290 if ($res > 0) {
291 $db->commit();
292 } else {
293 $db->rollback();
294 setEventMessages($object->error, $object->errors, 'errors');
295 }
296 }
297}
298
299// Action clone object
300if ($action == 'confirm_clone' && $confirm != 'yes') { // Test on permission not required
301 $action = '';
302}
303
304if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) {
305 $db->begin();
306
307 $originalId = $id;
308
309 $object->fetch($id);
310
311 if ($object->id > 0) {
312 unset($object->id);
313 unset($object->ref);
314
315 if (GETPOST('clone_label', 'alphanohtml')) {
316 $object->label = GETPOST('clone_label', 'alphanohtml');
317 } else {
318 $object->label = $langs->trans("CopyOf").' '.$object->label;
319 }
320
321 $newdatepayment = dol_mktime(0, 0, 0, GETPOSTINT('clone_date_paymentmonth'), GETPOSTINT('clone_date_paymentday'), GETPOSTINT('clone_date_paymentyear'));
322 $newdatevalue = dol_mktime(0, 0, 0, GETPOSTINT('clone_date_valuemonth'), GETPOSTINT('clone_date_valueday'), GETPOSTINT('clone_date_valueyear'));
323 if ($newdatepayment) {
324 $object->datep = $newdatepayment;
325 }
326 if (!empty($newdatevalue)) {
327 $object->datev = $newdatevalue;
328 } else {
329 $object->datev = $newdatepayment;
330 }
331
332 if (GETPOSTISSET("clone_sens")) {
333 $object->sens = GETPOSTINT("clone_sens");
334 } // else { $object->sens = $object->sens; }
335
336 if (GETPOSTISSET("clone_amount")) {
337 $object->amount = GETPOSTFLOAT("clone_amount");
338 } else {
339 $object->amount = (float) price2num($object->amount);
340 }
341
342 if ($object->check()) {
343 $id = $object->create($user);
344 if ($id > 0) {
345 $db->commit();
346 $db->close();
347
348 header("Location: ".dolBuildUrl($_SERVER["PHP_SELF"], ["id" => $id]));
349 exit;
350 } else {
351 $id = $originalId;
352 $db->rollback();
353
354 setEventMessages($object->error, $object->errors, 'errors');
355 }
356 } else {
357 $id = $originalId;
358 $db->rollback();
359
360 setEventMessages($object->error, $object->errors, 'errors');
361 }
362 } else {
363 $db->rollback();
364 dol_print_error($db, $object->error);
365 }
366}
367
368
369/*
370 * View
371 */
372
373$form = new Form($db);
374if (isModEnabled('accounting')) {
375 $formaccounting = new FormAccounting($db);
376} else {
377 $formaccounting = null;
378}
379if (isModEnabled('project')) {
380 $formproject = new FormProjets($db);
381} else {
382 $formproject = null;
383}
384
385if ($id) {
387 $result = $object->fetch($id);
388 if ($result <= 0) {
390 exit;
391 }
392}
393
394$title = $object->ref." - ".$langs->trans('Card');
395if ($action == 'create') {
396 $title = $langs->trans("NewVariousPayment");
397}
398$help_url = 'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
399llxHeader('', $title, $help_url);
400
401$options = array();
402
403// Load bank groups
404require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
405$bankcateg = new BankCateg($db);
406
407$arrayofbankcategs = $bankcateg->fetchAll();
408
409foreach ($arrayofbankcategs as $bankcategory) {
410 $options[$bankcategory->id] = $bankcategory->label;
411}
412
413// Create mode
414if ($action == 'create') {
415 // Update fields properties in realtime
416 if (!empty($conf->use_javascript_ajax)) {
417 ?>
418 <script type="text/javascript">
419 $(document).ready(function() {
420 setPaymentType();
421 $("#selectpaymenttype").change(function() {
422 setPaymentType();
423 });
424
425 function setPaymentType() {
426 console.log("setPaymentType");
427 var code = $("#selectpaymenttype option:selected").val();
428 if (code == "CHQ" || code == "VIR") {
429 if (code == 'CHQ') {
430 $('.fieldrequireddyn').addClass('fieldrequired');
431 }
432 if ($('#fieldchqemetteur').val() == '') {
433 var emetteur = jQuery('#thirdpartylabel').val();
434 $('#fieldchqemetteur').val(emetteur);
435 }
436 } else {
437 $(".fieldrequireddyn").removeClass("fieldrequired");
438 $("#fieldchqemetteur").val("");
439 }
440 }
441
442 function toggleSubledger() {
443 var isCentral = $("#accountancy_code option:selected").data("centralized");
444 console.log("the selected general ledger account is centralised?", isCentral);
445 if (isCentral) {
446 $("#subledger_account").prop("disabled", false);
447 } else {
448 $("#subledger_account").prop("disabled", true);
449 }
450 }
451 toggleSubledger();
452
453 $("#accountancy_code").on("change", toggleSubledger);
454 $("#accountancy_code").on("select2:select", toggleSubledger);
455 });
456 </script>
457 <?php
458 }
459
460 print '<form action="'.dolBuildUrl($_SERVER["PHP_SELF"]).'" method="POST">';
461 print '<input type="hidden" name="token" value="'.newToken().'">';
462 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
463 print '<input type="hidden" name="action" value="add">';
464
465 print load_fiche_titre($langs->trans("NewVariousPayment"), '', 'object_payment');
466
467 print dol_get_fiche_head([], '');
468
469 print '<table class="border centpercent">';
470
471 // Date payment
472 print '<tr><td class="titlefieldcreate">';
473 print $form->editfieldkey('DatePayment', 'datep', '', $object, 0, 'string', '', 1).'</td><td>';
474 print $form->selectDate((empty($datep) ? -1 : $datep), "datep", 0, 0, 0, 'add', 1, 1);
475 print '</td></tr>';
476
477 // Date value for bank
478 print '<tr><td>';
479 print $form->editfieldkey('DateValue', 'datev', '', $object, 0).'</td><td>';
480 print $form->selectDate((empty($datev) ? -1 : $datev), "datev", 0, 0, 0, 'add', 1, 1);
481 print '</td></tr>';
482
483 // Label
484 print '<tr><td>';
485 print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'</td><td>';
486 print '<input name="label" id="label" class="minwidth300 maxwidth150onsmartphone" value="'.($label ? $label : $langs->trans("VariousPayment")).'">';
487 print '</td></tr>';
488
489 // Amount
490 print '<tr><td>';
491 print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).'</td><td>';
492 print '<input name="amount" id="amount" class="minwidth50 maxwidth100" value="'.$amount.'">';
493 print ' '.$langs->getCurrencySymbol();
494 print '</td></tr>';
495
496 // Bank
497 if (isModEnabled("bank")) {
498 print '<tr><td>';
499 print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
500 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
501 print $form->select_comptes($accountid, "accountid", 0, '', 2, '', (isModEnabled('multicurrency') ? 1 : 0), '', 1); // Show list of main accounts (comptes courants)
502 print '</td></tr>';
503 }
504
505 // Type payment
506 print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
507 $form->select_types_paiements($paymenttype, 'paymenttype', '', 2);
508 print "</td>\n";
509 print '</tr>';
510
511 // Number
512 if (isModEnabled("bank")) {
513 print '<tr><td><label for="num_payment">'.$langs->trans('Numero');
514 print ' <em class="opacitymedium">('.$langs->trans("ChequeOrTransferNumber").')</em>';
515 print '</label></td>';
516 print '<td><input name="num_payment" class="maxwidth150onsmartphone" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
517
518 // Check transmitter
519 print '<tr><td class="'.(GETPOST('paymenttype') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn"><label for="fieldchqemetteur">'.$langs->trans('CheckTransmitter');
520 print ' <em class="opacitymedium">('.$langs->trans("ChequeMaker").')</em>';
521 print '</label></td>';
522 print '<td><input id="fieldchqemetteur" name="chqemetteur" size="30" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
523
524 // Bank name
525 print '<tr><td><label for="chqbank">'.$langs->trans('Bank');
526 print ' <em class="opacitymedium">('.$langs->trans("ChequeBank").')</em>';
527 print '</label></td>';
528 print '<td><input id="chqbank" name="chqbank" size="30" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
529 }
530
531 // Project
532 if (isModEnabled('project')) {
533 $formproject = new FormProjets($db);
534
535 // Associated project
536 $langs->load("projects");
537
538 print '<tr><td>'.$langs->trans("Project").'</td><td>';
539 print img_picto('', 'project', 'class="pictofixedwidth"');
540 print $formproject->select_projects(-1, (string) $projectid, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 1);
541 print '</td></tr>';
542 }
543
544 // Other attributes
545 print $object->showOptionals($extrafields, 'create');
546
547 $parameters = array();
548 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
549 print $hookmanager->resPrint;
550
551 // Category
552 if (is_array($options) && count($options) && isModEnabled('category')) {
553 print '<tr><td>'.$langs->trans("RubriquesTransactions").'</td><td>';
554 print img_picto('', 'category', 'class="pictofixedwidth"') . Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1, 0, 0, '', 0, 0, 0, '', 'minwidth300', 1);
555 print '</td></tr>';
556 }
557
558 print '<tr><td colspan="2"><hr></td></tr>';
559
560 // Accountancy account
561 if (isModEnabled('accounting')) {
563 // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code
564 print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("AccountAccounting").'</td>';
565 print '<td>';
566 print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, array(), 1, 1);
567 print '</td></tr>';
568 } else { // For external software
569 print '<tr><td class="titlefieldcreate">'.$langs->trans("AccountAccounting").'</td>';
570 print '<td><input class="minwidth100 maxwidthonsmartphone" name="accountancy_code" value="'.$accountancy_code.'">';
571 print '</td></tr>';
572 }
573
574 // Subledger account
575 if (isModEnabled('accounting')) {
577 print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
578 print '<td>';
579 print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, '');
580 print '</td></tr>';
581 } else { // For external software
582 print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
583 print '<td><input class="minwidth100 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
584 print '</td></tr>';
585 }
586
587 // Sens
588 print '<tr><td>';
589 $labelsens = $form->textwithpicto($langs->trans('Sens'), $langs->trans("AccountingDirectionHelp"));
590 print $form->editfieldkey($labelsens, 'sens', '', $object, 0, 'string', '', 1).'</td><td>';
591 $sensarray = array(
592 '0' => array('label' => $langs->trans("Debit")),
593 '1' => array('label' => $langs->trans("Credit"))
594 );
595 // We can't use this module to enter customer payments
596 include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php';
597 if (isALNERunningVersion()) {
598 $sensarray['1']['disabled'] = 1;
599 }
600
601 print $form->selectarray('sens', $sensarray, $sens, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
602 print '</td></tr>';
603
604 print '</table>';
605
606 print dol_get_fiche_end();
607
608 print $form->buttonsSaveCancel();
609
610 print '</form>';
611}
612
613// View in read or edit mode
614if ($id) {
615 $alreadyaccounted = $object->getVentilExportCompta();
616
617 $head = various_payment_prepare_head($object);
618
619 // Clone confirmation
620 if ($action === 'clone') {
621 $set_value_help = $form->textwithpicto('', $langs->trans($langs->trans("AccountingDirectionHelp")));
622 $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit"));
623
624 $formquestion = array(
625 array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
626 array('type' => 'date', 'tdclass' => 'fieldrequired', 'name' => 'clone_date_payment', 'label' => $langs->trans("DatePayment"), 'value' => -1),
627 array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1),
628 array('type' => 'other', 'tdclass' => 'fieldrequired', 'name' => 'clone_accountid', 'label' => $langs->trans("BankAccount"), 'value' => $form->select_comptes($object->fk_account, "accountid", 0, '', 1, '', 0, 'minwidth200', 1)),
629 array('type' => 'text', 'name' => 'clone_amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount)),
630 array('type' => 'select', 'name' => 'clone_sens', 'label' => $langs->trans("Sens").' ' . $set_value_help, 'values' => $sensarray, 'default' => (string) $object->sens),
631 );
632
633 print $form->formconfirm(dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id]), $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 350);
634 }
635
636 // Confirmation of the removal of the Various Payment
637 if ($action == 'delete') {
638 $text = $langs->trans('ConfirmDeleteVariousPayment');
639 print $form->formconfirm(dolBuildUrl($_SERVER["PHP_SELF"], ['id' => $object->id]), $langs->trans('DeleteVariousPayment'), $text, 'confirm_delete', '', '', 2);
640 }
641
642 print dol_get_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto);
643
644 $morehtmlref = '<div class="refidno">';
645 // Project
646 if (isModEnabled('project') && $formproject !== null) {
647 $langs->load("projects");
648 //$morehtmlref .= '<br>';
649 if ($permissiontoadd) {
650 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
651 if ($action != 'classify') {
652 $morehtmlref .= '<a class="editfielda" href="' . dolBuildUrl($_SERVER['PHP_SELF'], ['action' => 'classify', 'id' => $object->id], true).'">' . img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
653 }
654 if ($action == 'classify') {
655 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
656 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
657 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
658 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
659 $morehtmlref .= $formproject->select_projects(-1, (string) $object->fk_project, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx');
660 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
661 $morehtmlref .= '</form>';
662 } else {
663 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (property_exists($object, 'socid') ? $object->socid : 0), (string) $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
664 }
665 } else {
666 if (!empty($object->fk_project)) {
667 $proj = new Project($db);
668 $proj->fetch($object->fk_project);
669 $morehtmlref .= $proj->getNomUrl(1);
670 if ($proj->title) {
671 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
672 }
673 }
674 }
675 }
676
677 $morehtmlref .= '</div>';
678 $linkback = '<a href="' . DOL_URL_ROOT . '/compta/bank/various_payment/list.php?restore_lastsearch_values=1' . (!empty($socid) ? '&socid=' . $socid : '').'">'.$langs->trans("BackToList").'</a>';
679
680 $morehtmlstatus = '';
681
682 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus);
683
684 print '<div class="fichecenter">';
685 print '<div class="underbanner clearboth"></div>';
686
687 print '<table class="border centpercent tableforfield">';
688
689 // Label
690 print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
691
692 // Payment date
693 print "<tr>";
694 print '<td>'.$langs->trans("DatePayment").'</td><td>';
695 print dol_print_date($object->datep, 'day');
696 print '</td></tr>';
697
698 // Value date
699 print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
700 print dol_print_date($object->datev, 'day');
701 print '</td></tr>';
702
703 // Debit / Credit
704 if ($object->sens == '1') {
705 $sens = $langs->trans("Credit");
706 } else {
707 $sens = $langs->trans("Debit");
708 }
709 print '<tr><td>'.$langs->trans("Sens").'</td><td>'.$sens.'</td></tr>';
710
711 print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">' . price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'</span></td></tr>';
712
713 // Account of Chart of account
714 $editvalue = '';
715 if (isModEnabled('accounting')) {
717 print '<tr><td class="nowrap">';
718 print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (int) (!$alreadyaccounted && $permissiontoadd), 'string', '', 0);
719 print '</td><td>';
720 if ($action == 'editaccountancy_code' && (!$alreadyaccounted && $permissiontoadd)) {
721 //print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->hasRight('banque', 'modifier')), 'string', '', 0);
722 print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->accountancy_code, 'accountancy_code', 0, 1, '', 1);
723 } else {
724 $accountingaccount = new AccountingAccount($db);
725 $accountingaccount->fetch(0, $object->accountancy_code, 1);
726
727 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
728 }
729 print '</td></tr>';
730 } else {
731 print '<tr><td class="nowrap">';
732 print $langs->trans("AccountAccounting");
733 print '</td><td>';
734 print $object->accountancy_code;
735 print '</td></tr>';
736 }
737
738 // Subledger account
739 print '<tr><td class="nowrap">';
740 print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (int) (!$alreadyaccounted && $permissiontoadd), 'string', '', 0);
741 print '</td><td>';
742 if ($action == 'editsubledger_account' && (!$alreadyaccounted && $permissiontoadd)) {
743 if (getDolGlobalString('ACCOUNTANCY_AUXACCOUNT_USE_SEARCH_TO_SELECT') > 0) {
745 print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->subledger_account, 'subledger_account', 1, 1, '', 1);
746 } else {
747 print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', null, null, '', 1, 'lengthAccounta');
748 }
749 } else {
750 print length_accounta($object->subledger_account);
751 }
752 print '</td></tr>';
753
754 $bankaccountnotfound = 0;
755
756 if (isModEnabled('bank')) {
757 print '<tr>';
758 print '<td>'.$langs->trans('BankTransactionLine').'</td>';
759 print '<td colspan="3">';
760 if ($object->fk_bank > 0) {
761 $bankline = new AccountLine($db);
762 $result = $bankline->fetch($object->fk_bank);
763
764 if ($result <= 0) {
765 $bankaccountnotfound = 1;
766 } else {
767 print $bankline->getNomUrl(1, 0, 'showall');
768 }
769 } else {
770 $bankaccountnotfound = 1;
771
772 print '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
773 }
774 print '</td>';
775 print '</tr>';
776 }
777
778 // Other attributes
779 $parameters = array('socid' => $object->id);
780 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
781
782 print '</table>';
783
784 print '</div>';
785
786 print '<div class="clearboth"></div>';
787
788 print dol_get_fiche_end();
789
790
791 /*
792 * Action bar
793 */
794 print '<div class="tabsAction">' . "\n";
795
796 // TODO
797 // Add button modify
798
799 // Clone
800 if ($permissiontoadd) {
801 print '<div class="inline-block divButAction"><a class="butAction butActionClone" href="' . dolBuildUrl(DOL_DOCUMENT_ROOT."/compta/bank/various_payment/card.php", ['id' => $object->id, 'action' => 'clone']).'">'.$langs->trans("ToClone") . "</a></div>";
802 }
803
804 // Delete
805 if (empty($object->rappro) || $bankaccountnotfound) {
806 if ($permissiontoadd) {
807 if ($alreadyaccounted) {
808 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("Accounted").'">'.$langs->trans("Delete").'</a></div>';
809 } else {
810 print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete&token=' . newToken().'">'.$langs->trans("Delete").'</a></div>';
811 }
812 } else {
813 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>';
814 }
815 } else {
816 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("LinkedToAConciliatedTransaction").'">'.$langs->trans("Delete").'</a></div>';
817 }
818
819 print "</div>";
820}
821
822// End of page
823llxFooter();
824$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
checkGeneralAccountAllowsAuxiliary($db, $general_account, $auxiliary_account, $general_account_id=0)
Check if a general accounting account allows the use of an auxiliary account.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
various_payment_prepare_head($object)
Prepare array with list of tabs.
Definition bank.lib.php:321
isALNERunningVersion($blockedlogtestalreadydone=0, $blockedlogmodulealreadydone=0)
Return if the application is executed with the LNE requirements on.
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage accounting accounts.
Class to manage bank categories.
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
static selectarray($htmlname, $array, $id='', $show_empty=0, $key_in_label=0, $value_as_key=0, $moreparam='', $translate=0, $maxlen=0, $disabled=0, $sort='', $morecss='minwidth75', $addjscombo=1, $moreparamonempty='', $disablebademail=0, $nohtmlescape=0)
Return a HTML select string, built from an array of key+value.
Class to manage building of HTML components.
Class to manage various payments.
Class to manage projects.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
dol_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='', $useCache=true)
Return an id or code from a code or id.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
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.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130
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.