function add() { $app = get_app(); //GET if ($app->request()->isGet()) { $app->render('Productions/add.php'); } //POST if ($app->request()->isPost()) { // 工装管理员 生产安全部 if (!has_perm(6, 1)) { exit; } $post = $app->request()->post(); if (isset($post['is_urgent'])) { $post['is_urgent'] = 1; } $post['user_id'] = $_SESSION['user_id']; $post['use_dep'] = 18; /* 工装管理员没有权限 默认设为18 */ $prod = Production::create($post); $results = array(); if (!$prod->is_valid()) { $app->flashNow('errors', $prod->errors); $results['is_success'] = false; } else { $prod->save(); $app->flashNow('success', '新增产品下达项添加成功!'); $results['is_success'] = true; $results['newNode'] = array('id' => $prod->id, 'name' => $prod->num . ' ' . $prod->name . ' (0)', 'isParent' => false, 'type' => 'prod', 'icon' => get_path('/webroot/css/img/diy/2.png', true), 'moveFirst' => true); } $results['html'] = $app->view->fetch('Productions/add.php'); echo json_encode($results); } }