<?php
// +----------------------------------------------------------------------
// | 推送信息控制器
// +----------------------------------------------------------------------
// | ThinkOAO （Online And Offline）
// +----------------------------------------------------------------------
// | Copyright (c) 2016 http://www.hanchao9999.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: xiaogg <xiaogg@sina.cn>
// +----------------------------------------------------------------------
namespace Admin\Controller;
class PushLogController extends BaseController {

	public function _initialize() {
		parent::_initialize();
		$this->model = D('PushLog');
	}
	//添加新推送
	public function add() {   
    	$this->display('edit');   
	}
	public function index() {
        /* 查询条件初始化 */
        $map = array();$getdata=I('param.');
        //$map  = array('status' => 1);
        if(!empty($getdata['group']))$map['group']   =   $getdata['group'];
        if(!empty($getdata['name'])){
            $whereor['name']=array('like','%'.$getdata['name'].'%');
            $whereor['title']=array('like','%'.$getdata['name'].'%');
            $whereor['value']=array('like','%'.$getdata['name'].'%');
            $whereor['extra']=array('like','%'.$getdata['name'].'%');
            $whereor['remark']=array('like','%'.$getdata['name'].'%');
            $whereor['_logic'] = 'or';
            $map['_complex'] = $whereor;
        }
        $list = $this->lists('PushLog', $map);
        $this->assign('list', $list);
		$this->display();

	}
    // 推送信息
    public function pushsend() {
		/*$getdata=I('param.');
		$result = array();
		if($getdata['uid']&&$getdata['id']&&$getdata['resend']){//重新发送
			$member = M('Member')->where('id='.$getdata['uid'])->find();
			if(empty($getdata['content']))$getdata['content']=M('PushLog')->where('id='.$getdata['id'])->getField('content');
			if(!empty($member['push_android_registrationid']))$ids[] = $member['push_android_registrationid'];
			if(!empty($member['push_ios_registrationid']))$ids[] = $member['push_ios_registrationid'];			
			if($ids)$result = pushSend($ids,$getdata['content'],$getdata['id']);
		}else{//发送信息
			if(empty($getdata['send_id'])){//全站广播
				if($ids)$result = pushSend(0,$getdata['content'],'all');
			}else{
				$send_id = explode(',',$getdata['send_id']);
				foreach($send_id as $k=>$v){
					$member = M('Member')->where('id='.$v)->find();
					if(!empty($member['push_android_registrationid']))$ids[] = $member['push_android_registrationid'];
					if(!empty($member['push_ios_registrationid']))$ids[] = $member['push_ios_registrationid'];		
				}
				if($ids)$result = pushSend($ids,$getdata['content'],'member');
			}
		}
		if($result['is_success']==1){
			$this->success('发送成功');
		}else{
			$this->error('发送失败');
		}*/
       
    }
}
?>