<?php
/**
* 2007-2020 PrestaShop
*
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@buy-addons.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author    Buy-Addons <contact@buy-addons.com>
*  @copyright 2007-2020 PrestaShop SA
*  @license   http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
* @since 1.6
*/

class AskforaquotemodulbaaddproducttoincludeModuleFrontController extends ModuleFrontController
{
    public function run()
    {
        
        $quote_module_token = Tools::getValue('quote_token');
        if ($quote_module_token != md5(sha1(_COOKIE_KEY_.'askforaquotemodul'))) {
            die;
        } else {
            $store_product = array();
            $id_product_search = Tools::getValue('id_product_search');
            $name_product = Tools::getValue('name_product');
            $db = Db::getInstance(_PS_USE_SQL_SLAVE_);
            $sql_list_product = 'Insert into ' . _DB_PREFIX_ . '';
            $sql_list_product .= 'include_product_dbboo(id_product,name_product,type)';
            $sql_list_product .= ' values("' . (int) $id_product_search . '","' . pSQL($name_product) . '","0")';
            $db->query($sql_list_product);
            $include_pro = 'Select * from ' . _DB_PREFIX_ . 'include_product_dbboo';
            $include_product = $db->executeS($include_pro, true, false);
            $include_pro_save = 'Select * from ' . _DB_PREFIX_ . 'include_product_dbboo_save';
            $include_product_save = $db->executeS($include_pro_save, true, false);
            $store_product = array_merge($include_product, $include_product_save);
            $count_sp = Count($store_product);
            $store_product['number_pr'] = $count_sp;
            echo Tools::jsonEncode($store_product);
        }
    }
}
