<?php

/* ========================================================================
 * $Id: products.php 1663 2020-07-07 04:26:52Z onez $
 * 
 * Email: www@onez.cn
 * QQ: 6200103
 * HomePage: http://www.onez.cn
 * ========================================================================
 * Copyright 2016-2017 佳蓝科技.
 * 
 * ======================================================================== */

!defined('IN_ONEZ') && exit('Access Denied');
# products
#请求数据
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('products')->delete("id='$id'");
      return $this->ok('删除成功','reload');
    }
    $data=array();
    $data['title']='虚拟商品管理';

    $data['btns'][]=array(
      'name'=>'添加虚拟商品',
      'href'=>'./edit.php',
      'args'=>'width=1200&height=650&title=添加虚拟商品',
    );
    
    $datatable=$this->load('datatable');
    


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

    $datatable->add('商品名称','name',array('function'=>function($rs){
      global $G;
      $html='';
      $html='<a href="index.php#/products/view.php?id='.$rs['id'].'" target="_blank"><img src="'.$rs['thumb'].'" style="width:32px;height:32px" />'.$rs['name'].'</a>';
      return $html;
    },'autoHide'=>false));
    $datatable->add('商品编码','token');
    $datatable->add('价格','price');
    $datatable->output($data,array(
      'table'=>'products',
      'where'=>"key2='message' order by step desc,id desc",
      'pagesize'=>20,
    ));
    $A['pagedata']=$data;
  }
  return;
}
$this->add(array(
  'type'=>'breadcrumb',
  'name'=>'面包屑导航',
  'data'=>'pagedata',
));
$this->add(array(
  'type'=>'datatable',
  'name'=>'数据列表',
  'data'=>'pagedata',
));
?>