Пример #1
0
 public function actionUpdate()
 {
     $where['cnum'] = YII::$app->user->identity->cnum;
     $where['row'] = $_POST['changes'][0][0];
     $where['col'] = $_POST['changes'][0][1];
     $where['date'] = $_POST['date'];
     if ($_POST['changes'][0][1] < 2 || $_POST['changes'][0][0] > 65) {
         return;
     }
     $model = $this->findModel($where);
     if ($model) {
         $model->val = $_POST['changes'][0][3];
     } else {
         $model = new Profit();
         $model->row = $_POST['changes'][0][0];
         $model->col = $_POST['changes'][0][1];
         $model->cnum = YII::$app->user->identity->cnum;
         $model->date = $_POST['date'];
         $model->val = $_POST['changes'][0][3];
     }
     if (Yii::$app->request->isAjax && $model->save()) {
         Yii::$app->cache->delete('profit_' . $_POST['date']);
         echo '1';
         exit;
     } else {
         echo '0';
         exit;
     }
 }