public function actionUpdate($id)
 {
     $modelClassified = Classified::findOne($id);
     $modelImage = ClassifiedImage::find()->where(['classified_id' => $id])->all();
     //$modelImage = $modelClassified->id;
     if ($modelClassified->load(Yii::$app->request->post())) {
         $oldIDs = \yii\helpers\ArrayHelper::map($modelImage, 'id', 'classified_id');
         print_r($oldIDs);
         $modelImage = \common\models\Model::createMultiple(ClassifiedImage::classname(), $modelImage);
         \common\models\Model::loadMultiple($modelImage, Yii::$app->request->post());
         $deletedIDs = array_diff($oldIDs, array_filter(\yii\helpers\ArrayHelper::map($modelImage, 'id', 'classified_id')));
         // ajax validation
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
             return \yii\helpers\ArrayHelper::merge(\yii\widgets\ActiveForm::validateMultiple($modelImage), \yii\widgets\ActiveForm::validate($modelClassified));
         }
         // validate all models
         $valid = $modelClassified->validate();
         $valid = \common\models\Model::validateMultiple($modelImage) && $valid;
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 if ($flag = $modelClassified->save(false)) {
                     if (!empty($deletedIDs)) {
                         ClassifiedImage::deleteAll(['id' => $deletedIDs]);
                     }
                     foreach ($modelImage as $i => $modelImage) {
                         $modelImage->classified_id = $modelClassified->id;
                         if (empty($modelImage->imageFile)) {
                             $name = Yii::$app->security->generateRandomString();
                             $modelImage->imageFile = \yii\web\UploadedFile::getInstance($modelImage, "[{$i}]imageFile");
                             if ($modelImage->imageFile) {
                                 $modelImage->imageFile->saveAs('uploads/' . $name . '.' . $modelImage->imageFile->extension);
                                 //Upload files to server
                                 ////save path in db column
                                 $modelImage->image = 'uploads/' . $name . '.' . $modelImage->imageFile->extension;
                                 //$model->fileProfile->saveAs($model->image_profile);
                             }
                         }
                         if (!($flag = $modelImage->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     return $this->refresh();
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     }
     return $this->render('update', ['modelClassified' => $modelClassified, 'modelImage' => empty($modelImage) ? [new ClassifiedImage()] : $modelImage]);
 }
Exemplo n.º 2
1
 /**
  * Updates an existing Po model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     //        $model = $this->findModel($id);
     //
     //        if ($model->load(Yii::$app->request->post()) && $model->save()) {
     //            return $this->redirect(['view', 'id' => $model->id]);
     //        } else {
     //            return $this->render('update', [
     //                'model' => $model,
     //            ]);
     //        }
     $model = $this->findModel($id);
     $modelsPoItems = $model->poItems;
     if ($model->load(Yii::$app->request->post())) {
         $oldIDs = ArrayHelper::map($modelsPoItems, 'id', 'id');
         $modelsPoItems = Model::createMultiple(Poitem::classname(), $modelsPoItems);
         Model::loadMultiple($modelsPoItems, Yii::$app->request->post());
         $deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($modelsPoItems, 'id', 'id')));
         // ajax validation
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ArrayHelper::merge(ActiveForm::validateMultiple($modelsPoItems), ActiveForm::validate($model));
         }
         // validate all models
         $valid = $model->validate();
         $valid = Model::validateMultiple($modelsPoItems) && $valid;
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 if ($flag = $model->save(false)) {
                     if (!empty($deletedIDs)) {
                         Poitem::deleteAll(['id' => $deletedIDs]);
                     }
                     foreach ($modelsPoItems as $modelPoItem) {
                         $modelPoItem->po_id = $model->id;
                         if (!($flag = $modelPoItem->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $model->id]);
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     }
     return $this->render('update', ['model' => $model, 'modelsPoItems' => empty($modelsPoItems) ? [new Poitem()] : $modelsPoItems]);
 }
Exemplo n.º 3
0
 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;
             }
         }
     }
 }
Exemplo n.º 4
0
 /**
  * Creates data provider instance with search query applied
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Model::find();
     if (!\Yii::$app->user->can('administrator')) {
         $query->forDomain();
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'author_id' => $this->author_id, 'category_id' => $this->category_id, 'updater_id' => $this->updater_id, 'status' => $this->status, 'published_at' => $this->published_at, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'domain_id' => $this->domain_id]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'price', $this->price])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'weight', $this->weight])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'before_body', $this->before_body])->andFilterWhere(['like', 'after_body', $this->after_body])->andFilterWhere(['like', 'on_scenario', $this->on_scenario]);
     if (!empty($params['ModelSearch']['cid'])) {
         $query->onlyCategory($params['ModelSearch']['cid']);
     }
     return $dataProvider;
 }
Exemplo n.º 5
0
 /**
  * Lists all Info models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new InfoSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $dataProvider->sort = ['defaultOrder' => ['published_at' => SORT_DESC]];
     $dataProvider->query->andFilterWhere(['{{info}}.locale' => Yii::$app->language]);
     if (Yii::$app->request->get('mid')) {
         $parentModel = Model::findOne(['id' => Yii::$app->request->get('mid')]);
         $models = Info::find()->andFilterWhere(['{{info}}.domain_id' => Yii::getAlias('@defaultDomainId'), '{{info}}.locale' => 'uk-UA'])->andWhere(['like', 'slug', $parentModel->slug])->all();
     } else {
         $models = Info::find()->andFilterWhere(['{{info}}.domain_id' => Yii::getAlias('@defaultDomainId'), '{{info}}.locale' => 'uk-UA'])->all();
     }
     $list = \yii\helpers\ArrayHelper::map($models, 'locale_group_id', 'title');
     $cars = Model::find()->andFilterWhere(['{{model}}.domain_id' => Yii::getAlias('@defaultDomainId'), '{{model}}.locale' => 'uk-UA'])->all();
     $carList = \yii\helpers\ArrayHelper::map($cars, 'id', 'title');
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'list' => $list, 'carList' => $carList]);
 }
Exemplo n.º 6
0
 /**
  * Lists all Info models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new InfoSearch();
     $searchModel->detachBehaviors();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     // $dataProvider->sort = [
     //     'defaultOrder' => ['published_at' => SORT_DESC]
     // ];
     $dataProvider->sort->attributes['search_date_published'] = ['asc' => ['published_at' => SORT_ASC], 'desc' => ['published_at' => SORT_DESC]];
     $dataProvider->query->andFilterWhere(['info.locale' => Yii::$app->language]);
     //        $dataProvider->query->andFilterWhere(['!=', 'info.locale', 'en-US']);
     if (Yii::$app->request->get('mid')) {
         $parentModel = Model::findOne(['id' => Yii::$app->request->get('mid')]);
         $models = Info::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA'])->andWhere(['like', 'slug', $parentModel->slug])->all();
     } else {
         $models = Info::find()->andFilterWhere(['domain_id' => Yii::getAlias('@defaultDomainId'), 'locale' => 'uk-UA'])->all();
     }
     $list = \yii\helpers\ArrayHelper::map($models, 'locale_group_id', 'title');
     $cars = Model::find()->andFilterWhere(['domain_id' => Yii::$app->user->identity->domain_id, 'locale' => 'uk-UA'])->all();
     $carList = \yii\helpers\ArrayHelper::map($cars, 'id', 'title');
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'list' => $list, 'carList' => $carList]);
 }
Exemplo n.º 7
0
 /**
  * Creates a new Parameter model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $models = [new Parameter()];
     if (Yii::$app->request->post()) {
         $models = Model::createMultiple(Parameter::classname());
         Model::loadMultiple($models, Yii::$app->request->post());
         // ajax validation
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validateMultiple($models);
         }
         // validate all models
         $valid = Model::validateMultiple($models);
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 $flag = true;
                 foreach ($models as $model) {
                     if (!($flag = $model->save(false))) {
                         $transaction->rollBack();
                         break;
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     Yii::$app->session->setFlash('alert', ['options' => ['class' => 'alert-success'], 'body' => Yii::t('backend', 'Your data has been successfully saved')]);
                     return $this->redirect(['index']);
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
                 Yii::$app->session->setFlash('alert', ['options' => ['class' => 'alert-danger'], 'body' => Yii::t('backend', 'Your data can\'t be saved')]);
                 return $this->redirect(['index']);
             }
         }
     }
     return $this->render('create', ['models' => empty($models) ? [new Parameter()] : $models]);
 }
Exemplo n.º 8
0
 public function afterDelete()
 {
     $model = Model::find()->andWhere(['locale_group_id' => $this->locale_group_id, 'domain_id' => Yii::$app->user->identity->domain_id])->one();
     if ($model) {
         $model->delete();
     }
     return parent::afterDelete();
 }
Exemplo n.º 9
0
 /**
  * Deletes an existing ModelCategory model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $modelModel = Model::find()->andWhere(['category_id' => $id])->one();
     if (null === $modelModel) {
         $this->findModel($id)->delete();
     } else {
         Yii::$app->session->setFlash('alert', ['body' => \Yii::t('backend', 'Can not delete category #' . $id . '. It used in other table. Change category for model #' . $modelModel->id . ' before delete.'), 'options' => ['class' => 'alert-error']]);
     }
     return $this->redirect(['index']);
 }
Exemplo n.º 10
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getModel()
 {
     return $this->hasOne(Model::className(), ['id' => 'model_id']);
 }
Exemplo n.º 11
0
 /**
  * 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 = Model::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 12
0
 /**
  * Updates an existing Product model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $product = $this->findModel($id);
     $product->setScenario('product-update');
     $ingredients = $product->ingredients;
     if ($product->load(Yii::$app->request->post())) {
         $oldIDs = ArrayHelper::map($ingredients, 'id', 'id');
         $ingredients = Model::createMultiple(Ingredients::classname(), $ingredients);
         Model::loadMultiple($ingredients, Yii::$app->request->post());
         $deletedIDs = array_diff($oldIDs, array_filter(ArrayHelper::map($ingredients, 'id', 'id')));
         // ajax validation
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ArrayHelper::merge(ActiveForm::validateMultiple($ingredients), ActiveForm::validate($product));
         }
         $product->seen = 0;
         $product->sold = 0;
         $product->user_id = 0;
         // change to admin id or user id
         $product->created_by = Yii::$app->user->identity->username;
         $product->created_date = date('Y-m-d h:m:s');
         $product->modified_by = Yii::$app->user->identity->username;
         $product->modified_date = date('Y-m-d h:m:s');
         $product->status = Status::STATUS_ACTIVE;
         // validate all models
         $valid = $product->validate();
         foreach ($ingredients as $detail) {
             $fields = array('ingredient');
             $valid = $detail->validate($fields) && $valid;
         }
         if ($valid) {
             $transaction = \Yii::$app->db->beginTransaction();
             try {
                 if ($flag = $product->save(false)) {
                     if (!empty($deletedIDs)) {
                         //Ingredients::updateAll(array( 'status' => Status::STATUS_DELETED ), 'id IN ( ' . implode(",", $deletedIDs) .')' );
                         Ingredients::deleteAll(['id' => $deletedIDs]);
                     }
                     foreach ($ingredients as $ingredient) {
                         $ingredient->created_by = Yii::$app->user->identity->username;
                         $ingredient->created_date = date('Y-m-d h:m:s');
                         $ingredient->modified_by = Yii::$app->user->identity->username;
                         $ingredient->modified_date = date('Y-m-d h:m:s');
                         $ingredient->status = Status::STATUS_ACTIVE;
                         $ingredient->product_id = $product->id;
                         if (!($flag = $ingredient->save(false))) {
                             $transaction->rollBack();
                             break;
                         }
                     }
                     $product->files = UploadedFile::getInstances($product, 'files');
                     if ($product->files) {
                         foreach ($product->files as $file) {
                             $productPhoto = new ProductPhoto();
                             $imageName = $file->baseName . substr(md5(rand()), 0, 7);
                             $productPhoto->caption = $imageName;
                             $productPhoto->product_id = $product->id;
                             $productPhoto->product_photo_order = 0;
                             $productPhoto->created_by = Yii::$app->user->identity->username;
                             $productPhoto->created_date = date('Y-m-d h:m:s');
                             $productPhoto->modified_by = Yii::$app->user->identity->username;
                             $productPhoto->modified_date = date('Y-m-d h:m:s');
                             $productPhoto->status = Status::STATUS_ACTIVE;
                             $productPhoto->image_path = 'uploads/product/' . $imageName . '.' . $file->extension;
                             if (!($flag = $productPhoto->save(false))) {
                                 $transaction->rollBack();
                                 break;
                             } else {
                                 $file->saveAs('uploads/product/' . $imageName . '.' . $file->extension);
                             }
                         }
                     }
                 }
                 if ($flag) {
                     $transaction->commit();
                     return $this->redirect(['view', 'id' => $product->id]);
                 }
             } catch (Exception $e) {
                 $transaction->rollBack();
             }
         }
     } else {
         return $this->render('create', ['product' => $product, 'ingredients' => empty($ingredients) ? [new Ingredients()] : $ingredients]);
     }
 }
Exemplo n.º 13
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getModels()
 {
     return $this->hasMany(Model::className(), ['category_id' => 'id']);
 }
Exemplo n.º 14
0
                    <?php 
    $forms = ['label' => Yii::t('backend', 'Forms'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'Subscribes'), 'url' => ['/subscribes/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Corporate Sales'), 'url' => ['/corporate/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>']]];
    $feedbacks = ['label' => Yii::t('backend', 'Feedback'), 'icon' => '<i class="fa fa-envelope-o"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'Emails'), 'url' => ['/emailf/index'], 'icon' => '<i class="fa fa-at"></i>'], ['label' => Yii::t('backend', 'Questions'), 'url' => ['/feedback/index'], 'icon' => '<i class="fa fa-comments-o"></i>']]];
    ?>

                <?php 
} else {
    ?>
                    <?php 
    $feedbacks = ['label' => Yii::t('backend', 'Feedback'), 'icon' => '<i class="fa fa-envelope-o"></i>', 'options' => ['class' => 'treeview'], 'url' => ['/feedback/index']];
    ?>
                <?php 
}
?>
                <?php 
echo Menu::widget(['options' => ['class' => 'sidebar-menu'], 'labelTemplate' => '<a href="#">{icon}<span>{label}</span>{right-icon}{badge}</a>', 'linkTemplate' => '<a href="{url}">{icon}<span>{label}</span>{right-icon}{badge}</a>', 'submenuTemplate' => "\n<ul class=\"treeview-menu\">\n{items}\n</ul>\n", 'activateParents' => true, 'items' => [['label' => Yii::t('backend', 'Timeline'), 'icon' => '<i class="fa fa-bar-chart-o"></i>', 'url' => ['/timeline-event/index'], 'badge' => TimelineEvent::find()->today()->count(), 'badgeBgClass' => 'label-success'], ['label' => Yii::t('backend', 'Content'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'Pages'), 'url' => ['/page/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'active' => preg_match('/^page/', Yii::$app->request->pathinfo)], ['label' => Yii::t('backend', 'News'), 'url' => ['/article/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'active' => preg_match('/^article/', Yii::$app->request->pathinfo)], ['label' => Yii::t('backend', 'Promo'), 'url' => ['/promo/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'active' => preg_match('/^promo/', Yii::$app->request->pathinfo)], ['label' => Yii::t('backend', 'Models'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'Categories'), 'url' => ['/model-category/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'List'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => Model::getLeftMenuListItems()], ['label' => Yii::t('backend', 'Pages'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => Model::getLeftMenuPageItems()]]], $forms, ['label' => Yii::t('backend', 'Service pages'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => Service::getLeftMenuItems()], ['label' => Yii::t('backend', 'About pages'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => About::getLeftMenuItems()], ['label' => Yii::t('backend', 'Finance pages'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => Finance::getLeftMenuItems()], ['label' => Yii::t('backend', 'Common blocks'), 'url' => ['/block/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>']]], ['label' => Yii::t('backend', 'SEO'), 'icon' => '<i class="fa fa-edit"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'robots.txt'), 'url' => ['widget-text/update?id=frontend.web.robots.txt'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'sitemap.xml'), 'url' => Domain::getFrontendUrl() . '/sitemap.xml', 'icon' => '<i class="fa fa-angle-double-right"></i>', 'template' => '<a href="{url}" target="_blank"><i class="fa fa-angle-double-right"></i><span>{label}</span></a>'], ['label' => Yii::t('backend', 'Third-party code'), 'url' => ['custom-code/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>']]], $feedbacks, ['label' => Yii::t('backend', 'Domains'), 'icon' => '<i class="fa fa-university"></i>', 'url' => ['/domain/index'], 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('backend', 'Users'), 'icon' => '<i class="fa fa-users"></i>', 'url' => ['/user/index'], 'visible' => Yii::$app->user->can('administrator')], ['label' => Yii::t('backend', 'System'), 'icon' => '<i class="fa fa-cogs"></i>', 'options' => ['class' => 'treeview'], 'visible' => Yii::$app->user->can('administrator'), 'items' => [['label' => Yii::t('backend', 'i18n'), 'icon' => '<i class="fa fa-flag"></i>', 'options' => ['class' => 'treeview'], 'items' => [['label' => Yii::t('backend', 'i18n Source Message'), 'url' => ['/i18n/i18n-source-message/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'i18n Message'), 'url' => ['/i18n/i18n-message/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>']]], ['label' => Yii::t('backend', 'Key-Value Storage'), 'url' => ['/key-storage/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'File Storage'), 'url' => ['/file-storage/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Cache'), 'url' => ['/cache/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'File Manager'), 'url' => ['/file-manager/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Widgets list'), 'url' => ['/site/widgets'], 'icon' => '<i class="fa fa-angle-double-right"></i>'], ['label' => Yii::t('backend', 'Logs'), 'url' => ['/log/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>', 'badge' => \backend\models\SystemLog::find()->count(), 'badgeBgClass' => 'label-danger']]]]]);
?>
            </section>
            <!-- /.sidebar -->
        </aside>

        <!-- Right side column. Contains the navbar and content of the page -->
        <aside class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                    <?php 
echo $this->title;
?>
                    <?php 
if (isset($this->params['subtitle'])) {
Exemplo n.º 15
0
 public static function multiSave($model)
 {
     //\yii\helpers\VarDumper::dump(Yii::$app->request->post(),11,1); die();
     $defaultAttributes = [];
     foreach ($model->getModels() as $key => $v) {
         foreach ($model->getModel($key)->attributes() as $attrKey) {
             if (empty($defaultAttributes[$attrKey])) {
                 if (!empty($model->getModel($key)->{$attrKey})) {
                     if ('[]' != $model->getModel($key)->{$attrKey}) {
                         $defaultAttributes[$attrKey] = $model->getModel($key)->{$attrKey};
                     }
                 }
             }
         }
     }
     unset($defaultAttributes['id']);
     unset($defaultAttributes['locale']);
     unset($defaultAttributes['locale_group_id']);
     //unset($defaultAttributes['slug']);
     $groupId = self::getLastLocaleGroupId() + 1;
     foreach ($model->getModels() as $key => $v) {
         if (!$model->getModel($key)->locale_group_id) {
             $model->getModel($key)->locale_group_id = $groupId;
         }
         foreach ($defaultAttributes as $key2 => $value2) {
             if (empty($model->getModel($key)->{$key2}) or "[]" == $model->getModel($key)->{$key2}) {
                 $model->getModel($key)->{$key2} = $value2;
             }
         }
         //model_id fix
         $modelGroupId = Model::findOne(['id' => $model->getModel($key)->model_id])->locale_group_id;
         $currentModelId = Model::findOne(['locale_group_id' => $modelGroupId, 'locale' => $model->getModel($key)->locale])->id;
         $model->getModel($key)->model_id = $currentModelId;
         //\yii\helpers\VarDumper::dump($model->getModel($key),11,1);
     }
     return $model->save();
 }
Exemplo n.º 16
0
            <span class="caret"></span>
        </button>
        <ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
            <?php 
    foreach ($list as $key => $value) {
        echo '<li><a href="/info/create?locale_group_id=' . $key . '&' . $additionalGetParam . '&scenario=extend">' . $value . '</a></li>';
    }
    ?>

        </ul>
    </span>
<?php 
}
?>
    <?php 
$campuses = Model::find()->orderBy('title')->where(['locale' => Yii::$app->language])->asArray()->all();
foreach ($campuses as $key => $value) {
    $id = $value['id'];
    $title = $value['title'];
    $user = User::findIdentity($value['author_id']);
    $user = $user->username;
    $data[] = ['id' => $id, 'title' => $title . "(" . $user . ")"];
}
$columns = ['id', ['attribute' => 'model_id', 'filter' => Arrayhelper::map($data, 'id', 'title')], 'title', 'slug', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => [Yii::t('backend', 'Not Published'), Yii::t('backend', 'Published')]], ['attribute' => 'search_date_published', 'label' => 'Дата публикации', 'value' => 'published_at', 'format' => ['date', 'php:d-m-Y']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {log} {delete}', 'buttons' => ['log' => function ($url, $model) {
    $customurl = Yii::$app->getUrlManager()->createUrl(['timeline-event/index', 'TimelineEventSearch[category]' => 'common\\models\\locale\\Info', 'TimelineEventSearch[row_id]' => $model->id]);
    return Html::a('<span class="glyphicon glyphicon-time"></span>', $customurl, ['title' => Yii::t('yii', 'Log'), 'data-pjax' => '0']);
}]]];
if (\Yii::$app->user->can('administrator')) {
    // adding after url
    array_splice($columns, 4, 0, [['attribute' => 'domain_id', 'content' => function ($model) {
        $domain = Domain::findOne($model->domain_id);