Переделал виджет, более читаем
This commit is contained in:
@ -2,35 +2,29 @@
|
||||
|
||||
namespace backend\modules\reports\controllers;
|
||||
|
||||
use backend\modules\reports\models\Month;
|
||||
|
||||
use Yii;
|
||||
use backend\modules\reports\models\ReportsSearch;
|
||||
use yii\helpers\ArrayHelper;
|
||||
use yii\web\Response;
|
||||
|
||||
class AjaxController extends \yii\web\Controller
|
||||
{
|
||||
|
||||
public function actionGetReportsForMonthByIdYearMonth($user_id, $year, $month){
|
||||
public function actionGetReportsForDayByDate($user_id, $date)
|
||||
{
|
||||
$searchModel = new ReportsSearch();
|
||||
$params = ['ReportsSearch' => ['created_at' => $date], 'user_id' => $user_id];
|
||||
$dataProvider = $searchModel->search($params);
|
||||
return $this->render('_gridView', [
|
||||
'dataProvider' => $dataProvider
|
||||
]);
|
||||
}
|
||||
|
||||
public function actionGetReportsForMonthByIdYearMonth($user_id, $year, $month)
|
||||
{
|
||||
$searchModel = new ReportsSearch();
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
$reports_array = ArrayHelper::toArray($dataProvider->getModels(), [
|
||||
'common\models\Reports' => [
|
||||
'id',
|
||||
'created_at',
|
||||
'difficulties',
|
||||
'tomorrow',
|
||||
'user_card_id',
|
||||
'today' => function ($report) {
|
||||
return ArrayHelper::toArray($report->task, [
|
||||
'common\models\ReportsTask' => [
|
||||
'hours_spent',
|
||||
'task'
|
||||
],
|
||||
]);
|
||||
}
|
||||
],
|
||||
]);
|
||||
$reports_array = array_column($dataProvider->getModels(), 'created_at');
|
||||
|
||||
$response = Yii::$app->response;
|
||||
$response->format = Response::FORMAT_JSON;
|
||||
|
Reference in New Issue
Block a user