Example #1
0
 public static function importData()
 {
     $arr_error = [];
     $timeimport = time();
     foreach (ImportRaw::find()->where(['imported' => null])->each() as $rawData) {
         $data = $rawData->data;
         $arrayPos = self::getPosArray($rawData->type);
         //			$arrayPos = $$arrayPos;
         $codmodel = str_ireplace(' ', '', substr($data, $arrayPos['model'], 17));
         $codColor = trim(substr($data, $arrayPos['color'], 3));
         $codSalon = trim(substr($data, $arrayPos['salon'], 3));
         $codEnj = trim(substr($data, $arrayPos['enj'], 12));
         $prodOrd = trim(substr($data, $arrayPos['prod_ord'], 5));
         $carrier = trim(substr($data, $arrayPos['carrier'], 8));
         $keyCode = trim(substr($data, $arrayPos['key_code'], 5));
         $dateShipping = trim(substr($data, $arrayPos['date_shipping'], 8));
         $shipCode = trim(substr($data, $arrayPos['ship_code'], 3));
         $numInvoice = trim(substr($data, $arrayPos['num_invoice'], 16));
         $car = new Car();
         $car->model_id = CatModel::findOne(['code' => $codmodel])->id;
         $car->color_id = cats\Color::findOne(['code' => $codColor])->id;
         $car->color_sal_id = cats\ColorSalon::find()->where(['name' => $codSalon])->one()->id;
         $car->vin = $rawData->vin;
         $car->enj_num = $codEnj;
         if ($car->validate()) {
             $car->save();
         } else {
             $arr_error[] = $car->getErrorsAsString();
             //				continue;
         }
         if ($sCarmod = Car::findOne(['vin' => $rawData->vin])) {
             $impData = new ImportPlant();
             $impData->production_ord = $prodOrd;
             $impData->carrier = $carrier;
             $impData->key_code = $keyCode;
             $impData->car_id = $sCarmod->id;
             $impData->date_shipping = $dateShipping;
             $impData->ship_code = $shipCode;
             $impData->num_invoice = $numInvoice;
             if ($impData->validate()) {
                 $impData->save();
                 $car_status = new CarStatus();
                 $car_status->car_id = $sCarmod->id;
                 $car_status->status = 'way';
                 $car_status->imp_data_id = $impData->id;
                 if ($car_status->validate()) {
                     $car_status->save();
                 } else {
                     $arr_error[] = $car_status->getErrorsAsString();
                 }
             } else {
                 $arr_error[] = $impData->getErrorsAsString();
                 //					continue;
             }
         }
         $rawData->imported = $timeimport;
         $rawData->save();
     }
     return $arr_error;
 }
Example #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getColor()
 {
     return $this->hasOne(cats\Color::className(), ['id' => 'color_id']);
 }
Example #3
0
use yii\helpers\ArrayHelper;
use app\models as Mod;
use kartik\select2\Select2;
/* @var $this yii\web\View */
/* @var $searchModel app\models\CarSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Cars');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="car-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Create Car'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'model.code', ['attribute' => 'model_id', 'value' => 'model.full_name', 'filter' => Select2::widget(['model' => $searchModel, 'attribute' => 'model_id', 'data' => ArrayHelper::map(Mod\CatModel::findAll(Mod\Car::getDiscArray('model_id')), 'id', 'full_name'), 'options' => ['placeholder' => Yii::t('app', 'Select a model')], 'pluginOptions' => ['allowClear' => true]])], ['attribute' => 'color_id', 'value' => 'color.name', 'filter' => Select2::widget(['model' => $searchModel, 'attribute' => 'color_id', 'data' => ArrayHelper::map(Mod\cats\Color::findAll(Mod\Car::getDiscArray('color_id')), 'id', 'name'), 'options' => ['placeholder' => Yii::t('app', 'Select a color')], 'pluginOptions' => ['allowClear' => true]])], ['attribute' => 'color_sal_id', 'value' => 'colorsal.name', 'filter' => ArrayHelper::map(Mod\cats\ColorSalon::findAll(Mod\Car::getDiscArray('color_sal_id')), 'id', 'name')], 'vin', 'enj_num', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Example #4
0
use yii\widgets\Menu;
use yii\bootstrap\Tabs;
/* @var $this yii\web\View */
/* @var $searchModel app\models\CarSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = $title;
$this->params['breadcrumbs'][] = $this->title;
?>

<?php 
echo Menu::widget(['options' => ['class' => 'nav nav-tabs'], 'items' => [['label' => Yii::t('app', 'Cars on road'), 'url' => ['/status/index']], ['label' => Yii::t('app', 'Cars on custum'), 'url' => ['/status/custum']], ['label' => Yii::t('app', 'Cars on distr'), 'url' => ['/status/distr']]]]);
?>
	

<div class="car-index">

    <h1><?php 
//= Html::encode($this->title)
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>


    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'model_id', 'value' => 'car.model.full_name', 'label' => Yii::t('app', 'Model ID'), 'filter' => Select2::widget(['model' => $searchModel, 'attribute' => 'model_id', 'data' => ArrayHelper::map(Mod\CatModel::findAll(Mod\Car::getDiscArray('model_id')), 'id', 'full_name'), 'options' => ['placeholder' => Yii::t('app', 'Select a model')], 'pluginOptions' => ['allowClear' => true]])], ['attribute' => 'color_id', 'value' => 'car.color.name', 'label' => Yii::t('app', 'Color ID'), 'filter' => Select2::widget(['model' => $searchModel, 'attribute' => 'color_id', 'data' => ArrayHelper::map(Mod\cats\Color::findAll(Mod\Car::getDiscArray('color_id')), 'id', 'name'), 'options' => ['placeholder' => Yii::t('app', 'Select a color')], 'pluginOptions' => ['allowClear' => true]])], ['attribute' => 'color_sal_id', 'value' => 'car.colorsal.name', 'label' => Yii::t('app', 'Color Sal ID'), 'filter' => ArrayHelper::map(Mod\cats\ColorSalon::findAll(Mod\Car::getDiscArray('color_sal_id')), 'id', 'name')], ['attribute' => 'diller.name', 'label' => Yii::t('app', 'Diller')], 'custum_date:date', ['attribute' => 'vin', 'value' => 'car.vin'], ['attribute' => 'enj_num', 'value' => 'car.enj_num', 'label' => Yii::t('app', 'Enj Num')], ['attribute' => 'stock.name', 'label' => Yii::t('app', 'Stock')], ['attribute' => 'plant.date_shipping', 'label' => Yii::t('app', 'Shiping date')]]]);
?>

</div>