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