Дипломная работа: Автоматизация учета рабочего времени сотрудников МБОУДО "ДДЮТ"

Внимание! Если размещение файла нарушает Ваши авторские права, то обязательно сообщите нам
132
$worker = WorkerController::findModel($id_worker);
$model = new WorkTime();
$model->id_worker = $worker->id;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('create', [
'model' => $model,
'worker' => $worker,
]);
}
/**
* Updates an existing WorkTime model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionUpdate($id)
{
133
$model = $this->findModel($id);
$worker = WorkerController::findModel($model->id_worker);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
return $this->render('update', [
'model' => $model,
'worker' => $worker,
]);
}
/**
* Deletes an existing WorkTime model.
* If deletion is successful, the browser will be redirected to the 'index' page.
* @param integer $id
* @return mixed
* @throws NotFoundHttpException if the model cannot be found
*/
public function actionDelete($id)
{
$model = $this->findModel($id);
$worker = WorkerController::findModel($model->id_worker);
134
$model->delete();
return $this->redirect(['index', 'id_worker' => $worker->id]);
}
/**
* Finds the WorkTime model based on its primary key value.
* If the model is not found, a 404 HTTP exception will be thrown.
* @param integer $id
* @return WorkTime the loaded model
* @throws NotFoundHttpException if the model cannot be found
*/
protected function findModel($id)
{
if (($model = WorkTime::findOne($id)) !== null) {
return $model;
}
throw new NotFoundHttpException(Yii::t('app', 'The requested page does
not exist.'));
}
}
<?php
namespace app\controllers;
135
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'],
136
'allow' => true,
'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])
Источник: https://baza.diplomsite.ru/previewfile/2451