dolibarr 22.0.5
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2017 Olivier Geffroy <jeff@jeffinfo.com>
3 * Copyright (C) 2013-2017 Florian Henry <florian.henry@open-concept.pro>
4 * Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
5 * Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
6 * Copyright (C) 2018-2024 Frédéric France <frederic.france@free.fr>
7 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
8 * Copyright (C) 2025 Nicolas Barrouillet <nicolas@pragma-tech.fr>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
33require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
35require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
36require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
37require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
38require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
39require_once DOL_DOCUMENT_ROOT.'/accountancy/class/lettering.class.php';
40
49// Load translation files required by the page
50$langs->loadLangs(array("accountancy", "bills", "compta"));
51
52$action = GETPOST('action', 'aZ09');
53$cancel = GETPOST('cancel');
54$confirm = GETPOST('confirm', 'alpha');
55
56$type = GETPOST('type', 'alpha');
57$backtopage = GETPOST('backtopage', 'alpha');
58if (empty($backtopage)) {
59 // Prefix with DOL_URL_ROOT so the redirect works when Dolibarr is installed
60 // under a subpath (e.g. https://host/dolibarr/). A bare /accountancy/...
61 // lands the browser at host root and breaks the redirect (see issue #38478).
62 $backtopage = DOL_URL_ROOT.'/accountancy/bookkeeping/list.php';
63}
64
65$optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
66
67$id = GETPOSTINT('id'); // id of record
68$mode = GETPOST('mode', 'aZ09'); // '' or '_tmp'
69$piece_num = GETPOSTINT("piece_num") ? GETPOSTINT("piece_num") : GETPOST('ref'); // id of transaction (several lines share the same transaction id)
70$clonedate = (int) GETPOSTINT('clonedate');
71
72$accountingaccount = new AccountingAccount($db);
73$accountingjournal = new AccountingJournal($db);
74
75$accountingaccount_number = GETPOST('accountingaccount_number', 'alphanohtml');
76$accountingaccount->fetch(0, $accountingaccount_number, true);
77$accountingaccount_label = $accountingaccount->label;
78
79$journal_code = GETPOST('code_journal', 'alpha');
80$accountingjournal->fetch(0, $journal_code);
81$journal_label = $accountingjournal->label;
82
83$subledger_account = GETPOST('subledger_account', 'alphanohtml');
84if ($subledger_account == -1) {
85 $subledger_account = null;
86}
87$subledger_label = GETPOST('subledger_label', 'alphanohtml');
88
89$label_operation = GETPOST('label_operation', 'alphanohtml');
90$debit = (float) price2num(GETPOST('debit', 'alpha'));
91$credit = (float) price2num(GETPOST('credit', 'alpha'));
92
93$save = GETPOST('save', 'alpha');
94if (!empty($save)) {
95 $action = 'add';
96}
97$update = GETPOST('update', 'alpha');
98if (!empty($update)) {
99 $action = 'confirm_update';
100}
101
102// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
103$hookmanager->initHooks(array('bookkeepingcard', 'globalcard'));
104
105$object = new BookKeeping($db);
106
107// Security check
108if (!isModEnabled('accounting')) {
110}
111if ($user->socid > 0) {
113}
114if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
116}
117
118$permissiontoadd = $user->hasRight('accounting', 'mouvements', 'creer');
119$permissiontodelete = $user->hasRight('accounting', 'mouvements', 'supprimer');
120$numRefModel = getDolGlobalString('BOOKKEEPING_ADDON', 'mod_bookkeeping_neon');
121
122/*
123 * Actions
124 */
125
126$parameters = array();
127$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
128if ($reshook < 0) {
129 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
130}
131if (empty($reshook)) {
132 $error = 0;
133
134 if ($cancel) {
135 header("Location: ". $backtopage . (!empty($type) ? '?type=sub' : ''));
136 exit;
137 }
138
139 if ($action == "confirm_update" && $permissiontoadd) {
140 if (((float) $debit != 0.0) && ((float) $credit != 0.0)) {
141 $error++;
142 setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
143 $action = 'update';
144 }
145 if (empty($accountingaccount_number) || $accountingaccount_number == '-1') {
146 $error++;
147 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
148 $action = 'update';
149 }
150
151 if (!$error) {
152 $object = new BookKeeping($db);
153
154 $result = $object->fetch($id, null, $mode);
155 if ($result < 0) {
156 $error++;
157 setEventMessages($object->error, $object->errors, 'errors');
158 } else {
159 $object->numero_compte = $accountingaccount_number;
160 $object->subledger_account = $subledger_account;
161 $object->subledger_label = $subledger_label;
162 $object->label_compte = $accountingaccount_label;
163 $object->label_operation = $label_operation;
164 $object->debit = $debit;
165 $object->credit = $credit;
166
167 if ((float) $debit != 0.0) {
168 $object->montant = $debit; // deprecated
169 $object->amount = $debit;
170 $object->sens = 'D';
171 }
172 if ((float) $credit != 0.0) {
173 $object->montant = $credit; // deprecated
174 $object->amount = $credit;
175 $object->sens = 'C';
176 }
177
178 $result = $object->update($user, 0, $mode);
179 if ($result < 0) {
180 setEventMessages($object->error, $object->errors, 'errors');
181 } else {
182 if ($mode != '_tmp') {
183 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
184 }
185
186 $debit = 0;
187 $credit = 0;
188
189 $action = '';
190 }
191 }
192 }
193 } elseif ($action == "add" && $permissiontoadd) {
194 if (((float) $debit != 0.0) && ((float) $credit != 0.0)) {
195 $error++;
196 setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
197 $action = '';
198 }
199 if (empty($accountingaccount_number) || $accountingaccount_number == '-1') {
200 $error++;
201 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountAccountingShort")), null, 'errors');
202 $action = '';
203 }
204
205 if (!$error) {
206 if (GETPOSTINT('doc_datemonth') && GETPOSTINT('doc_dateday') && GETPOSTINT('doc_dateyear')) {
207 $datedoc = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear'));
208 } else {
209 $datedoc = (int) GETPOSTINT('doc_date'); // TODO Use instead the mode day-month-year
210 }
211
212 $object = new BookKeeping($db);
213
214 $object->numero_compte = $accountingaccount_number;
215 $object->subledger_account = $subledger_account;
216 $object->subledger_label = $subledger_label;
217 $object->label_compte = $accountingaccount_label;
218 $object->label_operation = $label_operation;
219 $object->debit = $debit;
220 $object->credit = $credit;
221 $object->doc_date = $datedoc;
222 $object->doc_type = (string) GETPOST('doc_type', 'alpha');
223 $object->piece_num = $piece_num;
224 $object->doc_ref = (string) GETPOST('doc_ref', 'alpha');
225 $object->ref = (string) GETPOST('ref', 'alpha');
226 $object->code_journal = $journal_code;
227 $object->journal_label = $journal_label;
228 $object->fk_doc = GETPOSTINT('fk_doc');
229 $object->fk_docdet = GETPOSTINT('fk_docdet');
230
231 if ((float) $debit != 0.0) {
232 $object->montant = $debit; // deprecated
233 $object->amount = $debit;
234 $object->sens = 'D';
235 }
236
237 if ((float) $credit != 0.0) {
238 $object->montant = $credit; // deprecated
239 $object->amount = $credit;
240 $object->sens = 'C';
241 }
242
243 $result = $object->createStd($user, 0, $mode);
244
245 if ($result < 0) {
246 setEventMessages($object->error, $object->errors, 'errors');
247 } else {
248 if ($mode != '_tmp') {
249 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
250 }
251
252 $debit = 0;
253 $credit = 0;
254
255 $action = '';
256 }
257 }
258 } elseif ($action == "confirm_delete" && $permissiontoadd) { // Delete line
259 $object = new BookKeeping($db);
260
261 $result = $object->fetch($id, null, $mode);
262 $piece_num = (int) $object->piece_num;
263 if ($result < 0) {
264 setEventMessages($object->error, $object->errors, 'errors');
265
266 $action = 'create';
267 } elseif ($result > 0) {
268 $result = $object->delete($user, 0, $mode);
269 if ($result < 0) {
270 setEventMessages($object->error, $object->errors, 'errors');
271 }
272 }
273 $action = '';
274 } elseif ($action == "confirm_create" && $permissiontoadd) {
275 $object = new BookKeeping($db);
276
277 if (!$journal_code || $journal_code == '-1') {
278 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Journal")), null, 'errors');
279 $action = 'create';
280 $error++;
281 }
282 if (!GETPOST('doc_ref', 'alpha')) {
283 setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Piece")), null, 'errors');
284 $action = 'create';
285 $error++;
286 }
287
288 if (!$error) {
289 $date_start = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear'));
290
291 $object->label_compte = '';
292 $object->debit = 0;
293 $object->credit = 0;
294 $object->doc_date = $date_start;
295 $object->doc_type = GETPOST('doc_type', 'alpha');
296 $object->piece_num = GETPOSTINT('next_num_mvt');
297 $object->doc_ref = GETPOST('doc_ref', 'alpha');
298 $object->code_journal = $journal_code;
299 $object->journal_label = $journal_label;
300 $object->fk_doc = 0;
301 $object->fk_docdet = 0;
302 $object->ref = (GETPOST('ref', 'alpha') ? GETPOST('ref', 'alpha') : $object->getNextNumRef());
303 $object->montant = 0; // deprecated
304 $object->amount = 0;
305
306 $result = $object->createStd($user, 0, $mode);
307
308 if ($result < 0) {
309 setEventMessages($object->error, $object->errors, 'errors');
310
311 $action = 'create';
312 } else {
313 $reshook = $hookmanager->executeHooks('afterCreateBookkeeping', $parameters, $object, $action);
314
315 if ($mode != '_tmp') {
316 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
317 }
318 $action = '';
319 $id = $object->id;
320 $piece_num = (int) $object->piece_num;
321 }
322 }
323 }
324
325 if ($action == 'setdate' && $permissiontoadd) {
326 $datedoc = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear'));
327 $result = $object->updateByMvt($piece_num, 'doc_date', $db->idate($datedoc), $mode);
328 if ($result < 0) {
329 setEventMessages($object->error, $object->errors, 'errors');
330 } else {
331 if ($mode != '_tmp') {
332 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
333 }
334 $action = '';
335 }
336 }
337
338 if ($action == 'setjournal' && $permissiontoadd) {
339 $result = $object->updateByMvt($piece_num, 'code_journal', $journal_code, $mode);
340 $result = $object->updateByMvt($piece_num, 'journal_label', $journal_label, $mode);
341 if ($result < 0) {
342 setEventMessages($object->error, $object->errors, 'errors');
343 } else {
344 if ($mode != '_tmp') {
345 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
346 }
347 $action = '';
348 }
349 }
350
351 if ($action == 'setdocref' && $permissiontoadd) {
352 $refdoc = GETPOST('doc_ref', 'alpha');
353 $result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode);
354 if ($result < 0) {
355 setEventMessages($object->error, $object->errors, 'errors');
356 } else {
357 if ($mode != '_tmp') {
358 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
359 }
360 $action = '';
361 }
362 }
363
364 if ($action == 'setref' && $permissiontoadd && $numRefModel === 'mod_bookkeeping_neon') {
365 $newref = GETPOST('ref', 'alpha');
366 $result = $object->updateByMvt($piece_num, 'ref', $newref, $mode);
367 if ($result < 0) {
368 setEventMessages($object->error, $object->errors, 'errors');
369 } else {
370 if ($mode != '_tmp') {
371 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
372 }
373 $action = '';
374 }
375 }
376
377 // Validate transaction
378 if ($action == 'valid' && $permissiontoadd) {
379 $result = $object->transformTransaction(0, $piece_num);
380 if ($result < 0) {
381 setEventMessages($object->error, $object->errors, 'errors');
382 } else {
383 header("Location: " . $backtopage . "?sortfield=t.piece_num&sortorder=asc" . ($type ? '&type='.$type : ''));
384 exit;
385 }
386 }
387
388 // Delete all lines into the transaction
389 $toselect_str = explode(',', GETPOST('toselect', 'alphanohtml'));
390 $toselect = array();
391 foreach ($toselect_str as $i) {
392 $toselect[] = (int) $i;
393 }
394
395 if ($action == 'deletebookkeepingwriting' && $confirm == "yes" && $permissiontodelete) {
396 $db->begin();
397
398 if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
399 $lettering = new Lettering($db);
400 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
401 if ($nb_lettering < 0) {
402 setEventMessages('', $lettering->errors, 'errors');
403 $error++;
404 }
405 }
406
407 $nbok = 0;
408 $result = 0;
409 if (!$error) {
410 foreach ($toselect as $toselectid) {
411 $result = $object->fetch($toselectid);
412 if ($result >= 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
413 $result = $object->deleteMvtNum($object->piece_num);
414 if ($result >= 0) {
415 $nbok += $result;
416 } else {
417 setEventMessages($object->error, $object->errors, 'errors');
418 $error++;
419 break;
420 }
421 } elseif ($result < 0) {
422 setEventMessages($object->error, $object->errors, 'errors');
423 $error++;
424 break;
425 } elseif (isset($object->date_validation) && $object->date_validation != '') {
426 setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors');
427 $error++;
428 break;
429 }
430 }
431 }
432
433 if (!$error) {
434 $db->commit();
435
436 // Message for elements well deleted
437 if ($nbok > 1) {
438 setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
439 } elseif ($nbok > 0) {
440 setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
441 } else {
442 setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
443 }
444
445 header("Location: ".DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?noreset=1');
446 exit;
447 } else {
448 $db->rollback();
449 }
450 }
451
452 if ($action == 'clonebookkeepingwriting' && $confirm == "yes" && $permissiontoadd) {
453 // Reread the values sent by the validated form
454 $piece_num = GETPOST('piece_num', 'alpha');
455 $journal_code = GETPOST('code_journal', 'alpha');
456
457 // Reconstruct the selected date
458 $clonedate = dol_mktime(0, 0, 0, GETPOSTINT('clonedatemonth'), GETPOSTINT('clonedateday'), GETPOSTINT('clonedateyear'));
459
460 $result = $object->newClone($piece_num, $journal_code, $clonedate);
461
462 if ($result == -1) {
463 $error++;
464 }
465
466 if (!$error) {
467 $db->commit();
468 header("Location: " . $_SERVER['PHP_SELF'] . "?piece_num=" . ($object->getNextNumMvt() - 1));
469 exit();
470 } else {
471 $db->rollback();
472 }
473 }
474}
475
476
477
478/*
479 * View
480 */
481
482$form = new Form($db);
483$formaccounting = new FormAccounting($db);
484
485$title = $langs->trans("CreateMvts");
486$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double';
487
488llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-consultation page-card');
489
490// Confirmation to delete the command
491if ($action == 'delete') {
492 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'confirm_delete', '', 0, 1);
493 print $formconfirm;
494}
495
496if ($action == 'create') {
497 print load_fiche_titre($title);
498
499 $object = new BookKeeping($db);
500 $next_num_mvt = $object->getNextNumMvt('_tmp');
501
502 if (empty($next_num_mvt)) {
503 dol_print_error(null, 'Failed to get next piece number');
504 }
505
506 print '<form action="'.$_SERVER["PHP_SELF"].'" name="create_mvt" method="POST">';
507 if ($optioncss != '') {
508 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
509 }
510 print '<input type="hidden" name="token" value="'.newToken().'">';
511 print '<input type="hidden" name="action" value="confirm_create">'."\n";
512 print '<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.'">'."\n";
513 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
514 print '<input type="hidden" name="type" value="'.$type.'">';
515 print '<input type="hidden" name="mode" value="_tmp">'."\n";
516
517 print dol_get_fiche_head();
518
519 print '<table class="border centpercent">';
520
521 print '<tr>';
522 print '<td class="fieldrequired">'.$langs->trans("Docdate").'</td>';
523 print '<td>';
524 print $form->selectDate('', 'doc_date', 0, 0, 0, "create_mvt", 1, 1);
525 print '</td>';
526 print '</tr>';
527
528 print '<tr>';
529 print '<td class="fieldrequired">'.$langs->trans("Codejournal").'</td>';
530 print '<td>'.$formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1).'</td>';
531 print '</tr>';
532
533 print '<tr>';
534 print '<td class="fieldrequired">'.$form->textwithpicto($langs->trans("Piece"), $langs->trans("PieceDesc")).'</td>';
535 print '<td><input type="text" class="minwidth200" name="doc_ref" value="'.GETPOST('doc_ref', 'alpha').'"></td>';
536 print '</tr>';
537
538 // Piece number
539 print '<tr>';
540 print '<td>'.$form->textwithpicto($langs->trans("Ref"), $langs->trans("BankTransactionRef")).'</td>';
541 print '<td>';
542 if ($numRefModel === 'mod_bookkeeping_neon') {
543 print '<input type="text" class="minwidth200" name="ref" value="">';
544 } else {
545 print '<span class="opacitymedium">'.$langs->trans("Automatic").'</span>';
546 }
547 print '</td>';
548 print '</tr>';
549
550 /*
551 print '<tr>';
552 print '<td>' . $langs->trans("Doctype") . '</td>';
553 print '<td><input type="text" class="minwidth200 name="doc_type" value=""/></td>';
554 print '</tr>';
555 */
556 $reshookAddLine = $hookmanager->executeHooks('bookkeepingAddLine', $parameters, $object, $action);
557
558 print '</table>';
559
560 print dol_get_fiche_end();
561
562 print $form->buttonsSaveCancel("Create");
563
564 print '</form>';
565} else {
566 $object = new BookKeeping($db);
567
568 $result = $object->fetchPerMvt($piece_num, $mode);
569 if ($result < 0) {
570 setEventMessages($object->error, $object->errors, 'errors');
571 }
572
573 if (!empty($object->piece_num)) {
574 $backlink = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans('BackToList').'</a>';
575
576 /*if ($mode == '_tmp') {
577 print load_fiche_titre($langs->trans("CreateMvts"), $backlink);
578 } else {
579 print load_fiche_titre($langs->trans("UpdateMvts"), $backlink);
580 }*/
581
582 if ($action == 'clonebookkeepingwriting' && $confirm != 'yes' && $permissiontoadd) {
583 $piece_num = GETPOST('piece_num', 'alpha');
584 $formaccounting = new FormAccounting($db);
585
586 $form = new Form($db);
587 $input1 = $form->selectDate('', 'clonedate', 0, 0, 0, "", 1, 1);
588 $input2 = $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1);
589
590 $formquestion = array(
591 array(
592 'type' => 'other',
593 'name' => 'clonedate',
594 'label' => '<span class="fieldrequired">' . $langs->trans("Docdate") . '</span>',
595 'value' => $input1
596 )
597 );
598
599 $formquestion[] = array('type' => 'hidden', 'name' => 'piece_num', 'value' => $piece_num);
600
601 if (getDolGlobalString('ACCOUNTING_CLONING_ENABLE_INPUT_JOURNAL')) {
602 $formquestion[] = array(
603 'type' => 'text',
604 'name' => 'code_journal',
605 'label' => '<span class="fieldrequired">' . $langs->trans("Codejournal") . '</span>',
606 'value' => $input2
607 );
608 }
609
610 print $form->formconfirm(
611 $_SERVER["PHP_SELF"],
612 $langs->trans("ConfirmMassCloneBookkeepingWriting"),
613 $langs->trans("ConfirmMassCloneBookkeepingWritingQuestion", 1),
614 "clonebookkeepingwriting",
615 $formquestion,
616 '', 0, 300, 1000, 0
617 );
618 }
619
620 $head = array();
621 $h = 0;
622 $head[$h][0] = DOL_URL_ROOT."/accountancy/bookkeeping/card.php".'?piece_num='.((int) $object->piece_num).($mode ? '&mode='.$mode : '').($type ? '&type='.$type : '').'&backtopage='.urlencode($backtopage);
623 $head[$h][1] = $langs->trans("Transaction");
624 $head[$h][2] = 'transaction';
625 $h++;
626
627 print dol_get_fiche_head($head, 'transaction', '', -1);
628
629 //$object->label = $object->doc_ref;
630 if ($mode == '_tmp') {
631 $object->context['mode'] = $mode;
632 $object->next_prev_filter = '1=0'; // Add a test always false to disable navigation into the dol_banner_tab. In tmp mode, we just want to create/edit lines of bank transaction.
633 }
634 $object->label = $object->ref;
635
636 $morehtmlref = '<div style="clear: both;"></div>';
637 $morehtmlref .= '<div class="refidno opacitymedium">';
638 $morehtmlref .= $object->label;
639 $morehtmlref .= '</div>';
640
641 dol_banner_tab($object, 'ref', $backlink, 1, 'piece_num', 'piece_num', $morehtmlref);
642
643 print '<div class="fichecenter">';
644
645 print '<div class="fichehalfleft">';
646
647 print '<div class="underbanner clearboth"></div>';
648 print '<table class="border tableforfield centpercent">';
649
650 // Account movement
651 /*
652 print '<tr>';
653 print '<td class="titlefieldmiddle">'.$langs->trans("NumMvts").'</td>';
654 print '<td>'.($mode == '_tmp' ? '<span class="opacitymedium" title="Id tmp '.$object->piece_num.'">'.$langs->trans("Draft").'</span>' : $object->piece_num).'</td>';
655 print '</tr>';
656 */
657
658 // Account movement ref. Edit allowed only for free ref num model.
659 print '<tr><td class="titlefieldmiddle">';
660 print '<table class="nobordernopadding centpercent"><tr><td>';
661 print $langs->trans('Ref');
662 print '</td>';
663 if ($action != 'editref') {
664 print '<td class="right">';
665 if ($permissiontoadd && $numRefModel === 'mod_bookkeeping_neon') {
666 print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editref&token='.newToken().'&piece_num='.((int) $object->piece_num).'&mode='.urlencode((string) $mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a>';
667 }
668 print '</td>';
669 }
670 print '</tr></table>';
671 print '</td><td>';
672 if ($action == 'editref') {
673 print '<form name="setref" action="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).'" method="POST">';
674 if ($optioncss != '') {
675 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
676 }
677 print '<input type="hidden" name="token" value="'.newToken().'">';
678 print '<input type="hidden" name="action" value="setref">';
679 print '<input type="hidden" name="mode" value="'.$mode.'">';
680 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
681 print '<input type="hidden" name="type" value="'.$type.'">';
682 print '<input type="text" size="20" name="ref" value="'.dol_escape_htmltag($object->ref).'">';
683 print '<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans('Modify').'">';
684 print '</form>';
685 } else {
686 print $object->ref;
687 }
688 print '</td>';
689 print '</tr>';
690
691 // Ref document
692 print '<tr><td>';
693 print '<table class="nobordernopadding centpercent"><tr><td>';
694 print $form->textwithpicto($langs->trans('Piece'), $langs->trans('PieceDesc'));
695 print '</td>';
696 if ($action != 'editdocref') {
697 print '<td class="right">';
698 if ($permissiontoadd) {
699 print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdocref&token='.newToken().'&piece_num='.((int) $object->piece_num).'&mode='.urlencode((string) $mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a>';
700 }
701 print '</td>';
702 }
703 print '</tr></table>';
704 print '</td><td>';
705 if ($action == 'editdocref') {
706 print '<form name="setdocref" action="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).'" method="POST">';
707 if ($optioncss != '') {
708 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
709 }
710 print '<input type="hidden" name="token" value="'.newToken().'">';
711 print '<input type="hidden" name="action" value="setdocref">';
712 print '<input type="hidden" name="mode" value="'.$mode.'">';
713 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
714 print '<input type="hidden" name="type" value="'.$type.'">';
715 print '<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag($object->doc_ref).'">';
716 print '<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans('Modify').'">';
717 print '</form>';
718 } else {
719 print $object->doc_ref;
720 }
721 print '</td>';
722 print '</tr>';
723
724 // Date
725 print '<tr><td>';
726 print '<table class="nobordernopadding centpercent"><tr><td>';
727 print $langs->trans('Docdate');
728 print '</td>';
729 if ($action != 'editdate') {
730 print '<td class="right">';
731 if ($permissiontoadd) {
732 print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editdate&token='.newToken().'&piece_num='.((int) $object->piece_num).'&mode='.urlencode((string) $mode).'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'</a>';
733 }
734 print '</td>';
735 }
736 print '</tr></table>';
737 print '</td><td colspan="3">';
738 if ($action == 'editdate') {
739 print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).'" method="POST">';
740 if ($optioncss != '') {
741 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
742 }
743 print '<input type="hidden" name="token" value="'.newToken().'">';
744 print '<input type="hidden" name="action" value="setdate">';
745 print '<input type="hidden" name="mode" value="'.$mode.'">';
746 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
747 print '<input type="hidden" name="type" value="'.$type.'">';
748 print $form->selectDate($object->doc_date ? $object->doc_date : -1, 'doc_date', 0, 0, 0, "setdate");
749 print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
750 print '</form>';
751 } else {
752 print $object->doc_date ? dol_print_date($object->doc_date, 'day') : '&nbsp;';
753 }
754 print '</td>';
755 print '</tr>';
756
757 // Journal
758 print '<tr><td>';
759 print '<table class="nobordernopadding centpercent"><tr><td>';
760 print $langs->trans('Codejournal');
761 print '</td>';
762 if ($action != 'editjournal') {
763 print '<td class="right">';
764 if ($permissiontoadd) {
765 print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editjournal&token='.newToken().'&piece_num='.((int) $object->piece_num).'&mode='.urlencode((string) $mode).'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).'</a>';
766 }
767 print '</td>';
768 }
769 print '</tr></table>';
770 print '</td><td>';
771 if ($action == 'editjournal') {
772 print '<form name="setjournal" action="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).'" method="POST">';
773 if ($optioncss != '') {
774 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
775 }
776 print '<input type="hidden" name="token" value="'.newToken().'">';
777 print '<input type="hidden" name="action" value="setjournal">';
778 print '<input type="hidden" name="mode" value="'.$mode.'">';
779 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
780 print '<input type="hidden" name="type" value="'.$type.'">';
781 print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, 0, 1, '');
782 print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
783 print '</form>';
784 } else {
785 print $object->code_journal;
786 }
787 print '</td>';
788 print '</tr>';
789
790 print '</table>';
791
792 print '</div>';
793
794
795 print '<div class="fichehalfright">';
796
797 print '<div class="underbanner clearboth"></div>';
798 print '<table class="border tableforfield centpercent">';
799
800 // Doc type
801 if (!empty($object->doc_type)) {
802 print '<tr>';
803 print '<td class="titlefield">'.$langs->trans("Doctype").'</td>';
804 print '<td>'.$object->doc_type.'</td>';
805 print '</tr>';
806 }
807
808 // Date document creation
809 print '<tr>';
810 print '<td class="titlefield">'.$langs->trans("DateCreation").'</td>';
811 print '<td>';
812 print $object->date_creation ? dol_print_date($object->date_creation, 'day') : '&nbsp;';
813 print '</td>';
814 print '</tr>';
815
816 // Due date (if invoice)
817 //if (in_array($object->doc_type, array('customer_invoice', 'supplier_invoice'))) {
818 print '<tr>';
819 print '<td class="titlefield">' . $form->textwithpicto($langs->trans('DateDue'), $langs->trans("IfTransactionHasDueDate")) . '</td>';
820 print '<td>';
821 print $object->date_lim_reglement ? dol_print_date($object->date_lim_reglement, 'day') : '&nbsp;';
822 print '</td>';
823 print '</tr>';
824 //}
825
826 // Don't show in tmp mode, inevitably empty
827 if ($mode != "_tmp") {
828 // Date document export
829 print '<tr>';
830 print '<td class="titlefield">' . $langs->trans("DateExport") . '</td>';
831 print '<td>';
832 print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : '&nbsp;';
833 print '</td>';
834 print '</tr>';
835
836 // Date document validation
837 print '<tr>';
838 print '<td class="titlefield">' . $langs->trans("DateValidation") . '</td>';
839 print '<td>';
840 print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : '&nbsp;';
841 print '</td>';
842 print '</tr>';
843
844 // Id_import
845 if (!empty($object->import_key)) {
846 print '<tr>';
847 print '<td class="titlefield">' . $langs->trans("ImportId") . '</td>';
848 print '<td>';
849 print $object->import_key;
850 print '</td>';
851 print '</tr>';
852 }
853 }
854
855 // Validate
856 /*
857 print '<tr>';
858 print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
859 print '<td>';
860 if (empty($object->validated)) {
861 print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=enable&token='.newToken().'">';
862 print img_picto($langs->trans("Disabled"), 'switch_off');
863 print '</a>';
864 } else {
865 print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=disable&token='.newToken().'">';
866 print img_picto($langs->trans("Activated"), 'switch_on');
867 print '</a>';
868 }
869 print '</td>';
870 print '</tr>';
871 */
872
873 // check data
874 /*
875 print '<tr>';
876 print '<td class="titlefield">' . $langs->trans("Control") . '</td>';
877 if ($object->doc_type == 'customer_invoice')
878 {
879 $sqlmid = 'SELECT rowid as ref';
880 $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac";
881 $sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc);
882 dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG);
883 $resultmid = $db->query($sqlmid);
884 if ($resultmid) {
885 $objmid = $db->fetch_object($resultmid);
886 $invoicestatic = new Facture($db);
887 $invoicestatic->fetch($objmid->ref);
888 $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1);
889 }
890 else dol_print_error($db);
891 }
892 print '<td>' . $ref .'</td>';
893 print '</tr>';
894 */
895 print "</table>\n";
896
897 print '</div>';
898
899 print '</div>';
900 print '<div class="clearboth"></div>';
901
902
903 print dol_get_fiche_end();
904
905
906 $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt
907
908 if ($result < 0) {
909 setEventMessages($object->error, $object->errors, 'errors');
910 } else {
911 // Variable that contains all transaction lines
912 $tmptoselect = array();
913 $atleastonevalidated = 0;
914 $atleastoneexported = 0;
915 foreach ($object->linesmvt as $line) {
916 $tmptoselect[] = $line->id;
917 if (!empty($line->date_validation)) {
918 $atleastonevalidated = 1;
919 }
920 if (!empty($line->date_export) || !empty($line->date_validation)) {
921 $atleastoneexported = 1;
922 }
923 }
924
925 if ($mode != '_tmp' && !$atleastonevalidated) {
926 print "\n".'<div class="tabsAction">'."\n";
927
928 $parameters = array();
929 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
930 if (empty($reshook)) {
931 if ($permissiontodelete) {
932 if (!isset($hookmanager->resArray['no_button_edit']) || $hookmanager->resArray['no_button_edit'] != 1) {
933 print dolGetButtonAction('', $langs->trans('Delete'), 'delete', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=deletebookkeepingwriting&confirm=yes&token='.newToken().'&piece_num='.((int) $object->piece_num).'&toselect='.implode(',', $tmptoselect), '', $permissiontodelete);
934 }
935 }
936 if ($permissiontoadd) {
937 print dolGetButtonAction('', $langs->trans('Clone'), 'clone', DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?action=clonebookkeepingwriting&token=' . newToken() . '&piece_num=' . ((int) $object->piece_num) . '&toselect=' . implode(',', $tmptoselect), 'action-clone', $permissiontoadd);
938 }
939 }
940
941 print '</div>';
942 }
943
944 // List of movements
945 print load_fiche_titre($langs->trans("ListeMvts"), '', '');
946
947 print '<form action="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).'" method="POST">';
948 if ($optioncss != '') {
949 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
950 }
951 print '<input type="hidden" name="token" value="'.newToken().'">';
952 print '<input type="hidden" name="doc_date" value="'.$object->doc_date.'">'."\n";
953 print '<input type="hidden" name="doc_type" value="'.$object->doc_type.'">'."\n";
954 print '<input type="hidden" name="doc_ref" value="'.$object->doc_ref.'">'."\n";
955 print '<input type="hidden" name="ref" value="'.$object->ref.'">'."\n";
956 print '<input type="hidden" name="code_journal" value="'.$object->code_journal.'">'."\n";
957 print '<input type="hidden" name="fk_doc" value="'.$object->fk_doc.'">'."\n";
958 print '<input type="hidden" name="fk_docdet" value="'.$object->fk_docdet.'">'."\n";
959 print '<input type="hidden" name="mode" value="'.$mode.'">'."\n";
960 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
961 print '<input type="hidden" name="type" value="'.$type.'">';
962
963 if (count($object->linesmvt) > 0) {
964 print '<div class="div-table-responsive-no-min">';
965 print '<table class="noborder centpercent">';
966
967 $total_debit = 0;
968 $total_credit = 0;
969
970 print '<tr class="liste_titre">';
971
972 print_liste_field_titre("AccountAccountingShort");
973 print_liste_field_titre("SubledgerAccount");
974 print_liste_field_titre("LabelOperation");
975 print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"');
976 print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"');
977 if (empty($object->date_validation)) {
978 print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center ');
979 } else {
981 }
982
983 print "</tr>\n";
984
985 // Add an empty line if there is not yet
986 if (!empty($object->linesmvt[0])) {
987 $tmpline = $object->linesmvt[0];
988 if (!empty($tmpline->numero_compte)) {
989 $line = new BookKeepingLine($db);
990 $object->linesmvt[] = $line;
991 }
992 }
993
994 foreach ($object->linesmvt as $line) {
995 $total_debit += $line->debit;
996 $total_credit += $line->credit;
997
998 if ($action == 'update' && $line->id == $id) {
999 print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
1000 print '<!-- td columns in edit mode -->';
1001 print '<td>';
1002 print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500');
1003 print '</td>';
1004 print '<td>';
1005 // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
1006 // - It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases.
1007 // - Also, it is not possible to use a value that is not in the list.
1008 // - Also, the label is not automatically filled when a value is selected.
1009 if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
1010 print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
1011 } else {
1012 print '<input type="text" class="maxwidth150" name="subledger_account" value="'.(GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccount")).'">';
1013 }
1014 // Add also input for subledger label
1015 print '<br><input type="text" class="maxwidth150" name="subledger_label" value="'.(GETPOSTISSET("subledger_label") ? GETPOST("subledger_label", "alpha") : $line->subledger_label).'" placeholder="'.dol_escape_htmltag($langs->trans("SubledgerAccountLabel")).'">';
1016 print '</td>';
1017 print '<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation).'"></td>';
1018 print '<td class="right"><input type="text" class="right width50" name="debit" value="'.(GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)).'"></td>';
1019 print '<td class="right"><input type="text" class="right width50" name="credit" value="'.(GETPOSTISSET("credit") ? GETPOST("credit", "alpha") : price($line->credit)).'"></td>';
1020 print '<td>';
1021 print '<input type="hidden" name="id" value="'.$line->id.'">'."\n";
1022 print '<input type="submit" class="button" name="update" value="'.$langs->trans("Update").'">';
1023 print '</td>';
1024 print "</tr>\n";
1025 } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) {
1026 if (($action == "" || $action == 'add') && $permissiontoadd) {
1027 print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
1028 print '<!-- td columns in add mode -->';
1029 print '<td>';
1030 print $formaccounting->select_account($action == 'add' ? GETPOST('accountingaccount_number') : '', 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500');
1031 print '</td>';
1032 print '<td>';
1033 // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
1034 // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases.
1035 // Also, it is not possible to use a value that is not in the list.
1036 // Also, the label is not automatically filled when a value is selected.
1037 if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
1038 print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
1039 } else {
1040 print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccount")) . '">';
1041 }
1042 print '<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccountLabel")) . '">';
1043 print '</td>';
1044 print '<td><input type="text" class="minwidth200" name="label_operation" value="' . dol_escape_htmltag($label_operation) . '"/></td>';
1045 print '<td class="right"><input type="text" class="right width50" name="debit" value=""/></td>';
1046 print '<td class="right"><input type="text" class="right width50" name="credit" value=""/></td>';
1047 print '<td class="center"><input type="submit" class="button small" name="save" value="' . $langs->trans("Add") . '"></td>';
1048 print "</tr>\n";
1049 }
1050 } else {
1051 print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
1052 print '<!-- td columns in display mode -->';
1053 $resultfetch = $accountingaccount->fetch(0, $line->numero_compte, true);
1054 print '<td>';
1055 if ($resultfetch > 0) {
1056 print $accountingaccount->getNomUrl(0, 1, 1, '', 0);
1057 } else {
1058 print dol_escape_htmltag($line->numero_compte).' <span class="warning">('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')</span>';
1059 }
1060 print '</td>';
1061 print '<td>'.length_accounta($line->subledger_account);
1062 if ($line->subledger_label) {
1063 print ' - <span class="opacitymedium">'.dol_escape_htmltag($line->subledger_label).'</span>';
1064 }
1065 print '</td>';
1066 print '<td>'.$line->label_operation.'</td>';
1067 print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
1068 print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
1069
1070 print '<td class="center nowraponall">';
1071 if ($permissiontoadd) {
1072 if (empty($line->date_export) && empty($line->date_validation)) {
1073 print '<a class="editfielda reposition" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . ((int) $line->piece_num) . '&mode=' . urlencode((string) $mode) . '&token=' . urlencode(newToken()) . '">';
1074 print img_edit('', 0, 'class="marginrightonly"');
1075 print '</a> &nbsp;';
1076 } else {
1077 print '<a class="editfielda nohover cursornotallowed reposition disabled" href="#" title="'.dol_escape_htmltag($langs->trans("ForbiddenTransactionAlreadyExported")).'">';
1078 print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"');
1079 print '</a> &nbsp;';
1080 }
1081
1082 if (empty($line->date_validation)) {
1083 $actiontodelete = 'delete';
1084 if ($mode == '_tmp' || $action != 'delmouv') {
1085 $actiontodelete = 'confirm_delete';
1086 }
1087
1088 print '<a href="' . $_SERVER["PHP_SELF"] . '?action=' . $actiontodelete . '&id=' . $line->id . '&piece_num=' . ((int) $line->piece_num) . '&mode=' . urlencode((string) $mode) . '&token=' . urlencode(newToken()) . '">';
1089 print img_delete();
1090 print '</a>';
1091 } else {
1092 print '<a class="editfielda nohover cursornotallowed disabled" href="#" title="'.dol_escape_htmltag($langs->trans("ForbiddenTransactionAlreadyExported")).'">';
1093 print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated"));
1094 print '</a>';
1095 }
1096 }
1097 print '</td>';
1098 print "</tr>\n";
1099 }
1100 }
1101
1102 $total_debit = price2num($total_debit, 'MT');
1103 $total_credit = price2num($total_credit, 'MT');
1104
1105 if ($total_debit != $total_credit) {
1106 setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings');
1107 }
1108
1109 print '</table>';
1110 print '</div>';
1111
1112 if ($mode == '_tmp' && $action == '' && $permissiontoadd) {
1113 print '<br>';
1114 print '<div class="center">';
1115 if (empty($total_debit) && empty($total_credit)) {
1116 print '<a class="button disabled cursornotallowed" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("EnterNonEmptyLinesFirst")).'">'.dol_escape_htmltag($langs->trans("ValidTransaction")).'</a>';
1117 } elseif ($total_debit == $total_credit) {
1118 print '<a class="button" href="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).(!empty($type) ? '&type=sub' : '').'&backtopage='.urlencode($backtopage).'&action=valid&token='.newToken().'">'.$langs->trans("ValidTransaction").'</a>';
1119 } else {
1120 print '<a class="button disabled cursornotallowed" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("MvtNotCorrectlyBalanced", $total_debit, $total_credit)).'">'.dol_escape_htmltag($langs->trans("ValidTransaction")).'</a>';
1121 }
1122
1123 print ' &nbsp; ';
1124 print '<a class="button button-cancel" href="'.$backtopage.(!empty($type) ? '?type=sub' : '').'">'.$langs->trans("Cancel").'</a>';
1125
1126 print "</div>";
1127 }
1128 }
1129
1130 print '</form>';
1131 }
1132 } else {
1133 print $langs->trans("NoRecordFound");
1134 }
1135}
1136
1137print dol_get_fiche_end();
1138
1139// End of page
1140llxFooter();
1141$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:48
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to manage accounting accounts.
Class to manage accounting journals.
Class to manage Ledger (General Ledger and Subledger)
Class BookKeepingLine.
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
Class Lettering.
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.