<?php

class ModelPiyersoftCases extends Model {

    public function updateOrderProduct($order_product_id, $file_name) {
        $this->db->query("UPDATE ps_order_product SET admin_pattern_image = '" . $file_name . "' WHERE order_product_id = '" . (int) $order_product_id . "'");
    }

    public function updategradientimage($order_product_id, $file_name) {
        $this->db->query("UPDATE ps_order_product SET admin_gradient_pattern_image = '" . $file_name . "' WHERE order_product_id = '" . (int) $order_product_id . "'");
    }

    public function getCategorybyname($name = false, $parent_id = 0) {
        $query = $this->db->query("SELECT DISTINCT * FROM ps_category c
        LEFT JOIN ps_category_description cd ON (c.category_id = cd.category_id)
        LEFT JOIN ps_category_to_store c2s ON (c.category_id = c2s.category_id)
        WHERE  c.parent_id = '" . (int) $parent_id . "'" . ($name ? "AND cd.name like '" . $name . "%'" : '') . " AND cd.language_id = '" . (int) $this->config->get('config_language_id') . "' AND c2s.store_id = '" . (int) $this->config->get('config_store_id') . "' AND c.status = '1'");

        return $query->row;
    }

    public function updateCanvasImage($cart_id, $file_name) {
        $this->db->query("UPDATE ps_cart SET customer_order_image = '" . $file_name . "' WHERE cart_id = '" . (int) $cart_id . "'");
    }

}
