Beispiel #1
0
 public function getJobIndustryCoverageTitle()
 {
     $items = array();
     if ($this->agent_job_industry and is_array($this->agent_job_industry)) {
         $items = ArrayHelper::map(\app\modules\category\models\Category::find()->where(['module' => 'job'])->andWhere(['IN', '_id', $this->agent_job_industry])->asArray()->all(), '_id', 'name');
     }
     return $items ? implode(', ', $items) : Yii::t('common', 'Not set');
 }
Beispiel #2
0
 /** 
  * Creates data provider instance with search query applied 
  * 
  * @param array $params 
  * 
  * @return ActiveDataProvider 
  */
 public function search($params)
 {
     $query = Category::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['position' => SORT_ASC]]]);
     $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, 'parent_id' => $this->parent_id, 'position' => $this->position]);
     $query->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'keywords', $this->keywords]);
     return $dataProvider;
 }
Beispiel #3
0
 public function run()
 {
     switch ($this->type) {
         case '':
             $questions = Question::find()->where(['category' => $this->cat_id])->limit(10)->orderBy('rand()')->all();
             break;
         case 'comment':
             $questions = Question::find()->where(['count_comment' => ['$gt' => 0]])->limit(10)->orderBy('rand()')->all();
             break;
         case 'cat':
             $questions = Category::find()->where(['lft' => ['$gt' => 1], 'module' => 'question'])->limit(4)->orderBy('rand()')->all();
         default:
             break;
     }
     $assign = ['questions' => $questions, 'name' => $this->name];
     return $this->render($this->view, $assign);
 }
Beispiel #4
0
<div class="post-index">
    <p>
        <?php 
echo Html::a('Создать запись', ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    
    <?php 
Pjax::begin();
?>
    <?php 
echo himiklab\sortablegrid\SortableGridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'id' => 'post_tbl', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['class' => CheckboxColumn::classname()], ['attribute' => 'title', 'format' => 'html', 'value' => function ($model) {
    return Html::a($model['title'], ['update', 'id' => $model['id']]);
}], ['attribute' => 'cat_id', 'content' => function ($data) {
    return $data->getCategoryName();
}, 'filter' => \yii\helpers\Arrayhelper::map(\app\modules\category\models\Category::find()->all(), 'id', 'title')], ['attribute' => 'created_at', 'format' => ['date', 'dd.MM.yyyy'], 'options' => array('width' => '225px'), 'filter' => \yii\jui\DatePicker::widget(['dateFormat' => 'dd.MM.yyyy', 'model' => $searchModel, 'attribute' => 'created_at', 'options' => ['class' => 'form-control'], 'clientOptions' => ['dateFormat' => 'dd.mm.yy']])], ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    $class = $model->status === 1 ? '<i class="icon-ok"></i>' : '<i class="icon-lock">';
    return $class;
}, 'options' => array('width' => '100px'), 'filter' => Html::activeDropDownList($searchModel, 'status', array(1 => 'On', 0 => 'Off'), ['class' => 'form-control', 'prompt' => 'Все'])], ['attribute' => 'main', 'format' => 'html', 'value' => function ($model) {
    $res = $model->main === 1 ? '<i class="icon-ok"></i>' : '<i class="icon-minus">';
    return $res;
}, 'options' => array('width' => '100px'), 'filter' => Html::activeDropDownList($searchModel, 'main', array(1 => 'Да', 0 => 'Нет'), ['class' => 'form-control', 'prompt' => 'Все'])], 'username', ['class' => 'yii\\grid\\ActionColumn', 'header' => 'Действия', 'headerOptions' => ['width' => '100']]]]);
?>

<p> 
  <?php 
echo Html::a('Удалить выбранные', ['massdelete'], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Вы уверены?', 'data-method' => 'post']]);
?>
  
</p>
Beispiel #5
0
<div>

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

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

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

    <?php 
echo $form->field($model, 'parent_id')->dropdownList(\yii\helpers\ArrayHelper::map(\app\modules\category\models\Category::find()->all(), 'id', 'title'), ['prompt' => '---']);
?>



    <div class="alert alert-success" role="alert">
        <b>SEO</b>
    </div>
    <?php 
echo $form->field($model, 'keywords')->textInput(['maxlength' => 200]);
?>
    <?php 
echo $form->field($model, 'description')->textArea(['maxlength' => 200, 'rows' => 4]);
?>

    
Beispiel #6
0
 public function getCategoryNames()
 {
     $items = array();
     if ($this->category_ids and is_array($this->category_ids)) {
         $items = ArrayHelper::map(Category::find()->where(['module' => 'job'])->andWhere(['IN', '_id', $this->category_ids])->asArray()->all(), '_id', 'name');
     }
     return implode('<br/>', $items);
 }