Материал: Автоматизация учёта рабочего времени сотрудников компании ООО "ФВК СЕВЕР"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
106
Приложение. Листинг программного модуля
<?php
namespace app\controllers;
use Yii;
use app\models\User;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* ReportSettingsController implements the CRUD actions for User model.
*/
class ReportsController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' =>
[
[
'actions' => ['report-t7', 'report-t13',
'report-time-control'],
'allow' => true,
107
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
public function actionReportT7()
{
$vacations = \app\models\Vacation::find()->leftJoin('worker',
'worker.id = vacation.id_worker')
->andWhere(['active' => true])
->andWhere('begin_date >= :report_begin_date and
end_date <= :report_end_date')
->orderBy(['last_name' => SORT_ASC, 'first_name' =>
SORT_ASC, 'middle_name' => SORT_ASC])
->params ([':report_begin_date' => Yii::$app->user-
>identity->report_begin_date, ':report_end_date' => Yii::$app->user->identity-
>report_end_date])
->all();
108
return Yii::$app->response->sendContentAsFile($this-
>renderPartial('report-t7', ['vacations' => $vacations]), Yii::t('app', 'Report T7') . '.xls');
}
public function actionReportT13()
{
$workers = \app\models\Worker::find()
->andWhere(['active' => true])
->orderBy(['last_name' => SORT_ASC, 'first_name' =>
SORT_ASC, 'middle_name' => SORT_ASC])
->all();
return Yii::$app->response->sendContentAsFile($this-
>renderPartial('report-t13', ['workers' => $workers, 'settings' => Yii::$app->user-
>identity]), Yii::t('app', 'Report T13') . '.xls');
}
public function actionReportTimeControl()
{
$workers = \app\models\Worker::find()
->andWhere(['active' => true])
->orderBy(['last_name' => SORT_ASC, 'first_name' =>
SORT_ASC, 'middle_name' => SORT_ASC])
->all();
return Yii::$app->response->sendContentAsFile($this-
>renderPartial('report-time-control', ['workers' => $workers, 'settings' => Yii::$app-
>user->identity]), Yii::t('app', 'Report Time Control') . '.xls');
}
109
}
<?php
namespace app\controllers;
use Yii;
use app\models\User;
use yii\data\ActiveDataProvider;
use yii\web\Controller;
use yii\web\NotFoundHttpException;
use yii\filters\VerbFilter;
/**
* ReportSettingsController implements the CRUD actions for User model.
*/
class ReportSettingsController extends Controller
{
public function behaviors()
{
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' =>
[
110
[
'actions' => ['view', 'update'],
'allow' => true,
'roles' => ['@'],
],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['post'],
],
],
];
}
/**
* Displays a single User model.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionView()
{
return $this->render('view', [
'model' => $this->findModel(),
]);
Источник: https://baza.diplomsite.ru/previewfile/2483