/**
  * Lists all CsServices models.
  * @return mixed
  */
 public function actionIndex($entity = null, $title = null)
 {
     $request = Yii::$app->request;
     $session = Yii::$app->session;
     //$session->removeAll();
     $entity = $request->get('entity');
     $title = $request->get('title');
     if ($state = $request->get('st')) {
         $session->set('state', $state);
         if ($state == 'gl') {
             $session->remove('state');
         }
     }
     $q = $request->get('q');
     $queryObjects = $q ? new ActiveDataProvider(['query' => CsObjects::find()->joinWith(['t t'])->where(['like', 't.name', $q])->andWhere('cs_objects.class != "abstract"')->groupBy('cs_objects.id')]) : null;
     $queryIndustries = $q ? new ActiveDataProvider(['query' => CsIndustries::find()->joinWith(['t t'])->where(['like', 't.name', $q])->groupBy('cs_industries.id')]) : null;
     //$queryIndustries = ($q) ? $this->suggested_word($q) : null;
     $queryActions = $q ? new ActiveDataProvider(['query' => CsActions::find()->joinWith(['t t'])->where(['like', 't.name', $q])->groupBy('cs_actions.id')]) : null;
     $queryProducts = $q ? new ActiveDataProvider(['query' => CsProducts::find()->where(['like', 'name', $q])->andWhere(['or', 'level=1', 'level=2'])]) : null;
     $object = ($entity == 'o' and $title) ? $this->findObjectByTitle($title) : null;
     $industry = ($entity == 'i' and $title) ? $this->findIndustryByTitle($title) : null;
     $action = ($entity == 'a' and $title) ? $this->findActionByTitle($title) : null;
     $product = ($entity == 'p' and $title) ? $this->findProductByTitle($title) : null;
     $renderIndex = $object || $industry || $action || $product || $q ? false : true;
     $searchModel = new CsServicesSearch();
     $dataProvider = $searchModel->search(['CsServicesSearch' => ['name' => $q, 'industry_id' => $industry ? $industry->id : null, 'action_id' => $action ? $action->id : null, 'object_id' => $object ? $object->id : null]]);
     return $this->render('index', ['dataProvider' => $dataProvider, 'renderIndex' => $renderIndex, 'industry' => $industry, 'action' => $action, 'object' => $object, 'product' => $product, 'searchString' => $request->get('q'), 'queryObjects' => $queryObjects, 'queryIndustries' => $queryIndustries, 'queryActions' => $queryActions, 'queryProducts' => $queryProducts, 'countSearchResults' => $this->countSearchResults($dataProvider, $queryObjects, $queryIndustries, $queryActions, $queryProducts), 'countServicesResults' => $this->countServicesResults($dataProvider), 'countIndustriesResults' => $this->countIndustriesResults($queryIndustries), 'countActionsResults' => $this->countActionsResults($queryActions), 'countObjectsResults' => $this->countObjectsResults($queryObjects), 'countProductsResults' => $this->countProductsResults($queryProducts)]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = CsObjects::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, 'object_type_id' => $this->object_type_id, 'object_id' => $this->object_id, 'favour' => $this->favour, 'file_id' => $this->file_id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'class', $this->class]);
     return $dataProvider;
 }
Beispiel #3
0
use yii\helpers\Url;
use kartik\widgets\ActiveForm;
use kartik\switchinput\SwitchInput;
use kartik\widgets\DatePicker;
use kartik\select2\Select2;
use yii\helpers\ArrayHelper;
use kartik\widgets\FileInput;
?>


<?php 
$form = kartik\widgets\ActiveForm::begin(['id' => 'form-horizontal', 'type' => ActiveForm::TYPE_HORIZONTAL, 'fullSpan' => 7, 'formConfig' => ['labelSpan' => 3, 'deviceSize' => ActiveForm::SIZE_MEDIUM], 'options' => ['enctype' => 'multipart/form-data']]);
?>

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

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

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

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

    <?php 
 /**
  * Displays a single CsObjectTypes model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     return $this->render('view', ['model' => $this->findModel($id), 'objects' => new ActiveDataProvider(['query' => \common\models\CsObjects::find()->where(['object_type_id' => $id])])]);
 }
Beispiel #5
0
/* @var $this yii\web\View */
/* @var $model frontend\models\CsServicesSearch */
/* @var $form yii\widgets\ActiveForm */
?>


    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get', 'type' => ActiveForm::TYPE_HORIZONTAL, 'fullSpan' => 11, 'formConfig' => ['labelSpan' => 2, 'deviceSize' => ActiveForm::SIZE_SMALL]]);
?>

        <?php 
echo $form->field($model, 'industry_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\CsIndustries::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Izaberi uslužnu delatnost ...'], 'pluginOptions' => ['allowClear' => true, 'width' => '100%']]);
?>

        <?php 
echo $form->field($model, 'object_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\CsObjects::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Izaberi predmet usluge ...'], 'pluginOptions' => ['allowClear' => true, 'width' => '100%']]);
?>

        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-9">
                <?php 
echo Html::submitButton(Yii::t('app', 'Traži'), ['class' => 'btn btn-default']);
?>
            </div>
        </div>

    <?php 
ActiveForm::end();
?>