backend/group-training : improve delete© week
This commit is contained in:
parent
5fe59ff1d3
commit
50011a4e4f
@ -230,11 +230,11 @@ class EventRegistrationManager extends BaseObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($registration->canceled_at)) {
|
if (isset($registration->canceled_at)) {
|
||||||
throw new BadRequestHttpException('The registration is already canceled', self::ALREADY_CANCELLED);
|
throw new BadRequestHttpException('The registration is already canceled: '.$registration->id, self::ALREADY_CANCELLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($registration->deleted_at)) {
|
if (isset($registration->deleted_at)) {
|
||||||
throw new BadRequestHttpException('The reservation is already deleted', self::ALREADY_DELETED);
|
throw new BadRequestHttpException('The reservation is already deleted: '.$registration->id, self::ALREADY_DELETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
$event = Event::findOne($registration->id_event);
|
$event = Event::findOne($registration->id_event);
|
||||||
@ -245,10 +245,10 @@ class EventRegistrationManager extends BaseObject
|
|||||||
|
|
||||||
$now = strtotime("now UTC");
|
$now = strtotime("now UTC");
|
||||||
|
|
||||||
if ($reason != EventRegistration::CANCEL_REASON_CUSTOMER) {
|
if ($reason == EventRegistration::CANCEL_REASON_CUSTOMER) {
|
||||||
$timeUntilEventStart = $event->start - $now;
|
$timeUntilEventStart = $event->start - $now;
|
||||||
if ($timeUntilEventStart < Helper::getGroupTrainingRegistrationCancelLimitMinutes() * 60) {
|
if ($timeUntilEventStart < Helper::getGroupTrainingRegistrationCancelLimitMinutes() * 60) {
|
||||||
throw new BadRequestHttpException('The reservation is already deleted', self::CANCEL_TIME_LIMIT_REACHED);
|
throw new BadRequestHttpException('The reservation can\'t be deleted', self::CANCEL_TIME_LIMIT_REACHED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -302,9 +302,8 @@ class EventRegistrationManager extends BaseObject
|
|||||||
$tx = $db->beginTransaction();
|
$tx = $db->beginTransaction();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$eventRegistrationManager = new EventRegistrationManager();
|
$allRegistrations = $this->findAllRegistrations($event->id);
|
||||||
$allRegistrations = $eventRegistrationManager->findAllRegistrations($event->id);
|
$activeRegistrations = $this->findActiveRegistrations($event->id);
|
||||||
$activeRegistrations = $eventRegistrationManager->findActiveRegistrations($event->id);
|
|
||||||
|
|
||||||
// ////////////////////////////////
|
// ////////////////////////////////
|
||||||
// if event has no registrations
|
// if event has no registrations
|
||||||
|
|||||||
@ -8,7 +8,6 @@ use common\models\CardEventRegistrationForm;
|
|||||||
use common\models\EventEquipmentType;
|
use common\models\EventEquipmentType;
|
||||||
use common\models\EventEquipmentTypeAssignment;
|
use common\models\EventEquipmentTypeAssignment;
|
||||||
use common\models\EventRegistration;
|
use common\models\EventRegistration;
|
||||||
use common\models\EventRegistrationEquipmentTypeAssignment;
|
|
||||||
use common\models\Trainer;
|
use common\models\Trainer;
|
||||||
use common\modules\event\EventModule;
|
use common\modules\event\EventModule;
|
||||||
use common\modules\event\modelAndView\CreateEventModelAndView;
|
use common\modules\event\modelAndView\CreateEventModelAndView;
|
||||||
@ -20,7 +19,6 @@ use common\modules\event\models\EventPermissions;
|
|||||||
use common\modules\event\models\timetable\TimeTableSearch;
|
use common\modules\event\models\timetable\TimeTableSearch;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Exception;
|
use Exception;
|
||||||
use Throwable;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use common\models\Event;
|
use common\models\Event;
|
||||||
use common\modules\event\models\EventSearch;
|
use common\modules\event\models\EventSearch;
|
||||||
@ -354,7 +352,7 @@ class EventController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $id the id
|
* @param int $id the id
|
||||||
* @return string
|
* @return string
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -19,29 +19,6 @@ use yii\db\StaleObjectException;
|
|||||||
|
|
||||||
class EventManager
|
class EventManager
|
||||||
{
|
{
|
||||||
/** @noinspection PhpUnused */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Delete or mark deleted an event
|
|
||||||
* @param $id
|
|
||||||
* @throws Throwable
|
|
||||||
* @throws \yii\base\Exception on any error
|
|
||||||
* @throws StaleObjectException
|
|
||||||
*/
|
|
||||||
public function deleteEvent($id)
|
|
||||||
{
|
|
||||||
$event = Event::findOne($id);
|
|
||||||
if (!isset($event)) {
|
|
||||||
throw new \yii\base\Exception("Event $id not found");
|
|
||||||
}
|
|
||||||
$registrations = $event->eventRegistrations;
|
|
||||||
if (!isset($registrations) || count($registrations) === 0) {
|
|
||||||
$event->delete();
|
|
||||||
} else {
|
|
||||||
$event->deleted_at = time();
|
|
||||||
$event->save(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -91,10 +68,7 @@ class EventManager
|
|||||||
}
|
}
|
||||||
// get events between active dates
|
// get events between active dates
|
||||||
|
|
||||||
$trainers = null;
|
$trainers = $this->getAssignedTrainerIDsForPermission();
|
||||||
if ( RoleDefinition::isTrainer() ){
|
|
||||||
$trainers = $this->getAssignedTrainerIDs(\Yii::$app->user->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
$events = $this->getEvents($dateTimeFrom, $dateTimeTo,$trainers);
|
$events = $this->getEvents($dateTimeFrom, $dateTimeTo,$trainers);
|
||||||
|
|
||||||
@ -236,7 +210,15 @@ class EventManager
|
|||||||
|
|
||||||
public function getAssignedTrainerIDs($idUser){
|
public function getAssignedTrainerIDs($idUser){
|
||||||
$trainerObjects = $this->getAssignedTrainers($idUser);
|
$trainerObjects = $this->getAssignedTrainers($idUser);
|
||||||
|
return $this->mapTrainerToId($trainerObjects);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAllTrainerIDs( ){
|
||||||
|
$trainerObjects = Trainer::find()->all();
|
||||||
|
return $this->mapTrainerToId($trainerObjects);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function mapTrainerToId($trainerObjects){
|
||||||
$trainers = [];
|
$trainers = [];
|
||||||
foreach ($trainerObjects as $trainerObject){
|
foreach ($trainerObjects as $trainerObject){
|
||||||
$trainers[] = $trainerObject->id;
|
$trainers[] = $trainerObject->id;
|
||||||
@ -244,6 +226,46 @@ class EventManager
|
|||||||
return $trainers;
|
return $trainers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the trainers are not limited by the 'trainer' role, null will be returned.
|
||||||
|
* If the user has the 'trainer' permission, but no trainer is assigned, empty array will be returned.
|
||||||
|
* Otherwise the array of assigned trainer IDs will be returned.
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
|
public function getAssignedTrainerIDsForPermission(){
|
||||||
|
if ( RoleDefinition::isTrainer()){
|
||||||
|
$trainers = $this->getAssignedTrainerIDs(\Yii::$app->user->id);
|
||||||
|
} else {
|
||||||
|
$trainers = $this->getAllTrainerIDs();
|
||||||
|
}
|
||||||
|
return $trainers;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $trainerIDs int[]|null the trainer IDs. Null means, all trainers are allowed
|
||||||
|
* @param $trainerId
|
||||||
|
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function isTrainerAllowed($trainerIDs,$trainerId){
|
||||||
|
if ( !isset($trainerIDs) ){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return array_search($trainerId,$trainerIDs) !== false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use it with the result of getAssignedTrainerIDsForPermission().
|
||||||
|
* (
|
||||||
|
* @param $trainerIDs int[]|null the trainer IDs. Null means, all trainers are allowed
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasAnyTrainerAllowed($trainerIDs ){
|
||||||
|
if ( !isset($trainerIDs)){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return count($trainerIDs) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,13 +2,13 @@
|
|||||||
|
|
||||||
namespace common\modules\event\models\copy;
|
namespace common\modules\event\models\copy;
|
||||||
|
|
||||||
|
use common\components\RoleDefinition;
|
||||||
use common\manager\EventRegistrationManager;
|
use common\manager\EventRegistrationManager;
|
||||||
use common\modules\event\manager\EventManager;
|
use common\modules\event\manager\EventManager;
|
||||||
use common\modules\event\models\timetable\TimeTableMonth;
|
use common\modules\event\models\timetable\TimeTableMonth;
|
||||||
use common\modules\event\models\timetable\TimeTableMonthWeek;
|
use common\modules\event\models\timetable\TimeTableMonthWeek;
|
||||||
use customerapi\models\available\EventInterval;
|
use customerapi\models\available\EventInterval;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Throwable;
|
|
||||||
use Yii;
|
use Yii;
|
||||||
use yii\base\Model;
|
use yii\base\Model;
|
||||||
|
|
||||||
@ -45,7 +45,6 @@ class ClearWeekForm extends Model
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $params
|
* @param $params
|
||||||
* @throws Throwable
|
|
||||||
*/
|
*/
|
||||||
public function clear($params){
|
public function clear($params){
|
||||||
$this->load($params);
|
$this->load($params);
|
||||||
@ -65,10 +64,17 @@ class ClearWeekForm extends Model
|
|||||||
|
|
||||||
$events = $targetWeek->getAllEvents();
|
$events = $targetWeek->getAllEvents();
|
||||||
|
|
||||||
|
$trainers = $eventManager->getAssignedTrainerIDsForPermission();
|
||||||
$eventRegisterManager = new EventRegistrationManager();
|
$eventRegisterManager = new EventRegistrationManager();
|
||||||
|
if ( !$eventManager->hasAnyTrainerAllowed($trainers) ){
|
||||||
|
// no trainers assigned, can't do anything...
|
||||||
|
return;
|
||||||
|
}
|
||||||
foreach ($events as $event){
|
foreach ($events as $event){
|
||||||
|
if ( $eventManager->isTrainerAllowed($trainers,$event->id_trainer) ){
|
||||||
$eventRegisterManager->deleteEvent($event);
|
$eventRegisterManager->deleteEvent($event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
11
common/modules/event/models/copy/CopyWeekContext.php
Normal file
11
common/modules/event/models/copy/CopyWeekContext.php
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace common\modules\event\models\copy;
|
||||||
|
|
||||||
|
use yii\base\BaseObject;
|
||||||
|
|
||||||
|
class CopyWeekContext extends BaseObject
|
||||||
|
{
|
||||||
|
public $copyWeekForm;
|
||||||
|
public $copyWeekFormModel;
|
||||||
|
}
|
||||||
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace common\modules\event\models\copy;
|
namespace common\modules\event\models\copy;
|
||||||
|
|
||||||
|
use common\manager\EventRegistrationManager;
|
||||||
use common\modules\event\manager\EventManager;
|
use common\modules\event\manager\EventManager;
|
||||||
use common\modules\event\models\timetable\TimeTableMonth;
|
use common\modules\event\models\timetable\TimeTableMonth;
|
||||||
use common\modules\event\models\timetable\TimeTableMonthDay;
|
use common\modules\event\models\timetable\TimeTableMonthDay;
|
||||||
@ -38,6 +39,8 @@ class CopyWeekSearch extends Model
|
|||||||
public $sourceTimeTable;
|
public $sourceTimeTable;
|
||||||
public $targetTimeTable;
|
public $targetTimeTable;
|
||||||
|
|
||||||
|
public $selectedEvents;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritdoc
|
* @inheritdoc
|
||||||
@ -45,7 +48,8 @@ class CopyWeekSearch extends Model
|
|||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[['sourceDateString','targetDateString'], 'required'],
|
[['selectedEvents'], 'safe'],
|
||||||
|
[['sourceDateString', 'targetDateString'], 'required'],
|
||||||
[['sourceDateString',], 'date', 'format' => Yii::$app->formatter->dateFormat, 'timestampAttribute' => 'timestampSource', 'timeZone' => 'UTC'],
|
[['sourceDateString',], 'date', 'format' => Yii::$app->formatter->dateFormat, 'timestampAttribute' => 'timestampSource', 'timeZone' => 'UTC'],
|
||||||
[['targetDateString',], 'date', 'format' => Yii::$app->formatter->dateFormat, 'timestampAttribute' => 'timestampTarget', 'timeZone' => 'UTC'],
|
[['targetDateString',], 'date', 'format' => Yii::$app->formatter->dateFormat, 'timestampAttribute' => 'timestampTarget', 'timeZone' => 'UTC'],
|
||||||
];
|
];
|
||||||
@ -77,18 +81,26 @@ class CopyWeekSearch extends Model
|
|||||||
$targetDate = new DateTime();
|
$targetDate = new DateTime();
|
||||||
$targetDate->setTimestamp($this->timestampTarget);
|
$targetDate->setTimestamp($this->timestampTarget);
|
||||||
}
|
}
|
||||||
$this->sourceInterval = EventInterval::createInterval($sourceDate,7,7);
|
$this->sourceInterval = EventInterval::createInterval($sourceDate, 7, 7);
|
||||||
$this->targetInterval = EventInterval::createInterval($targetDate,7,7);
|
$this->targetInterval = EventInterval::createInterval($targetDate, 7, 7);
|
||||||
|
|
||||||
$eventManager = new EventManager();
|
$eventManager = new EventManager();
|
||||||
$this->sourceTimeTable = $eventManager->loadTimeTable($this->sourceInterval,"display");
|
$this->sourceTimeTable = $eventManager->loadTimeTable($this->sourceInterval, "display");
|
||||||
$this->targetTimeTable = $eventManager->loadTimeTable($this->targetInterval,"display");
|
$this->targetTimeTable = $eventManager->loadTimeTable($this->targetInterval, "display");
|
||||||
|
// if ( !isset($_POST['command'])){
|
||||||
|
// $this->selectedEvents = [];
|
||||||
|
// $events = $this->sourceTimeTable->getAllEvents();
|
||||||
|
// foreach ($events as $event){
|
||||||
|
// $this->selectedEvents[] = $event->id;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function save(){
|
public function save()
|
||||||
|
{
|
||||||
|
|
||||||
$sourceDate = new DateTime();
|
$sourceDate = new DateTime();
|
||||||
$sourceDate->setTimestamp($this->timestampSource);
|
$sourceDate->setTimestamp($this->timestampSource);
|
||||||
@ -98,19 +110,20 @@ class CopyWeekSearch extends Model
|
|||||||
$targetDate->setTimestamp($this->timestampTarget);
|
$targetDate->setTimestamp($this->timestampTarget);
|
||||||
$targetDate->modify('this week');
|
$targetDate->modify('this week');
|
||||||
|
|
||||||
$this->sourceInterval = EventInterval::createInterval($sourceDate,7,7);
|
$this->sourceInterval = EventInterval::createInterval($sourceDate, 7, 7);
|
||||||
$this->targetInterval = EventInterval::createInterval($targetDate,7,7);
|
$this->targetInterval = EventInterval::createInterval($targetDate, 7, 7);
|
||||||
|
|
||||||
// load the time table objects for source and target interval
|
// load the time table objects for source and target interval
|
||||||
$eventManager = new EventManager();
|
$eventManager = new EventManager();
|
||||||
$this->sourceTimeTable = $eventManager->loadTimeTable($this->sourceInterval,"display");
|
$this->sourceTimeTable = $eventManager->loadTimeTable($this->sourceInterval, "display");
|
||||||
$this->targetTimeTable = $eventManager->loadTimeTable($this->targetInterval,"display");
|
$this->targetTimeTable = $eventManager->loadTimeTable($this->targetInterval, "display");
|
||||||
|
|
||||||
$sourceWeek = array_values( $this->sourceTimeTable->weeks )[0];
|
$sourceWeek = array_values($this->sourceTimeTable->weeks)[0];
|
||||||
$targetWeek = array_values( $this->targetTimeTable->weeks )[0];
|
$targetWeek = array_values($this->targetTimeTable->weeks)[0];
|
||||||
|
|
||||||
|
$eventRegistrationManager = new EventRegistrationManager();
|
||||||
// Iterate over all the week days: monday, tuesday, ...
|
// Iterate over all the week days: monday, tuesday, ...
|
||||||
foreach (EventInterval::weekdays as $weekday ){
|
foreach (EventInterval::weekdays as $weekday) {
|
||||||
// this is very ugly
|
// this is very ugly
|
||||||
// it returns eg.: $sourceWeek->monday , $sourceWeek->tuesday...
|
// it returns eg.: $sourceWeek->monday , $sourceWeek->tuesday...
|
||||||
/** @var TimeTableMonthDay $sourceDay */
|
/** @var TimeTableMonthDay $sourceDay */
|
||||||
@ -121,7 +134,16 @@ class CopyWeekSearch extends Model
|
|||||||
$sourceEvents = $sourceDay->events;
|
$sourceEvents = $sourceDay->events;
|
||||||
|
|
||||||
/** @var Event $sourceEvent */
|
/** @var Event $sourceEvent */
|
||||||
foreach ($sourceEvents as $sourceEvent ){
|
foreach ($sourceEvents as $sourceEvent) {
|
||||||
|
|
||||||
|
$processEvent = true;
|
||||||
|
if (isset($this->selectedEvents)) {
|
||||||
|
$processEvent = in_array($sourceEvent->id, $this->selectedEvents);
|
||||||
|
}
|
||||||
|
if ($processEvent) {
|
||||||
|
if ($_POST['command' ] == 'delete') {
|
||||||
|
$eventRegistrationManager->deleteEvent($sourceEvent);
|
||||||
|
} else {
|
||||||
$event = new Event();
|
$event = new Event();
|
||||||
$event->start = $sourceEvent->start;
|
$event->start = $sourceEvent->start;
|
||||||
$event->id_room = $sourceEvent->id_room;
|
$event->id_room = $sourceEvent->id_room;
|
||||||
@ -131,7 +153,7 @@ class CopyWeekSearch extends Model
|
|||||||
$event->active = $sourceEvent->active;
|
$event->active = $sourceEvent->active;
|
||||||
$event->deleted_at = $sourceEvent->deleted_at;
|
$event->deleted_at = $sourceEvent->deleted_at;
|
||||||
|
|
||||||
$start = $this->createDateTime( clone $targetDay->date , new DateTime( '@'. $event->start ) );
|
$start = $this->createDateTime(clone $targetDay->date, new DateTime('@' . $event->start));
|
||||||
$event->start = $start->getTimestamp();
|
$event->start = $start->getTimestamp();
|
||||||
|
|
||||||
// end date is start date + duration
|
// end date is start date + duration
|
||||||
@ -139,7 +161,8 @@ class CopyWeekSearch extends Model
|
|||||||
$event->end = $start->getTimestamp() + $eventDuration;
|
$event->end = $start->getTimestamp() + $eventDuration;
|
||||||
|
|
||||||
$event->save(false);
|
$event->save(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -156,11 +179,12 @@ class CopyWeekSearch extends Model
|
|||||||
* @return DateTime
|
* @return DateTime
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function createDateTime($date,$time){
|
private function createDateTime($date, $time)
|
||||||
|
{
|
||||||
$result = new DateTime();
|
$result = new DateTime();
|
||||||
$result->setDate($date->format('Y'),$date->format('m'),$date->format('d'));
|
$result->setDate($date->format('Y'), $date->format('m'), $date->format('d'));
|
||||||
$result->setTimezone($time->getTimezone());
|
$result->setTimezone($time->getTimezone());
|
||||||
$result->setTime($time->format('H'),$time->format('i'));
|
$result->setTime($time->format('H'), $time->format('i'));
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,33 +0,0 @@
|
|||||||
<?php /** @noinspection PhpUnhandledExceptionInspection */
|
|
||||||
|
|
||||||
use common\modules\event\models\copy\CopyWeekSearch;
|
|
||||||
use yii\helpers\Html;
|
|
||||||
use yii\widgets\ActiveForm;
|
|
||||||
|
|
||||||
/* @var $model CopyWeekSearch */
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<div class="panel panel-default">
|
|
||||||
<div class="panel-heading">Másolás</div>
|
|
||||||
<div class="panel-body">
|
|
||||||
|
|
||||||
<?php $form = ActiveForm::begin(['options' =>['class' => 'form-inline' ]]); ?>
|
|
||||||
<?= $form->field($model, 'sourceDateString')->hiddenInput()->label(false) ?>
|
|
||||||
<?= $form->field($model, 'targetDateString')->hiddenInput()->label(false) ?>
|
|
||||||
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="inpSourceEvent">Forrás hét: </label>
|
|
||||||
|
|
||||||
<input type="text" id="inpSourceEvent" disabled class="form-control" value="<?=$model->sourceTimeTable->getWeekByIndex(0)->getWeekString()?>">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="inpTargetEvent">Cél hét:</label>
|
|
||||||
<input type="text" id="inpTargetEvent" disabled class="form-control" value="<?=$model->targetTimeTable->getWeekByIndex(0)->getWeekString()?>">
|
|
||||||
</div>
|
|
||||||
<?= Html::submitButton( 'Másol', ['class' => 'btn btn-success' ]) ?>
|
|
||||||
|
|
||||||
<?php ActiveForm::end(); ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@ -1,7 +1,10 @@
|
|||||||
<?php /** @noinspection PhpUnhandledExceptionInspection */
|
<?php /** @noinspection PhpUnhandledExceptionInspection */
|
||||||
|
|
||||||
|
use common\modules\event\models\copy\CopyWeekContext;
|
||||||
use common\modules\event\models\copy\CopyWeekSearch;
|
use common\modules\event\models\copy\CopyWeekSearch;
|
||||||
use common\modules\event\widgets\timetable\TimeTableMonthView;
|
use common\modules\event\widgets\timetable\TimeTableMonthView;
|
||||||
|
use yii\helpers\Html;
|
||||||
|
use yii\widgets\ActiveForm;
|
||||||
|
|
||||||
/* @var $this yii\web\View */
|
/* @var $this yii\web\View */
|
||||||
/* @var $tableHeaders string */
|
/* @var $tableHeaders string */
|
||||||
@ -12,11 +15,56 @@ use common\modules\event\widgets\timetable\TimeTableMonthView;
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
echo $this->render('_copy_week_search', ['model' => $model]);
|
echo $this->render('_copy_week_search', ['model' => $model]);
|
||||||
echo $this->render('_copy_week_form', ['model' => $model]);
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<?php $form = ActiveForm::begin(['options' =>['class' => 'form-inline' ]]); ?>
|
||||||
|
<div class="panel panel-default">
|
||||||
|
<div class="panel-heading">Másolás</div>
|
||||||
|
<div class="panel-body">
|
||||||
|
|
||||||
|
<?= $form->field($model, 'sourceDateString')->hiddenInput()->label(false) ?>
|
||||||
|
<?= $form->field($model, 'targetDateString')->hiddenInput()->label(false) ?>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="inpSourceEvent">Forrás hét: </label>
|
||||||
|
|
||||||
|
<input type="text" id="inpSourceEvent" disabled class="form-control" value="<?=$model->sourceTimeTable->getWeekByIndex(0)->getWeekString()?>">
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="inpTargetEvent">Cél hét:</label>
|
||||||
|
<input type="text" id="inpTargetEvent" disabled class="form-control" value="<?=$model->targetTimeTable->getWeekByIndex(0)->getWeekString()?>">
|
||||||
|
</div>
|
||||||
|
<?= Html::submitButton( 'Forrás hét másolása', ['class' => 'btn btn-success', 'value' => 'copy', 'name' => 'command' ]) ?>
|
||||||
|
<?= Html::submitButton( 'Forrás hét törlése', ['class' => 'btn btn-danger', 'value' => 'delete', 'name' => 'command' ]) ?>
|
||||||
|
<p>
|
||||||
|
<small>
|
||||||
|
Ha egy esemény sincsen kiválasztva, akkor a másolás/törlés, minden eseményt érinteni fog.
|
||||||
|
(Nincs esemény kiválasztva = Minden esemény kiválasztva)
|
||||||
|
</small>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<small>Ha valamelyik esemény ki van választva, akkor a másolás/törlés, csak a kiválasztott esemény(eke)t fogja érinteni</small>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<small><strong>Esemény törlése:</strong> a már regisztrált vendégek kártyájára visszakerül az alkalom</small>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<h2>Forrás hét</h2>
|
<h2>Forrás hét</h2>
|
||||||
<?= TimeTableMonthView::widget(['timeTable' => $model->sourceTimeTable]) ?>
|
<?= TimeTableMonthView::widget(
|
||||||
|
[
|
||||||
|
'timeTable' => $model->sourceTimeTable,
|
||||||
|
'copyWeekContext' =>new CopyWeekContext(
|
||||||
|
[
|
||||||
|
'copyWeekForm' => $form,
|
||||||
|
'copyWeekFormModel' => $model
|
||||||
|
]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
) ?>
|
||||||
|
<?php ActiveForm::end(); ?>
|
||||||
<h2>Cél hét</h2>
|
<h2>Cél hét</h2>
|
||||||
<?= TimeTableMonthView::widget(['timeTable' => $model->targetTimeTable]) ?>
|
<?= TimeTableMonthView::widget(['timeTable' => $model->targetTimeTable]) ?>
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace common\modules\event\widgets\day;
|
namespace common\modules\event\widgets\day;
|
||||||
|
use common\modules\event\models\copy\CopyWeekContext;
|
||||||
use common\modules\event\models\timetable\TimeTableMonthDay;
|
use common\modules\event\models\timetable\TimeTableMonthDay;
|
||||||
use yii\bootstrap\Widget;
|
use yii\bootstrap\Widget;
|
||||||
|
|
||||||
@ -11,13 +12,15 @@ use yii\bootstrap\Widget;
|
|||||||
* @package common\modules\event\widgets
|
* @package common\modules\event\widgets
|
||||||
*
|
*
|
||||||
* @property TimeTableMonthDay $day
|
* @property TimeTableMonthDay $day
|
||||||
|
* @property CopyWeekContext $copyWeekContext
|
||||||
*/
|
*/
|
||||||
class TimeTableMonthDayView extends Widget
|
class TimeTableMonthDayView extends Widget
|
||||||
{
|
{
|
||||||
public $day;
|
public $day;
|
||||||
|
public $copyWeekContext;
|
||||||
|
|
||||||
public function run(){
|
public function run(){
|
||||||
return $this->render('_day', [ 'day' => $this->day]);
|
return $this->render('_day', [ 'day' => $this->day,'copyWeekContext' => $this->copyWeekContext]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* @var $day TimeTableMonthDay */
|
/* @var $day TimeTableMonthDay */
|
||||||
|
/* @var $copyWeekContext \common\modules\event\models\copy\CopyWeekContext */
|
||||||
|
|
||||||
use common\models\Event;
|
use common\models\Event;
|
||||||
use common\modules\event\models\timetable\TimeTableMonthDay;
|
use common\modules\event\models\timetable\TimeTableMonthDay;
|
||||||
@ -15,6 +16,6 @@ use common\modules\event\widgets\event\EventView;
|
|||||||
} else {
|
} else {
|
||||||
/** @var Event $event */
|
/** @var Event $event */
|
||||||
foreach ($day->events as $event) {
|
foreach ($day->events as $event) {
|
||||||
echo EventView::widget(['event' => $event]);
|
echo EventView::widget(['event' => $event, 'copyWeekContext' => $copyWeekContext]);
|
||||||
}
|
}
|
||||||
} ?>
|
} ?>
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
namespace common\modules\event\widgets\event;
|
namespace common\modules\event\widgets\event;
|
||||||
use common\helpers\AppDateTimeHelper;
|
use common\helpers\AppDateTimeHelper;
|
||||||
use common\models\Event;
|
use common\models\Event;
|
||||||
|
use common\modules\event\models\copy\CopyWeekContext;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use yii\bootstrap\Widget;
|
use yii\bootstrap\Widget;
|
||||||
|
|
||||||
@ -11,6 +12,7 @@ use yii\bootstrap\Widget;
|
|||||||
* @package common\modules\event\widgets
|
* @package common\modules\event\widgets
|
||||||
*
|
*
|
||||||
* @property Event $event
|
* @property Event $event
|
||||||
|
* @property CopyWeekContext $copyWeekContext
|
||||||
*/
|
*/
|
||||||
class EventView extends Widget
|
class EventView extends Widget
|
||||||
{
|
{
|
||||||
@ -18,6 +20,8 @@ class EventView extends Widget
|
|||||||
public $start;
|
public $start;
|
||||||
public $end;
|
public $end;
|
||||||
|
|
||||||
|
public $copyWeekContext;
|
||||||
|
|
||||||
public function init(){
|
public function init(){
|
||||||
parent::init();
|
parent::init();
|
||||||
if ( isset($this->event )){
|
if ( isset($this->event )){
|
||||||
@ -32,7 +36,8 @@ class EventView extends Widget
|
|||||||
[
|
[
|
||||||
'event' => $this->event,
|
'event' => $this->event,
|
||||||
'start' => $this->start,
|
'start' => $this->start,
|
||||||
'end' => $this->end
|
'end' => $this->end,
|
||||||
|
'copyWeekContext' => $this->copyWeekContext
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
/* @var $event Event */
|
/* @var $event Event */
|
||||||
/* @var $start DateTime */
|
/* @var $start DateTime */
|
||||||
/* @var $end DateTime */
|
/* @var $end DateTime */
|
||||||
|
/* @var $copyWeekContext \common\modules\event\models\copy\CopyWeekContext */
|
||||||
|
|
||||||
|
|
||||||
use common\models\Event;
|
use common\models\Event;
|
||||||
use common\modules\event\models\timetable\TimeTableMonthDay;
|
use common\modules\event\models\timetable\TimeTableMonthDay;
|
||||||
@ -14,7 +16,13 @@ if (!isset($event)) {
|
|||||||
<?php
|
<?php
|
||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
<div class="alert alert-success">
|
<div class="alert alert-success" onclick=" ">
|
||||||
|
<?php if ( isset($copyWeekContext)) {?>
|
||||||
|
<div>
|
||||||
|
<?php echo Html::checkbox(Html::getInputName($copyWeekContext->copyWeekFormModel, 'selectedEvents[]') , isset($copyWeekContext->copyWeekFormModel->selectedEvents) && in_array($event->id, $copyWeekContext->copyWeekFormModel->selectedEvents), ['value' => $event->id] ); ?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<?php }?>
|
||||||
<?= Html::a( $start->format('H:i') .'-' . $end->format('H:i') , Url::toRoute(['event/update', 'id' => $event->id ] ) ) ?>
|
<?= Html::a( $start->format('H:i') .'-' . $end->format('H:i') , Url::toRoute(['event/update', 'id' => $event->id ] ) ) ?>
|
||||||
<br>
|
<br>
|
||||||
<?= Html::a( $event->eventType->name ,
|
<?= Html::a( $event->eventType->name ,
|
||||||
|
|||||||
@ -15,25 +15,27 @@ class TimeTableMonthView extends Widget
|
|||||||
{
|
{
|
||||||
public $timeTable;
|
public $timeTable;
|
||||||
public $actionsColumn;
|
public $actionsColumn;
|
||||||
|
public $copyWeekContext;
|
||||||
|
|
||||||
public function run() {
|
public function run() {
|
||||||
return $this->render('_timetable', [
|
return $this->render('_timetable', [
|
||||||
'timeTable' => $this->timeTable,
|
'timeTable' => $this->timeTable,
|
||||||
'actionsColumn' => ( isset($this->actionsColumn) ? $this->actionsColumn : null)
|
'actionsColumn' => ( isset($this->actionsColumn) ? $this->actionsColumn : null),
|
||||||
|
'copyWeekContext' => $this->copyWeekContext
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function renderDay($weekDay ){
|
public static function renderDay($weekDay , $copyWeekContext = null){
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TimeTableMonthWeek $week
|
* @param TimeTableMonthWeek $week
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
return static function ($week) use ($weekDay) {
|
return static function ($week) use ($weekDay, $copyWeekContext) {
|
||||||
return TimeTableMonthDayView::widget([
|
return TimeTableMonthDayView::widget([
|
||||||
'day' => $week->getWeekDay($weekDay),
|
'day' => $week->getWeekDay($weekDay),
|
||||||
|
'copyWeekContext' => $copyWeekContext
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* @var $timeTable TimeTableMonth */
|
/* @var $timeTable TimeTableMonth */
|
||||||
|
/* @var $copyWeekContext \common\modules\event\models\copy\CopyWeekContext */
|
||||||
|
|
||||||
use common\models\Event;
|
use common\models\Event;
|
||||||
use common\modules\event\models\timetable\TimeTableMonth;
|
use common\modules\event\models\timetable\TimeTableMonth;
|
||||||
@ -24,44 +25,44 @@ $columns = [
|
|||||||
'attribute' => 'monday',
|
'attribute' => 'monday',
|
||||||
'label' => 'Hétfő',
|
'label' => 'Hétfő',
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'value' => TimeTableMonthView::renderDay('monday')
|
'value' => TimeTableMonthView::renderDay('monday',$copyWeekContext)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'tuesday',
|
'attribute' => 'tuesday',
|
||||||
'label' => 'Kedd',
|
'label' => 'Kedd',
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'value' => TimeTableMonthView::renderDay('tuesday')
|
'value' => TimeTableMonthView::renderDay('tuesday',$copyWeekContext)
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'attribute' => 'wednesday',
|
'attribute' => 'wednesday',
|
||||||
'label' => 'Szerda',
|
'label' => 'Szerda',
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'value' => TimeTableMonthView::renderDay('wednesday')
|
'value' => TimeTableMonthView::renderDay('wednesday',$copyWeekContext)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'thursday',
|
'attribute' => 'thursday',
|
||||||
'label' => 'Csütörtök',
|
'label' => 'Csütörtök',
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'value' => TimeTableMonthView::renderDay('thursday')
|
'value' => TimeTableMonthView::renderDay('thursday',$copyWeekContext)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'friday',
|
'attribute' => 'friday',
|
||||||
'label' => 'Péntek',
|
'label' => 'Péntek',
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'value' => TimeTableMonthView::renderDay('friday')
|
'value' => TimeTableMonthView::renderDay('friday',$copyWeekContext)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'saturday',
|
'attribute' => 'saturday',
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'label' => 'Szombat',
|
'label' => 'Szombat',
|
||||||
'value' => TimeTableMonthView::renderDay('saturday')
|
'value' => TimeTableMonthView::renderDay('saturday',$copyWeekContext)
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'attribute' => 'Sunday',
|
'attribute' => 'Sunday',
|
||||||
'label' => 'Vasárnap',
|
'label' => 'Vasárnap',
|
||||||
'format' => 'raw',
|
'format' => 'raw',
|
||||||
'value' => TimeTableMonthView::renderDay('sunday')
|
'value' => TimeTableMonthView::renderDay('sunday',$copyWeekContext)
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user