2021-09-10 17:39:40 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace backend\modules\calendar\controllers;
|
|
|
|
|
|
|
|
use backend\modules\card\models\UserCardSearch;
|
|
|
|
use Yii;
|
|
|
|
use yii\web\Response;
|
|
|
|
|
|
|
|
class AjaxController extends \yii\web\Controller
|
|
|
|
{
|
2021-09-13 16:40:37 +03:00
|
|
|
|
|
|
|
public function actionGetBirthdayDate($date)
|
2021-09-10 17:39:40 +03:00
|
|
|
{
|
|
|
|
$searchModel = new UserCardSearch();
|
2021-09-13 16:40:37 +03:00
|
|
|
$dataProvider = $searchModel->search(['date' => $date]);
|
|
|
|
|
|
|
|
return $this->render('_gridView', [
|
|
|
|
'dataProvider' => $dataProvider
|
2021-09-10 17:39:40 +03:00
|
|
|
]);
|
2021-09-13 16:40:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function actionGetBirthdayDatesByMonth($month )
|
|
|
|
{
|
|
|
|
$searchModel = new UserCardSearch();
|
|
|
|
$models = $searchModel->search(Yii::$app->request->queryParams)->getModels();
|
|
|
|
$models_array = array_map(function ($date){return date('Y').substr($date, 4,6);},
|
|
|
|
array_column($models, 'dob')
|
|
|
|
);
|
|
|
|
|
2021-09-10 17:39:40 +03:00
|
|
|
|
|
|
|
$response = Yii::$app->response;
|
|
|
|
$response->format = Response::FORMAT_JSON;
|
|
|
|
$response->getHeaders()->set('Content-Type', 'application/json; charset=utf-8');
|
|
|
|
$response->content = json_encode(
|
|
|
|
$models_array
|
|
|
|
);
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
}?>
|