<?php

/* ========================================================================
 * $Id: cards.php 1756 2020-07-08 08:41:51Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# cards
#请求数据
if($MODE=='$post'){
  $action=onez()->gp('action');
  if($action=='data'){
    $action=onez()->gp('ac');

    $upid=onez()->gp('upid');
    if($action=='del'){
      $id=(int)onez()->gp('id');
      $G['this']->data()->open('cards')->delete("id='$id'");
      return $this->ok('删除成功','reload');
    }
    $data=array();
    $data['title']='卡号管理';

    $data['btns'][]=array(
      'name'=>'单个添加',
      'href'=>'./edit.php?upid='.$upid.'',
      'args'=>'width=520&height=480&title=添加卡号',
    );
    $data['btns'][]=array(
      'name'=>'批量生成',
      'href'=>'./add.php?upid='.$upid.'',
      'args'=>'width=520&height=480&title=批量生成',
    );
    
    $datatable=$this->load('datatable');
    


    
    $datatable->set('edit',array(
      'event'=>array(
        'option'=>array(
          'width'=>520,
          'height'=>480,
        ),
      ),
    ));
    $datatable->set('del','1');
    $datatable->set('fields','id');

    $datatable->add('卡号','name');
    $datatable->add('卡密','pwd');
    $datatable->add('使用时间','usetime',array('function'=>function($rs){
      if($rs['time']){
        return date('Y-m-d H:i:s',$rs['usetime']);
      }else{
        return '未使用';
      }
    },));
    $datatable->add('使用人','user');
    $datatable->output($data,array(
      'table'=>'cards',

      'where'=>"1 and upid='$upid' order by id desc",
      'pagesize'=>20,
    ));
    $A['pagedata']=$data;
  }
  return;
}
$this->add(array(
  'type'=>'breadcrumb',
  'name'=>'面包屑导航',
  'data'=>'pagedata',
));
$this->add(array(
  'type'=>'datatable',
  'name'=>'数据列表',
  'data'=>'pagedata',
));
?>