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

class Management_Model extends CI_Model {
  
  private $tableNameDeliveryMaster = 'marketing_loading_unloading';
  
  function __construct() 
  {
    /* Call the Model constructor */
    parent::__construct();
  }
  
  
function getPendingBulkRequest()
    {
        $this->db->select('brm.*,w.name,u.user_first_name,u.user_last_name');
        $this->db->from('bulk_requste_master brm');
        $this->db->join('warehouses w', 'w.id = brm.brn_to_warehouse_id', 'left');
        $this->db->join('user u', 'u.user_id = brm.added_user_id', 'left');
        $this->db->where("brm.is_deleted = 0 AND brm_approval_status = 0");
		$this->db->order_by("brm.brm_id", "desc");
		$this->db->group_by("brm.brm_id");
        $query = $this->db->get();
        if ($query->num_rows() > 0) {
            return $query->result();
        } else {
                return false;
        }
    }
	
	function getPendingCostEstimation()
    {
        $this->db->select('p.*');
        $this->db->select('bm.brm_ref_no,bm.brm_id');
        $this->db->select('w.name AS warehouse_name');
        $this->db->select('um.user_first_name');
        $this->db->select('uu.user_first_name AS modify_by');
        $this->db->from('production_cost_estimation_master p');
        $this->db->join('bulk_requste_master bm', 'bm.brm_id = p.pcem_request_id', 'inner');
        $this->db->join('warehouses w', 'w.id = p.pcem_warehouse_id', 'inner');
        $this->db->join('user um', 'um.user_id = p.pcem_user', 'inner');
        $this->db->join('user uu', 'uu.user_id = p.last_modify_by', 'left');
        $this->db->where('p.pcem_staus',1);
        $this->db->where('p.pcem_approval_status',0);
        $this->db->where('p.is_deleted',0);
          $query = $this->db->get();
          if ($query->num_rows() > 0) {
            return $query->result();
        } else {
            return false;
        }
    }
	
}