コード例 #1
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     // Дополнительные фото
     $productImages = new CatalogImage();
     $criteria = new CDbCriteria();
     $criteria->compare('id_product', $id);
     $photoDataProvider = new CActiveDataProvider('CatalogImage', array('criteria' => $criteria, 'pagination' => false));
     $this->breadcrumbs = CatalogCategory::getParents($model->id_category, true);
     $this->breadcrumbs[] = $model->title;
     $this->breadcrumbs[] = 'Редактирование';
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['CatalogProduct'])) {
         $model->attributes = $_POST['CatalogProduct'];
         // Чтобы красиво написано было
         //$model->noyml=!$model->noyml;
         $model->hide = !$model->hide;
         //$model->hide=!$this->hide;
         // if(isset($_POST['CatalogProductAttribute'])){
         //  $model->productAttrubute=$_POST['CatalogProductAttribute'];
         //}
         if ($model->save()) {
             // записываем атрибуты товара, переданные из формы
             if (isset($_POST['CatalogProductAttribute'])) {
                 $model->productAttributeSave($_POST['CatalogProductAttribute']);
             }
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     //print_r($model->productAttrubute);
     $this->render('update', array('model' => $model, 'productImages' => $productImages, 'photoDataProvider' => $photoDataProvider));
 }
コード例 #2
0
ファイル: ServiceController.php プロジェクト: xPashaNx/diet
 /**
  * Updates a particular model
  * If update is successful, the browser will be redirected to the 'view' page
  *
  * @param integer $id the ID of the model to be updated
  *
  * @throws CHttpException
  */
 public function actionUpdate($id)
 {
     $model = $this->loadModel($id);
     $serviceImages = new CatalogImage();
     $this->breadcrumbs = CatalogCategory::getParents($model->id_category, true);
     $this->breadcrumbs[] = $model->short_title;
     $this->breadcrumbs[] = 'Редактирование';
     if (isset($_POST['CatalogService'])) {
         $model->attributes = $_POST['CatalogService'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $this->render('update', array('model' => $model, 'serviceImages' => $serviceImages));
 }
コード例 #3
0
 /**
  * Вывод категории (подкатегории и товары)
  */
 public function actionIndex($id = 0)
 {
     if (!($category = $this->loadModel($id))) {
         $category = new CatalogCategory();
         $category->id = 0;
         $category->title = 'Каталог животных';
     }
     $this->breadcrumbs = CatalogCategory::getParents($category->id);
     $this->breadcrumbs[] = $category->title;
     $category_criteria = new CDbCriteria();
     $category_criteria->compare('parent_id', $category->id);
     $categoryDataProvider = new CActiveDataProvider('CatalogCategory', array('criteria' => $category_criteria, 'sort' => array('defaultOrder' => 'sort_order ASC'), 'pagination' => false));
     $products = new CatalogProduct('search');
     $products->unsetAttributes();
     $products->id_category = $category->id;
     $products->attach = 0;
     if (isset($_GET['CatalogProduct'])) {
         $products->attributes = $_GET['CatalogProduct'];
     }
     $this->render('index', array('products' => $products, 'categoryDataProvider' => $categoryDataProvider, 'category' => $category));
 }
コード例 #4
0
ファイル: DefaultController.php プロジェクト: xPashaNx/diet
 /**
  * Output category (categories and services)
  *
  * @param int $id
  */
 public function actionIndex($id = 0)
 {
     if (!($category = $this->loadModel($id))) {
         $category = new CatalogCategory();
         $category->id = 0;
         $category->short_title = 'Управление услугами';
     }
     $this->breadcrumbs = CatalogCategory::getParents($category->id);
     $this->breadcrumbs[] = $category->short_title;
     $categoryData = new CatalogCategory();
     $services = new CatalogService('search');
     $services->unsetAttributes();
     $services->id_category = $category->id;
     if (isset($_GET['CatalogService'])) {
         $services->attributes = $_GET['CatalogService'];
     }
     $this->render('index', array('services' => $services, 'categoryData' => $categoryData, 'category' => $category));
 }