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

class Job_Tools extends MY_Controller
{

    function __construct()
    {
      parent::__construct();
    }


    /**
    * 刷新求购数据为新版数据
    * @author xz
    */
    public function update_buy_data( $page = 1 )
    {
        
        $pagesize = 100;
        $offset = ($page - 1) * $pagesize;

        //加载房源操作统计类
        $this->load->model('tool_model');
        $result = $this->tool_model->update_buy_data($offset,$pagesize);

        if($result)
        {
            sleep(1);
            $page++;
            echo '<script type="text/javascript">location.href="'.USER_CENTER.'job_tools/update_buy_data/'.$page.'";</script>';
        }
        else
        {
            echo 'over';
        }
    }


    /**
    * 刷新求租数据为新版数据
    * @author xz
    */
    public function update_rentwant_data( $page = 1 )
    {
        //exit;
        $pagesize = 100;
        $offset = ($page - 1) * $pagesize;

        //加载房源操作统计类
        $this->load->model('tool_model');
        $result = $this->tool_model->update_rentwant_data($offset,$pagesize);

        if($result)
        {
            sleep(1);
            $page++;
            echo '<script type="text/javascript">location.href="'.USER_CENTER.'job_tools/update_rentwant_data/'.$page.'";</script>';
        }
        else
        {
            echo 'over';
        }
    }


    public function get_match_data()
    {

        $tbl = $this->input->post('tbl',TRUE);
        $count_date = $this->input->post('count_date',TRUE);

        $count_date = $count_date ? $count_date : date('Y-m-d',time() - 86400);
        $tbl = $tbl ? $tbl :'buy';

        //加载工具类
        $this->load->model('tool_model');

        //需求个数
        $want_num = $this->tool_model->get_want_num_by_day( $tbl , $count_date );

        //匹配房源个数
        $match_num = $this->tool_model->get_match_num_by_day( $tbl , $count_date );

        //参与的人数
        $match_broker_num = $this->tool_model->get_match_broker_num_by_day( $tbl , $count_date );

        //表单类
        $this->load->helper('form');

        $tbl_arr = array( 'buy' => '求购', 'rentwanted' => '求租');

        /** 页面初始化 */
        $data['title'] = '匹配统计';
        $data['want_num'] = $want_num;
        $data['match_num'] = $match_num;
        $data['match_broker_num'] = $match_broker_num;
        $data['count_date'] = $count_date;
        $data['want_tbl'] = $tbl;
        $data['tbl_arr'] = $tbl_arr;
        $data['form_attributes'] = array('name' => 'search_form', 'id' => 'search_form');
        $js = "<script type='text/javascript' src='".USER_CENTER."js/My97DatePicker/WdatePicker.js'></script>";
        $data['js'] = $js;

        //加载模板
        $this->load->view('tools_test',$data);
    }

	
	public function get_passport_uid($page = 1)
    {
	}

}
?>