-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d78d276
commit d36ef88
Showing
6 changed files
with
357 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,25 +8,28 @@ | |
|
||
namespace skeeks\cms\measure\controllers; | ||
|
||
use skeeks\cms\backend\BackendController; | ||
use skeeks\cms\backend\controllers\BackendModelStandartController; | ||
use skeeks\cms\backend\grid\DefaultActionColumn; | ||
use skeeks\cms\backend\ViewBackendAction; | ||
use skeeks\cms\kladr\models\KladrLocation; | ||
use skeeks\cms\measure\models\Measure; | ||
use skeeks\cms\measure\models\CmsMeasure; | ||
use skeeks\yii2\form\fields\FieldSet; | ||
use skeeks\yii2\form\fields\NumberField; | ||
use yii\helpers\ArrayHelper; | ||
|
||
/** | ||
* @author Semenov Alexander <[email protected]> | ||
*/ | ||
class AdminMeasureController extends BackendController | ||
class AdminMeasureController extends BackendModelStandartController | ||
{ | ||
public function init() | ||
{ | ||
$this->name = \Yii::t('skeeks/measure', 'Units of measurement'); | ||
/*$this->name = \Yii::t('skeeks/measure', 'Units of measurement'); | ||
$this->modelShowAttribute = "code"; | ||
$this->modelClassName = Measure::className(); | ||
|
||
$this->generateAccessActions = false;*/ | ||
$this->modelShowAttribute = "asText"; | ||
$this->modelClassName = CmsMeasure::class; | ||
|
||
$this->generateAccessActions = false; | ||
|
||
parent::init(); | ||
} | ||
|
@@ -37,28 +40,38 @@ public function init() | |
public function actions() | ||
{ | ||
return ArrayHelper::merge(parent::actions(), [ | ||
'index' => [ | ||
'classifier' => [ | ||
'class' => ViewBackendAction::class, | ||
] | ||
/*'index' => [ | ||
'name' => 'Классификатор', | ||
'icon' => 'fa fa-list' | ||
], | ||
'index' => [ | ||
'filters' => [ | ||
'visibleFilters' => [ | ||
'code', | ||
'name', | ||
], | ||
], | ||
'grid' => [ | ||
'defaultOrder' => [ | ||
//'def' => SORT_DESC, | ||
'priority' => SORT_ASC | ||
], | ||
"visibleColumns" => [ | ||
'checkbox', | ||
'actions', | ||
|
||
'code', | ||
'name', | ||
'customName', | ||
|
||
'symbol', | ||
'symbol_intl', | ||
'symbol_letter_intl', | ||
'priority', | ||
], | ||
'columns' => [ | ||
'customName' => [ | ||
'attribute' => 'name', | ||
'class' => DefaultActionColumn::class, | ||
'viewAttribute' => 'asText' | ||
] | ||
] | ||
], | ||
], | ||
|
||
|
@@ -69,19 +82,35 @@ public function actions() | |
|
||
"update" => [ | ||
'fields' => [$this, 'updateFields'], | ||
],*/ | ||
], | ||
]); | ||
} | ||
|
||
|
||
public function updateFields() | ||
{ | ||
return [ | ||
'code', | ||
'name', | ||
'symbol', | ||
'symbol_intl', | ||
'symbol_letter_intl', | ||
'main' => [ | ||
'class' => FieldSet::class, | ||
'name' => 'Основные данные', | ||
'fields' => [ | ||
'code', | ||
'name', | ||
'symbol', | ||
] | ||
], | ||
'second' => [ | ||
'class' => FieldSet::class, | ||
'elementOptions' => ['isOpen' => false], | ||
'name' => 'Дополнительно', | ||
'fields' => [ | ||
'symbol_intl', | ||
'symbol_letter_intl', | ||
'priority' => [ | ||
'class' => NumberField::class | ||
] | ||
] | ||
], | ||
]; | ||
} | ||
|
||
|
78 changes: 78 additions & 0 deletions
78
src/migrations/m200307_090601_create_table__cms_measure.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?php | ||
/** | ||
* @author Semenov Alexander <[email protected]> | ||
* @link http://skeeks.com/ | ||
* @copyright 2010 SkeekS (СкикС) | ||
* @date 28.08.2015 | ||
*/ | ||
use yii\db\Migration; | ||
|
||
class m200307_090601_create_table__cms_measure extends Migration | ||
{ | ||
public function safeUp() | ||
{ | ||
$tableExist = $this->db->getTableSchema("{{%cms_measure}}", true); | ||
if ($tableExist) { | ||
return true; | ||
} | ||
|
||
$tableOptions = null; | ||
if ($this->db->driverName === 'mysql') { | ||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB'; | ||
} | ||
|
||
$this->createTable("{{%cms_measure}}", [ | ||
|
||
'id' => $this->primaryKey(), | ||
|
||
'created_by' => $this->integer(), | ||
'updated_by' => $this->integer(), | ||
|
||
'created_at' => $this->integer(), | ||
'updated_at' => $this->integer(), | ||
|
||
'code' => $this->string(20)->notNull()->unique(), | ||
'name' => $this->string(128)->notNull(), | ||
|
||
'symbol' => $this->string(20), | ||
|
||
'symbol_intl' => $this->string(20), | ||
'symbol_letter_intl' => $this->string(20), | ||
|
||
'priority' => $this->integer()->notNull()->defaultValue(500), | ||
|
||
], $tableOptions); | ||
|
||
|
||
$this->createIndex('cms_measure__updated_by', '{{%cms_measure}}', 'updated_by'); | ||
$this->createIndex('cms_measure__created_by', '{{%cms_measure}}', 'created_by'); | ||
$this->createIndex('cms_measure__created_at', '{{%cms_measure}}', 'created_at'); | ||
$this->createIndex('cms_measure__updated_at', '{{%cms_measure}}', 'updated_at'); | ||
|
||
$this->createIndex('cms_measure__name', '{{%cms_measure}}', 'name'); | ||
|
||
$this->createIndex('cms_measure__code', '{{%cms_measure}}', 'code'); | ||
$this->createIndex('cms_measure__symbol', '{{%cms_measure}}', 'symbol'); | ||
$this->createIndex('cms_measure__symbol_intl', '{{%cms_measure}}', 'symbol_intl'); | ||
$this->createIndex('cms_measure__symbol_letter_intl', '{{%cms_measure}}', 'symbol_letter_intl'); | ||
$this->createIndex('cms_measure__priority', '{{%cms_measure}}', 'priority'); | ||
|
||
$this->addForeignKey( | ||
'cms_measure_created_by', "{{%cms_measure}}", | ||
'created_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL' | ||
); | ||
|
||
$this->addForeignKey( | ||
'cms_measure_updated_by', "{{%cms_measure}}", | ||
'updated_by', '{{%cms_user}}', 'id', 'SET NULL', 'SET NULL' | ||
); | ||
|
||
|
||
} | ||
|
||
public function safeDown() | ||
{ | ||
echo "m191204_180601_alter_table__measure cannot be reverted.\n"; | ||
return false; | ||
} | ||
} |
104 changes: 104 additions & 0 deletions
104
src/migrations/m200307_090602_append_data_table__cms_measure.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
/** | ||
* @author Semenov Alexander <[email protected]> | ||
* @link http://skeeks.com/ | ||
* @copyright 2010 SkeekS (СкикС) | ||
* @date 28.08.2015 | ||
*/ | ||
use yii\db\Migration; | ||
|
||
class m200307_090602_append_data_table__cms_measure extends Migration | ||
{ | ||
public function safeUp() | ||
{ | ||
$this->insert('{{%cms_measure}}', [ | ||
'code' => '796', | ||
'name' => 'Штука', | ||
'symbol' => 'шт', | ||
'symbol_intl' => 'pc. 1', | ||
'symbol_letter_intl' => 'PCE. NMB', | ||
'priority' => 100, | ||
]); | ||
|
||
|
||
$this->insert('{{%cms_measure}}', [ | ||
'code' => '778', | ||
'name' => 'Упаковка', | ||
'symbol' => 'упак', | ||
'symbol_letter_intl' => 'NMP', | ||
'priority' => 200, | ||
|
||
]); | ||
|
||
|
||
$this->insert('{{%cms_measure}}', [ | ||
'code' => '003', | ||
'name' => 'Миллиметр', | ||
'symbol' => 'мм', | ||
'symbol_intl' => 'mm', | ||
'symbol_letter_intl' => 'MMT', | ||
'priority' => 300, | ||
]); | ||
|
||
$this->insert('{{%cms_measure}}', [ | ||
'code' => '006', | ||
'name' => 'Метр', | ||
'symbol' => 'м', | ||
'symbol_intl' => 'm', | ||
'symbol_letter_intl' => 'MTR', | ||
'priority' => 310, | ||
]); | ||
|
||
|
||
$this->insert('{{%cms_measure}}', [ | ||
'code' => '163', | ||
'name' => 'Грамм', | ||
'symbol' => 'г', | ||
'symbol_intl' => 'g', | ||
'symbol_letter_intl' => 'GRM', | ||
'priority' => 320, | ||
]); | ||
|
||
$this->insert('{{%cms_measure}}', [ | ||
'code' => '166', | ||
'name' => 'Килограмм', | ||
'symbol' => 'кг', | ||
'symbol_intl' => 'kg', | ||
'symbol_letter_intl' => 'KGM', | ||
'priority' => 330, | ||
]); | ||
|
||
|
||
$this->insert('{{%cms_measure}}', [ | ||
'code' => '112', | ||
'name' => 'Литр', | ||
'symbol' => 'л', | ||
'symbol_intl' => 'l', | ||
'symbol_letter_intl' => 'LTR', | ||
'priority' => 340, | ||
]); | ||
|
||
|
||
$this->insert('{{%cms_measure}}', [ | ||
'code' => '055', | ||
'name' => 'Квадратный метр', | ||
'symbol' => 'м2', | ||
'symbol_intl' => 'm2', | ||
'symbol_letter_intl' => 'MTK', | ||
'priority' => 350, | ||
]); | ||
|
||
$this->insert('{{%cms_measure}}', [ | ||
'code' => '383', | ||
'name' => 'Рубль', | ||
'symbol' => 'руб', | ||
]); | ||
|
||
} | ||
|
||
public function safeDown() | ||
{ | ||
echo "m191204_180601_alter_table__measure cannot be reverted.\n"; | ||
return false; | ||
} | ||
} |
Oops, something went wrong.