dolibarr 24.0.0-beta
card.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2024 AWeerWolf
3 * Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 *
18 */
19
26// Load Dolibarr environment
27require '../../../main.inc.php';
36require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php';
37require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
38require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
39require_once DOL_DOCUMENT_ROOT . '/core/lib/accounting.lib.php';
40require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
41require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeepingtemplate.class.php';
42require_once DOL_DOCUMENT_ROOT . '/accountancy/class/bookkeepingtemplateline.class.php';
43
44// Load translation files required by the page
45$langs->loadLangs(array("accountancy", "other"));
46
47// Set needed objects
48$accountingaccount = new AccountingAccount($db);
49$formaccounting = new FormAccounting($db);
50
51// Get parameters
52$id = GETPOST('id', 'int');
53$code = GETPOST('code', 'alpha');
54$lineid = GETPOSTINT('lineid');
55$action = GETPOST('action', 'aZ09');
56$confirm = GETPOST('confirm', 'alpha');
57$cancel = GETPOST('cancel', 'aZ09');
58$contextpage = GETPOST('contextpage', 'aZ') ? GETPOST('contextpage', 'aZ') : 'bookkeepingtemplatecard';
59$backtopage = GETPOST('backtopage', 'alpha');
60$backtopageforcancel = GETPOST('backtopageforcancel', 'alpha');
61
62// Initialize technical objects
64$diroutputmassaction = $conf->accounting->dir_output . '/temp/massgeneration/' . $user->id;
65$hookmanager->initHooks(array($object->element . 'card', 'globalcard'));
66
67// Fetch optionals attributes and labels
68$extrafields->fetch_name_optionals_label($object->table_element);
69
70$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
71
72// Initialize array of search criteria
73$search_all = trim(GETPOST("search_all", 'alpha'));
74$search = array();
75foreach ($object->fields as $key => $val) {
76 if (GETPOST('search_' . $key, 'alpha')) {
77 $search[$key] = GETPOST('search_' . $key, 'alpha');
78 }
79}
80
81if (empty($action) && empty($id) && empty($code)) {
82 $action = 'view';
83}
84
85// Load object
86include DOL_DOCUMENT_ROOT . '/core/actions_fetchobject.inc.php';
87
88if ($id > 0 && empty($object->id)) {
89 dol_print_error($db, 'Failed to load object');
90}
91
92// Security check
93$permissiontoread = $user->hasRight('accounting', 'chartofaccount');
94$permissiontoadd = $user->hasRight('accounting', 'chartofaccount');
95$permissiontodelete = $user->hasRight('accounting', 'chartofaccount');
96$permissionnote = $user->hasRight('accounting', 'chartofaccount');
97$permissiondellink = $user->hasRight('accounting', 'chartofaccount');
98
99$upload_dir = $conf->accounting->multidir_output[isset($object->entity) ? $object->entity : 1];
100
101if (!$permissiontoread) {
103}
104
105$form = new Form($db);
106$formfile = new FormFile($db);
107
108/*
109 * Actions
110 */
111
112$parameters = array();
113$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action);
114if ($reshook < 0) {
115 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
116}
117
118if (empty($reshook)) {
119 $error = 0;
120
121 $backurlforlist = DOL_URL_ROOT . '/accountancy/admin/template/list.php';
122
123 if (empty($backtopage) || ($cancel && empty($id))) {
124 if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
125 if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) {
126 $backtopage = $backurlforlist;
127 } else {
128 $backtopage = DOL_URL_ROOT . '/accountancy/admin/template/card.php?id=' . ((!empty($id) && $id > 0) ? $id : '__ID__');
129 }
130 }
131 }
132
133 $triggermodname = 'ACCOUNTING_BOOKKEEPINGTEMPLATE_MODIFY';
134
135 // Actions cancel, add, update, update_extras, confirm_validate, confirm_delete, confirm_deleteline, confirm_clone, confirm_close, confirm_setdraft, confirm_reopen
136 include DOL_DOCUMENT_ROOT . '/core/actions_addupdatedelete.inc.php';
137
138 // Actions when linking object each other
139 include DOL_DOCUMENT_ROOT . '/core/actions_dellink.inc.php';
140
141 // Actions when printing a doc from card
142 include DOL_DOCUMENT_ROOT . '/core/actions_printing.inc.php';
143
144 // Action to build doc
145 include DOL_DOCUMENT_ROOT . '/core/actions_builddoc.inc.php';
146
147 // Actions to send emails
148 $triggersendname = 'ACCOUNTING_BOOKKEEPINGTEMPLATE_SENTBYMAIL';
149 $autocopy = 'MAIN_MAIL_AUTOCOPY_BOOKKEEPINGTEMPLATE_TO';
150 $trackid = 'bookkeepingtemplate' . $object->id;
151 include DOL_DOCUMENT_ROOT . '/core/actions_sendmails.inc.php';
152}
153
154// Action to add a new line
155if ($action == 'addline' && $permissiontoadd) {
156 $error = 0;
157
158 // Get line data from POST
159 $general_account = GETPOST('general_account', 'alphanohtml');
160 $subledger_account = GETPOST('subledger_account', 'alphanohtml');
161 if ($subledger_account == '-1') {
162 $subledger_account = null;
163 }
164 $subledger_label = GETPOST('subledger_label', 'alphanohtml');
165 $operation_label = GETPOST('operation_label', 'alphanohtml');
166 $debit = price2num(GETPOST('debit', 'alpha'));
167 $credit = price2num(GETPOST('credit', 'alpha'));
168
169 // Validation
170 if (((float) $debit != 0.0) && ((float) $credit != 0.0)) {
171 $error++;
172 setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
173 $action = 'edit';
174 }
175
176 if (empty($general_account) || $general_account == '-1') {
177 $error++;
178 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountNumber")), null, 'errors');
179 $action = 'edit';
180 }
181
182 if (!$error) {
183 // Fetch account label
184 $accountingaccount->fetch(0, $general_account, 1);
185 $general_label = $accountingaccount->label;
186
187 // Create line object
188 $line = new BookkeepingTemplateLine($db);
189 $line->fk_transaction_template = $object->id;
190 $line->general_account = $general_account;
191 $line->general_label = $general_label;
192 $line->subledger_account = $subledger_account;
193 $line->subledger_label = $subledger_label;
194 $line->operation_label = $operation_label;
195 $line->debit = $debit;
196 $line->credit = $credit;
197
198 $result = $line->create($user, 0);
199
200 if ($result < 0) {
201 $error++;
202 setEventMessages($line->error, $line->errors, 'errors');
203 $action = 'edit';
204 } else {
205 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
206 header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $object->id);
207 exit;
208 }
209 }
210}
211
212// Action to update a line
213if ($action == 'updateline' && $permissiontoadd) {
214 $error = 0;
215
216 // Get line data from POST
217 $general_account = GETPOST('general_account', 'alphanohtml');
218 $subledger_account = GETPOST('subledger_account', 'alphanohtml');
219 if ($subledger_account == '-1') {
220 $subledger_account = null;
221 }
222 $subledger_label = GETPOST('subledger_label', 'alphanohtml');
223 $operation_label = GETPOST('operation_label', 'alphanohtml');
224 $debit = price2num(GETPOST('debit', 'alpha'));
225 $credit = price2num(GETPOST('credit', 'alpha'));
226
227 // Validation
228 if (((float) $debit != 0.0) && ((float) $credit != 0.0)) {
229 $error++;
230 setEventMessages($langs->trans('ErrorDebitCredit'), null, 'errors');
231 $action = 'editline';
232 }
233
234 if (empty($general_account) || $general_account == '-1') {
235 $error++;
236 setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("AccountNumber")), null, 'errors');
237 $action = 'editline';
238 }
239
240 if (!$error) {
241 // Fetch account label
242 $accountingaccount->fetch(0, $general_account, 1);
243 $general_label = $accountingaccount->label;
244
245 // Load and update line
246 $line = new BookkeepingTemplateLine($db);
247 $result = $line->fetch($lineid);
248
249 if ($result > 0) {
250 $line->general_account = $general_account;
251 $line->general_label = $general_label;
252 $line->subledger_account = $subledger_account;
253 $line->subledger_label = $subledger_label;
254 $line->operation_label = $operation_label;
255 $line->debit = $debit;
256 $line->credit = $credit;
257
258 $result = $line->update($user, 0);
259
260 if ($result < 0) {
261 $error++;
262 setEventMessages($line->error, $line->errors, 'errors');
263 $action = 'editline';
264 } else {
265 setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
266 header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $object->id);
267 exit;
268 }
269 } else {
270 $error++;
271 setEventMessages($line->error, $line->errors, 'errors');
272 }
273 }
274}
275
276// Action to delete a line
277if ($action == 'confirm_deleteline' && $confirm == 'yes' && $permissiontodelete) {
278 $result = $object->deleteLine($user, $lineid);
279 if ($result > 0) {
280 setEventMessages($langs->trans('RecordDeleted'), null, 'mesgs');
281 header("Location: " . $_SERVER["PHP_SELF"] . "?id=" . $object->id);
282 exit;
283 } else {
284 setEventMessages($object->error, $object->errors, 'errors');
285 }
286}
287
288/*
289 * View
290 */
291
292$title = $langs->trans('BookkeepingTemplate') . " - " . $langs->trans('Card');
293if ($action == 'create') {
294 $title = $langs->trans("NewBookkeepingTemplate");
295}
296$help_url = '';
297
298llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-accountancy page-admin-template-card');
299
300// Update fields properties in realtime
301if (!empty($conf->use_javascript_ajax)) {
302 print "\n" . '<script type="text/javascript">';
303 print '$(document).ready(function () {
304 function toggleSubledger() {
305 var isCentral = $("#accountingaccount_number option:selected").data("centralized");
306 console.log("the selected general ledger account is centralised?", isCentral);
307 if (isCentral) {
308 $("#subledger_account, #subledger_label").prop("disabled", false);
309 } else {
310 $("#subledger_account, #subledger_label").prop("disabled", true);
311 }
312 }
313
314 toggleSubledger();
315
316 $("#accountingaccount_number").on("change", toggleSubledger);
317 $("#accountingaccount_number").on("select2:select", toggleSubledger);
318 ';
319 print ' });' . "\n";
320 print ' </script>' . "\n";
321}
322
323// Part to create
324if ($action == 'create') {
325 if (empty($permissiontoadd)) {
326 accessforbidden('NotEnoughPermissions', 0, 1);
327 }
328
329 print load_fiche_titre($title, '', 'object_' . $object->picto);
330
331 print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
332 print '<input type="hidden" name="token" value="' . newToken() . '">';
333 print '<input type="hidden" name="action" value="add">';
334 if ($backtopage) {
335 print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
336 }
337 if ($backtopageforcancel) {
338 print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
339 }
340
341 print dol_get_fiche_head(array(), '');
342
343 print '<table class="border centpercent tableforfieldcreate">' . "\n";
344
345 // Common attributes
346 include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_add.tpl.php';
347
348 // Other attributes
349 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_add.tpl.php';
350
351 print '</table>' . "\n";
352
353 print dol_get_fiche_end();
354
355 print $form->buttonsSaveCancel("Create");
356
357 print '</form>';
358
359 dol_set_focus('input[name="code"]');
360}
361
362// Part to edit record
363if (($id || $code) && $action == 'edit') {
364 print load_fiche_titre($langs->trans("BookkeepingTemplate"), '', 'object_' . $object->picto);
365
366 print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
367 print '<input type="hidden" name="token" value="' . newToken() . '">';
368 print '<input type="hidden" name="action" value="update">';
369 print '<input type="hidden" name="id" value="' . $object->id . '">';
370 if ($backtopage) {
371 print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
372 }
373 if ($backtopageforcancel) {
374 print '<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel . '">';
375 }
376
377 print dol_get_fiche_head();
378
379 print '<table class="border centpercent tableforfieldedit">' . "\n";
380
381 // Common attributes
382 include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
383
384 // Other attributes
385 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
386
387 print '</table>';
388
389 print dol_get_fiche_end();
390
391 print $form->buttonsSaveCancel();
392
393 print '</form>';
394}
395
396// Part to show record
397if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) {
399
400 print dol_get_fiche_head($head, 'card', $langs->trans("BookkeepingTemplate"), -1, $object->picto, 0, '', '', 0, '', 1);
401
402 $formconfirm = '';
403
404 // Confirmation to delete template
405 if ($action == 'delete') {
406 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteBookkeepingTemplate'), $langs->trans('ConfirmDeleteObject'), 'confirm_delete', '', 0, 1);
407 }
408
409 // Confirmation to delete line
410 if ($action == 'deleteline') {
411 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id . '&lineid=' . $lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
412 }
413
414 // Clone confirmation
415 if ($action == 'clone') {
416 // Create an array for form
417 $formquestion = array();
418 $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->code), 'confirm_clone', $formquestion, 'yes', 1);
419 }
420
421 // Call Hook formConfirm
422 $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid);
423 $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action);
424 if (empty($reshook)) {
425 $formconfirm .= $hookmanager->resPrint;
426 } elseif ($reshook > 0) {
427 $formconfirm = $hookmanager->resPrint;
428 }
429
430 // Print form confirm
431 print $formconfirm;
432
433 // Object card
434 $linkback = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/template/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
435
436 $morehtmlref = '<div class="refidno">';
437 $morehtmlref .= '</div>';
438
439 dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'code', $morehtmlref);
440
441 print '<div class="fichecenter">';
442 print '<div class="fichehalfleft">';
443 print '<div class="underbanner clearboth"></div>';
444 print '<table class="border centpercent tableforfield">' . "\n";
445
446 // Common attributes
447 $keyforbreak = '';
448 include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php';
449
450 // Other attributes
451 include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
452
453 print '</table>';
454 print '</div>';
455 print '</div>';
456
457 print '<div class="clearboth"></div>';
458
459 print dol_get_fiche_end();
460
461 // Buttons for actions
462 if ($action != 'presend' && $action != 'editline' && $action != 'addline') {
463 print '<div class="tabsAction">' . "\n";
464 $parameters = array();
465 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action);
466 if ($reshook < 0) {
467 setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
468 }
469
470 if (empty($reshook)) {
471 // Modify
472 if ($permissiontoadd) {
473 print dolGetButtonAction($langs->trans('Modify'), '', 'default', $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=edit&token=' . newToken(), '', $permissiontoadd);
474 }
475
476 // Clone
477 if ($permissiontoadd) {
478 print dolGetButtonAction($langs->trans('ToClone'), '', 'clone', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=clone&token=' . newToken(), '', $permissiontoadd);
479 }
480
481 // Delete
482 print dolGetButtonAction($langs->trans('Delete'), '', 'delete', $_SERVER['PHP_SELF'] . '?id=' . $object->id . '&action=delete&token=' . newToken(), '', $permissiontodelete);
483 }
484 print '</div>' . "\n";
485 }
486
487 // Lines section
488 print '<div class="div-table-responsive-no-min">';
489 if (!empty($object->table_element_line)) {
490 // Show object lines
491 $result = $object->getLinesArray();
492
493 print '<form name="addproduct" id="addproduct" action="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . (($action != 'editline') ? '' : '#line_' . GETPOST('lineid', 'int')) . '" method="POST">';
494 print '<input type="hidden" name="token" value="' . newToken() . '">';
495 print '<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline') . '">';
496 print '<input type="hidden" name="mode" value="">';
497 print '<input type="hidden" name="page_y" value="">';
498 print '<input type="hidden" name="id" value="' . $object->id . '">';
499
500 if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
501 // Define required variables for ajaxrow.tpl.php
502 $fk_element = 'fk_transaction_template';
503 $table_element_line = $object->table_element_line;
504 include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php';
505 }
506
507 print '<div class="div-table-responsive-no-min">';
508 print '<table id="tablelines" class="noborder noshadow centpercent">';
509
510 // Show header
511 print '<tr class="liste_titre">';
512 print_liste_field_titre("AccountAccountingShort");
513 print_liste_field_titre("SubledgerAccount");
514 print_liste_field_titre("LabelOperation");
515 print_liste_field_titre("AccountingDebit", "", "", "", "", 'class="right"');
516 print_liste_field_titre("AccountingCredit", "", "", "", "", 'class="right"');
517 print_liste_field_titre("Action", "", "", "", "", 'width="60"', "", "", 'center ');
518 print "</tr>\n";
519
520 $i = 0;
521
522 // Show existing lines
523 foreach ($object->lines as $line) {
524 // Line in view mode
525 if ($action != 'editline' || GETPOST('lineid', 'int') != $line->id) {
526 print '<tr class="oddeven" id="row-' . $line->id . '">';
527 print '<!-- td columns in display mode -->';
528 $resultfetch = $accountingaccount->fetch(0, $line->general_account, true);
529 print '<td>';
530 if ($resultfetch > 0) {
531 print $accountingaccount->getNomUrl(0, 1, 1, '', 0);
532 } else {
533 print dol_escape_htmltag($line->general_account).' <span class="warning">('.$langs->trans("AccountRemovedFromCurrentChartOfAccount").')</span>';
534 }
535 print '</td>';
536 print '<td>'.length_accounta($line->subledger_account ?? '');
537 if (!empty($line->subledger_label)) {
538 print ' - <span class="opacitymedium">'.dol_escape_htmltag($line->subledger_label).'</span>';
539 }
540 print '</td>';
541 print '<td>' . ($line->operation_label ? dol_escape_htmltag($line->operation_label) : '') . '</td>';
542 print '<td class="right">' . ($line->debit ? price($line->debit) : '') . '</td>';
543 print '<td class="right">' . ($line->credit ? price($line->credit) : '') . '</td>';
544
545 // Edit link
546 print '<td class="center">';
547 if ($permissiontoadd) {
548 print '<a class="editfielda reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=editline&token=' . newToken() . '&lineid=' . $line->id . '#line_' . $line->id . '">';
549 print img_edit('', 0, 'class="marginrightonly"');
550 print '</a> &nbsp;';
551 }
552
553 // Delete link
554 if ($permissiontodelete) {
555 print '<a class="reposition" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=deleteline&token=' . newToken() . '&lineid=' . $line->id . '">';
556 print img_delete();
557 print '</a>';
558 }
559 print '</td>';
560 print '</tr>';
561 }
562
563 // Line in edit mode
564 if ($action == 'editline' && GETPOST('lineid', 'int') == $line->id) {
565 print '<tr class="oddeven" data-lineid="'.((int) $line->id).'">';
566 print '<input type="hidden" name="lineid" value="' . GETPOST('lineid', 'int') . '">';
567
568 // Account number
569 print '<td>';
570 print $formaccounting->select_account((GETPOSTISSET("accountingaccount_number") ? GETPOST("accountingaccount_number", "alpha") : $line->general_account), 'general_account', 1, array(), 1, 1, 'minwidth200 maxwidth500');
571 print '</td>';
572
573 // Subledger account
574 print '<td>';
575 // TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because:
576 // It does not use the setup of "key pressed" to select a thirdparty and this hang browser on large databases.
577 // Also, it is not possible to use a value that is not in the list.
578 // Also, the label is not automatically filled when a value is selected.
579 print $formaccounting->select_auxaccount((GETPOSTISSET("subledger_account") ? GETPOST("subledger_account", "alpha") : $line->subledger_account), 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
580 // Add also input for subledger label
581 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")).'">';
582 print '</td>';
583
584 // Operation label
585 print '<td>';
586 print '<input type="text" class="minwidth200" name="operation_label" value="'.(GETPOSTISSET("operation_label") ? GETPOST("operation_label", "alpha") : $line->operation_label).'">';
587 print '</td>';
588
589 // Debit
590 print '<td class="right">';
591 print '<input type="text" name="debit" class="flat right maxwidth75" value="' . ($line->debit ? price($line->debit) : '') . '">';
592 print '</td>';
593
594 // Credit
595 print '<td class="right">';
596 print '<input type="text" name="credit" class="flat right maxwidth75" value="' . ($line->credit ? price($line->credit) : '') . '">';
597 print '</td>';
598
599 // Save button
600 print '<td class="center" colspan="2">';
601 print '<input type="submit" class="button buttongen marginbottomonly button-save" name="save" value="' . $langs->trans("Save") . '">';
602 print '<br>';
603 print '<input type="submit" class="button buttongen marginbottomonly button-cancel" name="cancel" value="' . $langs->trans("Cancel") . '">';
604 print '</td>';
605
606 print '</tr>';
607 }
608
609 $i++;
610 }
611
612 // Form to add new line
613 if ($action != 'editline' && $permissiontoadd) {
614 print '<tr class="liste_titre nodrag nodrop">';
615 print '<td>';
616 print $formaccounting->select_account('', 'general_account', 1, [], 1, 1, 'maxwidth300');
617 print '</td>';
618 print '<td>';
619 print $formaccounting->select_auxaccount('', 'subledger_account', 1, 'maxwidth250', '', 'subledger_label');
620 print '<br><input type="text" class="maxwidth150" name="new_subledger_label" value="" placeholder="' . dol_escape_htmltag($langs->trans("SubledgerAccountLabel")) . '">';
621 print '</td>';
622 print '<td><input type="text" name="operation_label" class="flat minwidth150"></td>';
623 print '<td class="right"><input type="text" name="debit" class="flat right maxwidth75"></td>';
624 print '<td class="right"><input type="text" name="credit" class="flat right maxwidth75"></td>';
625 print '<td class="center" colspan="2"><input type="submit" class="button buttongen marginbottomonly" name="addline" value="' . $langs->trans("Add") . '"></td>';
626 print '</tr>';
627 }
628
629 print '</table>';
630 print '</div>';
631
632 print '</form>';
633 }
634 print '</div>';
635}
636
637// End of page
638llxFooter();
639$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
accountingTransactionTemplatePrepareHead(BookkeepingTemplate $object)
Prepare array with list of tabs for accounting transaction template.
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 for BookkeepingTemplate.
Class for BookkeepingTemplateLine.
Class to manage generation of HTML components for accounting management.
Class to offer components to list and upload files.
Class to manage generation of HTML components Only common components must be here.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_liste_field_titre($name, $file="", $field="", $begin="", $param="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
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.