Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CsCategories::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, 'sector_id' => $this->sector_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
use yii\helpers\ArrayHelper;
$new_provider_industry = new \common\models\ProviderIndustries();
foreach ($user->provider->industries as $provider_industry) {
    $new_provider_industry->selection[] = $provider_industry->industry_id;
}
?>
<div class="container-fluid">
	<div class="row">
		<div class="col-md-12">				
			<?php 
$form = kartik\widgets\ActiveForm::begin(['id' => 'form-vertical', 'action' => '/' . $user->username . '/services', 'type' => ActiveForm::TYPE_VERTICAL]);
?>
				<p class="hint">Možete izabrati više vrsta.</p>
				<hr>
				<?php 
foreach (\common\models\CsCategories::find()->all() as $category) {
    $models_list = ArrayHelper::map($category->industries, 'id', 'sCaseName');
    ?>
					
					<h3><?php 
    echo $category->tName;
    ?>
</h3>
					<div class="enclosedCheckboxes" style="padding:20px 30px;">
						<div class="checkbox"><label><input type="checkbox" id="ckbCheckAll"> <i>Izaberite/Poništite sve</i></label></div>
						<ul class="column3">
						<?php 
    echo $form->field($new_provider_industry, 'selection')->checkboxList($models_list, ['unselect' => null, 'item' => function ($index, $label, $name, $checked, $value) {
        $disable = false;
        if ($checked) {
            $disable = true;
Ejemplo n.º 3
0
 public static function getAllIndustriesByCategories()
 {
     $options = [];
     $parents = CsCategories::find()->all();
     foreach ($parents as $key => $p) {
         $children = self::find()->where("category_id=:parent_id", [":parent_id" => $p->id])->all();
         $children = self::find()->where("category_id=:parent_id", [":parent_id" => $p->id])->all();
         $options[$p->name] = yii\helpers\ArrayHelper::map($children, 'id', 'tName');
         /*$child_options = [];
           foreach($children as $child) {
               $child_options[$child->id] = $child->tName;
           }
           $options[$p->tName] = $child_options;*/
     }
     return $options;
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategories()
 {
     return $this->hasMany(CsCategories::className(), ['sector_id' => 'id']);
 }
Ejemplo n.º 5
0
 /**
  * Finds the CsCategories model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CsCategories the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CsCategories::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCategory()
 {
     return $this->hasOne(CsCategories::className(), ['id' => 'category_id']);
 }
Ejemplo n.º 7
0
?>

    <?php 
echo $form->field($model_trans, 'name')->input(['value' => $model->name]);
?>

    <?php 
echo $form->field($model_trans, 'name_gen')->input(['value' => $model->name]);
?>

    <?php 
echo $form->field($model_trans, 'name_akk')->input(['value' => $model->name]);
?>
    <hr>
    <?php 
echo $form->field($model, 'category_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\CsCategories::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Izaberite...'], 'language' => 'sr-Latn', 'changeOnReset' => false]);
?>

    <?php 
echo $form->field($model, 'imageFile')->widget(FileInput::classname(), ['options' => ['accept' => 'image/*'], 'pluginOptions' => ['previewFileType' => 'any', 'showCaption' => false, 'showUpload' => false, 'browseClass' => 'btn btn-info shadow', 'browseIcon' => '<i class="glyphicon glyphicon-camera"></i> ', 'browseLabel' => Yii::t('app', 'Izaberite sliku'), 'removeLabel' => Yii::t('app', 'Izbaci sve'), 'resizeImage' => true, 'maxImageWidth' => 200, 'maxImageHeight' => 200, 'resizePreference' => 'width']]);
?>

    <?php 
if ($model->file) {
    echo '<label class="control-label col-md-3" for="">Slika delatnosti</label>';
    echo '<div class="col-sm-9 margin-bottom-20">';
    $image = Html::img('/images/industries/' . $model->file->ime);
    echo Html::a($image, Url::to(), ['class' => 'margin-bottom-10 margin-right-10']);
    echo '</div>';
}
?>