|
@@ -88,4 +88,57 @@ class Attestation extends Backend |
|
@@ -88,4 +88,57 @@ class Attestation extends Backend |
88
|
$this->assign('data',$data);
|
88
|
$this->assign('data',$data);
|
89
|
return $this->view->fetch();
|
89
|
return $this->view->fetch();
|
90
|
}
|
90
|
}
|
|
|
91
|
+
|
|
|
92
|
+
|
|
|
93
|
+ /**
|
|
|
94
|
+ * 编辑
|
|
|
95
|
+ */
|
|
|
96
|
+ public function edit($ids = null)
|
|
|
97
|
+ {
|
|
|
98
|
+ $row = $this->model->get($ids);
|
|
|
99
|
+ if (!$row) {
|
|
|
100
|
+ $this->error(__('No Results were found'));
|
|
|
101
|
+ }
|
|
|
102
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
103
|
+ if (is_array($adminIds)) {
|
|
|
104
|
+ if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
105
|
+ $this->error(__('You have no permission'));
|
|
|
106
|
+ }
|
|
|
107
|
+ }
|
|
|
108
|
+ if ($this->request->isPost()) {
|
|
|
109
|
+ $params = $this->request->post("row/a");
|
|
|
110
|
+ if ($params) {
|
|
|
111
|
+ $params = $this->preExcludeFields($params);
|
|
|
112
|
+ $result = false;
|
|
|
113
|
+ Db::startTrans();
|
|
|
114
|
+ try {
|
|
|
115
|
+ //是否采用模型验证
|
|
|
116
|
+ if ($this->modelValidate) {
|
|
|
117
|
+ $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
|
|
|
118
|
+ $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
|
|
|
119
|
+ $row->validateFailException(true)->validate($validate);
|
|
|
120
|
+ }
|
|
|
121
|
+ $result = $row->allowField(true)->save($params);
|
|
|
122
|
+ Db::commit();
|
|
|
123
|
+ } catch (ValidateException $e) {
|
|
|
124
|
+ Db::rollback();
|
|
|
125
|
+ $this->error($e->getMessage());
|
|
|
126
|
+ } catch (PDOException $e) {
|
|
|
127
|
+ Db::rollback();
|
|
|
128
|
+ $this->error($e->getMessage());
|
|
|
129
|
+ } catch (Exception $e) {
|
|
|
130
|
+ Db::rollback();
|
|
|
131
|
+ $this->error($e->getMessage());
|
|
|
132
|
+ }
|
|
|
133
|
+ if ($result !== false) {
|
|
|
134
|
+ $this->success();
|
|
|
135
|
+ } else {
|
|
|
136
|
+ $this->error(__('No rows were updated'));
|
|
|
137
|
+ }
|
|
|
138
|
+ }
|
|
|
139
|
+ $this->error(__('Parameter %s can not be empty', ''));
|
|
|
140
|
+ }
|
|
|
141
|
+ $this->view->assign("row", $row);
|
|
|
142
|
+ return $this->view->fetch();
|
|
|
143
|
+ }
|
91
|
} |
144
|
} |