<?php

/* ========================================================================
 * $Id: sites.php 3059 2020-05-21 08:19:21Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# index
$where=$G['this']->where();
#请求数据
if($MODE=='$post'){
  $action=onez()->gp('action');
  if($action=='data'){
    $action=onez()->gp('ac');
    if($action=='del'){
      $id=(int)onez()->gp('id');
      $G['this']->data()->open('sites')->delete("id='$id'$where");
      return $this->ok('删除成功','reload');
    }
    $data=array();
    $data['title']='站点管理';
    $data['btns'][]=array(
      'name'=>'新建站点',
      'href'=>'./edit.php',
      'args'=>'width=800&height=600&title=新建站点',
    );
    
    $datatable=$this->load('datatable');
    $datatable->addBtn(array(
      'name'=>'设计',
      'skin'=>'warning',
      'event'=>array(
        'token'=>'location',
        'action'=>'index.php?siteId=${id}#/design/design.php',
      ),
    ));
    $datatable->addBtn(array(
      'name'=>'用户',
      'skin'=>'info',
      'event'=>array(
        'token'=>'page',
        'option'=>array(
          'title'=>'站点“${name}” - 用户管理',
          'width'=>1200,
          'height'=>600,
        ),
        'action'=>'/develop/members/members.php?siteId=${id}',
      ),
    ));
    $datatable->set('edit',array(
      'event'=>array(
        'option'=>array(
          'width'=>600,
          'height'=>500,
        ),
      ),
    ));
    $datatable->set('del','1');
    $datatable->set('fields','id');
    $datatable->add('网站名','name',array(
      'event'=>array(
        'token'=>'open',
        'action'=>'index.php?siteId=${id}#/design/design.php',
      ),
    ));
    #$datatable->add('核心功能','type',array('options'=>$G['this']->siteTypes(),'faq'=>'什么是核心功能？'));
    $datatable->add('域名','domains');
    $datatable->add('状态','status',array('options'=>$G['this']->siteStatus()));
    
    
    $datas=array();
    $T=$G['this']->data()->open('datas')->record("1$where order by id desc");
    foreach($T as $rs){
      $datas[$rs['id']]=$rs['name'];
    }
    $datatable->add('数据体系','data',array('options'=>$datas,'faq'=>'什么是数据体系？'));
    
    $users=array();
    $T=$G['this']->data()->open('users')->record("1$where order by id desc");
    foreach($T as $rs){
      $users[$rs['id']]=$rs['name'];
    }
    $datatable->add('用户体系','user',array('options'=>$users,'faq'=>'什么是用户体系？'));
    
    $datatable->add('创建时间','addtime',array('type'=>'time'));
    $datatable->add('备注','summary');
    $datatable->output($data,array(
      'table'=>'sites',
      'where'=>"1$where order by id desc",
      'pagesize'=>20,
    ));
    $A['pagedata']=$data;
  }elseif($action=='del'){
    $id=(int)onez()->gp('id');
    $G['this']->data()->open('sites')->delete("id='$id'$where");
    $G['this']->siteUpdate();
    return $this->ok('','reload2');
  }
  return;
}
$this->add(array(
  'type'=>'breadcrumb',
  'name'=>'面包屑导航',
  'data'=>'pagedata',
));
$this->add(array(
  'type'=>'datatable',
  'name'=>'数据列表',
  'data'=>'pagedata',
));

?>
