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/public_html/nueva/modules/roja45quotationsprofree/classes/QuotationProduct.php
<?php
/**
 * QuotationProduct.
 *
 * @author    Roja45
 * @copyright 2016 Roja45
 * @license   license.txt
 * @category  QuotationProduct
 *
 *
 * 2016 ROJA45 - All rights reserved.
 *
 * DISCLAIMER
 * Changing this file will render any support provided by us null and void.
 */

/**
 * QuotationProduct.
 *
 * @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 QuotationProduct extends ObjectModel
{
    public $id_roja45_quotation_product;
    public $id_roja45_quotation;
    public $id_product;
    public $id_product_attribute;
    public $id_shop;
    public $product_title;
    public $qty;
    public $unit_price_tax_excl;
    public $unit_price_tax_incl;
    public $custom_price;
    public $id_specific_price;

    /**
     * @see ObjectModel::$definition
     */
    public static $definition = array(
        'table' => 'roja45_quotationspro_product',
        'primary' => 'id_roja45_quotation_product',
        'multilang' => false,
        'fields' => array(
            'id_roja45_quotation' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
            'id_product' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
            'id_product_attribute' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
            'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
            'product_title' => array('type' => self::TYPE_STRING, 'size' => 255, 'required' => true),
            'qty' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
            'unit_price_tax_excl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
            'unit_price_tax_incl' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'),
            'custom_price' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
            'id_specific_price' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
        ),
    );

    public function setQty($qty)
    {
        $this->qty = $qty;
        return $this->update();
    }

    public static function getIdQuotationProduct($id_roja45_quotation, $id_product)
    {
        $sql = new DbQuery();
        $sql->select('qp.id_roja45_quotation_product');
        $sql->from('roja45_quotationspro_product', 'qp');
        $sql->where('qp.`id_roja45_quotation` = ' . (int) $id_roja45_quotation);
        $sql->where('qp.`id_product` = ' . (int) $id_product);
        return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
    }

    public static function getList($id_roja45_quotation)
    {
        $sql = new DbQuery();
        $sql->select('*');
        $sql->from('roja45_quotationspro_product', 'qp');
        $sql->where('qp.`id_roja45_quotation` = ' . (int) $id_roja45_quotation);
        return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
    }

    public static function getQuotationProduct($id_roja45_quotation, $id_product, $id_product_attribute)
    {
        $sql = new DbQuery();
        $sql->select('qp.id_roja45_quotation_product');
        $sql->from('roja45_quotationspro_product', 'qp');
        $sql->where('qp.`id_roja45_quotation` = ' . (int) $id_roja45_quotation);
        $sql->where('qp.`id_product` = ' . (int) $id_product);
        $sql->where('qp.`id_product_attribute` = ' . (int) $id_product_attribute);
        return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
    }
}