<?php

class BranchDeliveryView extends CI_Model
{
    public function __construct()
	{
		parent::__construct();

		$this->load->database();
    }


    public function getHdrDataByTransID($transID)
    {
        return $this->db->get_where("branchdeliveryhdr", array("transid"=>$transID));
    }

    public function getDtlDataByTransIDBrCode($transID, $brCode)
    {
        return $this->db->get_where("branchdeliverydtl", array("transid"=>$transID, "brCode"=>$brCode));
    }

    public function getDataByTransIDBrCode($transID, $brCode)
    {
        $sql = "SELECT branchdeliverydtl.transid, branchdeliverydtl.itemcode, items.modelno, items.seriescode, items.item_desc, items.karat, items.size, items.grams, items.cts, items.mrp AS itemmrp, items.srp as itemsrp, items.manref, items.catCode, items.goldID, items.supCode, items.modifieddate, items.sourceDate, branchdeliverydtl.mrp AS brdmrp, branchdeliverydtl.srp AS brdsrp, branchdeliverydtl.qty, branchdeliverydtl.brCode FROM branchdeliverydtl LEFT JOIN items ON branchdeliverydtl.itemcode=items.itemcode WHERE branchdeliverydtl.transid=? AND branchdeliverydtl.brCode=? ORDER BY items.catCode, items.modelno";
        return $this->db->query($sql, array($transID, $brCode));
    }
}