<?php
// +----------------------------------------------------------------------
// | WANCMS游戏平台管理系统
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://www.wancms.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: zjb <435795218@qq.com> <http://www.wancms.com>
// +----------------------------------------------------------------------
// | 修改时间: 2016/04/19
// +----------------------------------------------------------------------

namespace Phonegame\Controller;
use Common\Controller\AdminbaseController;
/**
 * 手游游戏平台管理
 */
class platformadminController extends AdminbaseController{

/**
  * 平台管理
 */
public function index(){
    $count=M("m_game_platform")->count();
    $page= new \Think\Page($count,20);//实例化分页类 传入总记录数和每页显示的记录数
   $show = $page->show();// 分页显示输出
   $lists = M("m_game_platform")
   ->order("time DESC")
   ->limit($page->firstRow . ',' . $page->listRows)
   ->select();
   $this->assign('lists',$lists);
   $this->assign("page", $show);
   $this->display();
}
/**
  * 增加平台
 */
public function add(){
   if(IS_POST){
    $_POST['time']=time();
    if (M("m_game_platform")->create()){
        if (M("m_game_platform")->add()!==false) {
            $this->success("添加成功！", U("Indexadmin/index"));
        } else {
            $this->error("添加失败！");
        }
    } else {
        $this->error(M("m_game_platform")->getError());
    }
}else{
    $this->assign('info', '');   
    $this->display();
}
}

    /**
     * 删除平台
     */
    public function del(){
            $id = intval(I("get.id"));
            if (M('m_game_platform')->delete($id)!==false) {
                $this->success("删除成功！");
            } else {
                $this->error("删除失败！");
            }
    }

        /**
     * 修改平台
     */
    public function edit(){
        if(IS_POST){
            if (M('m_game_platform')->create()) {
                if (M('m_game_platform')->save()!==false) {
                    $this->success("保存成功！", U("index"));
                } else {
                    $this->error("保存失败！");
                }
            } else {
                $this->error(M('m_game_platform')->getError());
            }
        }else{
        $id=  intval(I("get.id"));
        $info = M('m_game_platform')->where(array("id"=>$id))->find(); 
        $this->assign('info', $info);   
        $this->display('add');
        }
    }

}