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