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