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

class Manual_Function_Model extends CI_Model {
  
  private $tableName = '';
  
  function __construct() 
  {
    /* Call the Model constructor */
    parent::__construct();
  }

	function save_area($area_data,$area_id)
	{
		if (!$area_id)
		{
			//$this->db->insert($this->tableName,$area_data);
		}else {
			//$this->db->where('area_id', $area_id);
			//return $this->db->update($this->tableName,$area_data);
		}
	}	
	
	public function disable_product($id)
	{
		$data = array(
			'product_status' => 0
		);	
		$this->db->where('product_id', $id);
		$this->db->update('product', $data);
	}
	
	public function enable_product($id)
	{
		$data = array(
			'product_status' => 1
		);	
		$this->db->where('product_id', $id);
		$this->db->update('product', $data);
	}
	
	public function get_unpaid_sales()
	{		
		$this->db->select('s.*');
		$this->db->from('sales s');
		$this->db->where("s.payment_status", 0);
		$query = $this->db->get();
		return $query->result_array(); 	
	}
	
	public function close_sale($id)
	{
		if($id>0){
			$data = array(
			'payment_status' => 1
		);	
		$this->db->where('sale_id', $id);
		$this->db->update('sales', $data);
		}else{
			return false;
		}
		
	}
	
	
}