<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request as Req;
use Illuminate\Support\Facades\DB;
use App\Models;
use Request;

/**
 *
 */
class SportsbqController extends Controller {

	//足球结果列表  sureblurs
	function outcome(Req $req) {
		$request=array();
		$request['status'] = isset($req->status) ? trim($req->status) : '-1';
		$request['source'] = isset($req->source) ? $req->source : null;
		$request['sureblurs'] = isset($req->sureblurs) ? $req->sureblurs : 'on';
		$request['home_team'] = isset($req->home_team) ? trim($req->home_team) : null;
		$dt = \App\Lib\DataTable\DataTable::init();
        $dt->setDataSource('/admin/Sportsbq/info');
        $dt->setLang('Sportsbq');
        $dt->addColsFields('home_team', array('templet' => '#home_team', 'sort' => false, 'width' => 200));
        $dt->addColsFields('guest_team', array('templet' => '#guest_team', 'sort' => false, 'width' => 80));
        $dt->addColsFields('home_rate', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
        $dt->addColsFields('guest_rate', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
        $dt->addColsFields('home_score', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
        $dt->addColsFields('guest_score', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
        $dt->addColsFields('all_goal', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
        $dt->addColsFields('first_score', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
        $dt->addColsFields('last_score', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
        $dt->addColsFields('match_score', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
        $dt->addColsFields('match_winer', array('templet' => '#home_rate', 'sort' => false, 'width' => 80));
		return view('admin.Sportsbq/outcome', $dt->render($request));
	}

	function info(){
		$page = Request::has('page') ? Request::get('page') : '';
		$list = Request::has('limit') ? Request::get('limit') : 10;
		$home_team = Request::has('home_team') ? Request::get('home_team') : '';
		$sureblur = Request::has('sureblurs') ? Request::get('sureblurs') : 'off';
		$status = Request::has('status') ? Request::get('status') : '';
		$source = Request::has('source') ? Request::get('source') : 'hg3535';
		$star_time = Request::get('star_time') ? Request::get('star_time').' 00:00:00' : '';
        $end_time = Request::get('end_time') ? Request::get('end_time').' 23:59:59' : '';
        $where = array();
        if ($status != -1) {
			$where[] = array('st_zq_result.status', '=', $status);
		}
		if (!empty($source)) {
			$where[] = array('st_zq_result.source', '=', $source);
		}
		$newapp = new \App\Models\Stbqresult();
        $data = $newapp->getinfo($list, $page, $where);
        
        return \App\Lib\DataTable\DataTable::init()->toJson($data['data'], $data['total']);
	}
}