add account model + crud ( kassza )
This commit is contained in:
38
common/messages/hu/common/account.php
Normal file
38
common/messages/hu/common/account.php
Normal 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 [
|
||||
'Accounts' => 'Kasszák',
|
||||
'Account' => 'Kassza',
|
||||
'Active' => 'Aktív',
|
||||
'Create' => 'Inaktív',
|
||||
'Create Account' => 'Új kassza',
|
||||
'Created At' => 'Létrehozás ideje',
|
||||
'Id Account' => 'Azonosító',
|
||||
'Inactive' => 'Inaktív',
|
||||
'Name' => 'Név',
|
||||
'Only the name is visible' => 'Csak a név látható',
|
||||
'Reset' => '',
|
||||
'Search' => 'Keresés',
|
||||
'Status' => 'Státusz',
|
||||
'Type' => 'Típus',
|
||||
'Update' => 'Módosítás',
|
||||
'Update {modelClass}: ' => '{modelClass} módosítása: ',
|
||||
'Updated At' => 'Módosítás ideje',
|
||||
'Visible for all' => 'Mindenkinek látható',
|
||||
];
|
||||
@@ -31,4 +31,5 @@ return [
|
||||
'Update {modelClass}: ' => '{modelClass} módosítása: ',
|
||||
'Updated At' => 'Módosítás ideje',
|
||||
'Warehouses' => 'Raktárak',
|
||||
'Warehouse' => 'Raktár',
|
||||
];
|
||||
|
||||
106
common/models/Account.php
Normal file
106
common/models/Account.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace common\models;
|
||||
|
||||
use Yii;
|
||||
use yii\behaviors\TimestampBehavior;
|
||||
|
||||
/**
|
||||
* This is the model class for table "account".
|
||||
*
|
||||
* @property integer $id_account
|
||||
* @property string $name
|
||||
* @property integer $status
|
||||
* @property integer $type
|
||||
* @property string $created_at
|
||||
* @property string $updated_at
|
||||
*/
|
||||
class Account extends \yii\db\ActiveRecord
|
||||
{
|
||||
|
||||
const STATUS_DELETED = 0;
|
||||
const STATUS_ACTIVE = 10;
|
||||
|
||||
const TYPE_ALL = 0;
|
||||
const TYPE_VALUE_HIDDEN = 10;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public static function tableName()
|
||||
{
|
||||
return 'account';
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function behaviors()
|
||||
{
|
||||
return [
|
||||
[ 'class' => TimestampBehavior::className(),
|
||||
'value' => function(){ return date('Y-m-d H:i:s' ); }
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'type'], 'required'],
|
||||
[['name', ], 'unique'],
|
||||
[['status', 'type'], 'integer'],
|
||||
[['name'], 'string', 'max' => 64]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function attributeLabels()
|
||||
{
|
||||
return [
|
||||
'id_account' => Yii::t('common/account', 'Id Account'),
|
||||
'name' => Yii::t('common/account', 'Name'),
|
||||
'status' => Yii::t('common/account', 'Status'),
|
||||
'type' => Yii::t('common/account', 'Type'),
|
||||
'created_at' => Yii::t('common/account', 'Created At'),
|
||||
'updated_at' => Yii::t('common/account', 'Updated At'),
|
||||
];
|
||||
}
|
||||
|
||||
static function statuses() {
|
||||
return [
|
||||
self::STATUS_ACTIVE => Yii::t('common/account', 'Active'),
|
||||
self::STATUS_DELETED => Yii::t('common/account', 'Inactive'),
|
||||
];
|
||||
}
|
||||
|
||||
public function getStatusHuman(){
|
||||
$result = null;
|
||||
$s = self::statuses($this->status);
|
||||
if ( array_key_exists($this->status, $s)){
|
||||
$result = $s[$this->status];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
static function types() {
|
||||
return [
|
||||
self::TYPE_ALL => Yii::t('common/account', 'Visible for all'),
|
||||
self::TYPE_VALUE_HIDDEN => Yii::t('common/account', 'Only the name is visible'),
|
||||
];
|
||||
}
|
||||
|
||||
public function getTypeHuman(){
|
||||
$result = null;
|
||||
$s = self::types($this->type);
|
||||
if ( array_key_exists($this->type, $s)){
|
||||
$result = $s[$this->status];
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user