Рефакторинг, дебаг календаря, добавление кнопки назад, отображение выбранного дня
This commit is contained in:
@ -12,35 +12,23 @@ use yii\web\Response;
|
||||
class AjaxController extends \yii\web\Controller
|
||||
{
|
||||
|
||||
public function actionGetReportsForMonthByIdYearMonth($id, $year=null, $month=null){
|
||||
if (!($year and $month)){
|
||||
$searchModel->month = date('m');
|
||||
$searchModel->year = date('Y');
|
||||
Debug::prn('Неверный год или месяц');
|
||||
}
|
||||
|
||||
public function actionGetReportsForMonthByIdYearMonth($user_id, $year, $month){
|
||||
$searchModel = new ReportsSearch();
|
||||
$searchModel->id = $id;
|
||||
|
||||
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
||||
|
||||
$reports = $dataProvider->getModels();
|
||||
$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');
|
||||
$reports_array = array_column($reports, 'attributes');
|
||||
foreach ($reports as $i => $report){
|
||||
$reports_array[$i]['today'] = array_column($report->task, 'attributes');
|
||||
}
|
||||
$reports = $reports_no_task;
|
||||
|
||||
$month = new Month($year.'-'.$month.'-01');
|
||||
|
||||
|
||||
$response = Yii::$app->response;
|
||||
|
||||
$response->format = Response::FORMAT_JSON;
|
||||
|
||||
$response->content = json_encode(array_merge(['reports' => $reports_no_task],
|
||||
['month'=>(array)$month]));
|
||||
$response->getHeaders()->set('Content-Type', 'application/json; charset=utf-8');
|
||||
$response->content = json_encode(array_merge(
|
||||
['reports' => $reports_array],
|
||||
['month' => (array)new Month($year.'-'.$month.'-01')])
|
||||
);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
@ -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,
|
||||
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user