bd calendar and salary sum
This commit is contained in:
24
backend/modules/calendar/Calendar.php
Normal file
24
backend/modules/calendar/Calendar.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\calendar;
|
||||
|
||||
/**
|
||||
* calendar module definition class
|
||||
*/
|
||||
class Calendar extends \yii\base\Module
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public $controllerNamespace = 'backend\modules\calendar\controllers';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
parent::init();
|
||||
|
||||
// custom initialization code goes here
|
||||
}
|
||||
}
|
46
backend/modules/calendar/controllers/CalendarController.php
Normal file
46
backend/modules/calendar/controllers/CalendarController.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace backend\modules\calendar\controllers;
|
||||
|
||||
use backend\modules\card\models\UserCardSearch;
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
use yii\data\ArrayDataProvider;
|
||||
use yii\web\Controller;
|
||||
|
||||
/**
|
||||
* Default controller for the `calendar` module
|
||||
*/
|
||||
class CalendarController extends Controller
|
||||
{
|
||||
/**
|
||||
* Renders the index view for the module
|
||||
* @return string
|
||||
*/
|
||||
public function actionIndex()
|
||||
{
|
||||
$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);
|
||||
}
|
||||
|
||||
return $this->render('index', [
|
||||
'searchModel' => $searchModel,
|
||||
'dataProvider' => $dataProvider,
|
||||
]);
|
||||
}
|
||||
}
|
42
backend/modules/calendar/views/calendar/index.php
Normal file
42
backend/modules/calendar/views/calendar/index.php
Normal file
@ -0,0 +1,42 @@
|
||||
<div class="calendar-default-index">
|
||||
|
||||
<p>
|
||||
<select id="options" class="btn btn-secondary dropdown-toggle">
|
||||
<option selected="selected">Выберите месяц</option>
|
||||
<option value="?month=00">Показать все</option>
|
||||
<option value="?month=01">январь</option>
|
||||
<option value="?month=02">февраль</option>
|
||||
<option value="?month=03">март</option>
|
||||
<option value="?month=04">апрель</option>
|
||||
<option value="?month=05">май</option>
|
||||
<option value="?month=06">июнь</option>
|
||||
<option value="?month=07">июль</option>
|
||||
<option value="?month=08">август</option>
|
||||
<option value="?month=09">сентябрь</option>
|
||||
<option value="?month=10">октябрь</option>
|
||||
<option value="?month=11">ноябрь</option>
|
||||
<option value="?month=12">декабрь</option>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
|
||||
/* @var $searchModel backend\modules\card\models\UserCardSearch */
|
||||
/* @var $dataProvider yii\data\ActiveDataProvider */
|
||||
|
||||
use yii\grid\GridView;
|
||||
use yii\widgets\Pjax;
|
||||
|
||||
Pjax::begin(['id' => 'reload']);
|
||||
echo GridView::widget([
|
||||
'dataProvider' => $dataProvider,
|
||||
'filterModel' => $searchModel,
|
||||
'columns' => [
|
||||
['class' => 'yii\grid\SerialColumn'],
|
||||
'fio',
|
||||
'dob',
|
||||
['class' => 'yii\grid\ActionColumn'],
|
||||
],
|
||||
]);
|
||||
Pjax::end();
|
||||
?>
|
Reference in New Issue
Block a user