accountant.php 11 KB

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