guild/console/controllers/MovingController.php

49 lines
1.3 KiB
PHP
Raw Normal View History

2019-06-27 17:36:56 +03:00
<?php
namespace console\controllers;
use common\models\FieldsValueNew;
use yii\console\Controller;
class MovingController extends Controller
{
/*const TYPE_PROFILE = 0;
const TYPE_PROJECT = 1;
const TYPE_COMPANY = 2;
const TYPE_BALANCE = 3;*/
public function actionIndex()
{
$field_value = \common\models\FieldsValue::find()->all();
2019-06-28 11:36:50 +03:00
foreach ($field_value as $item)
2019-06-27 17:36:56 +03:00
{
2019-06-28 11:36:50 +03:00
$new_value = new FieldsValueNew();
$new_value->order = $item->order;
$new_value->field_id = $item->field_id;
$new_value->value = $item->value;
if($item->card_id != null)
2019-06-27 17:36:56 +03:00
{
2019-06-28 11:36:50 +03:00
$new_value->item_type = 0;
$new_value->item_id = $item->card_id;
2019-06-27 17:36:56 +03:00
}
2019-06-28 11:36:50 +03:00
if($item->balance_id != null)
2019-06-27 17:36:56 +03:00
{
2019-06-28 11:36:50 +03:00
$new_value->item_type = 3 ;
$new_value->item_id = $item->balance_id;
2019-06-27 17:36:56 +03:00
}
2019-06-28 11:36:50 +03:00
if($item->project_id != null)
2019-06-27 17:36:56 +03:00
{
2019-06-28 11:36:50 +03:00
$new_value->item_type = 1;
$new_value->item_id = $item->project_id;
2019-06-27 17:36:56 +03:00
}
2019-06-28 11:36:50 +03:00
if($item->company_id!= null)
2019-06-27 17:36:56 +03:00
{
2019-06-28 11:36:50 +03:00
$new_value->item_type = 2;
$new_value->item_id = $item->company_id;
2019-06-27 17:36:56 +03:00
}
2019-06-28 11:36:50 +03:00
$new_value->save();
2019-06-27 17:36:56 +03:00
}
}
}