add basic event objects
This commit is contained in:
69
backend/models/EventRegistrationSearch.php
Normal file
69
backend/models/EventRegistrationSearch.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\EventRegistration;
|
||||
|
||||
/**
|
||||
* EventRegistrationSearch represents the model behind the search form about `common\models\EventRegistration`.
|
||||
*/
|
||||
class EventRegistrationSearch extends EventRegistration
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'id_event', 'id_customer'], 'integer'],
|
||||
[['created_at', 'updated_at', 'canceled_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = EventRegistration::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'id_event' => $this->id_event,
|
||||
'id_customer' => $this->id_customer,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
'canceled_at' => $this->canceled_at,
|
||||
]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
153
backend/models/EventSearch.php
Normal file
153
backend/models/EventSearch.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use common\components\Helper;
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Event;
|
||||
use yii\db\Expression;
|
||||
use yii\db\Query;
|
||||
|
||||
/**
|
||||
* EventSearch represents the model behind the search form about `common\models\Event`.
|
||||
*/
|
||||
class EventSearch extends Event
|
||||
{
|
||||
|
||||
public $roomName;
|
||||
public $trainerName;
|
||||
public $eventTypeName;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id','roomName', 'trainerName','eventTypeName'], 'string' , 'max' => 250],
|
||||
[['startDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'start', 'timeZone' => 'UTC'],
|
||||
[['endDateString',], 'date', 'format' => Yii::$app->formatter->datetimeFormat, 'timestampAttribute' => 'end' , 'timeZone' => 'UTC'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = new Query();
|
||||
|
||||
$query->select([
|
||||
'event.id as event_id',
|
||||
'event.start as event_start',
|
||||
'event.end as event_end',
|
||||
'event.created_at as event_created_at',
|
||||
'event.updated_at as event_updated_at',
|
||||
'trainer.name as trainer_name',
|
||||
'room.name as room_name',
|
||||
'event_type.name as event_type_name',
|
||||
new Expression('count(event_registration.id) as registration_count')
|
||||
]);
|
||||
|
||||
$query->from("event");
|
||||
$query->innerJoin('trainer', 'event.id_trainer = trainer.id');
|
||||
$query->innerJoin('room', 'event.id_room = room.id');
|
||||
$query->innerJoin('event_type', 'event_type.id = event.id_event_type');
|
||||
$query->leftJoin('event_registration', 'event_registration.id_event = event.id' );
|
||||
$query->groupBy(
|
||||
[
|
||||
'event_id',
|
||||
'event_start',
|
||||
'event_end',
|
||||
'event_created_at',
|
||||
'event_updated_at',
|
||||
'trainer_name',
|
||||
'room_name',
|
||||
'event_type_name',
|
||||
]
|
||||
);
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
'sort' => [
|
||||
'defaultOrder' => [
|
||||
'event_start' => SORT_DESC
|
||||
],
|
||||
'attributes' => Helper::mkYiiSortItems([
|
||||
['event_id'],
|
||||
['event_start'],
|
||||
['event_end'],
|
||||
['trainer_name'],
|
||||
['room_name'],
|
||||
['event_type_name'],
|
||||
['customer_name'],
|
||||
['event_created_at'],
|
||||
['event_updated_at'],
|
||||
['registration_count'],
|
||||
]),
|
||||
]
|
||||
]) ;
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'event.id' => $this->id,
|
||||
]);
|
||||
$query->andFilterWhere(
|
||||
[ 'room.id' => $this->roomName]
|
||||
);
|
||||
|
||||
$query->andFilterWhere(
|
||||
[ 'trainer.id' => $this->trainerName]
|
||||
);
|
||||
|
||||
$query->andFilterWhere(
|
||||
[ 'event_type.id' => $this->eventTypeName]
|
||||
);
|
||||
|
||||
if ( isset($this->start)){
|
||||
$query->andWhere(
|
||||
[
|
||||
'>=',
|
||||
'start' ,
|
||||
$this->start
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ( isset($this->end)){
|
||||
$query->andWhere(
|
||||
[
|
||||
'<=',
|
||||
'end' ,
|
||||
$this->end
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
68
backend/models/EventTypeSearch.php
Normal file
68
backend/models/EventTypeSearch.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\EventType;
|
||||
|
||||
/**
|
||||
* EventTypeSearch represents the model behind the search form about `common\models\EventType`.
|
||||
*/
|
||||
class EventTypeSearch extends EventType
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id'], 'integer'],
|
||||
[['name', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = EventType::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
69
backend/models/RoomSearch.php
Normal file
69
backend/models/RoomSearch.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Room;
|
||||
|
||||
/**
|
||||
* RoomSearch represents the model behind the search form about `common\models\Room`.
|
||||
*/
|
||||
class RoomSearch extends Room
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'seat_count'], 'integer'],
|
||||
[['name', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Room::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'seat_count' => $this->seat_count,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
72
backend/models/TrainerSearch.php
Normal file
72
backend/models/TrainerSearch.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
namespace backend\models;
|
||||
|
||||
use Yii;
|
||||
use yii\base\Model;
|
||||
use yii\data\ActiveDataProvider;
|
||||
use common\models\Trainer;
|
||||
|
||||
/**
|
||||
* TrainerSearch represents the model behind the search form about `common\models\Trainer`.
|
||||
*/
|
||||
class TrainerSearch extends Trainer
|
||||
{
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['id', 'active'], 'integer'],
|
||||
[['name', 'phone', 'email', 'password', 'created_at', 'updated_at'], 'safe'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function scenarios()
|
||||
{
|
||||
// bypass scenarios() implementation in the parent class
|
||||
return Model::scenarios();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates data provider instance with search query applied
|
||||
*
|
||||
* @param array $params
|
||||
*
|
||||
* @return ActiveDataProvider
|
||||
*/
|
||||
public function search($params)
|
||||
{
|
||||
$query = Trainer::find();
|
||||
|
||||
$dataProvider = new ActiveDataProvider([
|
||||
'query' => $query,
|
||||
]);
|
||||
|
||||
$this->load($params);
|
||||
|
||||
if (!$this->validate()) {
|
||||
// uncomment the following line if you do not want to return any records when validation fails
|
||||
// $query->where('0=1');
|
||||
return $dataProvider;
|
||||
}
|
||||
|
||||
$query->andFilterWhere([
|
||||
'id' => $this->id,
|
||||
'active' => $this->active,
|
||||
'created_at' => $this->created_at,
|
||||
'updated_at' => $this->updated_at,
|
||||
]);
|
||||
|
||||
$query->andFilterWhere(['like', 'name', $this->name])
|
||||
->andFilterWhere(['like', 'phone', $this->phone])
|
||||
->andFilterWhere(['like', 'email', $this->email])
|
||||
->andFilterWhere(['like', 'password', $this->password]);
|
||||
|
||||
return $dataProvider;
|
||||
}
|
||||
}
|
||||
@@ -167,6 +167,8 @@ class TransferSearch extends Transfer
|
||||
}
|
||||
}
|
||||
|
||||
['like', 'name', ['test', 'sample']]
|
||||
|
||||
$query->andFilterWhere([
|
||||
'transfer.id_account' => $this->id_account,
|
||||
'transfer.status' => $this->status,
|
||||
|
||||
Reference in New Issue
Block a user