accountant.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. /* Copyright (C) 2018 Alexandre Spangaro <aspangaro@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. /**
  18. * \file htdocs/admin/accountant.php
  19. * \ingroup accountant
  20. * \brief Setup page to configure accountant / auditor
  21. */
  22. require '../main.inc.php';
  23. require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  28. $action = GETPOST('action', 'aZ09');
  29. $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'adminaccoutant'; // To manage different context of search
  30. // Load translation files required by the page
  31. $langs->loadLangs(array('admin', 'companies'));
  32. if (!$user->admin) accessforbidden();
  33. $error = 0;
  34. /*
  35. * Actions
  36. */
  37. $parameters = array();
  38. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  39. if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  40. if (($action == 'update' && !GETPOST("cancel", 'alpha'))
  41. || ($action == 'updateedit'))
  42. {
  43. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NAME", GETPOST("nom", 'nohtml'), 'chaine', 0, '', $conf->entity);
  44. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ADDRESS", GETPOST("address", 'nohtml'), 'chaine', 0, '', $conf->entity);
  45. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_TOWN", GETPOST("town", 'nohtml'), 'chaine', 0, '', $conf->entity);
  46. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_ZIP", GETPOST("zipcode", 'alpha'), 'chaine', 0, '', $conf->entity);
  47. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_STATE", GETPOST("state_id", 'alpha'), 'chaine', 0, '', $conf->entity);
  48. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_REGION", GETPOST("region_code", 'alpha'), 'chaine', 0, '', $conf->entity);
  49. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_COUNTRY", GETPOST('country_id', 'int'), 'chaine', 0, '', $conf->entity);
  50. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_PHONE", GETPOST("tel", 'alpha'), 'chaine', 0, '', $conf->entity);
  51. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_FAX", GETPOST("fax", 'alpha'), 'chaine', 0, '', $conf->entity);
  52. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_MAIL", GETPOST("mail", 'alpha'), 'chaine', 0, '', $conf->entity);
  53. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_WEB", GETPOST("web", 'alpha'), 'chaine', 0, '', $conf->entity);
  54. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_CODE", GETPOST("code", 'nohtml'), 'chaine', 0, '', $conf->entity);
  55. dolibarr_set_const($db, "MAIN_INFO_ACCOUNTANT_NOTE", GETPOST("note", 'none'), 'chaine', 0, '', $conf->entity);
  56. if ($action != 'updateedit' && !$error)
  57. {
  58. header("Location: ".$_SERVER["PHP_SELF"]);
  59. exit;
  60. }
  61. }
  62. /*
  63. * View
  64. */
  65. $help_url = '';
  66. llxHeader('', $langs->trans("CompanyFoundation"), $help_url);
  67. print load_fiche_titre($langs->trans("CompanyFoundation"), '', 'title_setup');
  68. $head = company_admin_prepare_head();
  69. dol_fiche_head($head, 'accountant', $langs->trans("Company"), -1, 'company');
  70. $form = new Form($db);
  71. $formother = new FormOther($db);
  72. $formcompany = new FormCompany($db);
  73. $countrynotdefined = '<font class="error">'.$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')</font>';
  74. print '<span class="opacitymedium">'.$langs->trans("AccountantDesc")."</span><br>\n";
  75. print "<br>\n";
  76. /**
  77. * Edit parameters
  78. */
  79. print "\n".'<script type="text/javascript" language="javascript">';
  80. print '$(document).ready(function () {
  81. $("#selectcountry_id").change(function() {
  82. document.form_index.action.value="updateedit";
  83. document.form_index.submit();
  84. });
  85. });';
  86. print '</script>'."\n";
  87. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'" name="form_index">';
  88. print '<input type="hidden" name="token" value="'.newToken().'">';
  89. print '<input type="hidden" name="action" value="update">';
  90. print '<table class="noborder centpercent editmode">';
  91. print '<tr class="liste_titre"><th class="titlefield wordbreak">'.$langs->trans("CompanyInfo").'</th><th>'.$langs->trans("Value").'</th></tr>'."\n";
  92. // Name
  93. print '<tr class="oddeven"><td><label for="name">'.$langs->trans("CompanyName").'</label></td><td>';
  94. print '<input name="nom" id="name" class="minwidth200" value="'.($conf->global->MAIN_INFO_ACCOUNTANT_NAME ? $conf->global->MAIN_INFO_ACCOUNTANT_NAME : GETPOST("nom", 'nohtml')).'"'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? '' : ' autofocus="autofocus"').'></td></tr>'."\n";
  95. // Address
  96. print '<tr class="oddeven"><td><label for="address">'.$langs->trans("CompanyAddress").'</label></td><td>';
  97. print '<textarea name="address" id="address" class="quatrevingtpercent" rows="'.ROWS_3.'">'.($conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS ? $conf->global->MAIN_INFO_ACCOUNTANT_ADDRESS : GETPOST("address", 'nohtml')).'</textarea></td></tr>'."\n";
  98. print '<tr class="oddeven"><td><label for="zipcode">'.$langs->trans("CompanyZip").'</label></td><td>';
  99. print '<input class="minwidth100" name="zipcode" id="zipcode" value="'.($conf->global->MAIN_INFO_ACCOUNTANT_ZIP ? $conf->global->MAIN_INFO_ACCOUNTANT_ZIP : GETPOST("zipcode", 'alpha')).'"></td></tr>'."\n";
  100. print '<tr class="oddeven"><td><label for="town">'.$langs->trans("CompanyTown").'</label></td><td>';
  101. print '<input name="town" class="minwidth100" id="town" value="'.($conf->global->MAIN_INFO_ACCOUNTANT_TOWN ? $conf->global->MAIN_INFO_ACCOUNTANT_TOWN : GETPOST("town", 'nohtml')).'"></td></tr>'."\n";
  102. // Country
  103. print '<tr class="oddeven"><td><label for="selectcountry_id">'.$langs->trans("Country").'</label></td><td class="maxwidthonsmartphone">';
  104. //if (empty($country_selected)) $country_selected=substr($langs->defaultlang,-2); // By default, country of localization
  105. print $form->select_country($conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 'country_id');
  106. if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
  107. print '</td></tr>'."\n";
  108. print '<tr class="oddeven"><td><label for="state_id">'.$langs->trans("State").'</label></td><td class="maxwidthonsmartphone">';
  109. $formcompany->select_departement($conf->global->MAIN_INFO_ACCOUNTANT_STATE, $conf->global->MAIN_INFO_ACCOUNTANT_COUNTRY, 'state_id');
  110. print '</td></tr>'."\n";
  111. print '<tr class="oddeven"><td><label for="phone">'.$langs->trans("Phone").'</label></td><td>';
  112. print img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright');
  113. print '<input name="tel" id="phone" value="'.$conf->global->MAIN_INFO_ACCOUNTANT_PHONE.'"></td></tr>';
  114. print '</td></tr>'."\n";
  115. print '<tr class="oddeven"><td><label for="fax">'.$langs->trans("Fax").'</label></td><td>';
  116. print img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright');
  117. print '<input name="fax" id="fax" value="'.$conf->global->MAIN_INFO_ACCOUNTANT_FAX.'"></td></tr>';
  118. print '</td></tr>'."\n";
  119. print '<tr class="oddeven"><td><label for="email">'.$langs->trans("EMail").'</label></td><td>';
  120. print img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright');
  121. print '<input name="mail" id="email" class="minwidth200" value="'.$conf->global->MAIN_INFO_ACCOUNTANT_MAIL.'"></td></tr>';
  122. print '</td></tr>'."\n";
  123. // Web
  124. print '<tr class="oddeven"><td><label for="web">'.$langs->trans("Web").'</label></td><td>';
  125. print img_picto('', 'globe', '', false, 0, 0, '', 'paddingright');
  126. print '<input name="web" id="web" class="minwidth300" value="'.$conf->global->MAIN_INFO_ACCOUNTANT_WEB.'"></td></tr>';
  127. print '</td></tr>'."\n";
  128. // Code
  129. print '<tr class="oddeven"><td><label for="code">'.$langs->trans("AccountantFileNumber").'</label></td><td>';
  130. print '<input name="code" id="code" class="minwidth100" value="'.($conf->global->MAIN_INFO_ACCOUNTANT_CODE ? $conf->global->MAIN_INFO_ACCOUNTANT_CODE : GETPOST("code", 'nohtml')).'"></td></tr>'."\n";
  131. // Note
  132. print '<tr class="oddeven"><td class="tdtop"><label for="note">'.$langs->trans("Note").'</label></td><td>';
  133. print '<textarea class="flat quatrevingtpercent" name="note" id="note" rows="'.ROWS_5.'">'.(GETPOST('note', 'none') ? GETPOST('note', 'none') : $conf->global->MAIN_INFO_ACCOUNTANT_NOTE).'</textarea></td></tr>';
  134. print '</td></tr>';
  135. print '</table>';
  136. print '<br><div class="center">';
  137. print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
  138. //print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
  139. //print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
  140. print '</div>';
  141. //print '<br>';
  142. print '</form>';
  143. llxFooter();
  144. $db->close();