<?php

class My_feedback extends MY_Controller {
    
    
     /**
    * 当前页码
    *
    * @access private
    * @var string
    */
    private $_current_page = 1;

    /**
    * 每页条目数
    *
    * @access private
    * @var int
    */
    private $_limit = 10;

    /**
    * 偏移
    *
    * @access private
    * @var int
    */
    private $_offset = 0;

    /**
    * 条目总数
    *
    * @access private
    * @var int
    */
    private $_total_count = 0;
    



    /**
     * 解析函数
     *
     * @access public
     * @return void
     */
    public function __construct($type = NULL) {
        parent::__construct($type);
        $this->config_cityflag = 'nj';
        $this->load->model('broker_model');     
        $this->load->model('feedback_model');
        //用户信息初始化
        $info = $this->broker_model->get_user_session();
        $this->info = $info;
    }
    
    
    
    /**
     * 提交反馈tab
     */
    public function feedback(){
		$viewData['page_title'] = "意见反馈";
        $viewData['css'] = load_css('zsb/css/v1.0/style1.css,zsb/css/v1.0/feedback.css');
        $viewData['js'] = load_js('common/js/swf/swfupload.js,zsb/js/v1.0/swfu.js,zsb/js/v1.0/handlers.js');
        $this->view('ucenter','feedback', $viewData);
    }


   /**
    * 提交反馈
    */    
    public function ajaxFeedback(){      
        $post_param = $this->input->post(NULL , TRUE);        
        $type = intval($post_param['type']);
        $description = $this->textConvert($post_param['description']);
        if(isset($description)){ 
            $data = array();
			$data['uid'] = $this->user_arr['uid'];
			$data['source'] = 3;
			$data['feedback'] = $description;
			$data['type'] = $type;
			$data['telno'] = $this->user_arr['telno'];
			$data['dateline'] = time();
			$data['esta'] = 0;
            if(!empty($post_param['p_filename']) && is_array($post_param['p_filename'])){
                $data['images'] = serialize($post_param['p_filename']);
            }
			$info = $this->feedback_model->insert($data);
			if($info > 0){
				$return = array('status'=>1,'msg'=>'提交成功！');
			}else{
				$return = array('status'=>2,'msg'=>'提交失败！');
			}
        }else{
            $return = array('status'=>0,'msg'=>'问题描述不能为空！');
        }
        echo json_encode($return);       
       
    }

	//中文编码转换
    private function textConvert($answerText){
        $answerText = urldecode($answerText);
        return  iconv('utf-8','gb2312',$answerText);        
    }
    
}