add basic event objects

This commit is contained in:
Roland Schneider
2018-12-12 20:42:17 +01:00
parent 5599d2ef4b
commit b6e590f196
54 changed files with 2811 additions and 0 deletions

View File

@@ -0,0 +1,24 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: rocho
* Date: 2018.12.06.
* Time: 7:55
*/
return [
'ID' => 'ID',
'Name' => 'Név',
'Create Event Type' => 'Új esemény Típus',
'Update Event Type:' => 'Esemény Típus adatainak módosítása:',
'Event Types' => 'Esemény Típusok',
'Created At' => 'Létrehozási dátum, idő',
'Updated At' => 'Módosítási dátum, idő',
'Search' => 'Keres',
'Create' => 'Mentés',
'Update' => 'Módosít',
'Delete' => 'Törlés',
'All' => 'Mind',
];

View File

@@ -0,0 +1,36 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: rocho
* Date: 2018.12.06.
* Time: 7:55
*/
return [
'ID' => 'ID',
'Name' => 'Név',
'Seat Count' => 'Férőhelyek száma',
'Create Event' => 'Új esemény',
'Update Event:' => 'Esemény adatainak módosítása:',
'Events' => 'Események',
'Created At' => 'Létrehozási dátum, idő',
'Updated At' => 'Módosítási dátum, idő',
'Search' => 'Keres',
'Create' => 'Mentés',
'Update' => 'Módosít',
'Delete' => 'Törlés',
'All' => 'Mind',
'Start' => 'Esemény kezdete',
'End' => 'Esemény vége',
'Room Name' => 'Terem',
'Trainer Name' => 'Edző',
'Event start' => 'Esemény Kezdete',
'Event end' => 'Esemény vége',
'Id Room' => 'Terem',
'Id Trainer' => 'Edző',
'Id Event Type' => 'Esemény Típus',
'Registration Count' => 'Résztvevők'
];

View File

@@ -0,0 +1,25 @@
<?php
/**
* Created by IntelliJ IDEA.
* User: rocho
* Date: 2018.12.06.
* Time: 7:55
*/
return [
'ID' => 'ID',
'Name' => 'Név',
'Seat Count' => 'Férőhelyek száma',
'Create Room' => 'Új terem',
'Update Room:' => 'Terem adatainak módosítása:',
'Rooms' => 'Termek',
'Created At' => 'Létrehozási dátum, idő',
'Updated At' => 'Módosítási dátum, idő',
'Search' => 'Keres',
'Create' => 'Mentés',
'Update' => 'Módosít',
'Delete' => 'Törlés',
'All' => 'Mind',
];

View File

@@ -0,0 +1,38 @@
<?php
/**
* Message translations.
*
* This file is automatically generated by 'yii message' command.
* It contains the localizable messages extracted from source code.
* You may modify this file by translating the extracted messages.
*
* Each array element represents the translation (value) of a message (key).
* If the value is empty, the message is considered as not translated.
* Messages that no longer need translation will have their translations
* enclosed between a pair of '@@' marks.
*
* Message string can be used with plural forms format. Check i18n section
* of the guide for details.
*
* NOTE: this file must be saved in UTF-8 encoding.
*/
return [
'ID' => 'ID',
'Name' => 'Név',
'Phone' => 'Telefon',
'Email' => 'E-Mail',
'Password' => 'Jelszó',
'Active' => 'Aktív',
'Created At' => 'Létrehozási dátum, idő',
'Updated At' => 'Módosítási dátum, idő',
'Create Trainer' => 'Új edző',
'Trainers' => 'Edzők',
'Search' => 'Keres',
'Create' => 'Mentés',
'Update' => 'Módosít',
'Delete' => 'Törlés',
'active_on' => 'Aktív',
'active_off' => 'Inaktív',
'Update Trainer:' => 'Edző adatainak módosítása:',
'All' => 'Mind',
];

111
common/models/Event.php Normal file
View File

@@ -0,0 +1,111 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event".
*
// * @property integer $id
* @property integer $start
* @property integer $end
* @property integer $id_room
* @property integer $id_trainer
* @property integer $id_event_type
* @property string $created_at
* @property string $updated_at
*/
class Event extends \yii\db\ActiveRecord
{
public $startDateString;
public $endDateString;
public $timestampStart;
public $timestampEnd;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'event';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['startDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'start', 'timeZone' => 'UTC'],
[['endDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'end' , 'timeZone' => 'UTC'],
[['id_trainer','id_room', 'id_event_type'], 'required'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('event', 'ID'),
'start' => Yii::t('event', 'Start'),
'end' => Yii::t('event', 'End'),
'id_room' => Yii::t('event', 'Id Room'),
'id_trainer' => Yii::t('event', 'Id Trainer'),
'id_event_type' => Yii::t('event', 'Id Event Type'),
'created_at' => Yii::t('event', 'Created At'),
'updated_at' => Yii::t('event', 'Updated At'),
'trainerName' => Yii::t('event', 'Trainer Name'),
'roomName' => Yii::t('event', 'Room Name'),
'eventTypeName' => Yii::t('event', 'Típus'),
'event_start' => Yii::t('event', 'Start'),
'event_end' => Yii::t('event', 'End'),
'startDateString' => Yii::t('event', 'Start'),
'endDateString' => Yii::t('event', 'End'),
'status' => Yii::t('event', 'Status'),
];
}
public function afterFind()
{
parent::afterFind(); // TODO: Change the autogenerated stub
$format = "Y.m.d H:i";
$date = new \DateTime();
$date->setTimestamp($this->start);
$date->setTimezone(new \DateTimeZone('UTC'));
$this->startDateString = $date->format($format);
$date->setTimestamp($this->end);
$this->endDateString = $date->format($format);
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
public function getEventType(){
return $this->hasOne(EventType::className(),['id' => 'id_event_type']);
}
public function getTrainer(){
return $this->hasOne(Trainer::className(),['id' => 'id_trainer']);
}
public function getRoom(){
return $this->hasOne(Room::className(),['id' => 'id_room']);
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "event_registration".
*
* @property integer $id
* @property integer $id_event
* @property integer $id_customer
* @property string $created_at
* @property string $updated_at
* @property string $canceled_at
*/
class EventRegistration extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'event_registration';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_event', 'id_customer'], 'integer'],
[['created_at', 'updated_at', 'canceled_at'], 'required'],
[['created_at', 'updated_at', 'canceled_at'], 'safe']
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('event-registration', 'ID'),
'id_event' => Yii::t('event-registration', 'Id Event'),
'id_customer' => Yii::t('event-registration', 'Id Customer'),
'created_at' => Yii::t('event-registration', 'Created At'),
'updated_at' => Yii::t('event-registration', 'Updated At'),
'canceled_at' => Yii::t('event-registration', 'Canceled At'),
];
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "event_type".
*
* @property integer $id
* @property string $name
* @property string $created_at
* @property string $updated_at
*/
class EventType extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'event_type';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name'], 'required'],
[['name'], 'unique'],
[['name'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('event-type', 'ID'),
'name' => Yii::t('event-type', 'Name'),
'created_at' => Yii::t('event-type', 'Created At'),
'updated_at' => Yii::t('event-type', 'Updated At'),
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
public function asOptions(){
$items = ArrayHelper::map(EventType::find()->all(),'id','name');
return ArrayHelper::merge(['' => \Yii::t('event-type','All')],$items);
}
public static function eventTypeOptions($all = false, $emptyString = false){
$items = ArrayHelper::map(EventType::find()->all(),'id','name');
$extra = [];
if ( $all ) {
$extra = ['' => \Yii::t('event-type','All')];
}
if ( $emptyString ) {
$extra = ['' => '' ];
}
return ArrayHelper::merge($extra,$items);
}
}

83
common/models/Room.php Normal file
View File

@@ -0,0 +1,83 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "room".
*
* @property integer $id
* @property string $name
* @property integer $seat_count
* @property string $created_at
* @property string $updated_at
*/
class Room extends \yii\db\ActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'room';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['name', 'seat_count'], 'required'],
[['seat_count'], 'integer'],
[['name'], 'unique'],
[['name'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('room', 'ID'),
'name' => Yii::t('room', 'Name'),
'seat_count' => Yii::t('room', 'Seat Count'),
'created_at' => Yii::t('room', 'Created At'),
'updated_at' => Yii::t('room', 'Updated At'),
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
public function asOptions(){
$items = ArrayHelper::map(Room::find()->all(),'id','name');
return ArrayHelper::merge(['' => \Yii::t('event-type','All')],$items);
}
public static function roomOptions($all = false, $emtpyString = false){
$items = ArrayHelper::map(Room::find()->all(),'id','name');
$extra = [];
if ( $all ) {
$extra = ['' => \Yii::t('room','All')];
}
if ( $emtpyString ) {
$extra = ['' => '' ];
}
return ArrayHelper::merge($extra,$items);
}
}

94
common/models/Trainer.php Normal file
View File

@@ -0,0 +1,94 @@
<?php
namespace common\models;
use Yii;
use yii\behaviors\TimestampBehavior;
use yii\helpers\ArrayHelper;
/**
* This is the model class for table "trainer".
*
* @property integer $id
* @property string $name
* @property string $phone
* @property string $email
* @property string $password
* @property integer $active
* @property string $created_at
* @property string $updated_at
*/
class Trainer extends \yii\db\ActiveRecord
{
const ACTIVE_ON = 1;
const ACTIVE_OFF = 0;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'trainer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['active'], 'integer'],
[['name', 'email'], 'string', 'max' => 255],
[['phone'], 'string', 'max' => 20],
[['name','phone','email'] , 'required'],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id' => Yii::t('trainer', 'ID'),
'name' => Yii::t('trainer', 'Name'),
'phone' => Yii::t('trainer', 'Phone'),
'email' => Yii::t('trainer', 'Email'),
'password' => Yii::t('trainer', 'Password'),
'active' => Yii::t('trainer', 'Active'),
'created_at' => Yii::t('trainer', 'Created At'),
'updated_at' => Yii::t('trainer', 'Updated At'),
];
}
public function behaviors()
{
return ArrayHelper::merge( [
[
'class' => TimestampBehavior::className(),
'value' => function(){ return date('Y-m-d H:i:s' ); }
]
],
parent::behaviors());
}
public static function prettyPrintActive($active){
if ( $active == Trainer::ACTIVE_ON ){
return \Yii::t("trainer",'active_on');
}
return \Yii::t("trainer",'active_off');
}
public static function trainerOptions($all = false, $emptyString = false){
$items = ArrayHelper::map(Trainer::find()->all(),'id','name');
$extra = [];
if ( $all ) {
$extra = ['' => \Yii::t('trainer','All')];
}
if ( $emptyString ) {
$extra = ['' => '' ];
}
return ArrayHelper::merge($extra,$items);
}
}