Example #1
0
$filter = array();
if (intval(Tools::getRequest('delete')) > 0) {
    $object = new Product(intval(Tools::getRequest('delete')));
    if (Validate::isLoadedObject($object)) {
        $object->delete();
    }
    if (is_array($object->_errors) and count($object->_errors) > 0) {
        $errors = $object->_errors;
    } else {
        echo '<div class="conf">删除分类成功</div>';
    }
} elseif (Tools::isSubmit('subDelete')) {
    $select_cat = Tools::getRequest('productBox');
    $product = new Product();
    if (is_array($select_cat)) {
        if ($product->deleteSelection($select_cat)) {
            echo '<div class="conf">删除分类成功</div>';
        }
    }
} elseif (Tools::isSubmit('subActiveON') or Tools::isSubmit('subActiveOFF')) {
    $select_cat = Tools::getRequest('productBox');
    $action = Tools::isSubmit('subActiveON') ? 1 : 0;
    $object = new Product();
    if (is_array($select_cat)) {
        if ($object->statusSelection($select_cat, $action)) {
            echo '<div class="conf">更新分类状态成功</div>';
        }
    }
}
$table = new UIAdminTable('product', 'Product', 'id_product');
$table->header = array(array('sort' => false, 'isCheckAll' => 'productBox[]'), array('name' => 'id_product', 'title' => 'ID', 'width' => '80px', 'filter' => 'string'), array('sort' => false, 'name' => 'image_small', 'isImage' => true, 'title' => '图片'), array('name' => 'name', 'title' => '名称', 'filter' => 'string'), array('name' => 'quantity', 'title' => '库存'), array('name' => 'price', 'title' => '现价', 'width' => '80px', 'filter' => 'string'), array('name' => 'old_price', 'title' => '原价', 'width' => '80px', 'filter' => 'string'), array('name' => 'active', 'title' => '状态', 'filter' => 'bool'), array('name' => 'in_stock', 'title' => '购买', 'filter' => 'bool'), array('name' => 'is_new', 'title' => '新品', 'filter' => 'bool'), array('name' => 'is_sale', 'title' => '热销', 'filter' => 'bool'), array('name' => 'is_top', 'title' => '推荐', 'filter' => 'bool'), array('sort' => false, 'title' => '操作', 'class' => 'text-right', 'isAction' => array('edit', 'view', 'delete')));