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", "errors"));
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 if (dol_strlen(GETPOST('ref', 'alpha')) > 30) { // Size of field ref in database
288 setEventMessages($langs->trans("ErrorFieldTooLong", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
289 $action = 'create';
290 $error++;
291 }
292
293 if (!$error) {
294 $date_start = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear'));
295
296 $object->label_compte = '';
297 $object->debit = 0;
298 $object->credit = 0;
299 $object->doc_date = $date_start;
300 $object->doc_type = GETPOST('doc_type', 'alpha');
301 $object->piece_num = GETPOSTINT('next_num_mvt');
302 $object->doc_ref = GETPOST('doc_ref', 'alpha');
303 $object->code_journal = $journal_code;
304 $object->journal_label = $journal_label;
305 $object->fk_doc = 0;
306 $object->fk_docdet = 0;
307 $object->ref = (GETPOST('ref', 'alpha') ? GETPOST('ref', 'alpha') : $object->getNextNumRef());
308 $object->montant = 0; // deprecated
309 $object->amount = 0;
310
311 $result = $object->createStd($user, 0, $mode);
312
313 if ($result < 0) {
314 setEventMessages($object->error, $object->errors, 'errors');
315
316 $action = 'create';
317 } else {
318 $reshook = $hookmanager->executeHooks('afterCreateBookkeeping', $parameters, $object, $action);
319
320 if ($mode != '_tmp') {
321 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
322 }
323 $action = '';
324 $id = $object->id;
325 $piece_num = (int) $object->piece_num;
326 }
327 }
328 }
329
330 if ($action == 'setdate' && $permissiontoadd) {
331 $datedoc = dol_mktime(0, 0, 0, GETPOSTINT('doc_datemonth'), GETPOSTINT('doc_dateday'), GETPOSTINT('doc_dateyear'));
332 $result = $object->updateByMvt($piece_num, 'doc_date', $db->idate($datedoc), $mode);
333 if ($result < 0) {
334 setEventMessages($object->error, $object->errors, 'errors');
335 } else {
336 if ($mode != '_tmp') {
337 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
338 }
339 $action = '';
340 }
341 }
342
343 if ($action == 'setjournal' && $permissiontoadd) {
344 $result = $object->updateByMvt($piece_num, 'code_journal', $journal_code, $mode);
345 $result = $object->updateByMvt($piece_num, 'journal_label', $journal_label, $mode);
346 if ($result < 0) {
347 setEventMessages($object->error, $object->errors, 'errors');
348 } else {
349 if ($mode != '_tmp') {
350 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
351 }
352 $action = '';
353 }
354 }
355
356 if ($action == 'setdocref' && $permissiontoadd) {
357 $refdoc = GETPOST('doc_ref', 'alpha');
358 $result = $object->updateByMvt($piece_num, 'doc_ref', $refdoc, $mode);
359 if ($result < 0) {
360 setEventMessages($object->error, $object->errors, 'errors');
361 } else {
362 if ($mode != '_tmp') {
363 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
364 }
365 $action = '';
366 }
367 }
368
369 if ($action == 'setref' && $permissiontoadd && $numRefModel === 'mod_bookkeeping_neon') {
370 $newref = GETPOST('ref', 'alpha');
371 if (dol_strlen($newref) > 30) { // Size of field ref in database
372 $result = -1;
373 $object->error = $langs->trans("ErrorFieldTooLong", $langs->transnoentitiesnoconv("Ref"));
374 $object->errors = array();
375 } else {
376 $result = $object->updateByMvt($piece_num, 'ref', $newref, $mode);
377 }
378 if ($result < 0) {
379 setEventMessages($object->error, $object->errors, 'errors');
380 } else {
381 if ($mode != '_tmp') {
382 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
383 }
384 $action = '';
385 }
386 }
387
388 // Validate transaction
389 if ($action == 'valid' && $permissiontoadd) {
390 $result = $object->transformTransaction(0, $piece_num);
391 if ($result < 0) {
392 setEventMessages($object->error, $object->errors, 'errors');
393 } else {
394 header("Location: " . $backtopage . "?sortfield=t.piece_num&sortorder=asc" . ($type ? '&type='.$type : ''));
395 exit;
396 }
397 }
398
399 // Delete all lines into the transaction
400 $toselect_str = explode(',', GETPOST('toselect', 'alphanohtml'));
401 $toselect = array();
402 foreach ($toselect_str as $i) {
403 $toselect[] = (int) $i;
404 }
405
406 if ($action == 'deletebookkeepingwriting' && $confirm == "yes" && $permissiontodelete) {
407 $db->begin();
408
409 if (getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING')) {
410 $lettering = new Lettering($db);
411 $nb_lettering = $lettering->bookkeepingLetteringAll($toselect, true);
412 if ($nb_lettering < 0) {
413 setEventMessages('', $lettering->errors, 'errors');
414 $error++;
415 }
416 }
417
418 $nbok = 0;
419 $result = 0;
420 if (!$error) {
421 foreach ($toselect as $toselectid) {
422 $result = $object->fetch($toselectid);
423 if ($result >= 0 && (!isset($object->date_validation) || $object->date_validation === '')) {
424 $result = $object->deleteMvtNum($object->piece_num);
425 if ($result >= 0) {
426 $nbok += $result;
427 } else {
428 setEventMessages($object->error, $object->errors, 'errors');
429 $error++;
430 break;
431 }
432 } elseif ($result < 0) {
433 setEventMessages($object->error, $object->errors, 'errors');
434 $error++;
435 break;
436 } elseif (isset($object->date_validation) && $object->date_validation != '') {
437 setEventMessages($langs->trans("ValidatedRecordWhereFound"), null, 'errors');
438 $error++;
439 break;
440 }
441 }
442 }
443
444 if (!$error) {
445 $db->commit();
446
447 // Message for elements well deleted
448 if ($nbok > 1) {
449 setEventMessages($langs->trans("RecordsDeleted", $nbok), null, 'mesgs');
450 } elseif ($nbok > 0) {
451 setEventMessages($langs->trans("RecordDeleted", $nbok), null, 'mesgs');
452 } else {
453 setEventMessages($langs->trans("NoRecordDeleted"), null, 'mesgs');
454 }
455
456 header("Location: ".DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?noreset=1');
457 exit;
458 } else {
459 $db->rollback();
460 }
461 }
462
463 if ($action == 'clonebookkeepingwriting' && $confirm == "yes" && $permissiontoadd) {
464 // Reread the values sent by the validated form
465 $piece_num = GETPOST('piece_num', 'alpha');
466 $journal_code = GETPOST('code_journal', 'alpha');
467
468 // Reconstruct the selected date
469 $clonedate = dol_mktime(0, 0, 0, GETPOSTINT('clonedatemonth'), GETPOSTINT('clonedateday'), GETPOSTINT('clonedateyear'));
470
471 $result = $object->newClone($piece_num, $journal_code, $clonedate);
472
473 if ($result == -1) {
474 $error++;
475 }
476
477 if (!$error) {
478 $db->commit();
479 header("Location: " . $_SERVER['PHP_SELF'] . "?piece_num=" . ($object->getNextNumMvt() - 1));
480 exit();
481 } else {
482 $db->rollback();
483 }
484 }
485}
486
487
488
489/*
490 * View
491 */
492
493$form = new Form($db);
494$formaccounting = new FormAccounting($db);
495
496$title = $langs->trans("CreateMvts");
497$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double';
498
499llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-consultation page-card');
500
501// Confirmation to delete the command
502if ($action == 'delete') {
503 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$id.'&mode='.$mode, $langs->trans('DeleteMvt'), $langs->trans('ConfirmDeleteMvt', $langs->transnoentitiesnoconv("RegistrationInAccounting")), 'confirm_delete', '', 0, 1);
504 print $formconfirm;
505}
506
507if ($action == 'create') {
508 print load_fiche_titre($title);
509
510 $object = new BookKeeping($db);
511 $next_num_mvt = $object->getNextNumMvt('_tmp');
512
513 if (empty($next_num_mvt)) {
514 dol_print_error(null, 'Failed to get next piece number');
515 }
516
517 print '<form action="'.$_SERVER["PHP_SELF"].'" name="create_mvt" method="POST">';
518 if ($optioncss != '') {
519 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
520 }
521 print '<input type="hidden" name="token" value="'.newToken().'">';
522 print '<input type="hidden" name="action" value="confirm_create">'."\n";
523 print '<input type="hidden" name="next_num_mvt" value="'.$next_num_mvt.'">'."\n";
524 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
525 print '<input type="hidden" name="type" value="'.$type.'">';
526 print '<input type="hidden" name="mode" value="_tmp">'."\n";
527
528 print dol_get_fiche_head();
529
530 print '<table class="border centpercent">';
531
532 print '<tr>';
533 print '<td class="fieldrequired">'.$langs->trans("Docdate").'</td>';
534 print '<td>';
535 print $form->selectDate('', 'doc_date', 0, 0, 0, "create_mvt", 1, 1);
536 print '</td>';
537 print '</tr>';
538
539 print '<tr>';
540 print '<td class="fieldrequired">'.$langs->trans("Codejournal").'</td>';
541 print '<td>'.$formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1).'</td>';
542 print '</tr>';
543
544 print '<tr>';
545 print '<td class="fieldrequired">'.$form->textwithpicto($langs->trans("Piece"), $langs->trans("PieceDesc")).'</td>';
546 print '<td><input type="text" class="minwidth200" name="doc_ref" value="'.GETPOST('doc_ref', 'alpha').'"></td>';
547 print '</tr>';
548
549 // Piece number
550 print '<tr>';
551 print '<td>'.$form->textwithpicto($langs->trans("Ref"), $langs->trans("BankTransactionRef")).'</td>';
552 print '<td>';
553 if ($numRefModel === 'mod_bookkeeping_neon') {
554 print '<input type="text" class="minwidth200" name="ref" maxlength="30" value="">';
555 } else {
556 print '<span class="opacitymedium">'.$langs->trans("Automatic").'</span>';
557 }
558 print '</td>';
559 print '</tr>';
560
561 /*
562 print '<tr>';
563 print '<td>' . $langs->trans("Doctype") . '</td>';
564 print '<td><input type="text" class="minwidth200 name="doc_type" value=""/></td>';
565 print '</tr>';
566 */
567 $reshookAddLine = $hookmanager->executeHooks('bookkeepingAddLine', $parameters, $object, $action);
568
569 print '</table>';
570
571 print dol_get_fiche_end();
572
573 print $form->buttonsSaveCancel("Create");
574
575 print '</form>';
576} else {
577 $object = new BookKeeping($db);
578
579 $result = $object->fetchPerMvt($piece_num, $mode);
580 if ($result < 0) {
581 setEventMessages($object->error, $object->errors, 'errors');
582 }
583
584 if (!empty($object->piece_num)) {
585 $backlink = '<a href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/list.php?restore_lastsearch_values=1">'.$langs->trans('BackToList').'</a>';
586
587 /*if ($mode == '_tmp') {
588 print load_fiche_titre($langs->trans("CreateMvts"), $backlink);
589 } else {
590 print load_fiche_titre($langs->trans("UpdateMvts"), $backlink);
591 }*/
592
593 if ($action == 'clonebookkeepingwriting' && $confirm != 'yes' && $permissiontoadd) {
594 $piece_num = GETPOST('piece_num', 'alpha');
595 $formaccounting = new FormAccounting($db);
596
597 $form = new Form($db);
598 $input1 = $form->selectDate('', 'clonedate', 0, 0, 0, "", 1, 1);
599 $input2 = $formaccounting->select_journal($journal_code, 'code_journal', 0, 0, 1, 1);
600
601 $formquestion = array(
602 array(
603 'type' => 'other',
604 'name' => 'clonedate',
605 'label' => '<span class="fieldrequired">' . $langs->trans("Docdate") . '</span>',
606 'value' => $input1
607 )
608 );
609
610 $formquestion[] = array('type' => 'hidden', 'name' => 'piece_num', 'value' => $piece_num);
611
612 if (getDolGlobalString('ACCOUNTING_CLONING_ENABLE_INPUT_JOURNAL')) {
613 $formquestion[] = array(
614 'type' => 'text',
615 'name' => 'code_journal',
616 'label' => '<span class="fieldrequired">' . $langs->trans("Codejournal") . '</span>',
617 'value' => $input2
618 );
619 }
620
621 print $form->formconfirm(
622 $_SERVER["PHP_SELF"],
623 $langs->trans("ConfirmMassCloneBookkeepingWriting"),
624 $langs->trans("ConfirmMassCloneBookkeepingWritingQuestion", 1),
625 "clonebookkeepingwriting",
626 $formquestion,
627 '', 0, 300, 1000, 0
628 );
629 }
630
631 $head = array();
632 $h = 0;
633 $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);
634 $head[$h][1] = $langs->trans("Transaction");
635 $head[$h][2] = 'transaction';
636 $h++;
637
638 print dol_get_fiche_head($head, 'transaction', '', -1);
639
640 //$object->label = $object->doc_ref;
641 if ($mode == '_tmp') {
642 $object->context['mode'] = $mode;
643 $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.
644 }
645 $object->label = $object->ref;
646
647 $morehtmlref = '<div style="clear: both;"></div>';
648 $morehtmlref .= '<div class="refidno opacitymedium">';
649 $morehtmlref .= $object->label;
650 $morehtmlref .= '</div>';
651
652 dol_banner_tab($object, 'ref', $backlink, 1, 'piece_num', 'piece_num', $morehtmlref);
653
654 print '<div class="fichecenter">';
655
656 print '<div class="fichehalfleft">';
657
658 print '<div class="underbanner clearboth"></div>';
659 print '<table class="border tableforfield centpercent">';
660
661 // Account movement
662 /*
663 print '<tr>';
664 print '<td class="titlefieldmiddle">'.$langs->trans("NumMvts").'</td>';
665 print '<td>'.($mode == '_tmp' ? '<span class="opacitymedium" title="Id tmp '.$object->piece_num.'">'.$langs->trans("Draft").'</span>' : $object->piece_num).'</td>';
666 print '</tr>';
667 */
668
669 // Account movement ref. Edit allowed only for free ref num model.
670 print '<tr><td class="titlefieldmiddle">';
671 print '<table class="nobordernopadding centpercent"><tr><td>';
672 print $langs->trans('Ref');
673 print '</td>';
674 if ($action != 'editref') {
675 print '<td class="right">';
676 if ($permissiontoadd && $numRefModel === 'mod_bookkeeping_neon') {
677 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>';
678 }
679 print '</td>';
680 }
681 print '</tr></table>';
682 print '</td><td>';
683 if ($action == 'editref') {
684 print '<form name="setref" action="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).'" method="POST">';
685 if ($optioncss != '') {
686 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
687 }
688 print '<input type="hidden" name="token" value="'.newToken().'">';
689 print '<input type="hidden" name="action" value="setref">';
690 print '<input type="hidden" name="mode" value="'.$mode.'">';
691 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
692 print '<input type="hidden" name="type" value="'.$type.'">';
693 print '<input type="text" size="20" name="ref" maxlength="30" value="'.dol_escape_htmltag($object->ref).'">';
694 print '<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans('Modify').'">';
695 print '</form>';
696 } else {
697 print $object->ref;
698 }
699 print '</td>';
700 print '</tr>';
701
702 // Ref document
703 print '<tr><td>';
704 print '<table class="nobordernopadding centpercent"><tr><td>';
705 print $form->textwithpicto($langs->trans('Piece'), $langs->trans('PieceDesc'));
706 print '</td>';
707 if ($action != 'editdocref') {
708 print '<td class="right">';
709 if ($permissiontoadd) {
710 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>';
711 }
712 print '</td>';
713 }
714 print '</tr></table>';
715 print '</td><td>';
716 if ($action == 'editdocref') {
717 print '<form name="setdocref" action="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).'" method="POST">';
718 if ($optioncss != '') {
719 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
720 }
721 print '<input type="hidden" name="token" value="'.newToken().'">';
722 print '<input type="hidden" name="action" value="setdocref">';
723 print '<input type="hidden" name="mode" value="'.$mode.'">';
724 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
725 print '<input type="hidden" name="type" value="'.$type.'">';
726 print '<input type="text" size="20" name="doc_ref" value="'.dol_escape_htmltag($object->doc_ref).'">';
727 print '<input type="submit" class="button button-edit smallpaddingimp" value="'.$langs->trans('Modify').'">';
728 print '</form>';
729 } else {
730 print $object->doc_ref;
731 }
732 print '</td>';
733 print '</tr>';
734
735 // Date
736 print '<tr><td>';
737 print '<table class="nobordernopadding centpercent"><tr><td>';
738 print $langs->trans('Docdate');
739 print '</td>';
740 if ($action != 'editdate') {
741 print '<td class="right">';
742 if ($permissiontoadd) {
743 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>';
744 }
745 print '</td>';
746 }
747 print '</tr></table>';
748 print '</td><td colspan="3">';
749 if ($action == 'editdate') {
750 print '<form name="setdate" action="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).'" method="POST">';
751 if ($optioncss != '') {
752 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
753 }
754 print '<input type="hidden" name="token" value="'.newToken().'">';
755 print '<input type="hidden" name="action" value="setdate">';
756 print '<input type="hidden" name="mode" value="'.$mode.'">';
757 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
758 print '<input type="hidden" name="type" value="'.$type.'">';
759 print $form->selectDate($object->doc_date ? $object->doc_date : -1, 'doc_date', 0, 0, 0, "setdate");
760 print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
761 print '</form>';
762 } else {
763 print $object->doc_date ? dol_print_date($object->doc_date, 'day') : '&nbsp;';
764 }
765 print '</td>';
766 print '</tr>';
767
768 // Journal
769 print '<tr><td>';
770 print '<table class="nobordernopadding centpercent"><tr><td>';
771 print $langs->trans('Codejournal');
772 print '</td>';
773 if ($action != 'editjournal') {
774 print '<td class="right">';
775 if ($permissiontoadd) {
776 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>';
777 }
778 print '</td>';
779 }
780 print '</tr></table>';
781 print '</td><td>';
782 if ($action == 'editjournal') {
783 print '<form name="setjournal" action="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).'" method="POST">';
784 if ($optioncss != '') {
785 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
786 }
787 print '<input type="hidden" name="token" value="'.newToken().'">';
788 print '<input type="hidden" name="action" value="setjournal">';
789 print '<input type="hidden" name="mode" value="'.$mode.'">';
790 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
791 print '<input type="hidden" name="type" value="'.$type.'">';
792 print $formaccounting->select_journal($object->code_journal, 'code_journal', 0, 0, 0, 1, '');
793 print '<input type="submit" class="button button-edit" value="'.$langs->trans('Modify').'">';
794 print '</form>';
795 } else {
796 print $object->code_journal;
797 }
798 print '</td>';
799 print '</tr>';
800
801 print '</table>';
802
803 print '</div>';
804
805
806 print '<div class="fichehalfright">';
807
808 print '<div class="underbanner clearboth"></div>';
809 print '<table class="border tableforfield centpercent">';
810
811 // Doc type
812 if (!empty($object->doc_type)) {
813 print '<tr>';
814 print '<td class="titlefield">'.$langs->trans("Doctype").'</td>';
815 print '<td>'.$object->doc_type.'</td>';
816 print '</tr>';
817 }
818
819 // Date document creation
820 print '<tr>';
821 print '<td class="titlefield">'.$langs->trans("DateCreation").'</td>';
822 print '<td>';
823 print $object->date_creation ? dol_print_date($object->date_creation, 'day') : '&nbsp;';
824 print '</td>';
825 print '</tr>';
826
827 // Due date (if invoice)
828 //if (in_array($object->doc_type, array('customer_invoice', 'supplier_invoice'))) {
829 print '<tr>';
830 print '<td class="titlefield">' . $form->textwithpicto($langs->trans('DateDue'), $langs->trans("IfTransactionHasDueDate")) . '</td>';
831 print '<td>';
832 print $object->date_lim_reglement ? dol_print_date($object->date_lim_reglement, 'day') : '&nbsp;';
833 print '</td>';
834 print '</tr>';
835 //}
836
837 // Don't show in tmp mode, inevitably empty
838 if ($mode != "_tmp") {
839 // Date document export
840 print '<tr>';
841 print '<td class="titlefield">' . $langs->trans("DateExport") . '</td>';
842 print '<td>';
843 print $object->date_export ? dol_print_date($object->date_export, 'dayhour') : '&nbsp;';
844 print '</td>';
845 print '</tr>';
846
847 // Date document validation
848 print '<tr>';
849 print '<td class="titlefield">' . $langs->trans("DateValidation") . '</td>';
850 print '<td>';
851 print $object->date_validation ? dol_print_date($object->date_validation, 'dayhour') : '&nbsp;';
852 print '</td>';
853 print '</tr>';
854
855 // Id_import
856 if (!empty($object->import_key)) {
857 print '<tr>';
858 print '<td class="titlefield">' . $langs->trans("ImportId") . '</td>';
859 print '<td>';
860 print $object->import_key;
861 print '</td>';
862 print '</tr>';
863 }
864 }
865
866 // Validate
867 /*
868 print '<tr>';
869 print '<td class="titlefield">' . $langs->trans("Status") . '</td>';
870 print '<td>';
871 if (empty($object->validated)) {
872 print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=enable&token='.newToken().'">';
873 print img_picto($langs->trans("Disabled"), 'switch_off');
874 print '</a>';
875 } else {
876 print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?piece_num=' . $line->id . '&action=disable&token='.newToken().'">';
877 print img_picto($langs->trans("Activated"), 'switch_on');
878 print '</a>';
879 }
880 print '</td>';
881 print '</tr>';
882 */
883
884 // check data
885 /*
886 print '<tr>';
887 print '<td class="titlefield">' . $langs->trans("Control") . '</td>';
888 if ($object->doc_type == 'customer_invoice')
889 {
890 $sqlmid = 'SELECT rowid as ref';
891 $sqlmid .= " FROM ".MAIN_DB_PREFIX."facture as fac";
892 $sqlmid .= " WHERE fac.rowid=" . ((int) $object->fk_doc);
893 dol_syslog("accountancy/bookkeeping/card.php::sqlmid=" . $sqlmid, LOG_DEBUG);
894 $resultmid = $db->query($sqlmid);
895 if ($resultmid) {
896 $objmid = $db->fetch_object($resultmid);
897 $invoicestatic = new Facture($db);
898 $invoicestatic->fetch($objmid->ref);
899 $ref=$langs->trans("Invoice").' '.$invoicestatic->getNomUrl(1);
900 }
901 else dol_print_error($db);
902 }
903 print '<td>' . $ref .'</td>';
904 print '</tr>';
905 */
906 print "</table>\n";
907
908 print '</div>';
909
910 print '</div>';
911 print '<div class="clearboth"></div>';
912
913
914 print dol_get_fiche_end();
915
916
917 $result = $object->fetchAllPerMvt($piece_num, $mode); // This load $object->linesmvt
918
919 if ($result < 0) {
920 setEventMessages($object->error, $object->errors, 'errors');
921 } else {
922 // Variable that contains all transaction lines
923 $tmptoselect = array();
924 $atleastonevalidated = 0;
925 $atleastoneexported = 0;
926 foreach ($object->linesmvt as $line) {
927 $tmptoselect[] = $line->id;
928 if (!empty($line->date_validation)) {
929 $atleastonevalidated = 1;
930 }
931 if (!empty($line->date_export) || !empty($line->date_validation)) {
932 $atleastoneexported = 1;
933 }
934 }
935
936 if ($mode != '_tmp' && !$atleastonevalidated) {
937 print "\n".'<div class="tabsAction">'."\n";
938
939 $parameters = array();
940 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
941 if (empty($reshook)) {
942 if ($permissiontodelete) {
943 if (!isset($hookmanager->resArray['no_button_edit']) || $hookmanager->resArray['no_button_edit'] != 1) {
944 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);
945 }
946 }
947 if ($permissiontoadd) {
948 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);
949 }
950 }
951
952 print '</div>';
953 }
954
955 // List of movements
956 print load_fiche_titre($langs->trans("ListeMvts"), '', '');
957
958 print '<form action="'.$_SERVER["PHP_SELF"].'?piece_num='.((int) $object->piece_num).'" method="POST">';
959 if ($optioncss != '') {
960 print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
961 }
962 print '<input type="hidden" name="token" value="'.newToken().'">';
963 print '<input type="hidden" name="doc_date" value="'.$object->doc_date.'">'."\n";
964 print '<input type="hidden" name="doc_type" value="'.$object->doc_type.'">'."\n";
965 print '<input type="hidden" name="doc_ref" value="'.$object->doc_ref.'">'."\n";
966 print '<input type="hidden" name="ref" value="'.$object->ref.'">'."\n";
967 print '<input type="hidden" name="code_journal" value="'.$object->code_journal.'">'."\n";
968 print '<input type="hidden" name="fk_doc" value="'.$object->fk_doc.'">'."\n";
969 print '<input type="hidden" name="fk_docdet" value="'.$object->fk_docdet.'">'."\n";
970 print '<input type="hidden" name="mode" value="'.$mode.'">'."\n";
971 print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
972 print '<input type="hidden" name="type" value="'.$type.'">';
973
974 if (count($object->linesmvt) > 0) {
975 print '<div class="div-table-responsive-no-min">';
976 print '<table class="noborder centpercent">';
977
978 $total_debit = 0;
979 $total_credit = 0;
980
981 print '<tr class="liste_titre">';
982
983 print_liste_field_titre("AccountAccountingShort");
984 print_liste_field_titre("SubledgerAccount");
985 print_liste_field_titre("LabelOperation");
986 print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"');
987 print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"');
988 if (empty($object->date_validation)) {
989 print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center ');
990 } else {
992 }
993
994 print "</tr>\n";
995
996 // Add an empty line if there is not yet
997 if (!empty($object->linesmvt[0])) {
998 $tmpline = $object->linesmvt[0];
999 if (!empty($tmpline->numero_compte)) {
1000 $line = new BookKeepingLine($db);
1001 $object->linesmvt[] = $line;
1002 }
1003 }
1004
1005 foreach ($object->linesmvt as $line) {
1006 $total_debit += $line->debit;
1007 $total_credit += $line->credit;
1008
1009 if ($action == 'update' && $line->id == $id) {
1010 print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
1011 print '<!-- td columns in edit mode -->';
1012 print '<td>';
1013 print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->numero_compte), 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500');
1014 print '</td>';
1015 print '<td>';
1016 // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
1017 // - It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases.
1018 // - Also, it is not possible to use a value that is not in the list.
1019 // - Also, the label is not automatically filled when a value is selected.
1020 if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
1021 print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
1022 } else {
1023 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")).'">';
1024 }
1025 // Add also input for subledger label
1026 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")).'">';
1027 print '</td>';
1028 print '<td><input type="text" class="minwidth200" name="label_operation" value="'.(GETPOSTISSET("label_operation") ? GETPOST("label_operation", "alpha") : $line->label_operation).'"></td>';
1029 print '<td class="right"><input type="text" class="right width50" name="debit" value="'.(GETPOSTISSET("debit") ? GETPOST("debit", "alpha") : price($line->debit)).'"></td>';
1030 print '<td class="right"><input type="text" class="right width50" name="credit" value="'.(GETPOSTISSET("credit") ? GETPOST("credit", "alpha") : price($line->credit)).'"></td>';
1031 print '<td>';
1032 print '<input type="hidden" name="id" value="'.$line->id.'">'."\n";
1033 print '<input type="submit" class="button" name="update" value="'.$langs->trans("Update").'">';
1034 print '</td>';
1035 print "</tr>\n";
1036 } elseif (empty($line->numero_compte) || (empty($line->debit) && empty($line->credit))) {
1037 if (($action == "" || $action == 'add') && $permissiontoadd) {
1038 print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
1039 print '<!-- td columns in add mode -->';
1040 print '<td>';
1041 print $formaccounting->select_account($action == 'add' ? GETPOST('accountingaccount_number') : '', 'accountingaccount_number', 1, array(), 1, 1, 'minwidth200 maxwidth500');
1042 print '</td>';
1043 print '<td>';
1044 // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
1045 // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases.
1046 // Also, it is not possible to use a value that is not in the list.
1047 // Also, the label is not automatically filled when a value is selected.
1048 if (getDolGlobalString('ACCOUNTANCY_COMBO_FOR_AUX')) {
1049 print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
1050 } else {
1051 print '<input type="text" class="maxwidth150" name="subledger_account" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccount")) . '">';
1052 }
1053 print '<br><input type="text" class="maxwidth150" name="subledger_label" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccountLabel")) . '">';
1054 print '</td>';
1055 print '<td><input type="text" class="minwidth200" name="label_operation" value="' . dol_escape_htmltag($label_operation) . '"/></td>';
1056 print '<td class="right"><input type="text" class="right width50" name="debit" value=""/></td>';
1057 print '<td class="right"><input type="text" class="right width50" name="credit" value=""/></td>';
1058 print '<td class="center"><input type="submit" class="button small" name="save" value="' . $langs->trans("Add") . '"></td>';
1059 print "</tr>\n";
1060 }
1061 } else {
1062 print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
1063 print '<!-- td columns in display mode -->';
1064 $resultfetch = $accountingaccount->fetch(0, $line->numero_compte, true);
1065 print '<td>';
1066 if ($resultfetch > 0) {
1067 print $accountingaccount->getNomUrl(0, 1, 1, '', 0);
1068 } else {
1069 print dol_escape_htmltag($line->numero_compte).' <span class="warning">('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')</span>';
1070 }
1071 print '</td>';
1072 print '<td>'.length_accounta($line->subledger_account);
1073 if ($line->subledger_label) {
1074 print ' - <span class="opacitymedium">'.dol_escape_htmltag($line->subledger_label).'</span>';
1075 }
1076 print '</td>';
1077 print '<td>'.$line->label_operation.'</td>';
1078 print '<td class="right nowraponall amount">'.($line->debit != 0 ? price($line->debit) : '').'</td>';
1079 print '<td class="right nowraponall amount">'.($line->credit != 0 ? price($line->credit) : '').'</td>';
1080
1081 print '<td class="center nowraponall">';
1082 if ($permissiontoadd) {
1083 if (empty($line->date_export) && empty($line->date_validation)) {
1084 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()) . '">';
1085 print img_edit('', 0, 'class="marginrightonly"');
1086 print '</a> &nbsp;';
1087 } else {
1088 print '<a class="editfielda nohover cursornotallowed reposition disabled" href="#" title="'.dol_escape_htmltag($langs->trans("ForbiddenTransactionAlreadyExported")).'">';
1089 print img_edit($langs->trans("ForbiddenTransactionAlreadyExported"), 0, 'class="marginrightonly"');
1090 print '</a> &nbsp;';
1091 }
1092
1093 if (empty($line->date_validation)) {
1094 $actiontodelete = 'delete';
1095 if ($mode == '_tmp' || $action != 'delmouv') {
1096 $actiontodelete = 'confirm_delete';
1097 }
1098
1099 print '<a href="' . $_SERVER["PHP_SELF"] . '?action=' . $actiontodelete . '&id=' . $line->id . '&piece_num=' . ((int) $line->piece_num) . '&mode=' . urlencode((string) $mode) . '&token=' . urlencode(newToken()) . '">';
1100 print img_delete();
1101 print '</a>';
1102 } else {
1103 print '<a class="editfielda nohover cursornotallowed disabled" href="#" title="'.dol_escape_htmltag($langs->trans("ForbiddenTransactionAlreadyExported")).'">';
1104 print img_delete($langs->trans("ForbiddenTransactionAlreadyValidated"));
1105 print '</a>';
1106 }
1107 }
1108 print '</td>';
1109 print "</tr>\n";
1110 }
1111 }
1112
1113 $total_debit = price2num($total_debit, 'MT');
1114 $total_credit = price2num($total_credit, 'MT');
1115
1116 if ($total_debit != $total_credit) {
1117 setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings');
1118 }
1119
1120 print '</table>';
1121 print '</div>';
1122
1123 if ($mode == '_tmp' && $action == '' && $permissiontoadd) {
1124 print '<br>';
1125 print '<div class="center">';
1126 if (empty($total_debit) && empty($total_credit)) {
1127 print '<a class="button disabled cursornotallowed" disabled="disabled" href="#" title="'.dol_escape_htmltag($langs->trans("EnterNonEmptyLinesFirst")).'">'.dol_escape_htmltag($langs->trans("ValidTransaction")).'</a>';
1128 } elseif ($total_debit == $total_credit) {
1129 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>';
1130 } else {
1131 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>';
1132 }
1133
1134 print ' &nbsp; ';
1135 print '<a class="button button-cancel" href="'.$backtopage.(!empty($type) ? '?type=sub' : '').'">'.$langs->trans("Cancel").'</a>';
1136
1137 print "</div>";
1138 }
1139 }
1140
1141 print '</form>';
1142 }
1143 } else {
1144 print $langs->trans("NoRecordFound");
1145 }
1146}
1147
1148print dol_get_fiche_end();
1149
1150// End of page
1151llxFooter();
1152$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.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.