<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');

class Prodlabel_model extends CI_Model {

    public function __construct() {
        parent::__construct();
    }
 
    function getproductdetails($pname){
        $sql = "SELECT P.*,((P.PRICESELL*T.RATE)+P.PRICESELL) as SELLPRICETAX,P.PRICESELL,P.PRICESELL AS SELLPRICE FROM PRODUCTS P LEFT JOIN TAXES T ON P.TAXCAT = T.CATEGORY";
        if ($pname) $sql .= " WHERE P.ID='".$pname."'";
        $query = $this->db->query($sql);
        return $query->row();
    }

    function getlabelsizes(){
        $this->db->select('CONTENT');
        $this->db->where('NAME', 'label.sizes');
        $q = $this->db->get("RESOURCES");
        if($q) {
            return simplexml_load_string(htmlspecialchars_decode($q->row()->CONTENT));
        } else {
            return null;    
        }
    }

function getlabelformats(){
$this->db->select('CONTENT');
$this->db->where('NAME', 'label.formats');
$q = $this->db->get("RESOURCES");
if($q)
{
    return simplexml_load_string(htmlspecialchars_decode($q->row()->CONTENT));
}
 else {
    return null;    
}
}

function getproductautocomplete($term) {
        $this->db->select('P.ID, P.NAME');
        $this->db->from('PRODUCTS AS P');
        $where = "P.NAME LIKE '". $term. "%'";
        $this->db->where($where);
        return $this->db->get()->result();
 }

}