add accompanying document

This commit is contained in:
iIronside
2022-01-11 12:06:01 +03:00
parent 9c07e81fab
commit aaf4ee9f53
15 changed files with 1418 additions and 0 deletions

View File

@ -14,7 +14,10 @@ class m220110_205045_create_accompanying_document_table extends Migration
{
$this->createTable('{{%accompanying_document}}', [
'id' => $this->primaryKey(),
'document_id' => $this->integer(11),
'title' => $this->string()->notNull(),
]);
$this->addForeignKey('document_accompanying_document', 'accompanying_document', 'document_id', 'document', 'id');
}
/**
@ -22,6 +25,7 @@ class m220110_205045_create_accompanying_document_table extends Migration
*/
public function safeDown()
{
$this->dropForeignKey('document_accompanying_document', 'accompanying_document');
$this->dropTable('{{%accompanying_document}}');
}
}

View File

@ -0,0 +1,63 @@
<?php
use yii\db\Migration;
/**
* Class m220111_082339_add_default_templates
*/
class m220111_082339_add_default_templates extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$time = new \yii\db\Expression('NOW()');
Yii::$app->db->createCommand()->batchInsert('template', [ 'title', 'created_at' ],
[
['Акт', $time],
['Акт сверки', $time],
['Детализация', $time],
['Доверенность', $time],
['Договор', $time],
['Доп соглашение к договору', $time],
['Транспортная накладная', $time],
['Ценовой лист', $time],
])->execute();
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
Yii::$app->db->createCommand()->delete('template',
[
'in', 'title', [
'Акт',
'Акт сверки',
'Детализация',
'Доверенность',
'Договор',
'Доп соглашение к договору',
'Транспортная накладная',
'Ценовой лист',
]
])->execute();
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m220111_082339_add_default_templates cannot be reverted.\n";
return false;
}
*/
}

View File

@ -0,0 +1,62 @@
<?php
use yii\db\Migration;
/**
* Class m220111_084946_add_default_document_field
*/
class m220111_084946_add_default_document_field extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
Yii::$app->db->createCommand()->batchInsert('document_field', [ 'title', 'field_template'],
[
['№ документа', '№ dokumenta'],
['от', 'ot'],
['Сумма с НДС', 'Summa s NDS'],
['НДС', 'NDS'],
['Основание', 'Osnovaniye'],
['Цена', 'Tsena'],
['К договору', 'K dogovoru'],
['№', '№']
])->execute();
}
/**
* {@inheritdoc}
*/
public function safeDown()
{
Yii::$app->db->createCommand()->delete('document_field',
[
'in', 'title', [
'№ документа',
'от',
'Сумма с НДС',
'НДС',
'Основание',
'Цена',
'К договору',
'№',
]
])->execute();
}
/*
// Use up()/down() to run migration code without a transaction.
public function up()
{
}
public function down()
{
echo "m220111_084946_add_default_document_field cannot be reverted.\n";
return false;
}
*/
}