Merge branch 'master' of https://github.com/apuc/guild
This commit is contained in:
commit
df5823730f
@ -29,6 +29,7 @@ $this->registerCss('.list-cell__task{width:73%}')
|
|||||||
echo '<b>Дата заполнения отчета:</b>';
|
echo '<b>Дата заполнения отчета:</b>';
|
||||||
echo DatePicker::widget([
|
echo DatePicker::widget([
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
|
'language' => 'ru',
|
||||||
'attribute' => 'created_at',
|
'attribute' => 'created_at',
|
||||||
'options' => [],
|
'options' => [],
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
|
@ -75,6 +75,7 @@ class Reports extends \yii\db\ActiveRecord
|
|||||||
foreach ($this->task as $task) {
|
foreach ($this->task as $task) {
|
||||||
$this->_task[$i]['task'] = $task->task;
|
$this->_task[$i]['task'] = $task->task;
|
||||||
$this->_task[$i]['hours_spent'] = $task->hours_spent;
|
$this->_task[$i]['hours_spent'] = $task->hours_spent;
|
||||||
|
$this->_task[$i]['minutes_spent'] = $task->minutes_spent;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,15 @@ use Yii;
|
|||||||
*/
|
*/
|
||||||
class ReportsTask extends \yii\db\ActiveRecord
|
class ReportsTask extends \yii\db\ActiveRecord
|
||||||
{
|
{
|
||||||
|
const SCENARIO_WITHOUT_REPORT_ID = 'withoutReportID';
|
||||||
|
|
||||||
|
public function scenarios()
|
||||||
|
{
|
||||||
|
$scenarios = parent::scenarios();
|
||||||
|
$scenarios[self::SCENARIO_WITHOUT_REPORT_ID] = self::attributes();
|
||||||
|
return $scenarios;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -33,7 +42,7 @@ class ReportsTask extends \yii\db\ActiveRecord
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['report_id'], 'required'],
|
[['report_id'], 'required', 'on' => self::SCENARIO_DEFAULT],
|
||||||
[['report_id', 'created_at', 'status', 'minutes_spent'], 'integer'],
|
[['report_id', 'created_at', 'status', 'minutes_spent'], 'integer'],
|
||||||
[['hours_spent'], 'number'],
|
[['hours_spent'], 'number'],
|
||||||
['minutes_spent', 'compare', 'compareValue' => 60, 'operator' => '<'],
|
['minutes_spent', 'compare', 'compareValue' => 60, 'operator' => '<'],
|
||||||
|
@ -84,6 +84,7 @@ return [
|
|||||||
'rules' => [
|
'rules' => [
|
||||||
'site/index' => 'card/user-card/index',
|
'site/index' => 'card/user-card/index',
|
||||||
'api/profile/<id:\d+>' => 'api/profile/index',
|
'api/profile/<id:\d+>' => 'api/profile/index',
|
||||||
|
'api/reports/<id:\d+>' => 'api/reports/view',
|
||||||
'' => 'card/user-card/index',
|
'' => 'card/user-card/index',
|
||||||
['class' => 'yii\rest\UrlRule', 'controller' => 'skills'],
|
['class' => 'yii\rest\UrlRule', 'controller' => 'skills'],
|
||||||
],
|
],
|
||||||
|
@ -5,6 +5,7 @@ namespace frontend\modules\api\controllers;
|
|||||||
use common\behaviors\GsCors;
|
use common\behaviors\GsCors;
|
||||||
use common\classes\Debug;
|
use common\classes\Debug;
|
||||||
use common\models\Reports;
|
use common\models\Reports;
|
||||||
|
use common\models\ReportsTask;
|
||||||
use frontend\modules\api\models\ReportSearchForm;
|
use frontend\modules\api\models\ReportSearchForm;
|
||||||
use JsonException;
|
use JsonException;
|
||||||
use Yii;
|
use Yii;
|
||||||
@ -56,20 +57,43 @@ class ReportsController extends ApiController
|
|||||||
return $reportsModel->byParams();
|
return $reportsModel->byParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function actionView($id): array{
|
||||||
|
$report = Reports::findOne($id);
|
||||||
|
return array_merge($report->toArray(), ['tasks' => $report->_task]);
|
||||||
|
}
|
||||||
|
|
||||||
public function actionCreate()
|
public function actionCreate()
|
||||||
{
|
{
|
||||||
$reportsModel = new Reports();
|
|
||||||
|
|
||||||
$params = Yii::$app->request->post();
|
$params = Yii::$app->request->post();
|
||||||
|
if (!isset($params['tasks'])){
|
||||||
|
throw new BadRequestHttpException('Нет параметра tasks');
|
||||||
|
}
|
||||||
|
|
||||||
|
$reportsModel = new Reports();
|
||||||
$reportsModel->attributes = $params;
|
$reportsModel->attributes = $params;
|
||||||
|
|
||||||
if(!$reportsModel->validate()){
|
if(!$reportsModel->validate()){
|
||||||
throw new BadRequestHttpException(json_encode($reportsModel->errors));
|
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()
|
public function actionDelete()
|
||||||
|
@ -51,6 +51,11 @@ class UserCardController extends Controller
|
|||||||
$result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all();
|
$result = UserCard::find()->where(['id_user' => $id_user])->asArray()->all();
|
||||||
if($result) {
|
if($result) {
|
||||||
$id = $result[0]['id'];
|
$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([
|
$dataProvider = new ActiveDataProvider([
|
||||||
'query' => FieldsValueNew::find()
|
'query' => FieldsValueNew::find()
|
||||||
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE])
|
->where(['item_id' => $id, 'item_type' => FieldsValueNew::TYPE_PROFILE])
|
||||||
@ -69,7 +74,7 @@ class UserCardController extends Controller
|
|||||||
->all();
|
->all();
|
||||||
|
|
||||||
return $this->render('view', [
|
return $this->render('view', [
|
||||||
'model' => $this->findModel($id),
|
'model' => $model,
|
||||||
'modelFildValue' => $dataProvider,
|
'modelFildValue' => $dataProvider,
|
||||||
'skills' => $skills,
|
'skills' => $skills,
|
||||||
'achievements' => $achievements,
|
'achievements' => $achievements,
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use asmoday74\ckeditor5\EditorClassic;
|
||||||
use yii\grid\GridView;
|
use yii\grid\GridView;
|
||||||
use yii\helpers\Html;
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
use yii\widgets\DetailView;
|
use yii\widgets\DetailView;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
@ -67,4 +69,15 @@ $this->title = 'Профиль';
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
]); ?>
|
]); ?>
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(); ?>
|
||||||
|
<?= $form->field($model, 'vc_text')->widget(EditorClassic::className(), [
|
||||||
|
'clientOptions' => [
|
||||||
|
'language' => 'ru',
|
||||||
|
]
|
||||||
|
]); ?>
|
||||||
|
<div class="form-group">
|
||||||
|
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
|
||||||
|
</div>
|
||||||
|
<?php $form = ActiveForm::end(); ?>
|
||||||
</div>
|
</div>
|
||||||
|
@ -28,6 +28,7 @@ $this->registerCss('.list-cell__task{width:73%}')
|
|||||||
echo '<b>Дата заполнения отчета:</b>';
|
echo '<b>Дата заполнения отчета:</b>';
|
||||||
echo DatePicker::widget([
|
echo DatePicker::widget([
|
||||||
'model' => $model,
|
'model' => $model,
|
||||||
|
'language' => 'ru',
|
||||||
'attribute' => 'created_at',
|
'attribute' => 'created_at',
|
||||||
'options' => [],
|
'options' => [],
|
||||||
'pluginOptions' => [
|
'pluginOptions' => [
|
||||||
|
Loading…
Reference in New Issue
Block a user