public function actionIndex()
 {
     $male_cats = Categories::model()->getMaleCategory();
     $female_cats = Categories::model()->getFemaleCategory();
     $other_cats = Categories::model()->getOtherCategory();
     $this->render('index', array('male_cats' => $male_cats, 'female_cats' => $female_cats, 'other_cats' => $other_cats));
 }
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     switch ($_GET['s']) {
         case 'Author':
             $prof = Profile::model()->with('user', 'AuthAssignment')->findAll();
             $cat = Categories::model()->findAll();
             foreach ($cat as $key => $val) {
                 $rescat[$val->getAttributes()['id']] = $val->getAttributes()['cat_name'];
             }
             foreach ($prof as $key => $val) {
                 $res = $val->getAttributes();
                 $res1 = $val->AuthAssignment->getAttributes();
                 //---<<
                 $resuser = $val->user->getAttributes();
                 if ($res['discipline'] != '') {
                     $res['cat_name'] = implode(',', array_intersect_key($rescat, array_flip(explode(',', $res['discipline']))));
                 }
                 if ($res1['itemname'] == 'Author') {
                     $itog[$key] = array_merge($res, $resuser);
                 }
             }
             $dataProvider = new CArrayDataProvider($itog, array('pagination' => array('pageSize' => Yii::app()->controller->module->user_page_size)));
             break;
         default:
             $dataProvider = new CActiveDataProvider('User', array('criteria' => array('condition' => 'status>' . User::STATUS_BANNED, 'with' => array('AuthAssignment' => array('condition' => 'itemname="Customer"', 'together' => true))), 'pagination' => array('pageSize' => Yii::app()->controller->module->user_page_size)));
             break;
     }
     $this->render('/user/index', array('dataProvider' => $dataProvider));
 }
Example #3
0
 public function actionAddPost()
 {
     $male_cats = Categories::model()->getMaleCategory();
     $female_cats = Categories::model()->getFemaleCategory();
     $other_cats = Categories::model()->getOtherCategory();
     $celebs = Celebrities::model()->findAll();
     $this->render('addPost', array('celebs' => $celebs, 'male_cats' => $male_cats, 'female_cats' => $female_cats, 'other_cats' => $other_cats));
 }
Example #4
0
 public function run()
 {
     $criteria = new CDbCriteria();
     $criteria->limit = 4;
     $criteria->order = 'RAND()';
     $model = Categories::model()->findAll($criteria);
     $this->render('categoriesLanding', array('model' => $model));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Categories::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #6
0
 public function getArray()
 {
     $categories = Categories::model()->findAll(array('order' => 'name'));
     $array = array();
     foreach ($categories as $k => $v) {
         $array[$v->id] = $v->name;
     }
     return $array;
 }
 /**
  * Displays a listing of all blog posts
  */
 public function actionList()
 {
     $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => Yii::t('ciims.controllers.Categories', 'Categories'))));
     $this->setLayout('main');
     $this->breadcrumbs = array(Yii::t('ciims.controllers.Categories', 'All Categories'));
     $criteria = new CDbCriteria();
     $criteria->addCondition('id != 1');
     $categories = Categories::model()->findAll($criteria);
     $this->render('list', array('categories' => $categories));
 }
Example #8
0
 protected function beforeSave()
 {
     if (Categories::model()->findByPk($this->category_id)) {
         $ret = true;
     } else {
         echo 'No category with id = ' . $this->category_id;
         $ret = false;
     }
     return $ret;
 }
 /**
  * Deletes a particular model.
  * If deletion is successful, the browser will be redirected to the 'admin' page.
  * @param integer $id the ID of the model to be deleted
  */
 public function actionDelete($id)
 {
     if ($id === 1) {
         throw new CHttpException(400, Yii::t('Dashboard.main', 'Cannot delete parent category'));
     }
     // we only allow deletion via POST request
     Categories::model()->findByPk($id)->delete();
     Yii::app()->user->setFlash('success', Yii::t('Dashboard.main', 'Category has been deleted.'));
     // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
     if (!isset($_GET['ajax'])) {
         $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('index'));
     }
 }
Example #10
0
 public function actionAddCategory()
 {
     try {
         $attr = StringHelper::filterArrayString($_POST);
         if (Categories::model()->addCategory($attr)) {
             ResponseHelper::JsonReturnSuccess('', 'Success');
         } else {
             ResponseHelper::JsonReturnSuccess('', 'Error');
         }
     } catch (Exception $ex) {
         var_dump($ex->getMessage());
     }
 }
Example #11
0
 /**
  * [DELETE] [/category/<id>]
  * @return boolean
  */
 public function actionIndexDelete($id = NULL)
 {
     if ($id == NULL) {
         throw new CHttpException(400, Yii::t('Api.category', 'A category id must be specified to delete.'));
     }
     $category = Categories::model()->findByPk($id);
     if ($category == NULL) {
         throw new CHttpException(404, Yii::t('Api.category', 'A category with the id of {{id}} was not found.', array('{{id}}' => $id)));
     }
     if ($category->id == 1) {
         throw new CHttpException(400, Yii::t('Api.category', 'The root category cannot be deleted.'));
     }
     return $category->delete();
 }
Example #12
0
 protected function getItems()
 {
     $res = array();
     $cat = Categories::model()->find('isnull(parentId)');
     if ($cat == null) {
         return $res;
     }
     $url = '/' . $cat->url;
     foreach ($cat->children as $child) {
         $item = array('title' => $child->title, 'url' => $url . '/' . $child->url);
         $res['cat_f' . $child->id] = $item;
     }
     $item = array('title' => $cat->title, 'url' => $url);
     $res['cat_f' . $cat->id] = $item;
     return $res;
 }
Example #13
0
 /**
  * Retrieves all categories to display int he footer
  * @return array $items     The CMenu Items we are going to return
  */
 public function getCategories()
 {
     $items = array(array('label' => Yii::t('ciims.models.theme', 'All Posts'), 'url' => Yii::app()->createUrl('/blog')));
     $categories = Yii::app()->cache->get('categories-listing');
     if ($categories == false) {
         $criteria = new CDbCriteria();
         $criteria->addCondition('type_id = 2')->addCondition('status = 1');
         $criteria->with = 'content';
         $criteria->select = 't.id, t.slug, t.name';
         $categories = Categories::model()->findAll($criteria);
         Yii::app()->cache->set('categories-listing', $categories);
     }
     foreach ($categories as $k => $v) {
         if ($v['name'] != 'Uncategorized') {
             $items[] = array('label' => $v->name, 'url' => Yii::app()->createUrl('/' . $v->slug));
         }
     }
     return $items;
 }
 /**
  * Handles all incoming requests for the entire site that are not previous defined in CUrlManager
  * Requests come in, are verified, and then pulled from the database dynamically
  * Shows all blog posts for a particular category_id
  * @param $id	- The content ID that we want to pull from the database
  **/
 public function actionIndex($id = NULL)
 {
     // Run a pre check of our data
     $this->beforeCiiAction($id);
     // Retrieve the data
     $category = Categories::model()->findByPk($id);
     // Set the layout
     $this->setLayout('default');
     $this->setPageTitle(Yii::t('ciims.controllers.Categories', '{{app_name}} | {{label}}', array('{{app_name}}' => Cii::getConfig('name', Yii::app()->name), '{{label}}' => $category->name)));
     $pageSize = Cii::getConfig('categoryPaginationSize', 10);
     $criteria = Content::model()->getBaseCriteria()->addCondition('type_id >= 2')->addCondition("category_id = " . $id)->addCondition('password = ""');
     $criteria->limit = $pageSize;
     $criteria->order = 'created DESC';
     $itemCount = Content::model()->count($criteria);
     $pages = new CPagination($itemCount);
     $pages->pageSize = $pageSize;
     $criteria->offset = $criteria->limit * $pages->getCurrentPage();
     $data = Content::model()->findAll($criteria);
     $pages->applyLimit($criteria);
     $this->render('index', array('id' => $id, 'category' => $category, 'data' => $data, 'itemCount' => $itemCount, 'pages' => $pages, 'meta' => array('description' => $category->getDescription())));
 }
Example #15
0
<?php

/* @var $this CategoriesController */
/* @var $model Categories */
$this->breadcrumbs = array(Yii::t('site', 'Categories') => array('index'), $model->id);
$this->menu = array(array('label' => Yii::t('site', 'List Categories'), 'url' => array('index')), array('label' => Yii::t('site', 'Create Categories'), 'url' => array('create')), array('label' => Yii::t('site', 'View Categories'), 'url' => array('view', 'id' => $model->id)), array('label' => Yii::t('site', 'Manage Categories'), 'url' => array('admin')), array('label' => Yii::t('site', 'Delete Categories'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => Yii::t('site', 'Are you sure you want to delete this item?'))));
?>

<h1><?php 
echo Yii::t('site', 'View Categories');
?>
 #<?php 
echo $model->id;
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'cat_name', array('name' => 'parent_id', 'type' => 'raw', 'value' => Categories::model()->performParent($data->parent_id)))));
Example #16
0
: <?php 
    echo $model->text;
    ?>
<br>
<?php 
    echo $attributes['date'];
    ?>
: <?php 
    echo date("d.m.Y H:i:s", $event->timestamp);
    ?>
<br>
<?php 
    echo $attributes['category_id'];
    ?>
: <?php 
    echo Categories::model()->findByPk($model->category_id)->cat_name;
    ?>
<br>
<?php 
    echo $attributes['job_id'];
    ?>
: <?php 
    echo Jobs::model()->findByPk($model->job_id)->job_name;
    ?>
<br>
<?php 
    echo $attributes['max_exec_date'];
    ?>
: <?php 
    echo $model->dbmax_exec_date;
    ?>
Example #17
0
 public function categoryList($parent_id, $category, $value, $res = '', $sep = '')
 {
     //echo 'fix error not run......';die;
     foreach ($category as $m) {
         $temp_id = $m->id;
         $temp_parent_id = $m->parent_id;
         if ($temp_parent_id == $parent_id) {
             if ($temp_id == $value) {
                 $selected = 'selected="selected"';
                 $style = " style='color:#AD0000;font-weight:bold;' ";
             } else {
                 $selected = '';
                 $style = '';
             }
             if ($m->parent_id == $parent_id) {
                 $re = '<option value="' . $m->id . '" ' . $selected . $style . '>' . $sep . $m->category_name . '</option>';
                 $res .= Categories::model()->categoryList($m->id, $category, $value, $re, $sep . "--> ");
             }
         }
     }
     return $res;
 }
Example #18
0
 public static function returnCategoryNameById($cat_id)
 {
     $cat = Categories::model()->findByPk($cat_id);
     return $cat->cat_name;
 }
Example #19
0
echo CHtml::encode($data->title);
?>
    </td>
    <td>
        <?php 
echo CHtml::encode(User::model()->findByPk($data->user_id)->username);
?>
    </td>
    <td>
        <?php 
echo $data->job_id > 0 ? CHtml::encode(Jobs::model()->findByPk($data->job_id)->job_name) : '';
?>
    </td>
    <td>
        <?php 
echo CHtml::encode(Categories::model()->findByPk($data->category_id)->cat_name);
?>
    </td>
    <td>
        <?php 
echo CHtml::encode(date("Y-m-d H:i", $data->date));
?>
    </td>
    <td>
        <?php 
echo CHtml::encode(date("Y-m-d H:i", $data->manager_informed));
?>
    </td>
    <td>
        <?php 
echo CHtml::encode(date("Y-m-d H:i", $data->date_finish));
Example #20
0
 public function getOtherCategory()
 {
     $data = Categories::model()->findAllByAttributes(array('type' => 3));
     return $data;
 }
Example #21
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 protected function getAllCategories()
 {
     $categories = Categories::model()->findAll(array('order' => 'category'));
     $category_list = CHtml::listData($categories, 'category_id', 'category');
     return $category_list;
 }
Example #22
0
    if (Campaign::getId()) {
        $columns = array('id', ['name' => 'author_informed', 'value' => Yii::app()->dateFormatter->formatDateTime($order->author_informed)]);
        $projectFields = $order->getFields();
        if ($projectFields) {
            foreach ($projectFields as $field) {
                if ($field->field_type == 'LIST') {
                    $tmp = $field->varname;
                    $columns[] = ['name' => $field->title, 'type' => 'raw', 'value' => Catalog::model()->findByPk($order->{$tmp})->cat_name];
                } else {
                    $tmp = $field->varname;
                    $columns[] = ['name' => $field->title, 'value' => $order->{$tmp}];
                }
            }
        }
    } else {
        $columns = array('id', array('name' => 'category_id', 'type' => 'raw', 'value' => Categories::model()->findByPk($order->category_id)->cat_name), array('name' => 'job_id', 'type' => 'raw', 'value' => $order->job_id > 0 ? Jobs::model()->findByPk($order->job_id)->job_name : null), 'title', 'text', ['name' => 'author_informed', 'value' => Yii::app()->dateFormatter->formatDateTime($order->author_informed)], ['name' => 'date_finish', 'value' => Yii::app()->dateFormatter->formatDateTime($order->date_finish)], 'pages', 'add_demands');
    }
    $this->widget('zii.widgets.CDetailView', array('data' => $order, 'attributes' => $columns));
    echo '<div class="notes-author">';
    echo 'Заметки для автора:<br /> ' . $order->getAttribute('author_notes');
    echo '</div>';
    echo '<div class="materials"><h5>Прикреплённые материалы</h5><ul class="materials-files">' . $html_string . '</ul></div>';
} else {
    if ($order->is_active) {
        $this->renderPartial('/zakaz/_form', array('model' => $order, 'times' => $times));
    } else {
        $this->renderPartial('/zakaz/orderInModerate');
    }
}
?>
                            </div>
Example #23
0
    /**
     * @return array of category manufacturers
     */
    public function getCategory(){
        $items = Categories::model()->findByPk($this->setcat)->asCMenuArray();
        $data = array(
            'title'=>'Категории',
            'selectMany'=>true,
            'filters'=>array()
                        
        );

        if($items)
        {
            
             if(isset($items['items']))
            {
                $cookie = Yii::app()->request->cookies['city_id'];
                if($cookie){
                    $city_id = (int)$cookie->value;
                } else {
                    $city_id = MOSCID;
                }


                if(!empty(Yii::app()->request->cookies['city_all']) && Yii::app()->request->cookies['city_all'] == '1'){ // показываем все объявления
                    $cond =' (t.city_id !=0 or t.all_cities=1)';
                } else {
                    $cond = ' (t.city_id='.$city_id.' or t.all_cities=1)';  
                }
                
                foreach($items['items'] as $item)
                {

                        
                        $countProductsPerShop = 0;
                        $descendants = Categories::model()->findByPk($item['id'])->asCMenuArray();
                        if(isset($descendants['items']))
                        {
                            foreach($descendants['items'] as $d_item)
                            {
                                $countProductsPerShop = Products::model()
                                   ->count('(t.categories2 ='.$d_item['id'].' and t.is_active=1  and '.$cond.')');
                            }
                        }
                        $countProductsPerShop += Products::model()
                                ->count('(t.categories2 ='.$item['id'].' and t.is_active=1  and '.$cond.')');
                        $data['filters'][] = array(
                            'title'      => $item['label'],
                            'count'      => $countProductsPerShop,
                            'queryKey'   => 'catalog',
                            'queryParam' => $item['url']['url'],
                            'url_name'   => $item['url']['url'],
                            'descendants'=>$descendants

                        );

                                    
                }
                
                
            }
        }

        return $data;
    }
Example #24
0
echo $form->labelEx($model, 'cat_name');
?>
		<?php 
echo $form->textField($model, 'cat_name', array('size' => 60, 'maxlength' => 255));
?>
		<?php 
echo $form->error($model, 'cat_name');
?>
	</div>

	<div class="row">
	<?php 
echo $form->label($model, 'parent_id');
$criteria = new CDbCriteria();
$criteria->compare('parent_id', 0);
$list = CHtml::listData(Categories::model()->findAll($criteria), 'id', 'cat_name');
echo $form->dropDownList($model, 'parent_id', $list, array('empty' => Yii::t('site', 'Select')));
?>
	</div>

	<div class="row buttons">
		<?php 
$attr = array();
?>
		<?php 
if (Yii::app()->user->isGuest) {
    $attr['disabled'] = 'disabled';
}
?>
		<?php 
echo CHtml::submitButton($model->isNewRecord ? Yii::t('site', 'Create') : Yii::t('site', 'Save'), $attr);
Example #25
0
 function hasChild($listCat, $selectedCat)
 {
     foreach ($listCat as $item) {
         if ($selectedCat == $item->slug) {
             return $hasChild = Categories::model()->findAll("parent_id = " . $item->id);
         }
     }
     return null;
 }
Example #26
0
 /**
  * checkSlug - Recursive method to verify that the slug can be used
  * This method is purposfuly declared here to so that Content::findByPk is used instead of CiiModel::findByPk
  * @param string $slug - the slug to be checked
  * @param int $id - the numeric id to be appended to the slug if a conflict exists
  * @return string $slug - the final slug to be used
  */
 public function checkSlug($slug, $id = NULL)
 {
     $category = false;
     // Find the number of items that have the same slug as this one
     $count = $this->countByAttributes(array('slug' => $slug . $id));
     // Make sure we don't have a collision with
     if ($count == 0) {
         $category = true;
         $count = Categories::model()->countByAttributes(array('slug' => $slug . $id));
     }
     // If we found an item that matched, it's possible that it is the current item (or a previous version of it)
     // in which case we don't need to alter the slug
     if ($count) {
         // Ensures we don't have a collision on category
         if ($category) {
             return $this->checkSlug($slug, $id == NULL ? 1 : $id + 1);
         }
         // Pull the data that matches
         $data = $this->findByPk($this->id == NULL ? -1 : $this->id);
         // Check the pulled data id to the current item
         if ($data !== NULL && $data->id == $this->id) {
             return $slug;
         }
     }
     if ($count == 0 && !in_array($slug, $this->forbiddenRoutes)) {
         return $slug . $id;
     } else {
         return $this->checkSlug($slug, $id == NULL ? 1 : $id + 1);
     }
 }
Example #27
0
<?php

/* @var $this ZakazController */
/* @var $model Zakaz */
$filelist = Yii::app()->fileman->list_files($model->id);
foreach ($filelist as $fd) {
    $real_path = Yii::app()->fileman->get_file_path($fd['id'], $fd['file_id']);
    $files .= CHtml::link($fd['filename'], array('zakaz/download', 'path' => $real_path)) . '&nbsp;&nbsp;';
    //echo EDownloadHelper::download($real_path);
}
$this->breadcrumbs = array(ProjectModule::t('Zakazs') => array('index'), $model->title);
?>

<h1><?php 
echo ProjectModule::t('View Zakaz');
?>
 #<?php 
echo $model->id;
?>
</h1>
<?php 
if (User::model()->isManager() || User::model()->isAdmin()) {
    $attr = array('id', array('name' => 'user_id', 'type' => 'raw', 'value' => User::model()->findByPk($model->user_id)->username), array('name' => 'category_id', 'type' => 'raw', 'value' => Categories::model()->findByPk($model->category_id)->cat_name), array('name' => 'job_id', 'type' => 'raw', 'value' => Jobs::model()->findByPk($model->job_id)->job_name), 'title', 'text', 'date', 'max_exec_date', 'date_finish', 'pages', 'add_demands', array('name' => 'status', 'type' => 'raw', 'value' => $model->status > 0 ? ProjectStatus::model()->findByPk($model->status)->status : null), 'is_payed', 'informed', 'notes');
} else {
    $attr = array('id', array('name' => 'user_id', 'type' => 'raw', 'value' => User::model()->findByPk($model->user_id)->username), array('name' => 'category_id', 'type' => 'raw', 'value' => Categories::model()->findByPk($model->category_id)->cat_name), array('name' => 'job_id', 'type' => 'raw', 'value' => $model->job_id > 0 ? Jobs::model()->findByPk($model->job_id)->job_name : null), 'title', 'text', 'date', 'max_exec_date', 'pages', 'add_demands', array('name' => 'status', 'type' => 'raw', 'value' => $model->status > 0 ? ProjectStatus::model()->findByPk($model->status)->status : null));
}
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => $attr));
$this->widget('application.modules.project.widgets.zakazParts.ZakazPartWidget', array('projectId' => $model->id, 'userType' => '1', 'action' => 'show'));
Example #28
0
 public function getCategoryByType($type)
 {
     $data = Categories::model()->findAllByAttributes(array('type' => $type));
     return $data;
 }
		<?php echo $form->labelEx($model,'status',array('style' => 'float: left;'));
			echo $form->checkBox($model, 'status',array( 'style' => 'margin-left: 1em;',
				'checked' => ($model->status==2?'1':'0'),'data-id'=>$model->id));
			echo $form->error($model,'status'); ?>
</div>
	<?php */
echo $form->errorSummary($model);
?>
		<table>
			<tr>
				<td>
					<?php 
echo $form->labelEx($model, 'category_id');
?>
					<?php 
$models = Categories::model()->findAll();
$list = CHtml::listData($models, 'id', 'cat_name');
echo $form->dropDownList($model, 'category_id', $list, array('empty' => ProjectModule::t('Select a category')));
?>
					<?php 
echo $form->error($model, 'category_id');
?>
				</td>
				<td>
					<?php 
echo $form->labelEx($model, 'job_id');
?>
					<?php 
$models = Jobs::model()->findAll();
$list = CHtml::listData($models, 'id', 'job_name');
echo $form->dropDownList($model, 'job_id', $list, array('empty' => ProjectModule::t('Select a job')));
Example #30
0
<?php

$this->breadcrumbs = array('Manage Categories');
$this->menu = array(array('label' => 'Create Categories', 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('categories-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1>Manage Categories</h1>

<?php 
$dataProvider = new CArrayDataProvider(Categories::model()->getCategoryTree());
$this->widget('zii.widgets.grid.CGridView', array('id' => 'categories-grid', 'dataProvider' => $model->search(), 'afterAjaxUpdate' => 'function(id, data){ fixTargetBlank();}', 'columns' => array(array('header' => 'Category Name', 'name' => "category_name", 'type' => 'html'), array('header' => 'Actions', 'class' => 'CButtonColumn', 'template' => ControllerActionsName::createIndexButtonRoles($actions, array('update')), 'buttons' => array()))));