Example #1
0
<?php

if (Tools::P('saveOrderStatus') == 'add') {
    $orderstatus = new OrderStatus();
    $orderstatus->copyFromPost();
    $orderstatus->add();
    if (is_array($orderstatus->_errors) and count($orderstatus->_errors) > 0) {
        $errors = $orderstatus->_errors;
    } else {
        $_GET['id'] = $orderstatus->id;
        UIAdminAlerts::conf('定单状态已添加');
    }
}
if (isset($_GET['id'])) {
    $id = (int) $_GET['id'];
    $obj = new OrderStatus($id);
}
if (Tools::P('saveOrderStatus') == 'edit') {
    if (Validate::isLoadedObject($obj)) {
        $obj->copyFromPost();
        $obj->update();
    }
    if (is_array($obj->_errors) and count($obj->_errors) > 0) {
        $errors = $obj->_errors;
    } else {
        UIAdminAlerts::conf('定单状态已更新');
    }
}
/** 错误处理 */
if (isset($errors)) {
    UIAdminAlerts::MError($errors);