Рефакторинг, дебаг календаря, добавление кнопки назад, отображение выбранного дня

This commit is contained in:
maxim
2021-09-08 14:39:32 +03:00
parent 415d8e4ee9
commit 0c29d4f4d5
8 changed files with 692 additions and 747 deletions

View File

@ -3,7 +3,6 @@
namespace backend\modules\reports\controllers;
use backend\modules\card\models\UserCardSearch;
use backend\modules\reports\models\Month;
use Yii;
use common\models\Reports;
use backend\modules\reports\models\ReportsSearch;
@ -49,53 +48,29 @@ class ReportsController extends Controller
public function actionIndex()
{
$searchModel = new ReportsSearch();
$reports = $searchModel->search([])->getModels();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$user_id__fio = [];
for ($i=0; $i<count($reports);$i++){
$user_id__fio[$reports[$i]->user_card_id] = \common\models\Reports::getFio($reports[$i]);
}
foreach ($searchModel->search([])->getModels() as $model)
$user_id__fio[$model->user_card_id] = \common\models\Reports::getFio($model);
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'user_id__fio' => $user_id__fio,
]);
}
public function actionUser($id, $date = null)
public function actionUser($user_id)
{
if (!(isset($date) and preg_match("/^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$/", $date))) {
$date = date('Y-m-01');
}
$date = date('Y-m-01', strtotime($date));
$searchModel = new ReportsSearch();
$searchModel->id = $id;
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$reports = $dataProvider->getModels();
return $this->render('user', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
$ID = $reports[0]->user_card_id;
$reports_no_task = array_column($reports, 'attributes');
for ($i = 0; $i < count($reports); $i++) {
$reports_no_task[$i]['today'] = array_column($reports[$i]->task, 'attributes');
}
$month = new Month($date);
if (!Yii::$app->request->isAjax) {
return $this->render('user', [
'ID' => $ID,
'reports' => $reports,
'reports_month' => json_encode(array_merge(['reports' => $reports_no_task],
['month' => (array)$month])),
'date' => $date
]);
}
}
public function actionGroup()
@ -107,7 +82,6 @@ class ReportsController extends Controller
return $this->render('group', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}