accountancy_codes_edit.tpl.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /* Copyright (C) 2021 Open-Dsi <support@open-dsi.fr>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. *
  17. * Show extrafields. It also show fields from hook formAssetAccountancyCode. Need to have following variables defined:
  18. * $object (asset, assetmodel, ...)
  19. * $assetaccountancycodes
  20. * $action
  21. * $conf
  22. * $langs
  23. *
  24. * $parameters
  25. */
  26. // Protection to avoid direct call of template
  27. if (empty($object) || !is_object($object)) {
  28. print "Error, template page can't be called as URL";
  29. exit;
  30. }
  31. if (!is_object($form)) {
  32. $form = new Form($db);
  33. }
  34. if (isModEnabled('accounting') && !is_object($formaccounting)) {
  35. require_once DOL_DOCUMENT_ROOT . '/core/class/html.formaccounting.class.php';
  36. $formaccounting = new FormAccounting($db);
  37. }
  38. ?>
  39. <!-- BEGIN PHP TEMPLATE accountancy_code_edit.tpl.php -->
  40. <?php
  41. if (!is_array($parameters)) {
  42. $parameters = array();
  43. }
  44. $parameters['assetaccountancycodes'] = &$assetaccountancycodes;
  45. $reshook = $hookmanager->executeHooks('formAssetAccountancyCodes', $parameters, $object, $action);
  46. print $hookmanager->resPrint;
  47. if ($reshook < 0) {
  48. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  49. }
  50. if (empty($reshook)) {
  51. foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
  52. //if (empty($object->enabled_modes[$mode_key])) continue;
  53. print load_fiche_titre($langs->trans($mode_info['label']), '', '');
  54. print '<div class="fichecenter">';
  55. print '<div class="underbanner clearboth"></div>';
  56. print '<table class="border centpercent tableforfield">';
  57. foreach ($mode_info['fields'] as $field_key => $field_info) {
  58. $html_name = $mode_key . '_' . $field_key;
  59. print '<tr><td class="titlefieldcreate">' . $langs->trans($field_info['label']) . '</td><td colspan="3">';
  60. $accountancy_code = GETPOSTISSET($html_name) ? GETPOST($html_name, 'aZ09') : (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key]) ? $assetaccountancycodes->accountancy_codes[$mode_key][$field_key] : '');
  61. if (isModEnabled('accounting')) {
  62. print $formaccounting->select_account($accountancy_code, $html_name, 1, null, 1, 1, 'minwidth150 maxwidth300', 1);
  63. } else {
  64. print '<input name="' . $html_name . '" class="maxwidth200" value="' . dol_escape_htmltag($accountancy_code) . '">';
  65. }
  66. print '</td></tr>';
  67. }
  68. print '</table>';
  69. print '</div>';
  70. }
  71. }
  72. ?>
  73. <!-- END PHP TEMPLATE accountancy_code_edit.tpl.php -->