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/core/substitutions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/dev/htdocs/custom/discountprice/core/substitutions/functions_discountprice.lib.php
<?php
/* 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/lib/functions_discountprice.lib.php
 *	\brief      Ensemble de fonctions de substitutions pour le module DiscountPrice
 * 	\ingroup	discountprice
 */

function discountprice_completesubstitutionarray(&$substitutionarray, $langs, $object, $parameters) {
    global $conf, $db, $langs;

    if ($object->element == 'product' && $parameters['needforkey'] == 'SUBSTITUTION_DISCOUNTPRICETABLABEL') {
        $nbdiscountprices = 0;
        $now = dol_now();
        $now_text = dol_print_date($now, 'dayrfc');
        $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."discountprice_product WHERE entity = {$conf->entity} AND fk_product = {$object->id} AND date_end >= '".$db->escape($now_text)."'";
        $resql = $db->query($sql);
        if ($resql) {
            if ($obj = $db->fetch_object($resql)) {
                $nbdiscountprices = $obj->nb;
            }
        } else {
            dol_print_error($db);
        }

        $substitutionarray['DISCOUNTPRICETABLABEL'] = $langs->trans("DiscountPriceDiscountTab") . ($nbdiscountprices > 0 ? ' <span class="badge">' . ($nbdiscountprices) . '</span>' : '');
    }
}

Hry