Esempio n. 1
0
 function saveOffer($arOffer, &$arStrToSave)
 {
     $curGoodId = $arOffer['goods_id'];
     if (!isset($arStrToSave[$curGoodId])) {
         $arrGood = Goods::getName($curGoodId, 'array');
         $arRow['id'] = $curGoodId;
         $arRow['goods_type'] = $arOffer['goods_type_type'];
         $arRow['name'] = Goods::getName($curGoodId);
         $arRow['heigth'] = $arrGood['values']['tyre_heigth'];
         $arRow['width'] = $arrGood['values']['tyre_width'];
         $arRow['dia'] = $arrGood['values']['tyre_dia'];
         $arRow['i_load'] = $arrGood['values']['tyre_i_load'];
         $arRow['i_speed'] = $arrGood['values']['tyre_i_speed'];
         $arRow['model'] = $arrGood['values']['tyre_model'];
         $arRow['rf'] = $arrGood['values']['tyre_rf'] ? 44 : '';
         $arRow['brand'] = $arrGood['values']['tyre_brand'];
         $arRow['season'] = $arrGood['values']['tyre_season'];
         $arRow['type_auto'] = $arrGood['values']['tyre_type_auto'];
         $arRow['spike'] = $arrGood['values']['tyre_spike'] ? 3 : '';
         $arStrToSave[$curGoodId]['g'] = $arRow;
     }
     unset($arOffer['name'], $arOffer['goods_type_type']);
     $arStrToSave[$curGoodId]['o'][$arOffer['providers_id']] = $arOffer;
 }
Esempio n. 2
0
 /**
  * Deletes an existing GoodsParams model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionTech()
 {
     exit;
     $GoodsParamsName = \app\models\GoodsParamsName::find()->all();
     foreach ($GoodsParamsName as $gpn) {
         print '============================== <br>';
         print $gpn->id . '<br>';
         $oGP = \app\models\GoodsParams::find()->where('goods_params_name_id=:goods_params_name_id', [':goods_params_name_id' => $gpn->id])->all();
         //            print ('<pre>');print_r($oGP);print('</pre>');
         $arGP = \yii\helpers\ArrayHelper::map($oGP, 'id', 'id');
         print implode(',', $arGP) . '<br>';
         if (count($arGP) == 0) {
             continue;
         }
         //            $goods = \app\components\Goods::find($gpn->goods_type_type, $gpn->id . ' not in (:ids)', [':ids' => implode(',',$arGP)])->all();
         $goods = \app\components\Goods::find($gpn->goods_type_type, $gpn->id . ' not in (' . implode(',', $arGP) . ')', [])->all();
         foreach ($goods as $good) {
             $ar = \yii\helpers\ArrayHelper::toArray($good);
             print '<pre>';
             print_r($ar);
             print '</pre>';
             \app\models\Goods::deleteAll('id=:goods_id', [':goods_id' => $good->goods_id]);
         }
     }
 }
Esempio n. 3
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel app\models\AccordsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Имя в прайсе';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="accords-index">

    <h1><?php 
echo 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'], 'identifier', ['attribute' => 'providers_id', 'label' => 'Поставщик', 'format' => 'html', 'filter' => yii\helpers\ArrayHelper::map(app\models\Providers::find()->all(), 'id', 'name'), 'value' => function ($model) {
    return app\models\Providers::findOne($model->providers_id)->name;
}], ['attribute' => 'link_category', 'label' => 'Товар', 'format' => 'html', 'value' => function ($model) {
    return \app\components\Goods::getName($model->goods_id);
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}']]]);
?>

</div>
Esempio n. 4
0
 public function actionSaveFull($k, $saveAccord = 'y')
 {
     $post = $_POST;
     $goodTypeId = $post['type'];
     $cach = Yii::$app->cache->get($post['key']);
     $priceArr = $cach['arrToAccord'][$k];
     //Поиск в таблице Goods
     $code = \app\components\Goods::requiredParameters($post, $goodTypeId);
     $goods = \app\models\Goods::find()->where(['name' => $code])->one();
     if ($goods instanceof \app\models\Goods) {
         //Если нашли возвращаем id товара
         $goodId = $goods->id;
     } else {
         //Если не нашли записываем в Goods и возвращаем id товара
         $goodId = \app\components\Goods::save($goodTypeId, $post);
     }
     //Добавить запись в таблицу Accords
     if ($saveAccord == 'y') {
         $accord = new \app\models\Accords();
         $identifier = isset($priceArr['identifier']) && strlen($priceArr['identifier']) > 0 ? $priceArr['identifier'] : $priceArr['name'];
         $accord->identifier = $identifier;
         $accord->goods_id = $goodId;
         $accord->providers_id = $cach['providerId'];
         $accord->save();
     }
     //Добавить запись в таблицу Offers
     $offer = new \app\models\Offers();
     $offer->quantity = $priceArr['quantity'];
     $offer->price = $priceArr['price'];
     $offer->goods_id = $goodId;
     $offer->providers_id = $cach['providerId'];
     $offer->save();
     // Удалить строку из кеша
     unset($cach['arrToAccord'][$k]);
     Yii::$app->cache->set($post['key'], $cach);
     //Вренуть результат
     print json_encode(['res' => 'ok', 'k' => $k]);
 }