Add waste
This commit is contained in:
43
console/controllers/DetstaConsoleController.php
Normal file
43
console/controllers/DetstaConsoleController.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace console\controllers;
|
||||
|
||||
|
||||
use yii\console\Controller;
|
||||
use frontend\models\ContractForm;
|
||||
use common\models\TicketType;
|
||||
use common\models\Customer;
|
||||
use common\models\Transfer;
|
||||
|
||||
|
||||
class DetstaConsoleController extends Controller{
|
||||
|
||||
|
||||
public function actionCreateContract(){
|
||||
|
||||
|
||||
$contractForm = new ContractForm(
|
||||
[
|
||||
'idAccount' => 1,
|
||||
'idUser' => 1
|
||||
]
|
||||
);
|
||||
|
||||
$customer = Customer::findOne(5559);
|
||||
$contractForm->customer = $customer;
|
||||
$contractForm->payment_method = Transfer::PAYMENT_METHOD_TRANSFER;
|
||||
|
||||
|
||||
$contractForm->ticketType = TicketType::find()->andWhere(['status' => TicketType::STATUS_ACTIVE ,'installment_enabled' => '1'])->one();
|
||||
|
||||
|
||||
$start = new \DateTime();
|
||||
$startString = $start->format("'Y-m-d");
|
||||
|
||||
|
||||
$contractForm->make();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
48
console/migrations/m160502_055142_add_table_waste.php
Normal file
48
console/migrations/m160502_055142_add_table_waste.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
use yii\db\Schema;
|
||||
use yii\db\Migration;
|
||||
|
||||
class m160502_055142_add_table_waste extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$tableOptions = null;
|
||||
if ($this->db->driverName === 'mysql') {
|
||||
// http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
|
||||
$tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
|
||||
}
|
||||
|
||||
$this->createTable('{{%waste}}', [
|
||||
'id_waste' => $this->primaryKey(),
|
||||
'count' => $this->integer(11),
|
||||
'id_product' => $this->integer(11),
|
||||
'stock_before' => $this->integer(11),
|
||||
'stock_after' => $this->integer(11),
|
||||
'id_user' => $this->integer(11),
|
||||
'comment' => $this->string(),
|
||||
'created_at' => $this->dateTime()->notNull(),
|
||||
'updated_at' => $this->dateTime()->notNull(),
|
||||
], $tableOptions);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
echo "m160502_055142_add_table_waste cannot be reverted.\n";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
// Use safeUp/safeDown to run migration code within a transaction
|
||||
public function safeUp()
|
||||
{
|
||||
}
|
||||
|
||||
public function safeDown()
|
||||
{
|
||||
}
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user