コード例 #1
0
ファイル: PriceSearch.php プロジェクト: efabrikov/renault
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Price::find();
     if (!\Yii::$app->user->can('administrator')) {
         $query->forDomain();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['{{price}}.id' => $this->id, '{{price}}.model' => $this->model, '{{price}}.version' => $this->version, '{{price}}.version_code' => $this->version_code, '{{price}}.body_type' => $this->body_type, '{{price}}.price' => $this->price, '{{price}}.status' => $this->status, '{{price}}.created_at' => $this->created_at, '{{price}}.updated_at' => $this->updated_at, '{{price}}.domain_id' => $this->domain_id]);
     //        'id'         => Schema::TYPE_PK,
     //            'model' => Schema::TYPE_STRING . '(512)',
     //            'version'      => Schema::TYPE_STRING . '(512)',
     //            'version_code'       => Schema::TYPE_STRING . '(512)',
     //            'body_type'       => Schema::TYPE_STRING . '(512)',
     //            'price'       => Schema::TYPE_STRING . '(512)',
     //            'status'     => Schema::TYPE_SMALLINT . ' NOT NULL DEFAULT 0',
     //            'created_at' => Schema::TYPE_INTEGER,
     //            'updated_at' => Schema::TYPE_INTEGER,
     //            'weight'     => Schema::TYPE_SMALLINT,
     //            'locale'             => Schema::TYPE_STRING,
     //            'locale_group_id'    => Schema::TYPE_INTEGER,
     //            'domain_id'  => Schema::TYPE_INTEGER,
     $query->andFilterWhere(['like', '{{model}}.model', $this->model])->andFilterWhere(['like', '{{model}}.version', $this->version])->andFilterWhere(['like', '{{model}}.price', $this->title])->andFilterWhere(['like', '{{model}}.version_code', $this->version_code])->andFilterWhere(['like', '{{model}}.weight', $this->weight])->andFilterWhere(['like', '{{model}}.body_type', $this->body_type]);
     if (!empty($params['PriceSearch']['cid'])) {
         $query->onlyCategory($params['PriceSearch']['cid']);
     }
     return $dataProvider;
 }
コード例 #2
0
 public function getData()
 {
     $this->data['properties']['title'] = ['type' => 'string', 'title' => Yii::t('backend', 'Title.'), 'default' => 'ОБЕРІТЬ СВІЙ RENAULT'];
     $this->data['properties']['show_all_text'] = ['type' => 'string', 'title' => Yii::t('backend', 'Show all text.'), 'default' => 'ВСІ МОДЕЛІ RENAULT'];
     $this->data['properties']['items'] = ['type' => 'array', 'title' => Yii::t('backend', 'Vehicle list'), 'options' => ['collapsed' => true], 'items' => ['type' => 'object', 'title' => Yii::t('backend', 'Vehicle'), 'options' => ['collapsed' => true], 'properties' => ['title' => ['type' => 'string', 'title' => Yii::t('backend', 'Title.'), 'default' => 'Lorem ipsum dolor sit amet.'], 'start_price' => ['type' => 'string', 'title' => Yii::t('backend', 'Start price.'), 'default' => 'От 99999 грн'], 'version_code' => Price::getAllVersionCodesEnum(), 'img_src' => ['type' => 'string', 'format' => 'url', 'title' => Yii::t('backend', 'image320х200'), 'options' => ['upload' => true], 'links' => ['0' => ['href' => '{{self}}', 'rel' => 'View file']]], 'alt' => ['type' => 'string', 'title' => Yii::t('backend', 'Alt'), 'default' => 'renault '], 'details_url' => ['type' => 'string', 'title' => Yii::t('backend', 'Details url'), 'default' => '#'], 'details_text' => ['type' => 'string', 'title' => Yii::t('backend', 'Details text'), 'default' => 'Детальнiше'], 'Download_Brochure_url' => ['type' => 'string', 'title' => Yii::t('backend', 'Завантажити брошуру url'), 'default' => '#'], 'Download_Brochure' => ['type' => 'string', 'title' => Yii::t('backend', 'Завантажити брошуру text'), 'default' => 'Завантажити брошуру']]]];
     return $this->data;
 }
コード例 #3
0
ファイル: ImportBehavior.php プロジェクト: efabrikov/renault
 public function importExcel($function = null)
 {
     if ($this->upload_file()) {
         Price::deleteAll();
         if ($function) {
             $this->onImportRow = $function;
         }
         //$reader = \PHPExcel_IOFactory::createReader( /*$this->defaultFormat*/ );
         $objPHPExcel = \PHPExcel_IOFactory::load($this->_uploaded_file->tempName);
         $objWorksheet = $objPHPExcel->getActiveSheet();
         $highestRow = $objWorksheet->getHighestRow();
         $result = [];
         $foo = [];
         foreach ($objWorksheet->getRowIterator() as $i => $row) {
             $cellIterator = $row->getCellIterator();
             $cellIterator->setIterateOnlyExistingCells(false);
             $row = [];
             foreach ($cellIterator as $cell) {
                 $row[] = $cell->getValue();
             }
             $foo = [$row[0] => $row[4]];
             if (!array_key_exists($row[0], $result)) {
                 $result = array_merge($result, $foo);
             }
         }
         foreach ($result as $key => $field) {
             if (isset($field) and isset($key)) {
                 $models = Model::findAll(['title' => $key]);
                 if ($models) {
                     foreach ($models as $model) {
                         $model->price = $field;
                         $model->update();
                     }
                 }
             }
             //                \yii\helpers\VarDumper::dump($model, 9, 9);
         }
         foreach ($objWorksheet->getRowIterator() as $i => $row) {
             $cellIterator = $row->getCellIterator();
             $cellIterator->setIterateOnlyExistingCells(false);
             $row = [];
             foreach ($cellIterator as $cell) {
                 $row[] = $cell->getValue();
             }
             //                \yii\helpers\VarDumper::dump($row, 9, 9);
             $this->_current_row = $i;
             if ($this->import_row(['row' => $row, 'index' => $i, 'max_row' => $highestRow])) {
             } else {
                 break;
             }
         }
     }
 }
コード例 #4
0
ファイル: Characteristics.php プロジェクト: efabrikov/renault
 public function getData()
 {
     $this->data['properties']["eqandspec"] = ["type" => "string", "title" => Yii::t('backend', 'Оборудование и характеристики'), "default" => "Оборудование и характеристики Нового Renault DUSTER"];
     $this->data['properties']["header"] = ["type" => "string", "title" => Yii::t('backend', 'Оборудование и характеристики'), "default" => "Оборудование и характеристики Нового Renault DUSTER", "options" => ["hidden" => true]];
     $this->data['properties']["equipment_text"] = ["type" => "string", "title" => Yii::t('backend', 'Обладнання'), "default" => "Обладнання"];
     $this->data['properties']["sub_header"] = ["type" => "string", "title" => Yii::t('backend', 'Обладнання'), "default" => "Обладнання", "options" => ["hidden" => true]];
     $this->data['properties']["specifications_text"] = ["type" => "string", "title" => Yii::t('backend', 'ТЕХНИЧЕСКИЕ ХАРАКТЕРИСТИКИ'), "default" => "ТЕХНИЧЕСКИЕ ХАРАКТЕРИСТИКИ"];
     $this->data['properties']["model"] = ["type" => "string", "title" => Yii::t('backend', 'Модель'), "default" => "Новий Renault Logan"];
     $versionCodes = Price::getAllVersionCodesEnum();
     $this->data['properties']["items"] = ["type" => 'array', 'title' => Yii::t('backend', 'Комплектація'), 'options' => ['collapsed' => true], 'items' => ['type' => 'object', 'title' => Yii::t('backend', 'Комплектація'), 'options' => ['collapsed' => true], 'properties' => ['title' => ['type' => 'string', 'title' => Yii::t('backend', 'Назва Комплектації'), 'default' => 'Access'], 'cost' => ['type' => 'string', 'title' => Yii::t('backend', 'Початкова ціна'), 'default' => '399 000 руб.'], 'version_code' => $versionCodes, 'link_title' => ['type' => 'string', 'title' => Yii::t('backend', 'Текст посилання'), 'default' => 'Узнать больше'], 'link_href' => ['type' => 'string', 'title' => Yii::t('backend', 'Адреса посилання'), 'gefault' => '#'], 'alt' => ['type' => 'string', 'title' => Yii::t('backend', 'alt'), 'default' => 'alt'], 'img_src' => ['type' => 'string', 'format' => 'url', 'title' => Yii::t('backend', 'Image640x440'), 'options' => ['upload' => true], "links" => [["href" => "{{self}}", "rel" => "View file"]]], 'link_configur' => ['type' => 'string', 'title' => Yii::t('backend', 'Текст посилання конфігуратора'), 'default' => 'Конфігуратор'], 'link_configur_href' => ['type' => 'string', 'title' => Yii::t('backend', 'Адреса посилання конфігуратора'), 'gefault' => '#'], 'engine' => ["type" => 'array', 'title' => Yii::t('backend', 'Двигун'), 'options' => ['collapsed' => true], 'items' => ['type' => 'object', 'title' => Yii::t('backend', 'Двигун'), 'options' => ['collapsed' => true], 'properties' => ['title_eng' => ['type' => 'string', 'title' => Yii::t('backend', 'Назва двигуна'), 'default' => 'Access'], 'power' => ['type' => 'string', 'title' => Yii::t('backend', 'Потужність'), 'default' => '399 000 руб.'], 'volume' => ['type' => 'string', 'title' => Yii::t('backend', 'Об’єм'), 'default' => '1.2 л'], 'consumption' => ['type' => 'string', 'title' => Yii::t('backend', 'Витрати пального'), 'default' => 'Access'], 'cost' => ['type' => 'string', 'title' => Yii::t('backend', 'Початкова ціна'), 'default' => '399 000 руб.'], 'version_code' => $versionCodes]]], 'equipment' => ["type" => 'array', 'title' => Yii::t('backend', 'Обладнання'), 'options' => ['collapsed' => true], 'items' => ['type' => 'object', 'title' => Yii::t('backend', 'item'), 'options' => ['collapsed' => true], 'properties' => ['title' => ['type' => 'string', 'title' => Yii::t('backend', 'Заголовок'), 'default' => 'Access'], 'text' => ['type' => 'string', 'title' => Yii::t('backend', 'Текст'), "format" => "html", "options" => ["wysiwyg" => true], 'default' => '']]]], 'specifications' => ["type" => 'array', 'title' => Yii::t('backend', 'Характеристики'), 'options' => ['collapsed' => true], 'items' => ['type' => 'object', 'title' => Yii::t('backend', 'item'), 'options' => ['collapsed' => true], 'properties' => ['title' => ['type' => 'string', 'title' => Yii::t('backend', 'Заголовок'), 'default' => 'Access'], 'text' => ['type' => 'string', 'title' => Yii::t('backend', 'Текст'), "format" => "html", "options" => ["wysiwyg" => true], 'default' => '']]]]]]];
     return $this->data;
 }
コード例 #5
0
ファイル: PriceController.php プロジェクト: efabrikov/renault
 /**
  * Finds the Model model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Model the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Price::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #6
0
ファイル: Price.php プロジェクト: efabrikov/renault
 public function afterDelete()
 {
     $about = Price::find()->andWhere(['locale_group_id' => $this->locale_group_id, 'domain_id' => Yii::$app->user->identity->domain_id])->one();
     if ($about) {
         $about->delete();
     }
     return parent::afterDelete();
 }
コード例 #7
0
ファイル: Autocat.php プロジェクト: asadovkamran/365
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getPrices()
 {
     return $this->hasMany(Price::className(), ['catid' => 'id']);
 }
コード例 #8
0
ファイル: Intro.php プロジェクト: efabrikov/renault
 public function getData()
 {
     $this->data['properties']["items"] = ["type" => 'array', 'title' => Yii::t('backend', 'Intro'), 'options' => ['collapsed' => true], 'items' => ['type' => 'object', 'title' => Yii::t('backend', 'image'), 'options' => ['collapsed' => true], 'properties' => ['title' => ['type' => 'string', 'title' => Yii::t('backend', 'Заголовок'), 'default' => 'Новый DUSTER 4x4'], 'text' => ['type' => 'string', 'title' => Yii::t('backend', 'Текст'), 'default' => 'Встречайте!'], 'price' => ['type' => 'string', 'title' => Yii::t('backend', 'price'), 'default' => 'Вiд 500000 грн!'], 'version_code' => Price::getAllVersionCodesEnum(), 'link_href' => ['type' => 'string', 'title' => Yii::t('backend', 'Адреса посилання'), 'default' => '#'], 'link_title' => ['type' => 'string', 'title' => Yii::t('backend', 'Текст посилання'), 'default' => 'Узнать больше'], 'alt' => ['type' => 'string', 'title' => Yii::t('backend', 'alt'), 'default' => 'alt'], 'img_src' => ['type' => 'string', 'format' => 'url', 'title' => Yii::t('backend', 'imagePk1500x640'), 'options' => ['upload' => true], 'links' => ['href' => '{{self}}', 'rel' => 'View file']], 'alt_mobile' => ['type' => 'string', 'title' => Yii::t('backend', 'alt mobile'), 'default' => 'alt mobile'], 'img_src_mobile' => ['type' => 'string', 'format' => 'url', 'title' => Yii::t('backend', 'image_mobile_560х720'), 'options' => ['upload' => true], 'links' => ['href' => '{{self}}', 'rel' => 'View file']], 'img_src_tablet' => ['type' => 'string', 'format' => 'url', 'title' => Yii::t('backend', 'image_mobile_960х1248'), 'options' => ['upload' => true], 'links' => ['0' => ['href' => '{{self}}', 'rel' => 'View file']]]]]];
     $this->data['properties']["footnote"] = ["type" => "string", "title" => Yii::t('backend', 'footnote'), "default" => '* Цена включает стоимость доставки до дилерского центра...'];
     return $this->data;
 }