add_holidays

This commit is contained in:
SoHardKI
2019-07-16 11:58:05 +03:00
parent 3af5bcab71
commit e961c3f35f
15 changed files with 491 additions and 0 deletions

53
common/models/Holiday.php Normal file
View 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']);
}
}

View File

@ -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');
}
}