не работает ооп
This commit is contained in:
@@ -3,14 +3,17 @@
|
||||
namespace backend\modules\reports\controllers;
|
||||
|
||||
use backend\modules\card\models\UserCardSearch;
|
||||
use backend\modules\reports\models\Month;
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
use common\models\Reports;
|
||||
use backend\modules\reports\models\ReportsSearch;
|
||||
use yii\base\Model;
|
||||
use yii\filters\AccessControl;
|
||||
use yii\web\Controller;
|
||||
use yii\web\NotFoundHttpException;
|
||||
use yii\filters\VerbFilter;
|
||||
use yii\web\Response;
|
||||
|
||||
/**
|
||||
* ReportsController implements the CRUD actions for Reports model.
|
||||
@@ -56,6 +59,34 @@ class ReportsController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
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))) {
|
||||
// Debug::dd('неверный формат даты');
|
||||
$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();
|
||||
// Debug::dd($dataProvider);
|
||||
$month = new Month($date);
|
||||
|
||||
if (!Yii::$app->request->isAjax) {
|
||||
return $this->render('user', [
|
||||
'ID' => $reports[0]->id,
|
||||
'reports' => $reports,
|
||||
'reports_month' => json_encode(array_merge(['reports'=>array_column($reports, 'attributes')],
|
||||
['month'=>(array)$month])),
|
||||
'date' => $date
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function actionGroup()
|
||||
{
|
||||
$searchModel = new UserCardSearch();
|
||||
@@ -65,6 +96,7 @@ class ReportsController extends Controller
|
||||
return $this->render('group', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user