dolibarr/htdocs/salaries/admin/salaries.php

157 lines
4.2 KiB
PHP
Raw Normal View History

<?php
2019-07-19 23:08:24 +02:00
/* Copyright (C) 2014-2019 Alexandre Spangaro <aspangaro@open-dsi.fr>
*
* 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
* (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
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
/**
2019-12-15 10:02:20 +01:00
* \file htdocs/salaries/admin/salaries.php
* \ingroup Salaries
* \brief Setup page to configure salaries module
*/
2019-07-19 23:08:24 +02:00
require '../../main.inc.php';
2014-11-22 00:45:04 +01:00
// Class
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
2019-07-19 23:08:24 +02:00
require_once DOL_DOCUMENT_ROOT.'/core/lib/salaries.lib.php';
2022-08-29 10:52:37 +02:00
if (isModEnabled('accounting')) {
2021-02-26 21:17:52 +01:00
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
}
2018-05-26 18:52:14 +02:00
// Load translation files required by the page
$langs->loadLangs(array('admin', 'salaries'));
// Security check
2021-02-26 21:17:52 +01:00
if (!$user->admin) {
accessforbidden();
2021-02-26 21:17:52 +01:00
}
2020-09-16 19:39:50 +02:00
$action = GETPOST('action', 'aZ09');
// Other parameters SALARIES_*
$list = array(
2019-07-19 23:08:24 +02:00
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
);
/*
* Actions
*/
2014-11-22 00:45:04 +01:00
2021-02-26 21:17:52 +01:00
if ($action == 'update') {
$error = 0;
foreach ($list as $constname) {
$constvalue = GETPOST($constname, 'alpha');
if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
$error++;
}
}
2021-02-26 21:17:52 +01:00
if (!$error) {
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
} else {
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
2021-03-04 18:01:41 +01:00
$reg = array();
if (preg_match('/^(set|del)_?([A-Z_]+)$/', $action, $reg)) {
// Set boolean (on/off) constants
if (!dolibarr_set_const($db, $reg[2], ($reg[1] === 'set' ? '1' : '0'), 'chaine', 0, '', $conf->entity) > 0) {
dol_print_error($db);
}
}
/*
* View
*/
llxHeader('', $langs->trans('SalariesSetup'));
$form = new Form($db);
2022-08-29 10:52:37 +02:00
if (isModEnabled('accounting')) {
2021-02-26 21:17:52 +01:00
$formaccounting = new FormAccounting($db);
}
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans('SalariesSetup'), $linkback, 'title_setup');
2019-07-19 23:08:24 +02:00
$head = salaries_admin_prepare_head();
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head($head, 'general', $langs->trans("Salaries"), -1, 'payment');
2019-07-19 23:08:24 +02:00
// Document templates
print load_fiche_titre($langs->trans("Options"), '', '');
print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
print '<input type="hidden" name="token" value="'.newToken().'">';
print '<input type="hidden" name="action" value="update">';
/*
* Params
*/
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
2019-07-19 23:08:24 +02:00
print '<td>'.$langs->trans("Parameters").'</td>';
print '<td width="60">'.$langs->trans("Value")."</td>\n";
print "</tr>\n";
2021-02-26 21:17:52 +01:00
foreach ($list as $key) {
2017-04-25 11:59:18 +02:00
print '<tr class="oddeven value">';
// Param
2014-11-22 00:45:04 +01:00
$label = $langs->trans($key);
2019-07-19 23:08:24 +02:00
print '<td class="fieldrequired" width="50%"><label for="'.$key.'">'.$label.'</label></td>';
// Value
print '<td>';
2022-08-29 10:52:37 +02:00
if (isModEnabled('accounting')) {
2021-10-23 07:42:29 +02:00
print $formaccounting->select_account(getDolGlobalString($key), $key, 1, '', 1, 1);
2020-05-21 15:05:19 +02:00
} else {
2022-06-21 20:25:25 +02:00
print '<input type="text" size="20" id="'.$key.'" name="'.$key.'" value="'.getDolGlobalString($key).'">';
}
print '</td></tr>';
}
print '</tr>';
print "</table>\n";
2020-10-27 18:19:31 +01:00
//print dol_get_fiche_end();
print '<div class="center"><input type="submit" class="button button-edit" name="button" value="'.$langs->trans('Modify').'"></div>';
print '</form><br>';
echo '<div>';
echo '<table class="noborder centpercent">';
echo '<thead>';
echo '<tr class="liste_titre"><th>' . $langs->trans('Parameter') . '</th><th>' . $langs->trans('Value') . '</th></tr>';
echo '</thead>';
echo '<tbody>';
$key = 'CREATE_NEW_SALARY_WITHOUT_AUTO_PAYMENT';
echo '<tr><td>', $langs->trans($key), '</td><td>', ajax_constantonoff($key), '</td></tr>';
echo '</tbody>';
echo '</table>';
echo '</div>';
2018-07-28 18:03:14 +02:00
// End of page
llxFooter();
2018-11-26 14:29:25 +01:00
$db->close();