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