dolibarr 21.0.0-alpha
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2017-2024 Alexandre Spangaro <aspangaro@easya.solutions>
3 * Copyright (C) 2018-2024 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 MDW <mdeweerd@users.noreply.github.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
33require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
35require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
36require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
37if (isModEnabled('project')) {
38 require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
39 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
40}
41
42// Load translation files required by the page
43$langs->loadLangs(array("compta", "banks", "bills", "users", "accountancy", "categories"));
44
45// Get parameters
46$id = GETPOSTINT('id');
47$action = GETPOST('action', 'alpha');
48$confirm = GETPOST('confirm');
49$cancel = GETPOST('cancel', 'aZ09');
50$backtopage = GETPOST('backtopage', 'alpha');
51
52$accountid = GETPOSTINT("accountid") > 0 ? GETPOSTINT("accountid") : 0;
53$label = GETPOST("label", "alpha");
54$sens = GETPOSTINT("sens");
55$amount = GETPOST("amount");
56$paymenttype = GETPOST("paymenttype", "aZ09");
57$accountancy_code = GETPOST("accountancy_code", "alpha");
58$projectid = GETPOSTINT('projectid') ? GETPOSTINT('projectid') : GETPOSTINT('fk_project');
59if (isModEnabled('accounting') && getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
60 $subledger_account = GETPOST("subledger_account", "alpha") > 0 ? GETPOST("subledger_account", "alpha") : '';
61} else {
62 $subledger_account = GETPOST("subledger_account", "alpha");
63}
64
65// Security check
66$socid = GETPOSTINT("socid");
67if ($user->socid) {
68 $socid = $user->socid;
69}
70
71// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
72$hookmanager->initHooks(array('variouscard', 'globalcard'));
73
74$result = restrictedArea($user, 'banque', '', '', '');
75
76$object = new PaymentVarious($db);
77
78$permissiontoadd = $user->hasRight('banque', 'modifier');
79$permissiontodelete = $user->hasRight('banque', 'modifier');
80
81
86$parameters = array();
87$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
88if ($reshook < 0) {
89 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
90}
91
92if (empty($reshook)) {
93 if ($cancel) {
94 if ($action != 'addlink' && $action != 'setaccountancy_code' && $action != 'setsubledger_account') {
95 $urltogo = $backtopage ? $backtopage : dol_buildpath('/compta/bank/various_payment/list.php', 1);
96 header("Location: ".$urltogo);
97 exit;
98 }
99 if ($id > 0 || !empty($ref)) {
100 $ret = $object->fetch($id, $ref);
101 }
102 $action = '';
103 }
104
105 // Link to a project
106 if ($action == 'classin' && $permissiontoadd) {
107 $object->fetch($id);
108 $object->setProject(GETPOSTINT('projectid'));
109 }
110
111 if ($action == 'add' && $permissiontoadd) {
112 $error = 0;
113
114 $datep = dol_mktime(12, 0, 0, GETPOSTINT("datepmonth"), GETPOSTINT("datepday"), GETPOSTINT("datepyear"));
115 $datev = dol_mktime(12, 0, 0, GETPOSTINT("datevmonth"), GETPOSTINT("datevday"), GETPOSTINT("datevyear"));
116 if (empty($datev)) {
117 $datev = $datep;
118 }
119
120 $object->ref = ''; // TODO
121 $object->fk_account = GETPOSTINT("accountid") > 0 ? GETPOSTINT("accountid") : 0;
122 $object->accountid = $object->fk_account;
123 $object->datev = $datev;
124 $object->datep = $datep;
125 $object->amount = GETPOSTFLOAT("amount");
126 $object->label = GETPOST("label", 'restricthtml');
127 $object->note_private = GETPOST("note", 'restricthtml');
128 $object->note = $object->note_private;
129 $object->type_payment = dol_getIdFromCode($db, GETPOST('paymenttype'), 'c_paiement', 'code', 'id', 1);
130 $object->num_payment = GETPOST("num_payment", 'alpha');
131 $object->chqemetteur = GETPOST("chqemetteur", 'alpha');
132 $object->chqbank = GETPOST("chqbank", 'alpha');
133 $object->fk_user_author = $user->id;
134 $object->category_transaction = GETPOSTINT("category_transaction");
135
136 $object->accountancy_code = (GETPOST("accountancy_code") != '-1' ? GETPOST("accountancy_code", "alpha") : "");
137 $object->subledger_account = $subledger_account;
138
139 $object->sens = GETPOSTINT('sens');
140 $object->fk_project = GETPOSTINT('fk_project');
141
142 if (empty($datep) || empty($datev)) {
143 $langs->load('errors');
144 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Date")), null, 'errors');
145 $error++;
146 }
147 if (empty($object->amount)) {
148 $langs->load('errors');
149 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors');
150 $error++;
151 }
152 if (isModEnabled("bank") && !$object->accountid > 0) {
153 $langs->load('errors');
154 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("BankAccount")), null, 'errors');
155 $error++;
156 }
157 if (empty($object->type_payment) || $object->type_payment < 0) {
158 $langs->load('errors');
159 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors');
160 $error++;
161 }
162 if (isModEnabled('accounting') && !$object->accountancy_code) {
163 $langs->load('errors');
164 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountAccounting")), null, 'errors');
165 $error++;
166 }
167 if ($object->sens < 0) {
168 $langs->load('errors');
169 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Sens")), null, 'errors');
170 $error++;
171 }
172
173 $bankaccount = new Account($db);
174 $bankaccount->fetch($object->fk_account);
175
176 // Check currency
177 $currencyofpayment = $conf->currency; // The currency of various payment is not yet asked, so we suppose it is the main company currency
178
179 //var_dump($currencyofpayment); var_dump($bankaccount->currency_code);
180
181 if (isModEnabled('multicurrency') && $currencyofpayment != $bankaccount->currency_code) {
182 // TODO Support this feature the same way we do it for invoice payment
183 // using the $value_converted = MultiCurrency::getAmountConversionFromInvoiceRate($key, $value, $way);
184 setEventMessages($langs->trans("ErrorVariousPaymentOnBankAccountWithADifferentCurrencyNotYetSupported"), null, 'errors');
185 $error++;
186 }
187
188 if (!$error) {
189 $db->begin();
190
191 $ret = $object->create($user);
192 if ($ret > 0) {
193 $db->commit();
194 $urltogo = ($backtopage ? $backtopage : DOL_URL_ROOT.'/compta/bank/various_payment/list.php');
195 header("Location: ".$urltogo);
196 exit;
197 } else {
198 $db->rollback();
199 setEventMessages($object->error, $object->errors, 'errors');
200 $action = "create";
201 }
202 }
203
204 $action = 'create';
205 }
206
207 if ($action == 'confirm_delete' && $confirm == 'yes' && $permissiontodelete) {
208 $result = $object->fetch($id);
209
210 if ($object->rappro == 0) {
211 $db->begin();
212
213 $ret = $object->delete($user);
214 if ($ret > 0) {
215 if ($object->fk_bank) {
216 $accountline = new AccountLine($db);
217 $result = $accountline->fetch($object->fk_bank);
218 if ($result > 0) {
219 $result = $accountline->delete($user); // $result may be 0 if not found (when bank entry was deleted manually and fk_bank point to nothing)
220 }
221 }
222
223 if ($result >= 0) {
224 $db->commit();
225 header("Location: ".DOL_URL_ROOT.'/compta/bank/various_payment/list.php');
226 exit;
227 } else {
228 $object->error = $accountline->error;
229 $db->rollback();
230 setEventMessages($object->error, $object->errors, 'errors');
231 }
232 } else {
233 $db->rollback();
234 setEventMessages($object->error, $object->errors, 'errors');
235 }
236 } else {
237 setEventMessages('Error try do delete a line linked to a conciliated bank transaction', null, 'errors');
238 }
239 }
240
241 if ($action == 'setaccountancy_code' && $permissiontodelete) {
242 $db->begin();
243
244 $result = $object->fetch($id);
245
246 $object->accountancy_code = GETPOST('accountancy_code', 'alphanohtml');
247
248 $res = $object->update($user);
249 if ($res > 0) {
250 $db->commit();
251 } else {
252 $db->rollback();
253 setEventMessages($object->error, $object->errors, 'errors');
254 }
255 }
256
257 if ($action == 'setsubledger_account' && $permissiontodelete) {
258 $db->begin();
259
260 $result = $object->fetch($id);
261
262 $object->subledger_account = $subledger_account;
263
264 $res = $object->update($user);
265 if ($res > 0) {
266 $db->commit();
267 } else {
268 $db->rollback();
269 setEventMessages($object->error, $object->errors, 'errors');
270 }
271 }
272}
273
274// Action clone object
275if ($action == 'confirm_clone' && $confirm != 'yes') { // Test on permission not required
276 $action = '';
277}
278
279if ($action == 'confirm_clone' && $confirm == 'yes' && $permissiontoadd) {
280 $db->begin();
281
282 $originalId = $id;
283
284 $object->fetch($id);
285
286 if ($object->id > 0) {
287 unset($object->id);
288 unset($object->ref);
289
290 if (GETPOST('clone_label', 'alphanohtml')) {
291 $object->label = GETPOST('clone_label', 'alphanohtml');
292 } else {
293 $object->label = $langs->trans("CopyOf").' '.$object->label;
294 }
295
296 $newdatepayment = dol_mktime(0, 0, 0, GETPOSTINT('clone_date_paymentmonth'), GETPOSTINT('clone_date_paymentday'), GETPOSTINT('clone_date_paymentyear'));
297 $newdatevalue = dol_mktime(0, 0, 0, GETPOSTINT('clone_date_valuemonth'), GETPOSTINT('clone_date_valueday'), GETPOSTINT('clone_date_valueyear'));
298 if ($newdatepayment) {
299 $object->datep = $newdatepayment;
300 }
301 if (!empty($newdatevalue)) {
302 $object->datev = $newdatevalue;
303 } else {
304 $object->datev = $newdatepayment;
305 }
306
307 if (GETPOSTISSET("clone_sens")) {
308 $object->sens = GETPOSTINT("clone_sens");
309 } // else { $object->sens = $object->sens; }
310
311 if (GETPOSTISSET("clone_amount")) {
312 $object->amount = GETPOSTFLOAT("clone_amount");
313 } else {
314 $object->amount = (float) price2num($object->amount);
315 }
316
317 if ($object->check()) {
318 $id = $object->create($user);
319 if ($id > 0) {
320 $db->commit();
321 $db->close();
322
323 header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
324 exit;
325 } else {
326 $id = $originalId;
327 $db->rollback();
328
329 setEventMessages($object->error, $object->errors, 'errors');
330 }
331 } else {
332 $id = $originalId;
333 $db->rollback();
334
335 setEventMessages($object->error, $object->errors, 'errors');
336 }
337 } else {
338 $db->rollback();
339 dol_print_error($db, $object->error);
340 }
341}
342
343
344/*
345 * View
346 */
347
348$form = new Form($db);
349if (isModEnabled('accounting')) {
350 $formaccounting = new FormAccounting($db);
351}
352if (isModEnabled('project')) {
353 $formproject = new FormProjets($db);
354}
355
356if ($id) {
357 $object = new PaymentVarious($db);
358 $result = $object->fetch($id);
359 if ($result <= 0) {
360 dol_print_error($db);
361 exit;
362 }
363}
364
365$title = $object->ref." - ".$langs->trans('Card');
366if ($action == 'create') {
367 $title = $langs->trans("NewVariousPayment");
368}
369$help_url = 'EN:Module_Suppliers_Invoices|FR:Module_Fournisseurs_Factures|ES:Módulo_Facturas_de_proveedores|DE:Modul_Lieferantenrechnungen';
370llxHeader('', $title, $help_url);
371
372$options = array();
373
374// Load bank groups
375require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php';
376$bankcateg = new BankCateg($db);
377
378$arrayofbankcategs = $bankcateg->fetchAll();
379
380foreach ($arrayofbankcategs as $bankcategory) {
381 $options[$bankcategory->id] = $bankcategory->label;
382}
383
384// Create mode
385if ($action == 'create') {
386 // Update fields properties in realtime
387 if (!empty($conf->use_javascript_ajax)) {
388 print "\n".'<script type="text/javascript">';
389 print '$(document).ready(function () {
390 setPaymentType();
391 $("#selectpaymenttype").change(function() {
392 setPaymentType();
393 });
394 function setPaymentType()
395 {
396 console.log("setPaymentType");
397 var code = $("#selectpaymenttype option:selected").val();
398 if (code == \'CHQ\' || code == \'VIR\')
399 {
400 if (code == \'CHQ\')
401 {
402 $(\'.fieldrequireddyn\').addClass(\'fieldrequired\');
403 }
404 if ($(\'#fieldchqemetteur\').val() == \'\')
405 {
406 var emetteur = jQuery(\'#thirdpartylabel\').val();
407 $(\'#fieldchqemetteur\').val(emetteur);
408 }
409 }
410 else
411 {
412 $(\'.fieldrequireddyn\').removeClass(\'fieldrequired\');
413 $(\'#fieldchqemetteur\').val(\'\');
414 }
415 }
416 ';
417
418 print ' });'."\n";
419
420 print ' </script>'."\n";
421 }
422
423 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
424 print '<input type="hidden" name="token" value="'.newToken().'">';
425 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
426 print '<input type="hidden" name="action" value="add">';
427
428 print load_fiche_titre($langs->trans("NewVariousPayment"), '', 'object_payment');
429
430 print dol_get_fiche_head([], '');
431
432 print '<table class="border centpercent">';
433
434 // Date payment
435 print '<tr><td class="titlefieldcreate">';
436 print $form->editfieldkey('DatePayment', 'datep', '', $object, 0, 'string', '', 1).'</td><td>';
437 print $form->selectDate((empty($datep) ? -1 : $datep), "datep", 0, 0, 0, 'add', 1, 1);
438 print '</td></tr>';
439
440 // Date value for bank
441 print '<tr><td>';
442 print $form->editfieldkey('DateValue', 'datev', '', $object, 0).'</td><td>';
443 print $form->selectDate((empty($datev) ? -1 : $datev), "datev", 0, 0, 0, 'add', 1, 1);
444 print '</td></tr>';
445
446 // Label
447 print '<tr><td>';
448 print $form->editfieldkey('Label', 'label', '', $object, 0, 'string', '', 1).'</td><td>';
449 print '<input name="label" id="label" class="minwidth300 maxwidth150onsmartphone" value="'.($label ? $label : $langs->trans("VariousPayment")).'">';
450 print '</td></tr>';
451
452 // Amount
453 print '<tr><td>';
454 print $form->editfieldkey('Amount', 'amount', '', $object, 0, 'string', '', 1).'</td><td>';
455 print '<input name="amount" id="amount" class="minwidth50 maxwidth100" value="'.$amount.'">';
456 print '</td></tr>';
457
458 // Bank
459 if (isModEnabled("bank")) {
460 print '<tr><td>';
461 print $form->editfieldkey('BankAccount', 'selectaccountid', '', $object, 0, 'string', '', 1).'</td><td>';
462 print img_picto('', 'bank_account', 'class="pictofixedwidth"');
463 print $form->select_comptes($accountid, "accountid", 0, '', 2, '', (isModEnabled('multicurrency') ? 1 : 0), '', 1); // Show list of main accounts (comptes courants)
464 print '</td></tr>';
465 }
466
467 // Type payment
468 print '<tr><td><span class="fieldrequired">'.$langs->trans('PaymentMode').'</span></td><td>';
469 $form->select_types_paiements($paymenttype, 'paymenttype', '', 2);
470 print "</td>\n";
471 print '</tr>';
472
473 // Number
474 if (isModEnabled("bank")) {
475 print '<tr><td><label for="num_payment">'.$langs->trans('Numero');
476 print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';
477 print '</label></td>';
478 print '<td><input name="num_payment" class="maxwidth150onsmartphone" id="num_payment" type="text" value="'.GETPOST("num_payment").'"></td></tr>'."\n";
479
480 // Check transmitter
481 print '<tr><td class="'.(GETPOST('paymenttype') == 'CHQ' ? 'fieldrequired ' : '').'fieldrequireddyn"><label for="fieldchqemetteur">'.$langs->trans('CheckTransmitter');
482 print ' <em>('.$langs->trans("ChequeMaker").')</em>';
483 print '</label></td>';
484 print '<td><input id="fieldchqemetteur" name="chqemetteur" size="30" type="text" value="'.GETPOST('chqemetteur', 'alphanohtml').'"></td></tr>';
485
486 // Bank name
487 print '<tr><td><label for="chqbank">'.$langs->trans('Bank');
488 print ' <em>('.$langs->trans("ChequeBank").')</em>';
489 print '</label></td>';
490 print '<td><input id="chqbank" name="chqbank" size="30" type="text" value="'.GETPOST('chqbank', 'alphanohtml').'"></td></tr>';
491 }
492
493 // Project
494 if (isModEnabled('project')) {
495 $formproject = new FormProjets($db);
496
497 // Associated project
498 $langs->load("projects");
499
500 print '<tr><td>'.$langs->trans("Project").'</td><td>';
501 print img_picto('', 'project', 'class="pictofixedwidth"');
502 print $formproject->select_projects(-1, $projectid, 'fk_project', 0, 0, 1, 1, 0, 0, 0, '', 1);
503 print '</td></tr>';
504 }
505
506 // Other attributes
507 $parameters = array();
508 $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
509 print $hookmanager->resPrint;
510
511 // Category
512 if (is_array($options) && count($options) && $conf->categorie->enabled) {
513 print '<tr><td>'.$langs->trans("RubriquesTransactions").'</td><td>';
514 print img_picto('', 'category').Form::selectarray('category_transaction', $options, GETPOST('category_transaction'), 1, 0, 0, '', 0, 0, 0, '', 'minwidth300', 1);
515 print '</td></tr>';
516 }
517
518 print '<tr><td colspan="2"><hr></td></tr>';
519
520 // Accountancy account
521 if (isModEnabled('accounting')) {
522 // TODO Remove the fieldrequired and allow instead to edit a various payment to enter accounting code
523 print '<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans("AccountAccounting").'</td>';
524 print '<td>';
525 print $formaccounting->select_account($accountancy_code, 'accountancy_code', 1, null, 1, 1);
526 print '</td></tr>';
527 } else { // For external software
528 print '<tr><td class="titlefieldcreate">'.$langs->trans("AccountAccounting").'</td>';
529 print '<td><input class="minwidth100 maxwidthonsmartphone" name="accountancy_code" value="'.$accountancy_code.'">';
530 print '</td></tr>';
531 }
532
533 // Subledger account
534 if (isModEnabled('accounting')) {
535 print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
536 print '<td>';
537 if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
538 print $formaccounting->select_auxaccount($subledger_account, 'subledger_account', 1, '');
539 } else {
540 print '<input type="text" class="maxwidth200 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
541 }
542 print '</td></tr>';
543 } else { // For external software
544 print '<tr><td>'.$langs->trans("SubledgerAccount").'</td>';
545 print '<td><input class="minwidth100 maxwidthonsmartphone" name="subledger_account" value="'.$subledger_account.'">';
546 print '</td></tr>';
547 }
548
549 // Sens
550 print '<tr><td>';
551 $labelsens = $form->textwithpicto($langs->trans('Sens'), $langs->trans("AccountingDirectionHelp"));
552 print $form->editfieldkey($labelsens, 'sens', '', $object, 0, 'string', '', 1).'</td><td>';
553 $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit"));
554 print $form->selectarray('sens', $sensarray, $sens, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100', 1);
555 print '</td></tr>';
556
557 print '</table>';
558
559 print dol_get_fiche_end();
560
561 print $form->buttonsSaveCancel();
562
563 print '</form>';
564}
565
566// View in read or edit mode
567if ($id) {
568 $alreadyaccounted = $object->getVentilExportCompta();
569
571
572 // Clone confirmation
573 if ($action === 'clone') {
574 $set_value_help = $form->textwithpicto('', $langs->trans($langs->trans("AccountingDirectionHelp")));
575 $sensarray = array('0' => $langs->trans("Debit"), '1' => $langs->trans("Credit"));
576
577 $formquestion = array(
578 array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label),
579 array('type' => 'date', 'tdclass' => 'fieldrequired', 'name' => 'clone_date_payment', 'label' => $langs->trans("DatePayment"), 'value' => -1),
580 array('type' => 'date', 'name' => 'clone_date_value', 'label' => $langs->trans("DateValue"), 'value' => -1),
581 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)),
582 array('type' => 'text', 'name' => 'clone_amount', 'label' => $langs->trans("Amount"), 'value' => price($object->amount)),
583 array('type' => 'select', 'name' => 'clone_sens', 'label' => $langs->trans("Sens").' '.$set_value_help, 'values' => $sensarray, 'default' => $object->sens),
584 );
585
586 print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVariousPayment', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 350);
587 }
588
589 // Confirmation of the removal of the Various Payment
590 if ($action == 'delete') {
591 $text = $langs->trans('ConfirmDeleteVariousPayment');
592 print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVariousPayment'), $text, 'confirm_delete', '', '', 2);
593 }
594
595 print dol_get_fiche_head($head, 'card', $langs->trans("VariousPayment"), -1, $object->picto);
596
597 $morehtmlref = '<div class="refidno">';
598 // Project
599 if (isModEnabled('project')) {
600 $langs->load("projects");
601 //$morehtmlref .= '<br>';
602 if ($permissiontoadd) {
603 $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
604 if ($action != 'classify') {
605 $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
606 }
607 if ($action == 'classify') {
608 //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
609 $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
610 $morehtmlref .= '<input type="hidden" name="action" value="classin">';
611 $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
612 $morehtmlref .= $formproject->select_projects(-1, $object->fk_project, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 1, 0, 'maxwidth500 widthcentpercentminusxx');
613 $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
614 $morehtmlref .= '</form>';
615 } else {
616 $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, (property_exists($object, 'socid') ? $object->socid : 0), $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
617 }
618 } else {
619 if (!empty($object->fk_project)) {
620 $proj = new Project($db);
621 $proj->fetch($object->fk_project);
622 $morehtmlref .= $proj->getNomUrl(1);
623 if ($proj->title) {
624 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
625 }
626 }
627 }
628 }
629
630 $morehtmlref .= '</div>';
631 $linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/various_payment/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
632
633 $morehtmlstatus = '';
634
635 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlstatus);
636
637 print '<div class="fichecenter">';
638 print '<div class="underbanner clearboth"></div>';
639
640 print '<table class="border centpercent tableforfield">';
641
642 // Label
643 print '<tr><td class="titlefield">'.$langs->trans("Label").'</td><td>'.$object->label.'</td></tr>';
644
645 // Payment date
646 print "<tr>";
647 print '<td>'.$langs->trans("DatePayment").'</td><td>';
648 print dol_print_date($object->datep, 'day');
649 print '</td></tr>';
650
651 // Value date
652 print '<tr><td>'.$langs->trans("DateValue").'</td><td>';
653 print dol_print_date($object->datev, 'day');
654 print '</td></tr>';
655
656 // Debit / Credit
657 if ($object->sens == '1') {
658 $sens = $langs->trans("Credit");
659 } else {
660 $sens = $langs->trans("Debit");
661 }
662 print '<tr><td>'.$langs->trans("Sens").'</td><td>'.$sens.'</td></tr>';
663
664 print '<tr><td>'.$langs->trans("Amount").'</td><td><span class="amount">'.price($object->amount, 0, $langs, 1, -1, -1, $conf->currency).'</span></td></tr>';
665
666 // Account of Chart of account
667 $editvalue = '';
668 if (isModEnabled('accounting')) {
669 print '<tr><td class="nowrap">';
670 print $form->editfieldkey('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0);
671 print '</td><td>';
672 if ($action == 'editaccountancy_code' && (!$alreadyaccounted && $permissiontoadd)) {
673 //print $form->editfieldval('AccountAccounting', 'accountancy_code', $object->accountancy_code, $object, (!$alreadyaccounted && $user->hasRight('banque', 'modifier')), 'string', '', 0);
674 print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->accountancy_code, 'accountancy_code', 0, 1, '', 1);
675 } else {
676 $accountingaccount = new AccountingAccount($db);
677 $accountingaccount->fetch(0, $object->accountancy_code, 1);
678
679 print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
680 }
681 print '</td></tr>';
682 } else {
683 print '<tr><td class="nowrap">';
684 print $langs->trans("AccountAccounting");
685 print '</td><td>';
686 print $object->accountancy_code;
687 print '</td></tr>';
688 }
689
690 // Subledger account
691 print '<tr><td class="nowrap">';
692 print $form->editfieldkey('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', 0);
693 print '</td><td>';
694 if ($action == 'editsubledger_account' && (!$alreadyaccounted && $permissiontoadd)) {
695 if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
696 print $formaccounting->formAccountingAccount($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->subledger_account, 'subledger_account', 1, 1, '', 1);
697 } else {
698 print $form->editfieldval('SubledgerAccount', 'subledger_account', $object->subledger_account, $object, (!$alreadyaccounted && $permissiontoadd), 'string', '', null, null, '', 1, 'lengthAccounta');
699 }
700 } else {
701 print length_accounta($object->subledger_account);
702 }
703 print '</td></tr>';
704
705 $bankaccountnotfound = 0;
706
707 if (isModEnabled('bank')) {
708 print '<tr>';
709 print '<td>'.$langs->trans('BankTransactionLine').'</td>';
710 print '<td colspan="3">';
711 if ($object->fk_bank > 0) {
712 $bankline = new AccountLine($db);
713 $result = $bankline->fetch($object->fk_bank);
714
715 if ($result <= 0) {
716 $bankaccountnotfound = 1;
717 } else {
718 print $bankline->getNomUrl(1, 0, 'showall');
719 }
720 } else {
721 $bankaccountnotfound = 1;
722
723 print '<span class="opacitymedium">'.$langs->trans("NoRecordfound").'</span>';
724 }
725 print '</td>';
726 print '</tr>';
727 }
728
729 // Other attributes
730 $parameters = array('socid' => $object->id);
731 include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
732
733 print '</table>';
734
735 print '</div>';
736
737 print '<div class="clearboth"></div>';
738
739 print dol_get_fiche_end();
740
741
742 /*
743 * Action bar
744 */
745 print '<div class="tabsAction">'."\n";
746
747 // TODO
748 // Add button modify
749
750 // Clone
751 if ($permissiontoadd) {
752 print '<div class="inline-block divButAction"><a class="butAction" href="'.dol_buildpath("/compta/bank/various_payment/card.php", 1).'?id='.$object->id.'&amp;action=clone">'.$langs->trans("ToClone")."</a></div>";
753 }
754
755 // Delete
756 if (empty($object->rappro) || $bankaccountnotfound) {
757 if ($permissiontoadd) {
758 if ($alreadyaccounted) {
759 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("Accounted").'">'.$langs->trans("Delete").'</a></div>';
760 } else {
761 print '<div class="inline-block divButAction"><a class="butActionDelete" href="card.php?id='.$object->id.'&action=delete&token='.newToken().'">'.$langs->trans("Delete").'</a></div>';
762 }
763 } else {
764 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.(dol_escape_htmltag($langs->trans("NotAllowed"))).'">'.$langs->trans("Delete").'</a></div>';
765 }
766 } else {
767 print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans("LinkedToAConciliatedTransaction").'">'.$langs->trans("Delete").'</a></div>';
768 }
769
770 print "</div>";
771}
772
773// End of page
774llxFooter();
775$db->close();
$id
Definition account.php:39
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
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
various_payment_prepare_head($object)
Prepare array with list of tabs.
Definition bank.lib.php:236
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.
Class to manage building of HTML components.
Class to manage various payments.
Class to manage projects.
llxFooter()
Footer empty.
Definition document.php:107
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
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)
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
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.