Пример #1
0
 /**
  * Finds the Product model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $alias
  * @return Product the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($alias)
 {
     if (($model = Product::findOne(['alias' => $alias, 'active' => 1])) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #2
0
 /**
  * Finds the Product model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Product the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Product::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #3
0
    public function actionShowInfoProduct()
    {
        $id = (int) $_POST['id'];
        $out = '<div class="wrap-block">';
        $modelProduct = Product::findOne(['id' => $id]);
        $modelLinkProduct = LinkProduct::find()->where(['id_product' => $id])->all();
        //var_dump(count($modelLinkProduct));die();
        // $out = "<b>" . $modelProduct->name . "</b>";
        $modelCategory = null;
        foreach ($modelLinkProduct as $linkProduct) {
            //ar_dump($modelCategory->id.'----'.$linkProduct->id_category);
            //var_dump($modelCategory->id != $linkProduct->id_category);
            if ($modelCategory->id != $linkProduct->id_category) {
                $modelCategory = Category::findOne(['id' => $linkProduct->id_category]);
                $out .= "<div class='container-info border-con'>\n\t\t\t\t\t\t\t\t<p>" . $modelCategory->name . "</p></div>";
                $out .= "<input type='hidden' name='category[]" . "' value='" . $modelCategory->id . "'>";
                switch ($modelCategory->id_type) {
                    case 0:
                        $out .= "<div class=\"container-1 border-con\"><p><select name='sub_category_" . $modelCategory->id . "'><option>Выбрать</option>";
                        $modelLinkProduct2 = LinkProduct::find()->where(['id_product' => $id])->all();
                        foreach ($modelLinkProduct2 as $linkProduct2) {
                            if ($modelCategory->id == $linkProduct2->id_category) {
                                //var_dump($modelCategory->name);die();
                                $modelSubCategory = SubCategory::findOne(['id' => $linkProduct2->id_sub_category]);
                                $out .= "<option value='" . $modelSubCategory->id . "'>" . $modelSubCategory->name . "</option>";
                            } else {
                                continue;
                            }
                        }
                        $out .= "</select></p></div>";
                        break;
                    case 1:
                        $modelSubCategory = SubCategory::findOne(['id' => $linkProduct->id_sub_category]);
                        //var_dump($modelSubCategory);
                        $out .= "<input type='text' name='sub_category_" . $modelCategory->id . "' value='" . $modelSubCategory->id . "'>" . $modelSubCategory->name;
                        break;
                    case 2:
                        $modelLinkProduct2 = LinkProduct::find()->where(['id_product' => $id])->all();
                        foreach ($modelLinkProduct2 as $linkProduct2) {
                            //var_dump($modelCategory->id.$linkProduct2->id_category);
                            if ($modelCategory->id == $linkProduct2->id_category) {
                                $modelSubCategory = SubCategory::findOne(['id' => $linkProduct2->id_sub_category]);
                                //var_dump($modelSubCategory);
                                $out .= "<input type='radio' name='sub_category_" . $modelCategory->id . "' value='" . $modelSubCategory->id . "'>" . $modelSubCategory->name;
                            } else {
                                continue;
                            }
                        }
                        break;
                    case 3:
                        foreach ($modelLinkProduct as $linkProduct2) {
                            if ($modelCategory->id == $linkProduct2->id_category) {
                                $modelSubCategory = SubCategory::findOne(['id' => $linkProduct2->id_sub_category]);
                                $out .= "<input type='checkbox' name='sub_category_" . $modelCategory->id . "[]' value='" . $modelSubCategory->id . "'>" . $modelSubCategory->name;
                            } else {
                                continue;
                            }
                        }
                        break;
                }
                $out .= '</div>';
            }
        }
        $out .= '<div class="form-group field-order-comment has-success">
<label class="control-label" for="order-comment">Комментарий</label>
<textarea id="order-comment" class="form-control" name="Order[comment]"></textarea>
<div class="help-block"></div>
</div><div class="form-group field-order-file has-success">
<label class="control-label" for="order-file">Файлы</label>
<input type="hidden" name="Order[file]" value=""><input type="file" id="order-file" name="Order[file]">

<div class="help-block"></div>
</div></div>';
        return $out;
    }