fix clear and copy week
This commit is contained in:
@@ -5,6 +5,7 @@ namespace common\modules\event\controllers;
|
||||
use common\manager\EventRegistrationManager;
|
||||
use common\models\CardEventRegistrationForm;
|
||||
use common\modules\event\EventModule;
|
||||
use common\modules\event\models\copy\ClearWeekForm;
|
||||
use common\modules\event\models\copy\CopyWeekSearch;
|
||||
use common\modules\event\models\EventPermissions;
|
||||
use common\modules\event\models\timetable\TimeTableSearch;
|
||||
@@ -42,7 +43,7 @@ class EventController extends Controller
|
||||
|
||||
$module = EventModule::getInstance();
|
||||
assert(isset($module), 'event module not set');
|
||||
$allowedActions = ['index', 'view', 'reserve-card', 'cancel-registration', 'delete-registration', 'timetable','copy-week'];
|
||||
$allowedActions = ['index', 'view', 'reserve-card', 'cancel-registration', 'delete-registration', 'timetable', 'copy-week','clear-week'];
|
||||
if ($module->mode === 'backend') {
|
||||
$allowedActions[] = 'create';
|
||||
$allowedActions[] = 'update';
|
||||
@@ -259,10 +260,39 @@ class EventController extends Controller
|
||||
));
|
||||
}
|
||||
|
||||
public function actionCopyWeek(){
|
||||
/** @noinspection PhpUnused */
|
||||
/**
|
||||
* @return string
|
||||
* @throws Exception
|
||||
*/
|
||||
public function actionCopyWeek()
|
||||
{
|
||||
$model = new CopyWeekSearch();
|
||||
$model->search(\Yii::$app->request->get());
|
||||
return $this->render('copy_week',['model' => $model]);
|
||||
$model->sourceDateString = date('Y.m.d');
|
||||
$model->targetDateString = date('Y.m.d', strtotime('+1 week'));
|
||||
if (Yii::$app->request->isPost) {
|
||||
$model->search(Yii::$app->request->post());
|
||||
if (count($model->getErrors()) === 0) {
|
||||
$model->save();
|
||||
$this->redirect(['copy-week', $model->formName() . '[sourceDateString]'=> $model->sourceDateString, $model->formName() . '[targetDateString]' =>$model->targetDateString ]);
|
||||
}
|
||||
} else {
|
||||
$model->search(Yii::$app->request->get());
|
||||
}
|
||||
return $this->render('copy_week', ['model' => $model]);
|
||||
|
||||
|
||||
}/** @noinspection PhpUnused */
|
||||
|
||||
/**
|
||||
* @return Response
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function actionClearWeek(){
|
||||
|
||||
$clearWeekForm = new ClearWeekForm();
|
||||
$clearWeekForm->clear(Yii::$app->request->get());
|
||||
return $this->redirect(['timetable', []]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user