/** * Изменить параметр * @return string * @throws \Exception */ public function actionChangeParam() { if (Yii::$app->getRequest()->getQueryParam('user')) { $start_day = strtotime('now 00:00:00', time() + 7 * 60 * 60); $user = MarkUser::findOne(Yii::$app->getRequest()->getQueryParam('user')); if (Yii::$app->getRequest()->getQueryParam('param_id') && Yii::$app->getRequest()->getQueryParam('val')) { $rec_param = DiaryRecDayParams::findOne((int) Yii::$app->getRequest()->getQueryParam('param_id')); $rec_param->value = (double) Yii::$app->getRequest()->getQueryParam('val'); if ($rec_param->update()) { $today_acts = implode(',', ArrayHelper::map(DiaryActs::find()->where("time > {$start_day} and user_id = " . $user->id . " and model_id = 4")->all(), 'id', 'id')); //return var_dump($today_acts); $params = []; $recorded_params_in = []; $recorded_params = []; $recorded = []; if ($today_acts) { $recorded = DiaryRecDayParams::find()->where("act_id IN (" . $today_acts . ")")->all(); $param_array = implode(',', ArrayHelper::map($recorded, 'id', 'day_param_id')); if ($param_array) { $recorded_params_in = DiaryDayParams::find()->where("id IN (" . $param_array . ")")->all(); $params = DiaryDayParams::find()->where("id NOT IN (" . $param_array . ")")->all(); } foreach ($recorded_params_in as $param) { $recorded_params[DiaryRecDayParams::findOne($param->id)->value] = $param->name; } //return var_dump($recorded_params); } else { $params = DiaryDayParams::find()->all(); } //$params = DiaryDayParams::find()->all(); //return var_dump($params); return $this->renderPartial('today_params', ['params' => $params, 'recorded_params' => $recorded, 'user' => $user->id]); } return 'НЕ получилось'; } //return var_dump($user); } }