' => 'api/reports/view',
'' => 'card/user-card/index',
['class' => 'yii\rest\UrlRule', 'controller' => 'skills'],
],
diff --git a/frontend/modules/api/controllers/ReportsController.php b/frontend/modules/api/controllers/ReportsController.php
index b14be76..ca142df 100755
--- a/frontend/modules/api/controllers/ReportsController.php
+++ b/frontend/modules/api/controllers/ReportsController.php
@@ -5,6 +5,7 @@ namespace frontend\modules\api\controllers;
use common\behaviors\GsCors;
use common\classes\Debug;
use common\models\Reports;
+use common\models\ReportsTask;
use frontend\modules\api\models\ReportSearchForm;
use JsonException;
use Yii;
@@ -56,20 +57,43 @@ class ReportsController extends ApiController
return $reportsModel->byParams();
}
+ public function actionView($id): array{
+ $report = Reports::findOne($id);
+ return array_merge($report->toArray(), ['tasks' => $report->_task]);
+ }
+
public function actionCreate()
{
- $reportsModel = new Reports();
-
$params = Yii::$app->request->post();
+ if (!isset($params['tasks'])){
+ throw new BadRequestHttpException('Нет параметра tasks');
+ }
+
+ $reportsModel = new Reports();
$reportsModel->attributes = $params;
if(!$reportsModel->validate()){
throw new BadRequestHttpException(json_encode($reportsModel->errors));
}
- $reportsModel->save();
+ $tasks = [];
+ foreach (json_decode($params['tasks'], true) as $jsonTask){
+ $task = new ReportsTask();
+ $task->scenario = ReportsTask::SCENARIO_WITHOUT_REPORT_ID;
+ $task->attributes = $jsonTask;
+ if (!$task->validate()) {
+ throw new BadRequestHttpException(json_encode($task->errors));
+ }
+ $tasks []= $task->attributes;
+ }
+ $attributes = $task->attributes();
- return $reportsModel->toArray();
+ $reportsModel->save();
+ $tasks = array_map(function ($task)use($reportsModel){$task['report_id'] = $reportsModel->id; return $task;}, $tasks);
+
+ Yii::$app->db->createCommand()->batchInsert(ReportsTask::tableName(), $attributes, $tasks)->execute();
+
+ return array_merge($reportsModel->toArray(), ['tasks' => $tasks]);
}
public function actionDelete()
diff --git a/frontend/modules/card/controllers/UserCardController.php b/frontend/modules/card/controllers/UserCardController.php
index f9f7d54..b22cf28 100755
--- a/frontend/modules/card/controllers/UserCardController.php
+++ b/frontend/modules/card/controllers/UserCardController.php
@@ -51,6 +51,11 @@ class UserCardController extends Controller
$result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all();
if($result) {
$id = $result[0]['id'];
+ $model = $this->findModel($id);
+ if ($model->load(Yii::$app->request->post())) {
+ $model->updated_at = date('Y-m-d h:i:s');
+ $model->save();
+ }
$dataProvider = new ActiveDataProvider([
'query' => FieldsValueNew::find()
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE])
@@ -69,7 +74,7 @@ class UserCardController extends Controller
->all();
return $this->render('view', [
- 'model' => $this->findModel($id),
+ 'model' => $model,
'modelFildValue' => $dataProvider,
'skills' => $skills,
'achievements' => $achievements,
diff --git a/frontend/modules/card/views/user-card/view.php b/frontend/modules/card/views/user-card/view.php
index 22e3943..80bb663 100755
--- a/frontend/modules/card/views/user-card/view.php
+++ b/frontend/modules/card/views/user-card/view.php
@@ -1,7 +1,9 @@
title = 'Профиль';
],
],
]); ?>
+
+
+ = $form->field($model, 'vc_text')->widget(EditorClassic::className(), [
+ 'clientOptions' => [
+ 'language' => 'ru',
+ ]
+ ]); ?>
+
+ = Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
+
+
diff --git a/frontend/modules/reports/views/reports/_form.php b/frontend/modules/reports/views/reports/_form.php
index 61c040e..90dca96 100755
--- a/frontend/modules/reports/views/reports/_form.php
+++ b/frontend/modules/reports/views/reports/_form.php
@@ -28,6 +28,7 @@ $this->registerCss('.list-cell__task{width:73%}')
echo 'Дата заполнения отчета:';
echo DatePicker::widget([
'model' => $model,
+ 'language' => 'ru',
'attribute' => 'created_at',
'options' => [],
'pluginOptions' => [