accountancy_codes_view.tpl.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. ?>
  35. <!-- BEGIN PHP TEMPLATE accountancy_code_view.tpl.php -->
  36. <?php
  37. if (!is_array($parameters)) {
  38. $parameters = array();
  39. }
  40. $parameters['assetaccountancycodes'] = &$assetaccountancycodes;
  41. $reshook = $hookmanager->executeHooks('formAssetAccountancyCodes', $parameters, $object, $action);
  42. print $hookmanager->resPrint;
  43. if ($reshook < 0) {
  44. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  45. }
  46. if (empty($reshook)) {
  47. if (isModEnabled('accounting')) require_once DOL_DOCUMENT_ROOT . '/accountancy/class/accountingaccount.class.php';
  48. foreach ($assetaccountancycodes->accountancy_codes_fields as $mode_key => $mode_info) {
  49. //if (empty($object->enabled_modes[$mode_key])) continue;
  50. print load_fiche_titre($langs->trans($mode_info['label']), '', '');
  51. print '<div class="fichecenter">';
  52. print '<div class="underbanner clearboth"></div>';
  53. print '<table class="border centpercent tableforfield">';
  54. foreach ($mode_info['fields'] as $field_key => $field_info) {
  55. print '<tr><td class="titlefieldcreate">' . $langs->trans($field_info['label']) . '</td><td colspan="3">';
  56. if (!empty($assetaccountancycodes->accountancy_codes[$mode_key][$field_key])) {
  57. $accountancy_code = $assetaccountancycodes->accountancy_codes[$mode_key][$field_key];
  58. if (isModEnabled('accounting')) {
  59. $accountingaccount = new AccountingAccount($db);
  60. $accountingaccount->fetch('', $accountancy_code, 1);
  61. print $accountingaccount->getNomUrl(0, 1, 1, '', 1);
  62. } else {
  63. print $accountancy_code;
  64. }
  65. }
  66. print '</td></tr>';
  67. }
  68. print '</table>';
  69. print '</div>';
  70. }
  71. }
  72. ?>
  73. <!-- END PHP TEMPLATE accountancy_code_view.tpl.php -->