Exemplo n.º 1
0
    public function actionGetarendatypes($id)
    {
        $result = ArendaTypesForCats::find()->select(["arenda_types_for_cats.*", "images_for_arenda_types.url", "images_for_arenda_types.url_black"])->leftJoin('images_for_arenda_types', 'arenda_types_for_cats.arenda_type_id=images_for_arenda_types.arenda_type_id')->where(['cat_id' => $id])->asArray()->all();
        while (empty($result)) {
            $cat = ModArendaTree::findOne(['id' => $id]);
            if ($cat->parent_id != 0) {
                $result = ArendaTypesForCats::find()->select(["arenda_types_for_cats.*", "images_for_arenda_types.*"])->leftJoin('images_for_arenda_types', 'arenda_types_for_cats.arenda_type_id=images_for_arenda_types.arenda_type_id')->where(['cat_id' => $cat->parent_id])->asArray()->all();
                $id = $cat->parent_id;
            } else {
                return 'none';
            }
        }
        $options = '';
        foreach ($result as $key => $value) {
            $result2 = ArendaTypes::findOne(['id' => $value['arenda_type_id']]);
            $options .= '
            <div class="col-md-2 arenda_type_col">
                <label>
                    <input type="checkbox" value="' . $result2->id . '" name="arenda_type">

                    <span class="arenda_type_img">
                        <img class="img_blue" src="/images/arenda_types_images/' . $value['arenda_type_id'] . '/' . $value['url'] . '">
                        <img class="img_black"  style="display:none;" src="/images/arenda_types_images/' . $value['arenda_type_id'] . '/' . $value['url_black'] . '">
                    </span>

                </label>

                <span class="arenda_type_title">' . $result2->name . '</span>

            </div>';
        }
        return $options;
    }
Exemplo n.º 2
0
 public function actionEditarendatype($id)
 {
     $model_upload = new UploadFile1();
     if (Yii::$app->request->isPost) {
         $model_upload->imageFile = UploadedFile::getInstance($model_upload, 'imageFile');
         $model_upload->imageFile1 = UploadedFile::getInstance($model_upload, 'imageFile1');
         if ($model_upload->upload1($id)) {
             // file is uploaded successfully
         }
     }
     $icon = ImagesForArendaTypes::findOne(['arenda_type_id' => $id]);
     @session_start();
     $_SESSION['menu'] = 4;
     $arenda_type1 = new ArendaTypes();
     $arenda_type = ArendaTypes::findOne(['id' => $id]);
     $functions = new Functions();
     if ($arenda_type1->load(Yii::$app->request->post())) {
         $arenda_type->name = $arenda_type1->name;
         $arenda_type->url = $arenda_type1->url == $arenda_type->url ? $functions->translit($arenda_type->name) : $arenda_type1->url;
         if ($arenda_type->save()) {
             $session = Yii::$app->session;
             $session->setFlash('edit', '<div class="alert alert-success">Изменения успешно сохранены.</div>');
             return $this->redirect(['editarendatype', 'id' => $id]);
         }
     }
     return $this->render('edit_arenda_type', ['model' => $arenda_type, 'icon' => $icon, 'model_upload' => $model_upload]);
 }