Beispiel #1
0
 /**
  * Показывает контент
  * @return string
  * @TODO Нужно предусмотреть возможность вывода разного контента, привязаного к одной категории
  *
  */
 public function actionShow()
 {
     $this->cat_id = Yii::$app->getRequest()->getQueryParam('id') ? Yii::$app->getRequest()->getQueryParam('id') : null;
     $cat_obg = Categories::find()->where('id = ' . $this->cat_id)->one();
     $allContent = Articles::find()->where('cat_id = ' . $this->cat_id)->all();
     $allArticlesForPager = Articles::find()->where(['cat_id' => $this->cat_id]);
     $countQueryCont = clone $allArticlesForPager;
     $pagesGlobal = new Pagination(['totalCount' => $countQueryCont->count(), 'pageSize' => 1, 'forcePageParam' => false, 'pageSizeParam' => false]);
     $artPages = $allArticlesForPager->offset($pagesGlobal->offset)->limit($pagesGlobal->limit)->all();
     foreach ($allContent as $article) {
         //var_dump($this->cat_id);
         $this->article_id = $article->id;
         $article = Articles::findOne($this->article_id);
         $allArticles = ArticlesContent::find()->where(['articles_id' => $this->article_id])->orderBy(['id' => SORT_DESC]);
         //var_dump($allArticles); exit;
         $countQuery = clone $allArticles;
         $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => isset($article->onepages) ? $article->onepages : 0, 'forcePageParam' => false, 'pageSizeParam' => false]);
         $models = $allArticles->offset($pages->offset)->limit($pages->limit)->all();
         $this->source = Source::find()->where(['id' => $models[0]->source_id])->one()->title;
         $this->author = Author::find()->where(['id' => Source::find()->where(['id' => $models[0]->source_id])->one()->author_id])->one()->name;
         $this->articles[] = ['article' => $article, 'contents' => $models, 'pages' => $pages, 'source' => $this->source, 'author' => $this->author];
     }
     //var_dump($this->articles); exit;
     return $this->renderPartial($cat_obg->action, ['articles' => $this->articles, 'cat' => $this->cat_id, 'pagesGlobal' => $pagesGlobal, 'artPages' => $artPages, 'cat_obg' => $cat_obg]);
 }
Beispiel #2
0
 public function postForm(FormCategoryRequest $request)
 {
     if (!empty($request)) {
         $pathImage = $request->get('picture', null);
         $data = $request->all();
         if ($request->hasfile('picture')) {
             $validator = Validator::make($request->all(), ['picture' => ['mimes:jpg,png,jpeg']]);
             if ($validator->fails()) {
                 return redirect(action('Admin\\CategoryController@postForm'))->withErrors($validator)->withInput();
             }
             $file = $request->file('picture');
             $nameimage = date('Ymdhis') . rand(1, 1000) . '.' . $file->getClientOriginalExtension();
             $file->move(public_path() . "/dinamic/category/", $nameimage);
             $pathImage = '/dinamic/category/' . $nameimage;
             $data['picture'] = $pathImage;
         }
         $data['flagactive'] = $request->get('flagactive', 1);
         if ($request->id) {
             $obj = Categories::find($request->id);
             $obj->update($data);
             $idTips = $obj->id;
         } else {
             $obj = Categories::create($data);
             $idTips = $obj->id;
         }
         return redirect('admpanel/' . self::NAMEC)->with('messageSuccess', 'Caracteristicas Guardado');
     }
     return redirect('admpanel')->with('messageError', 'Error al guardar el tip');
 }
 /**
  * Lists all Categories models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $dataProvider = new ActiveDataProvider(['query' => Categories::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
 public function actionList($id = 0)
 {
     if ($id != 0) {
         return $this->redirect(['album/list', 'id' => $id]);
     }
     $q = Categories::find()->where(['handler' => $this->id]);
     $dataProvider = new ActiveDataProvider(['query' => $q]);
     return $this->render('list', ['dataProvider' => $dataProvider]);
 }
Beispiel #5
0
 public function actionKlavarosCats()
 {
     $res = [];
     $m = Categories::find()->where(['site_id' => 13])->all();
     foreach ($m as $h) {
         $res[] = $h->name;
     }
     return json_encode($res);
 }
Beispiel #6
0
 /**
  * Удаляет категорию
  * @param $id
  * @return \yii\web\Response
  * @throws \yii\web\HttpException
  */
 public function actionDelete($id)
 {
     if ($model = $this->loadModel($id)->delete()) {
         $cats = Categories::find()->all();
         return $this->render(['index', ['cats' => $cats]]);
     } else {
         throw new \yii\web\HttpException(404, 'Cant delete record.');
     }
 }
Beispiel #7
0
 /**
  * Updates an existing Categories model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $categoryId
  * @return mixed
  */
 public function actionUpdate($categoryId)
 {
     $categories = Categories::find()->all();
     //findAllExceptOne($categoryId);
     $model = $this->findModel($categoryId);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'categoryId' => $model->category_id]);
     } else {
         return $this->render('update', ['model' => $model, 'categories' => $categories]);
     }
 }
Beispiel #8
0
 /**
  * Updates an existing Product model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $itemId
  * @return mixed
  */
 public function actionUpdate($itemId)
 {
     $categories = Categories::find()->all();
     // need this for dropDownList in views/product/_form.php
     $model = $this->findModel($itemId);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'itemId' => $model->item_id]);
     } else {
         return $this->render('update', ['model' => $model, 'categories' => $categories]);
     }
 }
Beispiel #9
0
 public function actionList($categoryId = null)
 {
     /** @var Category $category */
     $category = null;
     $categories = Categories::find()->indexBy('category_id')->orderBy('category_id')->all();
     $productsQuery = Product::find();
     if ($categoryId !== null && isset($categories[$categoryId])) {
         $category = $categories[$categoryId];
         $productsQuery->where(['category_id' => $this->getCategoryIds($categories, $categoryId)]);
     }
     $productsDataProvider = new ActiveDataProvider(['query' => $productsQuery, 'pagination' => ['pageSize' => 10]]);
     return $this->render('list', ['category' => $category, 'menuItems' => $this->getMenuItems($categories, isset($category->category_id) ? $category->category_id : null), 'productsDataProvider' => $productsDataProvider]);
 }
Beispiel #10
0
 public function remove($category_id)
 {
     $category = Categories::find($category_id);
     $category->delete();
     if (Input::get('with_posts', '0') == '1') {
         Posts::where('category_id', $category_id)->delete();
         Notifications::add('Category removed with posts', 'success');
     } else {
         Posts::where('category_id', $category_id)->update(['category_id' => '1']);
         Notifications::add('Category removed. Posts moved to Uncategorized', 'success');
     }
     return Redirect::route('root-categories');
 }
Beispiel #11
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['category_id' => $this->category_id, 'parent_category_id' => $this->parent_category_id, 'date_added' => $this->date_added, 'date_modified' => $this->date_modified, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'category_name', $this->category_name]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_by' => $this->created_by, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Beispiel #13
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->joinWith('idArea');
     $query->andFilterWhere(['id' => $this->id, 'category_id' => $this->category_id, 'service_level_agreement_asignment' => $this->service_level_agreement_asignment, 'service_level_agreement_completion' => $this->service_level_agreement_completion]);
     $query->andFilterWhere(['like', 'categories.name', $this->name])->andFilterWhere(['like', 'categories.description', $this->description])->andFilterWhere(['like', 'areas.name', $this->id_area]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Categories::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'lft' => $this->lft, 'rgt' => $this->rgt, 'depth' => $this->depth, 'tree' => $this->tree]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Beispiel #15
0
 /**
  * @return string
  */
 public function actionIndex()
 {
     $uploadFile = new UploadForm();
     //var_dump($_POST);
     if (Yii::$app->request->isPost) {
         $uploadFile->file = UploadedFile::getInstance($uploadFile, 'file');
         // var_dump($uploadFile->file); exit;
         if ($uploadFile->file && $uploadFile->validate()) {
             $uploadFile->file->saveAs('uploads/' . Yii::$app->translater->translit($uploadFile->file->baseName) . '.' . $uploadFile->file->extension);
         } else {
             print_r($uploadFile->getErrors());
             exit;
         }
     }
     $cats = Categories::find()->where('site_id =' . $this->site->id)->roots()->all();
     $articles = Articles::find()->where('site_id =' . $this->site->id . ' or site_id = 13')->all();
     //$cats = Categories::find()->leaves()->all();
     return $this->render('index', ['cats' => $cats, 'articles' => $articles, 'uploadFile' => $uploadFile]);
 }
Beispiel #16
0
 /**
  * Updates an existing Bookings 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);
     $customers = $this->getCustomers();
     $categories = Categories::find(['ORDER BY' => 'name ASC'])->all();
     $booking_items = $this->getBookingItems($id);
     $customer = Customers::findOne($model->idCustomer);
     $is_order = !empty(Orders::find()->where(['idBooking' => $model->id])->one()->id) ? true : false;
     $date_passed = strtotime($model->deliveryDate) < strtotime(date('Y-m-d')) ? true : false;
     $delivered = $is_order ? Orders::find()->where(['idBooking' => $model->id])->one()->delivered == 1 ? true : false : false;
     if (isset($_POST['Bookings'])) {
         $model->attributes = $_POST['Bookings'];
         if (isset($_POST['added-items-list'])) {
             $this->actionAddeditems(json_decode($_POST['added-items-list']), $id);
         }
         if ($model->save()) {
             return json_encode(1);
         }
     } else {
         return $this->renderAjax('update', ['model' => $model, 'customers' => $customers, 'categories' => $categories, 'customer' => $customer, 'booking_items' => $booking_items, 'is_order' => $is_order, 'date_passed' => $date_passed, 'delivered' => $delivered]);
     }
 }
 public function index($categoryId)
 {
     $cacheTag = ['categories', 'category' . $categoryId, 'products'];
     $cacheKey = 'index';
     $response = Cache::tags($cacheTag)->remember($cacheKey, 60 * 24 * 7, function () use($categoryId) {
         $_category = Categories::find($categoryId);
         if ($_category) {
             $data = $_category->products()->select(['id', 'name', 'description', 'price', 'more', 'image'])->where('active', 1)->get()->toArray();
             if (count($data) > 0) {
                 foreach ($data as $key => $value) {
                     $data[$key]['category'] = $_category->description;
                 }
             }
             return $data;
         } else {
             return new \Exception("Houve um erro ao localizar registro (id not found)");
         }
     });
     if ($response instanceof \Exception) {
         Cache::tags($cacheTag)->flush();
     }
     return $response;
 }
 /**
  * Creates a new InsightsDef model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($idCategory = 4, $id = 0)
 {
     $model = new InsightsDef();
     $content = new InsightsContent();
     $model->name = $id;
     $model->id_category = $idCategory;
     if ($model->load(Yii::$app->request->post())) {
         $priorityCounter = 0;
         foreach (Yii::$app->request->post()['InsightsDef'] as $key => $value) {
             if (!in_array($key, ['id', 'id_category', 'priority', 'hospitals', 'units', 'specialities', 'name']) && $value != '') {
                 $priorityCounter++;
             }
         }
         $model->priority = $priorityCounter;
         $model->save();
         $content->id_insights_def = $model->id;
         $content->content = Yii::$app->request->post()['InsightsContent']['content'];
         $content->lang = 'pl';
         $content->save();
         return $this->redirect(['create', 'idCategory' => $model->id_category, 'id' => $model->id]);
     } else {
         $categories = Categories::find()->select(['name', 'id'])->indexBy('id')->column();
         $indicatorNames = CategoriesIndicators::find()->where('id_categories = ' . $idCategory)->all();
         $insights = InsightsDef::find()->where('id_category = ' . $idCategory)->all();
         $insightsCollection = [0 => ''];
         foreach ($insights as $insight) {
             $name = '';
             foreach ($insight->toArray() as $key => $value) {
                 if (!in_array($key, ['id', 'id_category', 'priority', 'hospitals', 'units', 'specialities']) && $value !== null) {
                     $name .= $key . '(' . $value . ')';
                 }
             }
             $insightsCollection[$insight->id] = $name;
         }
         return $this->render('create', ['model' => $model, 'content' => $content, 'categories' => $categories, 'indicatorNames' => $indicatorNames, 'insights' => $insightsCollection]);
     }
 }
 public function actionList($id)
 {
     $q = Categories::find()->where(['handler' => $this->id, 'parent_id' => $id]);
     $dataProvider = new ActiveDataProvider(['query' => $q]);
     return $this->render('list', ['dataProvider' => $dataProvider, 'gallery' => Categories::findOne($id)]);
 }
 /**
  * Choose a Category for an API.
  * @param integer $id
  * @return mixed
  */
 public function actionChoosecategory($id)
 {
     $model = $this->findModel($id);
     $categories = Categories::find()->asArray()->all();
     $categoriesList = ArrayHelper::map($categories, 'id', 'name');
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect('index');
     }
     return $this->render('chooseCategory', ['model' => $model, 'categoriesList' => $categoriesList]);
 }
Beispiel #21
0
 public function toCategory($post_id, $category_id)
 {
     $category = Categories::find($category_id);
     if (empty($category)) {
         Notifications::add('Category doesn\'t exist', 'danger');
         return Redirect::back();
     }
     $post = Posts::find($post_id);
     $post->category_id = $category_id;
     $post->save();
     Notifications::add('Post "' . str_limit($post->title, '35', '...') . '" moved to category "' . e($category->title) . '"', 'info');
     return Redirect::back();
 }
Beispiel #22
0
	?>
	
	<?= $form->field($request, 'name')->textInput(['value'=>$nameValue,'maxlength' => true]) ?>
	
	<?= $form->field($request, 'email')->textInput(['value'=> $emailValue,'maxlength' => true]) ?>
	
    <?= $form->field($request, 'area_id')->dropDownList(
		ArrayHelper::map(
			Areas::find()->all(),
			'id',
			'name'
		), array('prompt'=> "")) ?>
		
	<?= $form->field($request, 'category_id')->dropDownList(
		ArrayHelper::map(
			Categories::find()->all(),
			'id',
			'name'
		), array('prompt'=> "")) ?>
		

    <?= $form->field($request, 'subject')->textInput(['maxlength' => true]) ?>

    <?= $form->field($request, 'description')->textarea(['rows' => 6]) ?>
	

    <a id="agregarCampo" class="btn btn-info" >Agregar Archivo</a>
    <div id="contenedor">
        <div class="added">
            <!--<input type="file" name="Request[requestFile][]" id="campo_1" placeholder="Texto 1"/><a href="#" class="eliminar">&times;</a>-->
        </div>
Beispiel #23
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $category = Categories::find($id);
     $category->delete();
     return redirect()->route('admin.categories.index')->with('success', 'Successfully deleted!');
 }
Beispiel #24
0
 public function listCategorySub($parent, $space = '|---')
 {
     global $arr;
     $children = Categories::find()->where(['parent_id' => $parent])->all();
     foreach ($children as $child) {
         $data = array();
         $data['id'] = $child->id;
         $data['title'] = $space . ' ' . $child->title;
         $arr[] = $data;
         Categories::listCategorySub($child->id, $space . '---');
     }
 }
Beispiel #25
0
 public function actionAll()
 {
     $dataProvider = new ActiveDataProvider(['query' => Categories::find()->where(['handler' => $this->id]), 'pagination' => false]);
     return $this->render('all', ['dataProvider' => $dataProvider]);
 }
Beispiel #26
0
                        </form>
                    </div>
                    
                    <!-- Nav -->
                    <nav id="nav">
                        <ul class="sf-menu sf-js-enabled">
                            <li <?php 
if (!Yii::$app->request->get('id')) {
    echo 'class="current"';
}
?>
><a href="/">Home.</a></li>


                            <?php 
foreach (Categories::find()->orderBy(['updated_at' => SORT_DESC])->all() as $item) {
    ?>
                            <li <?php 
    if ($item->id == Yii::$app->request->get('id') && !Yii::$app->request->get('type')) {
        echo 'class="current"';
    }
    ?>
>
                            	<a href="<?php 
    echo Url::to(['site/category', 'slug' => $item->slug, 'id' => $item->id]);
    ?>
"><?php 
    echo $item->name;
    ?>
</a>
                                
Beispiel #27
0
 public function actionCreate()
 {
     $model = new Items();
     $upload = new UploadForm();
     $category = new Categories();
     $subCat = new SubCatgories();
     $category->find()->all();
     $subCat->find()->all();
     $model->is_aviable = 1;
     $description = new Description();
     $description->item_id = 1;
     $description->sub_id = 1;
     $description->text = "s";
     $description->save();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         if (isset($_POST['Description'])) {
             //                print_r($_POST['Description']['sub_name']);
             $subCat = new SubCatgories();
             $subCat->find()->where(['name' => $_POST['Description']['sub_name']])->all();
             $s = $subCat->find()->where(['name' => $_POST['Description']['sub_name']])->all();
             $description = new Description();
             $description->item_id = $model->id;
             $description->sub_id = $s[0]['id'];
             $description->text = $_POST['Description']['text'];
             $description->category_name = $_POST['Description']['category_name'];
             $description->sub_name = $_POST['Description']['sub_name'];
             $description->save();
             //                echo "sssss";
             //                echo $description->sub_id;
             //                echo $description->item_id;
         }
         if (isset($_POST['Description'])) {
             $upload = new UploadForm();
             $upload->imageFiles = UploadedFile::getInstances($upload, 'imageFiles');
             if ($upload->upload()) {
                 echo "upload";
                 // file is uploaded successfully
                 // return;
             }
         }
         //	else
         //      	return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'category' => $category, 'subCat' => $subCat, 'description' => $description, 'upload' => $upload]);
     }
 }
Beispiel #28
0
?>

        </div>
        <div class="col-lg-10">
            <?php 
$form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]);
?>

            <?php 
echo $form->field($model, 'title')->textInput();
?>
            <?php 
echo $form->field($model, 'site_id')->dropDownList(ArrayHelper::map(\app\models\Qpsites::find()->all(), 'id', 'title'), ['prompt' => 'Выбрать сайт']);
?>
             <?php 
echo $form->field($model, 'cat_id')->dropDownList(ArrayHelper::map(\app\models\Categories::find()->all(), 'id', 'name'), ['prompt' => 'Выбрать категорию']);
?>
            <?php 
echo $form->field($model, 'source_id')->dropDownList(ArrayHelper::map(\app\models\Source::find()->all(), 'id', 'title'), ['prompt' => 'Выбрать источник']);
?>
            <?php 
echo $form->field($model, 'redactor')->checkbox();
?>
            <?php 
echo $form->field($model, 'text')->textarea(['rows' => 5, 'cols' => 5, 'id' => 'my-textarea-id']);
?>
            <?php 
echo $form->field($model, 'tags')->textInput();
?>
            <?php 
echo $form->field($uploadFile, 'file')->fileInput();
Beispiel #29
0
use yii\widgets\ActiveForm;
use app\models\Categories;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model app\models\Purchases */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="purchases-form">

	<?php 
$form = ActiveForm::begin();
?>

	<?php 
echo $form->field($model, 'id_category')->dropDownList(ArrayHelper::map(Categories::find()->all(), 'id', 'name', 'parent.name'));
?>

	<?php 
echo $form->field($model, 'product')->textInput(['maxlength' => true]);
?>

	<?php 
echo $form->field($model, 'quantity')->textInput();
?>

	<?php 
echo $form->field($model, 'price')->textInput();
?>

	<?php 
Beispiel #30
0
 public function actionList($id = 0)
 {
     $dataProvider = new ActiveDataProvider(['query' => Categories::find()->where(['parent_id' => $id])->andWhere(['<>', 'alias', '0'])]);
     $model = Categories::findOne($id);
     return $this->render('list', ['dataProvider' => $dataProvider, 'model' => $model]);
 }