HEX
Server: Apache
System: Linux srv13.cpanelhost.cl 3.10.0-962.3.2.lve1.5.38.el7.x86_64 #1 SMP Thu Jun 18 05:28:41 EDT 2020 x86_64
User: cca63905 (4205)
PHP: 7.3.20
Disabled: NONE
Upload Files
File: /home4/cca63905/www/nueva/modules/roja45quotationsprofree/classes/QuotationRequestProduct.php
<?php
/**
 * QuotationRequestProduct.
 *
 * @author    Roja45
 * @copyright 2016 Roja45
 * @license   license.txt
 * @category  QuotationRequestProduct
 *
 * 2016 ROJA45 - All rights reserved.
 *
 * DISCLAIMER
 * Changing this file will render any support provided by us null and void.
 */

/**
 * QuotationRequestProduct.
 *
 * @author    Roja45
 * @copyright 2016 Roja45
 * @license   license.txt
 * @category  Class
 *
 * 2016 ROJA45 - All rights reserved.
 *
 * DISCLAIMER
 * Changing this file will render any support provided by us null and void.
 */

class QuotationRequestProduct extends ObjectModel
{
    public $id_roja45_quotation_request;
    public $id_shop;
    public $id_product;
    public $id_product_attribute;
    public $qty;
    public $date_add;

    /**
     * @see ObjectModel::$definition
     */
    public static $definition = array(
        'table' => 'roja45_quotationspro_requestproduct',
        'primary' => 'id_roja45_quotation_requestproduct',
        'multilang' => false,
        'fields' => array(
            'id_roja45_quotation_request' => array(
                'type' => self::TYPE_INT,
                'lang' => false,
                'required' => true
            ),
            'id_shop' => array(
                'type' => self::TYPE_INT,
                'lang' => false,
                'required' => true
            ),
            'id_product' => array(
                'type' => self::TYPE_INT,
                'lang' => false,
                'required' => true
            ),
            'id_product_attribute' => array(
                'type' => self::TYPE_INT,
                'lang' => false,
                'required' => false
            ),
            'qty' => array(
                'type' => self::TYPE_INT,
                'lang' => false,
                'required' => false
            ),
            'date_add' => array(
                'type' => self::TYPE_DATE,
                'lang' => false,
                'required' => false
            ),
        ),
    );

    public static function updateQty($id_roja45_quotation_request, $id_product, $id_product_attribute, $qty)
    {
        Db::getInstance()->execute(
            'UPDATE `'._DB_PREFIX_.'roja45_quotationspro_requestproduct`
			SET `qty` = '.$qty.', `date_add` = NOW()
			WHERE `id_product` = '.(int)$id_product.
            (!empty($id_product_attribute) ? ' AND `id_product_attribute` = '.(int)$id_product_attribute : '').'
			AND `id_roja45_quotation_request` = '.(int)$id_roja45_quotation_request.'
			LIMIT 1'
        );
    }
}