2020-01-17 16:28:25 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace backend\modules\calendar\controllers;
|
|
|
|
|
|
|
|
use backend\modules\card\models\UserCardSearch;
|
|
|
|
use Yii;
|
|
|
|
use yii\data\ArrayDataProvider;
|
2020-01-29 11:26:01 +03:00
|
|
|
use yii\filters\AccessControl;
|
|
|
|
use yii\filters\VerbFilter;
|
2020-01-17 16:28:25 +03:00
|
|
|
use yii\web\Controller;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default controller for the `calendar` module
|
|
|
|
*/
|
|
|
|
class CalendarController extends Controller
|
|
|
|
{
|
2020-01-29 11:26:01 +03:00
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*/
|
|
|
|
public function behaviors()
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'verbs' => [
|
|
|
|
'class' => VerbFilter::className(),
|
|
|
|
'actions' => [
|
|
|
|
'delete' => ['POST'],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'access' => [
|
|
|
|
'class' => AccessControl::className(),
|
|
|
|
'rules' => [
|
|
|
|
[
|
|
|
|
'allow' => true,
|
|
|
|
'roles' => ['admin'],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
2020-01-17 16:28:25 +03:00
|
|
|
/**
|
|
|
|
* Renders the index view for the module
|
|
|
|
* @return string
|
|
|
|
*/
|
2021-09-13 16:40:37 +03:00
|
|
|
public function actionIndex(){
|
|
|
|
return $this->render('index');
|
2021-09-10 17:39:40 +03:00
|
|
|
}
|
|
|
|
|
2021-09-13 16:40:37 +03:00
|
|
|
public function actionTable()
|
2020-01-17 16:28:25 +03:00
|
|
|
{
|
|
|
|
$searchModel = new UserCardSearch();
|
|
|
|
$user_card = \common\models\UserCard::find()->all();
|
|
|
|
$user_array = array();
|
|
|
|
try {
|
|
|
|
if($_GET['month'] == 00)
|
|
|
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
|
|
|
else {
|
|
|
|
foreach ($user_card as $value) {
|
|
|
|
if (substr(substr($value->dob, 5), 0, 2) == $_GET['month'])
|
|
|
|
array_push($user_array, $value);
|
|
|
|
}
|
|
|
|
$dataProvider = new ArrayDataProvider([
|
|
|
|
'allModels' => $user_array,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
|
|
|
|
}
|
|
|
|
|
2021-09-13 16:40:37 +03:00
|
|
|
return $this->render('table', [
|
2020-01-17 16:28:25 +03:00
|
|
|
'searchModel' => $searchModel,
|
|
|
|
'dataProvider' => $dataProvider,
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|