|
@@ -68,4 +68,37 @@ class CompanyTakeCash extends Backend
|
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 添加
|
|
|
+ */
|
|
|
+ public function add()
|
|
|
+ {
|
|
|
+ if ($this->request->isPost()) {
|
|
|
+ $params = $this->request->post("row/a");
|
|
|
+ $params = $this->preExcludeFields($params);
|
|
|
+ if (!$params) {
|
|
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
+ }
|
|
|
+ $result = false;
|
|
|
+ try {
|
|
|
+ //是否采用模型验证
|
|
|
+ if ($this->modelValidate) {
|
|
|
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.add' : $name) : $this->modelValidate;
|
|
|
+ $this->model->validateFailException(true)->validate($validate);
|
|
|
+ }
|
|
|
+ if (isset($params['user_id'])) {
|
|
|
+ $params['order_no'] = createUniqueNo('T',$params['user_id']);
|
|
|
+ }
|
|
|
+ $result = $this->model->allowField(true)->save($params);
|
|
|
+ } catch (ValidateException|PDOException|Exception $e) {
|
|
|
+ $this->error($e->getMessage());
|
|
|
+ }
|
|
|
+ if ($result == false) {
|
|
|
+ $this->error(__('No rows were inserted'));
|
|
|
+ }
|
|
|
+ $this->success();
|
|
|
+ }
|
|
|
+ return $this->view->fetch();
|
|
|
+ }
|
|
|
}
|