<?php
class Purchase_Orders extends CI_Model {

public function add_pur_details($data) {


		
		 
          $result = $this->db->insert('puchase_order_details',$data);
          if($result){return true;}else{return false;} 
		  
    }


    public function add_pur_pack_details($so_id,$id,$material_id,$unit,$all_condition) {


		$data = array(
					'so_id' => $so_id,
					'main_product' => $id,
			        'material_id' => $material_id,
			        'unit' => $unit,
			        'total' => $all_condition			        
			        );  
		 
          $result = $this->db->insert('puchase_order_details',$data);
          if($result){return true;}else{return false;} 
		  
    }

public function add_bom_salesorder_details($so_po_boms) {

		 
          $result = $this->db->insert('so_po_boms',$so_po_boms);
          if($result){return $this->db->insert_id();}else{return false;} 
		  
    }
    

    public function check_so($so_id)
		{
			$sql = $this->db->get_where('so_po_boms', array('so_id'=>$so_id));
			if($sql->num_rows() >0)
			{return true;
			}else
			{return false;}
		}

		public function check_so_po_boms($so_id)
		{
			$sql = $this->db->get_where('so_po_boms', array('so_id'=>$so_id));
			if($sql->num_rows() >0)
			{return true;
			}else
			{return false;}
		}

		

		public function get_vendors()
		{
			$sql = $this->db->get('vendors');
			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}

		public function get_all_po()
		{
			$sql = $this->db->get_where('purchase_order');
			//$sql = $this->db->get_where('purchase_order',array('qc_status' => 0));
			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}


			
		}
		
		
	public function get_all_po_details()
		{

		$this->db->select('purchase_order.vendor_id,purchase_order.id,purchase_order.po_no,purchase_order.po_date,purchase_order_materials_details.material_id,purchase_order_materials_details.weight,purchase_order_materials_details.unit,purchase_order_materials_details.product_id,purchase_order_materials_details.rate,purchase_order_materials_details.po_id,purchase_order_materials_details.created,purchase_order_materials_details.order_qty,purchase_order.approve_status,purchase_order.quot_ref');  
		  
		$this->db->from('purchase_order');
		
		$this->db->join('purchase_order_materials_details', 'purchase_order.id = purchase_order_materials_details.po_id', 'inner');
		//$this->db->where("purchase_order_materials_details.po_id",$id);
		$this->db->order_by('purchase_order.po_date','DESC');

		$sql = $this->db->get();

		if($sql->num_rows() >0)
		{return $sql->result_array();
		}else
		{return false;}

			
		}
		
		
		 public function get_code($id)
		{
			$this->db->select('vendors.code as vendors_code');    
			$this->db->from('vendors');
			$this->db->where("vendors.id",$id); 
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();;
			}else
			{return false;}
		}
		public function get_match_po($id)
		{
			$this->db->select('purchase_order_materials_details.po_id ');    
			$this->db->from('purchase_order_materials_details');
			$this->db->where("purchase_order_materials_details.po_id",$id); 
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();;
			}else
			{return false;}
		}


		public function add_purchase($save_po){

			 $result = $this->db->insert('purchase_order',$save_po);
         	 if($result){return $this->db->insert_id();}else{return false;} 
		}

		public function details_add_materials($all_data) {
          $result = $this->db->insert('purchase_order_materials_details',$all_data);
          if($result){return true;}else{return false;} 
		 }

		 public function details_add_products($all_data1) {
          $result = $this->db->insert('purchase_order_materials_details',$all_data1);
          if($result){return true;}else{return false;} 
		 }

		 public function get_materials_data($id)
	{
		
		$this->db->select('purchase_order_materials_details.id as purchase_order_materials_details_id,purchase_order_materials_details.material_id,purchase_order_materials_details.weight,purchase_order_materials_details.unit,materials.name,materials.id,materials.type,materials.material_code,materials.grade,purchase_order_materials_details.rate,purchase_order_materials_details.order_qty');  
		  
		$this->db->from('purchase_order_materials_details');
		$this->db->join('materials', 'purchase_order_materials_details.material_id = materials.id', 'inner');
		$this->db->where('purchase_order_materials_details.po_id',$id);
		$sql = $this->db->get();

		if($sql->num_rows() >0)
		{return $sql->result_array();
		}else
		{return false;}

	}
	
	public function get_data_products($id)
	{
		/*$sql = $this->db->get_where('boms', array('id'=>$id));
		*/


		$this->db->select('purchase_order_materials_details.id as purchase_order_id,purchase_order_materials_details.product_id,purchase_order_materials_details.weight,purchase_order_materials_details.unit,products.name,products.id,products.product_type,products.pro_code,products.remarks,purchase_order_materials_details.po_id,purchase_order_materials_details.rate,purchase_order_materials_details.order_qty');  
		  
		$this->db->from('purchase_order_materials_details');
		$this->db->join('products', 'purchase_order_materials_details.product_id = products.id', 'inner');
		
		$this->db->where("purchase_order_materials_details.po_id",$id); 
		$sql = $this->db->get();

		if($sql->num_rows() >0)
		{return $sql->result_array();
		}else
		{return false;}

	}
        
        
        public function delete_boms_data($so_po_id)
			{
				$sql = $this->db->delete('puchase_order_details', array('so_po_id'=>$so_po_id));
				
				return true;
			}
			
			public function delete_so_po_boms($so_po_id)
			{
				$sql = $this->db->delete('so_po_boms', array('id'=>$so_po_id));
				
				return true;
			}


		 public function delete_data_pro($id)
			{
				$sql = $this->db->delete('purchase_order_materials_details', array('id'=>$id));
				
				return true;
			}

			
			public function delete_data_mat($id)
			{
				$sql = $this->db->delete('purchase_order_materials_details', array('id'=>$id));
				
				return true;
			}

			public function update_data_mat_status($po_id)
			{
			
				$result = $this->db->where('id',$po_id);
				$result = $this->db->update('purchase_order',array('status' => 0));
				if($result){return true;}else{return false;}
			}

			

			public function d_active_challan($id)
			{
			
				$result = $this->db->where('id',$id);
				$result = $this->db->update('purchase_order',array('dc_status' => 3));
				if($result){return true;}else{return false;}
			}

			public function update_data_pro_status($po_id)
			{
			
				$result = $this->db->where('id',$po_id);
				$result = $this->db->update('purchase_order',array('status' => 0));
				if($result){return true;}else{return false;}
			}

			
			public function update_req_status($material_id)
			{
			
				$result = $this->db->where('material_id',$material_id);
				$result = $this->db->update('puchase_order_details',array('status' => 0));
				if($result){return true;}else{return false;}
			}

				public function update_req_status_pro($pro_id)
			{
			
				$result = $this->db->where('child_product',$pro_id);
				$result = $this->db->update('puchase_order_details',array('status' => 0));
				if($result){return true;}else{return false;}
			}


			
			public function update_status_so_p_o_d($material_id)
			{
			
				$result = $this->db->where('material_id',$material_id);
				$result = $this->db->update('puchase_order_details',array('status' => 1));
				if($result){return true;}else{return false;}
			}

			
			public function update_status_pro_so_p_o_d($product_id)
			{
			
				$result = $this->db->where('child_product',$product_id);
				$result = $this->db->update('puchase_order_details',array('status' => 1));
				if($result){return true;}else{return false;}
			}

			
			public function total_purchase_material($material_id)
		{
		
		$this->db->select('SUM(purchase_order_materials_details.order_qty) AS order_qty');
		$this->db->from('purchase_order_materials_details');
		$this->db->where('purchase_order_materials_details.material_id',$material_id);
		//$this->db->group_by('purchase_order_materials_details.material_id');

		$sql = $this->db->get();
			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}

		
		public function puchase_order_details_total($material_id)
		{
		
		$this->db->select('SUM(puchase_order_details.total) AS alltotal');
		$this->db->from('puchase_order_details');
		$this->db->where('puchase_order_details.material_id',$material_id);
		//$this->db->group_by('purchase_order_materials_details.material_id');

		$sql = $this->db->get();
			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}

	 public function update_po_products_status($id) {
        $result = $this->db->where('id',$id);
		$result = $this->db->update('purchase_order',array('status' => 1));
		if($result){return true;}else{return false;}
	}

	public function update_po_materials_status($id) {
        $result = $this->db->where('id',$id);
		$result = $this->db->update('purchase_order',array('status' => 1));
		if($result){return true;}else{return false;}
	}

	

	public function get_invoice_data($id)
	{
		

		$this->db->select('purchase_order.vendor_id,purchase_order.id,purchase_order.po_no,purchase_order.po_date,purchase_order_materials_details.material_id,purchase_order_materials_details.weight,purchase_order_materials_details.unit,purchase_order_materials_details.product_id,purchase_order_materials_details.rate,purchase_order_materials_details.po_id,purchase_order_materials_details.created,purchase_order_materials_details.order_qty,purchase_order_materials_details.gst_amount');  
		  
		$this->db->from('purchase_order');
		
		$this->db->join('purchase_order_materials_details', 'purchase_order.id = purchase_order_materials_details.po_id', 'inner');
		$this->db->where("purchase_order_materials_details.po_id",$id);	
		$sql = $this->db->get();

		if($sql->num_rows() >0)
		{return $sql->result_array();
		}else
		{return false;}

	}
    
		

		  public function get_materials_requsition()
		{
			$this->db->select('puchase_order_details.material_id');    
			$this->db->from('puchase_order_details');
			//$this->db->where("puchase_order_details.status",0); 
			//$this->db->where("material_id !=",0);
			$this->db->where("puchase_order_details.status !=",1);
			$this->db->group_by("puchase_order_details.material_id");
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}


		 public function get_po_no_dc(){

				$this->db->select('purchase_order.po_no');  
				  
				$this->db->from('purchase_order');
				//$this->db->where('type',1);
				$this->db->order_by('purchase_order.id','DESC');
				
				$this->db->limit(1);
				$sql = $this->db->get();

				if($sql->num_rows() >0)
				{return $sql->result_array();
				}else
				{return false;}
			}
		

		  public function material_request()
		{
			$this->db->select('SUM(total)as totalqty,material_id,so_po_id,unit');    
			$this->db->from('puchase_order_details');
			//$this->db->where("puchase_order_details.status",0); 
			$this->db->where("material_id !=",0);
			$this->db->where('puchase_order_details.inserted_date >=','2022-08-06');
		  //$this->db->where('machine_daily_report.insert_date <=',$inser8t_last);
			$this->db->group_by("puchase_order_details.material_id");

			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}


		 public function get_materials()
		{
			$this->db->select('materials.id,materials.name');    
			$this->db->from('materials');
			//$this->db->where("puchase_order_details.status",0); 
			//$this->db->where("material_id !=",0);
			//$this->db->where("puchase_order_details.status !=",1);
			//$this->db->group_by("puchase_order_details.material_id");
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}


		 public function get_products()
		{
			$this->db->select('products.id,products.name');    
			$this->db->from('products');
			//$this->db->where("puchase_order_details.status",0); 
			//$this->db->where("material_id !=",0);
			//$this->db->where("puchase_order_details.status !=",1);
			//$this->db->group_by("puchase_order_details.material_id");
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}

		

		 public function get_units()
		{
			$this->db->select('units.id,units.names');    
			$this->db->from('units');
			//$this->db->where("puchase_order_details.status",0); 
			//$this->db->where("material_id !=",0);
			//$this->db->where("puchase_order_details.status !=",1);
			//$this->db->group_by("puchase_order_details.material_id");
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}


		public function get_products_requsition()
		{
			$this->db->select('puchase_order_details.child_product');    
			$this->db->from('puchase_order_details');
			$this->db->where("puchase_order_details.status",0); 
			$this->db->where("child_product !=",0);
			$this->db->group_by("puchase_order_details.child_product");
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}

		/*public function get_materils_details($material)
		{
			$this->db->select('puchase_order_details.material_id,puchase_order_details.unit,SUM(puchase_order_details.total) AS total');    
			$this->db->from('puchase_order_details');
			$this->db->where("puchase_order_details.status",0); 
			$this->db->where("puchase_order_details.material_id",$material);
			$this->db->group_by("puchase_order_details.material_id");
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}*/


		public function get_materils_details($material)
		{
			$this->db->select('materials.material_code');    
			$this->db->from('materials');
			
			$this->db->where("materials.id",$material);
			
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}

		

		public function get_material_logs($material)
		{
			$this->db->select('*');    
			$this->db->from('purchase_order_materials_details');
			
			$this->db->where("purchase_order_materials_details.material_id",$material);
			
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}
		
		
		public function remaining_requisitions($material)
		{
		
		$this->db->select('SUM(purchase_order_materials_details.order_qty) AS order_qty');
		$this->db->from('purchase_order_materials_details');
		$this->db->where('purchase_order_materials_details.material_id',$material);
		$this->db->group_by('purchase_order_materials_details.material_id');
		

		$sql = $this->db->get();
			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}

		

		public function remaining_requisitions_pro($material)
		{
		
		$this->db->select('SUM(purchase_order_materials_details.order_qty) AS order_qty');
		$this->db->from('purchase_order_materials_details');
		$this->db->where('purchase_order_materials_details.material_id',$product_id);
		$this->db->group_by('purchase_order_materials_details.material_id');
		

		$sql = $this->db->get();
			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}

		/*public function get_product_details($product_id)
		{
			$this->db->select('puchase_order_details.child_product,puchase_order_details.unit,SUM(puchase_order_details.total) AS total');    
			$this->db->from('puchase_order_details');
			//$this->db->where("puchase_order_details.status",0); 
			$this->db->where("puchase_order_details.child_product",$product_id);
			$this->db->group_by("puchase_order_details.child_product");
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}*/

		public function get_product_details($product_id)
		{
			$this->db->select('products.id,products.pro_code');    
			$this->db->from('products');
			//$this->db->where("puchase_order_details.status",0); 
			$this->db->where("products.id",$product_id);
			/*$this->db->group_by("puchase_order_details.child_product");*/
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}
		

		

		public function get_product_rates($product_id)
		{
			$this->db->select('po_rates.product_id,po_rates.rates');    
			$this->db->from('po_rates');
			//$this->db->where("puchase_order_details.status",0); 
			$this->db->where("po_rates.product_id",$product_id);
			/*$this->db->group_by("puchase_order_details.child_product");*/
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}

		 public function po_id_vendor($id)
		{
			$this->db->select('purchase_order.vendor_id as vendor_id');    
			$this->db->from('purchase_order');
			$this->db->where("purchase_order.id",$id); 
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}


		public function approved_po($id)
			{
			
				$result = $this->db->where('id',$id);
				$result = $this->db->update('purchase_order',array('approve_status' => 1));
				if($result){return true;}else{return false;}
			}

			public function po_cancel($id)
			{
			
				$result = $this->db->where('id',$id);
				$result = $this->db->update('purchase_order',array('approve_status' => 3));
				if($result){return true;}else{return false;}
			}


			public function finish_requisition($id)
			{
			
				$result = $this->db->where('so_id',$id);
				$result = $this->db->update('sales_order_products',array('finish_requisition' => 2));


        ///print_r($this->db->last_query($result));   die;
				if($result){return true;}else{return false;}
			}



/*
			public function rate_last($id)
			{
				

				$this->db->select('*');
			    $this->db->from('sales_order');
			    $this->db->join('sales_order_products','sales_order.id = sales_order_products.so_id');
			    $this->db->where('sales_order.id',$id);
			    $sql = $this->db->get();

			    if($sql->num_rows() >0)
					{return $sql->result_array();
					}else
					{return false;}
			    //$this->db->delete('sales_order', 'sales_order_products');


				return true;
			}
*/
			

			public function pending_requisition($id)
			{
			
				$result = $this->db->where('so_id',$id);
				$result = $this->db->update('sales_order_products',array('finish_requisition' => 1));


        ///print_r($this->db->last_query($result));   die;
				if($result){return true;}else{return false;}
			}

			/*public function delete_data_purchase_order_data($id)
			{
				

				$this->db->select('*');
			    $this->db->from('purchase_order');
			    $this->db->join('purchase_order_materials_details','purchase_order.id = purchase_order_materials_details.po_id');
			    $this->db->where('purchase_order.id',$id);
			    $this->db->delete('purchase_order', 'purchase_order_materials_details');


				return true;
			}*/

			
			public function delete_data_purchase_order($id)
				{
					$sql = $this->db->delete('purchase_order', array('id'=>$id));
					
					return true;
				}


				public function delete_data_purchase_order_data($id)
				{
					$sql = $this->db->delete('purchase_order_materials_details', array('po_id'=>$id));
					
					return true;
				}



				public function get_edit_po_order($id)
			{
				

				$this->db->select('*');
			    $this->db->from('purchase_order');
			    $this->db->join('purchase_order_materials_details','purchase_order.id = purchase_order_materials_details.po_id');
			    $this->db->where('purchase_order.id',$id);
			    $sql = $this->db->get();

			    if($sql->num_rows() >0)
					{return $sql->result_array();
					}else
					{return false;}
			    //$this->db->delete('sales_order', 'sales_order_products');


				return true;
			}


			 public function update_po($id,$save_po) {
				$result = $this->db->where('id',$id);
				$result = $this->db->update('purchase_order',$save_po);
				if($result){return true;}else{return false;}

				}


				public function update_po_products($id,$save_po1) {
					$result = $this->db->where('po_id',$id);
					$result = $this->db->update('purchase_order_materials_details',$save_po1);
					if($result){return true;}else{return false;}

					}
					
					
					public function all_po_challan()
			{
				/*$sql = $this->db->get_where('boms', array('id'=>$id));
				*/

				$this->db->select('purchase_order.id,purchase_order.vendor_id,purchase_order.po_no,purchase_order.po_date,purchase_order.dc_status,purchase_order_materials_details.id,purchase_order_materials_details.product_id,purchase_order_materials_details.material_id,purchase_order_materials_details.order_qty,purchase_order_materials_details.unit,purchase_order.id as pur_id');  
				  
				$this->db->from('purchase_order');
				$this->db->join('purchase_order_materials_details', 'purchase_order.id = purchase_order_materials_details.po_id', 'left');
				$this->db->where('purchase_order.dc_status',0);
				$this->db->where('purchase_order.approve_status',1);
				$this->db->order_by("purchase_order.id","desc");

				//
				$sql = $this->db->get();

				if($sql->num_rows() >0)
				{return $sql->result_array();
				}else
				{return false;}

			}


			public function get_invoice_data1($id)
			{
				/*$sql = $this->db->get_where('boms', array('id'=>$id));
				*/

				$this->db->select('purchase_order.vendor_id,purchase_order.po_no,purchase_order.po_date,purchase_order.dc_status,purchase_order_materials_details.product_id,purchase_order_materials_details.material_id,purchase_order_materials_details.order_qty,purchase_order_materials_details.unit,purchase_order.id as pur_id,purchase_order.gst,purchase_order_materials_details.gst_amount');  
				  
				$this->db->from('purchase_order');
				$this->db->join('purchase_order_materials_details', 'purchase_order.id = purchase_order_materials_details.po_id', 'left');
				$this->db->where('purchase_order_materials_details.po_id',$id);
				

				//
				$sql = $this->db->get();

				if($sql->num_rows() >0)
				{return $sql->result_array();
				}else
				{return false;}

			}


			public function get_dc_qty($id)
		{
			$this->db->select('SUM(dc_record_po.qty) AS qty,dc_record_po.qc_status');    
			$this->db->from('dc_record_po');
			$this->db->where("dc_record_po.po_id",$id); 
			$this->db->where("dc_record_po.qc_status !=",3); 
			$sql = $this->db->get();

			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}


		 public function get_code_dc(){

		$this->db->select('dc_record_po.dc_no');  
		  
		$this->db->from('dc_record_po');
		//$this->db->where('type',1);
		$this->db->order_by('dc_record_po.id','DESC');
		
		$this->db->limit(1);
		$sql = $this->db->get();

		if($sql->num_rows() >0)
		{return $sql->result_array();
		}else
		{return false;}
	}
    

     public function add_dc($post) {
          $result = $this->db->insert('dc_record_po',$post);
          if($result){return $this->db->insert_id();}else{return false;} 
		 }


		 public function update_so_status($id) {
		$result = $this->db->where('id',$id);
		$result = $this->db->update('purchase_order',array('dc_status' =>1));
		if($result){return true;}else{return false;}
		}


		public function get_Orders_status(){

		$this->db->select('dc_record.qc_status');  
		  
		$this->db->from('dc_record');
		$this->db->where('dc_record.qc_status',0);
		$this->db->group_by('dc_record.qc_status');
		
		
		$sql = $this->db->get();

		if($sql->num_rows() >0)
		{return $sql->result_array();
		}else
		{return false;}
	}


	 public function get_code_dc_gst(){

		$this->db->select('dc_record_po.dc_no');  
		  
		$this->db->from('dc_record_po');
		$this->db->where('gst',0);
		$this->db->where('gst','');
		$this->db->order_by('dc_record_po.id','DESC');
		
		$this->db->limit(1);
		$sql = $this->db->get();

		if($sql->num_rows() >0)
		{return $sql->result_array();
		}else
		{return false;}
	}


	public function get_dc_qurantine($id)
		{
			$this->db->select('dc_record_po.lot_no,dc_record_po.grn_no,dc_record_po.created,dc_record_po.dc_no,dc_record_po.qty,dc_record_po.id as dc_id,dc_record_po.po_id,purchase_order_materials_details.po_id,purchase_order_materials_details.material_id,purchase_order_materials_details.product_id,purchase_order.vendor_id');
			$this->db->from('dc_record_po');
			$this->db->join('purchase_order_materials_details', 'dc_record_po.po_id = purchase_order_materials_details.po_id', 'inner');
			$this->db->join('purchase_order', 'purchase_order_materials_details.po_id = purchase_order.id', 'inner');
		$this->db->where('dc_record_po.id',$id );
		$sql = $this->db->get();
			if($sql->num_rows() >0)
			{return $sql->result_array();
			}else
			{return false;}
		}


		public function get_last_grn_dc_qc(){

		$this->db->select('dc_record_po.grn_no');  
		  
		$this->db->from('dc_record_po');
		//$this->db->where('dc_record_po.id',$id);
		$this->db->order_by('dc_record_po.grn_no','DESC');
		
		$this->db->limit(1);
		$sql = $this->db->get();

		if($sql->num_rows() >0)
		{return $sql->result_array();
		}else
		{return false;}
	}
	
	
	
	public function get_all_po_recived($id)
		{
			$this->db->select('*');  
		  
		$this->db->from('dc_record_po');
		$this->db->where("dc_record_po.po_id",$id);	
		$sql = $this->db->get();

		if($sql->num_rows() >0)
		{return $sql->result_array();
		}else
		{return false;}
		}
    
}