*
* 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
* along with this program. If not, see .
*/
/**
* \file /htdocs/margin/admin/margin.php
* \ingroup margin
* \brief Page to setup margin module
*/
include '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php');
require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php");
$langs->load("admin");
$langs->load("bills");
$langs->load("margins");
$langs->load("stocks");
if (! $user->admin) accessforbidden();
$action=GETPOST('action','alpha');
/*
* Action
*/
if (preg_match('/set_(.*)/',$action,$reg))
{
$code=$reg[1];
if (dolibarr_set_const($db, $code, 1, 'yesno', 0, '', $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}
if (preg_match('/del_(.*)/',$action,$reg))
{
$code=$reg[1];
if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{
dol_print_error($db);
}
}
if ($action == 'remises')
{
if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0)
{
setEventMessage($langs->trans("RecordModifiedSuccessfully"));
}
else
{
dol_print_error($db);
}
}
if ($action == 'typemarges')
{
if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
{
setEventMessage($langs->trans("RecordModifiedSuccessfully"));
}
else
{
dol_print_error($db);
}
}
if ($action == 'contact')
{
if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
{
setEventMessage($langs->trans("RecordModifiedSuccessfully"));
}
else
{
dol_print_error($db);
}
}
/*
* View
*/
llxHeader('',$langs->trans("margesSetup"));
$linkback=''.$langs->trans("BackToModuleList").'';
print_fiche_titre($langs->trans("margesSetup"),$linkback,'title_setup');
$head = marges_admin_prepare_head();
dol_fiche_head($head, 'parameters', $langs->trans("Margins"), 0, 'margin');
print_fiche_titre($langs->trans("MemberMainOptions"),'','');
print '
';
print '';
print ''.$langs->trans("Description").' | ';
print ''.$langs->trans("Value").' | '."\n";
print ''.$langs->trans("Description").' | '."\n";
print '
';
$var=true;
$form = new Form($db);
// GLOBAL DISCOUNT MANAGEMENT
$var=!$var;
print '';
// DISPLAY MARGIN RATES
$var=!$var;
print '';
print ''.$langs->trans("DisplayMarginRates").' | ';
print '';
if (! empty($conf->use_javascript_ajax))
{
print ajax_constantonoff('DISPLAY_MARGIN_RATES');
}
else
{
if (empty($conf->global->DISPLAY_MARGIN_RATES))
{
print ''.img_picto($langs->trans("Disabled"),'off').'';
}
else
{
print ''.img_picto($langs->trans("Enabled"),'on').'';
}
}
print ' | ';
print ''.$langs->trans('MarginRate').' = '.$langs->trans('Margin').' / '.$langs->trans('BuyingPrice').' | ';
print '
';
// DISPLAY MARK RATES
$var=!$var;
print '';
print ''.$langs->trans("DisplayMarkRates").' | ';
print '';
if (! empty($conf->use_javascript_ajax))
{
print ajax_constantonoff('DISPLAY_MARK_RATES');
}
else
{
if (empty($conf->global->DISPLAY_MARK_RATES))
{
print ''.img_picto($langs->trans("Disabled"),'off').'';
}
else
{
print ''.img_picto($langs->trans("Enabled"),'on').'';
}
}
print ' | ';
print ''.$langs->trans('MarkRate').' = '.$langs->trans('Margin').' / '.$langs->trans('SellingPrice').' | ';
print '
';
$var=!$var;
print '';
print ''.$langs->trans("ForceBuyingPriceIfNull").' | ';
print '';
if (! empty($conf->use_javascript_ajax))
{
print ajax_constantonoff('ForceBuyingPriceIfNull');
}
else
{
if (empty($conf->global->ForceBuyingPriceIfNull))
{
print ''.img_picto($langs->trans("Disabled"),'off').'';
}
else
{
print ''.img_picto($langs->trans("Enabled"),'on').'';
}
}
print ' | ';
print ''.$langs->trans('ForceBuyingPriceIfNullDetails').' | ';
print '
';
// GLOBAL DISCOUNT MANAGEMENT
$var=!$var;
print '';
// INTERNAL CONTACT TYPE USED AS COMMERCIAL AGENT
$var=!$var;
print '';
print '
';
dol_fiche_end();
print '
';
llxFooter();
$db->close();