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/stockalert/admin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/dev/htdocs/custom/stockalert/admin/admin_stockalert.php
<?php
/* StockAlert - Dolibarr module
 * Copyleft 2015 cyberesprit
 *
 * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
 * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
 *
 * 0. You just DO WHAT THE FUCK YOU WANT TO.
 *
 * 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.
 *
 */

/**
 * \file        admin/admin_stockalert.php
 * \ingroup     stockalert
 * \brief       Admin settings configuration for StockAlert - Dolibarr module
 *
 */
 
// Dolibarr environment
$res=0;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)
if (! $res && ! empty($_SERVER["CONTEXT_DOCUMENT_ROOT"])) $res=@include($_SERVER["CONTEXT_DOCUMENT_ROOT"]."/main.inc.php");
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME
$tmp=empty($_SERVER['SCRIPT_FILENAME'])?'':$_SERVER['SCRIPT_FILENAME'];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;
while($i > 0 && $j > 0 && isset($tmp[$i]) && isset($tmp2[$j]) && $tmp[$i]==$tmp2[$j]) { $i--; $j--; }
if (! $res && $i > 0 && file_exists(substr($tmp, 0, ($i+1))."/main.inc.php")) $res=@include(substr($tmp, 0, ($i+1))."/main.inc.php");
if (! $res && $i > 0 && file_exists(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php")) $res=@include(dirname(substr($tmp, 0, ($i+1)))."/main.inc.php");
// Try main.inc.php using relative path
if (! $res && file_exists("../../main.inc.php")) $res=@include("../../main.inc.php");
if (! $res && file_exists("../../../main.inc.php")) $res=@include("../../../main.inc.php");
if (! $res) die("Include of main fails");

global $langs, $user;

// Libraries
require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
require_once '../lib/stockalert.lib.php';

// Translations
$langs->load("stockalert@stockalert");

// Access control
if (!$user->admin)
{
    accessforbidden();
}

// Parameters
$action = GETPOST('action');

/*
 * Actions
 */
if ($action == "setvalue")
{
    // STOCKALERT_MOVEMENTS
    dolibarr_set_const
    (
        $db, 
        "STOCKALERT_MOVEMENTS_ENABLE", 
        GETPOST("stock_alert_movements_enable"), 
        'integer', 
        0, 
        '', 
        $conf->entity
    );
    
    // STOCKALERT_BOX
    if (GETPOST("stock_alert_box_count") >= 0)
    {
        dolibarr_set_const
        (
            $db, 
            "STOCKALERT_BOX_COUNT", 
            GETPOST("stock_alert_box_count"), 
            'integer', 
            0, 
            '', 
            $conf->entity
        );
    }
    else
    {
        setEventMessages($langs->trans("StockAlertConfigUpdateError_BoxCount"), null, 'errors');
    }
    
    // STOCKALERT_EMAIL
    dolibarr_set_const
    (
        $db, 
        "STOCKALERT_EMAIL_ENABLE", 
        GETPOST("stock_alert_email_enable"), 
        'integer', 
        0, 
        '', 
        $conf->entity
    );

    // STOCKALERT_EMAIL
    dolibarr_set_const
    (
        $db, 
        "STOCKALERT_RECIVER", 
        GETPOST("stock_alert_reciver"), 
        'text', 
        0, 
        '', 
        $conf->entity
    );
    
    setEventMessages($langs->trans("StockAlertConfigUpdateSuccess"), null, 'mesgs');
}

/*
 * View
 */
$page_name = "StockAlertSetup";
llxHeader('', $langs->trans($page_name));

// Subheader
$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'
            .$langs->trans("BackToModuleList").'</a>';
print_fiche_titre($langs->trans($page_name), $linkback);


// Configuration header
$head = stockalertAdminPrepareHead();
dol_fiche_head
(
    $head,
    'settings',
    $langs->trans("StockAlertName"),
    0,
    "stockalert@stockalert"
);

// Setup page goes here
if ($mesg) print '<br>'.$mesg.'<br />';

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

print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("StockAlertMovementsTitle").'</td>';
print "</tr>";

$var = true;

print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("StockAlertMovementsEnable").'</td>';
print '<td align="right">'.
        '<select name="stock_alert_movements_enable">'.
            '<option value="1" '.(($conf->global->STOCKALERT_MOVEMENTS_ENABLE == 1)? 'selected="selected"' : '' ).'>'.$langs->trans("yes").'</option>'.
            '<option value="0" '.(($conf->global->STOCKALERT_MOVEMENTS_ENABLE == 0)? 'selected="selected"' : '' ).'>'.$langs->trans("no").'</option>'.
        '</select>'.
    '</td>';
print '</tr>';

print '</table>';

print '<br />';

print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("StockAlertBoxTitle").'</td>';
print "</tr>";

$var = true;

print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("StockAlertBoxCount").'</td>';
print '<td align="right">'.
        '<input type="text" name="stock_alert_box_count" value="'.$conf->global->STOCKALERT_BOX_COUNT.'" /></td>';
print '</tr>';

print '</table>';

print '<br />';

print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("StockAlertEmailTitle").'</td>';
print "</tr>";

$var = true;

print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("StockAlertEmailEnable").'</td>';
print '<td align="right">'.
        '<select name="stock_alert_email_enable">'.
            '<option value="1" '.(($conf->global->STOCKALERT_EMAIL_ENABLE == 1)? 'selected="selected"' : '' ).'>'.$langs->trans("yes").'</option>'.
            '<option value="0" '.(($conf->global->STOCKALERT_EMAIL_ENABLE == 0)? 'selected="selected"' : '' ).'>'.$langs->trans("no").'</option>'.
        '</select>'.
    '</td>';
print '</tr>';

$var = true;

print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("StockAlertReciver").'</td>';
print '<td align="right">'.
        '<input type="text" name="stock_alert_reciver" value="'.$conf->global->STOCKALERT_RECIVER.'" /></td>';
print '</tr>';

print '</table>';

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

// Page end
dol_fiche_end();
llxFooter();

Hry