dolibarr/htdocs/admin/compta.php

172 lines
5.0 KiB
PHP
Raw Normal View History

2008-02-18 05:23:08 +01:00
<?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
2012-12-30 15:13:49 +01:00
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
2016-06-21 17:00:52 +02:00
* Copyright (C) 2013-2016 Philippe Grand <philippe.grand@atoo-net.com>
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
2008-02-18 05:23:08 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2008-02-18 05:23:08 +01:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2011-08-01 00:21:57 +02:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2008-02-18 05:23:08 +01:00
*/
/**
2009-08-02 18:16:15 +02:00
* \file htdocs/admin/compta.php
2010-12-15 02:13:06 +01:00
* \ingroup compta
* \brief Page to setup accountancy module
2008-11-04 18:26:33 +01:00
*/
2008-02-18 05:23:08 +01:00
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
2008-02-18 05:23:08 +01:00
$langs->load('admin');
$langs->load('compta');
2014-12-14 11:46:21 +01:00
$langs->load('accountancy');
2008-02-18 05:23:08 +01:00
if (!$user->admin)
2008-11-04 18:26:33 +01:00
accessforbidden();
2008-02-18 05:23:08 +01:00
2012-03-29 09:38:38 +02:00
$action = GETPOST('action','alpha');
2008-02-18 05:23:08 +01:00
// Other parameters ACCOUNTING_*
$list = array(
'ACCOUNTING_PRODUCT_BUY_ACCOUNT',
'ACCOUNTING_PRODUCT_SOLD_ACCOUNT',
'ACCOUNTING_SERVICE_BUY_ACCOUNT',
'ACCOUNTING_SERVICE_SOLD_ACCOUNT',
'ACCOUNTING_VAT_SOLD_ACCOUNT',
'ACCOUNTING_VAT_BUY_ACCOUNT',
'ACCOUNTING_ACCOUNT_CUSTOMER',
'ACCOUNTING_ACCOUNT_SUPPLIER'
);
2013-03-22 17:10:17 +01:00
/*
* Actions
*/
2014-09-21 20:42:46 +02:00
$accounting_mode = defined('ACCOUNTING_MODE')?ACCOUNTING_MODE:'RECETTES-DEPENSES';
2008-02-18 05:23:08 +01:00
if ($action == 'update')
2008-02-18 05:23:08 +01:00
{
$error = 0;
2008-02-18 05:23:08 +01:00
2014-09-21 20:42:46 +02:00
$accounting_modes = array(
'RECETTES-DEPENSES',
'CREANCES-DETTES'
2014-05-03 17:10:47 +02:00
);
2014-09-21 20:42:46 +02:00
$accounting_mode = GETPOST('accounting_mode','alpha');
2014-05-03 17:10:47 +02:00
2014-09-21 20:42:46 +02:00
if (in_array($accounting_mode,$accounting_modes)) {
2014-09-21 20:42:46 +02:00
if (!dolibarr_set_const($db, 'ACCOUNTING_MODE', $accounting_mode, 'chaine', 0, '', $conf->entity)) {
$error++;
}
} else {
$error++;
2011-08-31 16:45:02 +02:00
}
2008-02-18 05:23:08 +01:00
foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha');
2008-02-18 05:23:08 +01:00
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
if (! $error)
2011-08-31 16:45:02 +02:00
{
2015-10-23 12:58:30 +02:00
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
2011-08-31 16:45:02 +02:00
}
else
{
2015-10-23 12:58:30 +02:00
setEventMessages($langs->trans("Error"), null, 'errors');
2011-08-31 16:45:02 +02:00
}
2008-02-18 05:23:08 +01:00
}
/*
2013-03-22 17:10:17 +01:00
* View
2008-02-18 05:23:08 +01:00
*/
2011-08-31 16:45:02 +02:00
llxHeader();
$form=new Form($db);
2008-02-18 05:23:08 +01:00
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('ComptaSetup'),$linkback,'title_setup');
2008-02-18 05:23:08 +01:00
print '<br>';
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">';
2008-02-18 05:23:08 +01:00
print '<table class="noborder" width="100%">';
2016-06-21 17:00:52 +02:00
// case of the parameter ACCOUNTING_MODE
2008-02-18 05:23:08 +01:00
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('OptionMode').'</td><td>'.$langs->trans('Description').'</td>';
print "</tr>\n";
2014-09-21 20:42:46 +02:00
print '<tr '.$bc[false].'><td width="200"><input type="radio" name="accounting_mode" value="RECETTES-DEPENSES"'.($accounting_mode != 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeTrue').'</td>';
2008-02-18 05:23:08 +01:00
print '<td colspan="2">'.nl2br($langs->trans('OptionModeTrueDesc'));
// Write info on way to count VAT
//if (! empty($conf->global->MAIN_MODULE_COMPTABILITE))
//{
// // print "<br>\n";
// // print nl2br($langs->trans('OptionModeTrueInfoModuleComptabilite'));
//}
//else
//{
// // print "<br>\n";
// // print nl2br($langs->trans('OptionModeTrueInfoExpert'));
//}
2008-02-18 05:23:08 +01:00
print "</td></tr>\n";
2014-09-21 20:42:46 +02:00
print '<tr '.$bc[true].'><td width="200"><input type="radio" name="accounting_mode" value="CREANCES-DETTES"'.($accounting_mode == 'CREANCES-DETTES' ? ' checked' : '').'> '.$langs->trans('OptionModeVirtual').'</td>';
2008-02-18 05:23:08 +01:00
print '<td colspan="2">'.nl2br($langs->trans('OptionModeVirtualDesc'))."</td></tr>\n";
print "</table>\n";
print "<br>\n";
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans('OtherOptions').'</td>';
print "</tr>\n";
2010-12-15 02:13:06 +01:00
foreach ($list as $key)
{
$var=!$var;
print '<tr '.$bc[$var].' class="value">';
// Param
2014-12-14 11:46:21 +01:00
$libelle = $langs->trans($key);
print '<td><label for="'.$key.'">'.$libelle.'</label></td>';
2010-12-15 02:13:06 +01:00
// Value
print '<td>';
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.$conf->global->$key.'">';
print '</td></tr>';
2008-02-18 05:23:08 +01:00
}
print "</table>\n";
print '<br /><br /><div style="text-align:center"><input type="submit" class="button" value="'.$langs->trans('Modify').'" name="button"></div>';
print '</form>';
2008-02-18 05:23:08 +01:00
llxFooter();
$db->close();