<?php
/**
 * 图片审核
 *
 * @author user
 */
class admin_check extends MY_Model {

	/**
     * 360全景图片审核表
	 *
	 */
	private $_tbl_360_check_pic = 'admin_360_pic_check';
   
    /**
     * 进入审核附属表待夜间JOB过滤入库
     * @var type 
     */
    private $_tbl_pic_check_sub = 'admin_pic_check_sub';
    
    /**
     * 审核图片入库
     * @var type 
     */
    private $_tbl_pic_check = 'admin_pic_check';
    
    /**
     * 审核房源描述
     * @var type 
     */
    private $_tbl_remark_check_sub = 'admin_remark_check_sub';
    
    
   /**
    * 类初始化
    */
    public function __construct()
    {
        parent::__construct(1,0,0);
    }
    
    /**
     * 
     * @param type $tbl
     * @param type $insert_data
     * @return type
     */
    public function insert($tbl, $insert_data)
    {
        if ($this->db->insert($tbl, $insert_data))
        {
            return $this->db->insert_id();
        }
    }
    
    /**
     * 
     * @param type $insert_data
     */
    public function insert_check_pic($insert_data)
    {
        $this->insert($this->_tbl_pic_check, $insert_data);
    }
    
    /**
     * 
     * @param type $insert_data
     */
    public function insert_check_pic_sub($insert_data)
    {
        $this->insert($this->_tbl_pic_check_sub, $insert_data);
    }
    
    /**
     * 
     * @param type $tbl
     * @param type $house_id
     * @param type $pic_id
     */
    public function delete_check_pic($tbl, $house_id, $pic_id)
    {
        $this->db->where('housetbl', $tbl);
        $this->db->where('houseid', $house_id);
        $this->db->where('picid', $pic_id);
        $this->db->delete($this->_tbl_pic_check);
    }
    
    /**
     * 
     * @param type $tbl
     * @param type $house_id
     * @param type $pic_id
     */
    public function delete_check_pic_sub($tbl, $house_id, $pic_id)
    {
        $this->db->where('housetbl', $tbl);
        $this->db->where('houseid', $house_id);
        $this->db->where('picid', $pic_id);
        $this->db->delete($this->_tbl_pic_check_sub);
    }
    
    /**
     * 
     * @param type $insert_data
     */
    public function insert_check_remark_sub($insert_data)
    {
        $this->insert($this->_tbl_remark_check_sub, $insert_data);
    } 
	
	/**
     * 获取360全景图片审核信息
     * @param array $insert_data 房源数据数组
     * @return int
     */
    public function get_360_pic_check($tbl,$houseid,$surface = 1) 
    {
		$this->db->select('id,uid,housetbl,houseid,infotype,pictbl,picid,picurl,surface');
        $this->db->where('housetbl', $tbl);
        $this->db->where('houseid', $houseid);
		$this->db->where('surface', $surface);

        return $this->db->get('admin_360_pic_check')->row_array();
    }
	
	/**
     * 获取360全景图片审核信息
     * @param array $insert_data 房源数据数组
     * @return int
     */
    public function get_all_360_pic_check($tbl,$houseid)
	{
		$this->db->select('id,uid,housetbl,houseid,infotype,pictbl,picid,picurl,surface');
        $this->db->where('housetbl', $tbl);
        $this->db->where('houseid', $houseid);

        return $this->db->get('admin_360_pic_check')->result_array();
	}
	

	/**
     * 
     * @param type $insert_data
     */
    public function insert_360_check_pic($insert_data)
    {
        $this->insert($this->_tbl_360_check_pic, $insert_data);
    }

	/**
     * 更新360全景图片审核
	 *
	 */
	public function update_360_check_pic($data)
	{
        $this->db->where('id',$data['id']);       
        $this->db->update($this->_tbl_360_check_pic,$data);	
	}

	
	/**
     * 删除360全景图片审核
	 *
	 */
	public function delete_360_check_pic($id = 0)
	{
		if(empty($id))
		{
			return false;
		}

        $this->db->where('id', $id);
        $this->db->delete($this->_tbl_360_check_pic);  
	}
}
