add_holidays
This commit is contained in:
53
common/models/Holiday.php
Normal file
53
common/models/Holiday.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use yii\db\ActiveRecord;
|
||||
|
||||
/**
|
||||
*@property int $id
|
||||
*@property int $card_id
|
||||
* @property int $dt_start
|
||||
* @property int $dt_end
|
||||
*/
|
||||
class Holiday extends ActiveRecord
|
||||
{
|
||||
public function init()
|
||||
{
|
||||
parent::init(); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
public static function tableName()
|
||||
{
|
||||
return 'holiday'; // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['card_id', 'dt_start', 'dt_end'], 'integer'],
|
||||
// [['card_id', 'dt_start', 'dt_end'], 'required'],
|
||||
];
|
||||
}
|
||||
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'card_id' => 'ID пользователя',
|
||||
'dt_start' => 'Дата начала отпуска',
|
||||
'dt_end' => 'Дата конца отпуска'
|
||||
];
|
||||
}
|
||||
|
||||
public function afterFind()
|
||||
{
|
||||
parent::afterFind(); // TODO: Change the autogenerated stub
|
||||
$this->dt_start = date('d-m-Y', $this->dt_start);
|
||||
$this->dt_end = date('d-m-Y', $this->dt_end);
|
||||
}
|
||||
|
||||
public function getUsers()
|
||||
{
|
||||
return $this->hasOne(UserCard::className(),['id' => 'card_id']);
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use common\classes\Debug;
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
use yii\db\Expression;
|
||||
@ -151,4 +152,9 @@ class UserCard extends \yii\db\ActiveRecord
|
||||
{
|
||||
return ArrayHelper::map(Skill::find()->all(),'id', 'name');
|
||||
}
|
||||
|
||||
public static function getUserList()
|
||||
{
|
||||
return ArrayHelper::map(self::find()->all(), 'id', 'fio');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user