This commit is contained in:
andrey
2021-09-07 16:36:39 +03:00
20 changed files with 4771 additions and 607 deletions

View File

@ -3,7 +3,7 @@
namespace backend\modules\reports\controllers;
use backend\modules\card\models\UserCardSearch;
use common\classes\Debug;
use backend\modules\reports\models\Month;
use Yii;
use common\models\Reports;
use backend\modules\reports\models\ReportsSearch;
@ -49,14 +49,55 @@ 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]);
}
return $this->render('index', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
'user_id__fio' => $user_id__fio,
]);
}
public function actionUser($id, $date = null)
{
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();
$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()
{
$searchModel = new UserCardSearch();
@ -66,6 +107,7 @@ class ReportsController extends Controller
return $this->render('group', [
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}