/**
  * @param Bool $filterBool
  * @throws ErrorException
  */
 private function addCondition(bool $filterBool)
 {
     foreach ($this->condition as $parameter => $queryAttr) {
         $conditionModel = new Condition();
         $conditionModel->parameter = $parameter;
         $conditionModel->attributes = $queryAttr;
         $itemFilter = $conditionModel->getElasticaFilter();
         if ($conditionModel->condition !== Condition::CONDITION_NOT_EQ) {
             $filterBool->addMust($itemFilter);
         } else {
             $filterBool->addMustNot($itemFilter);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @param array $attributes
  * @return array
  */
 private function getViewAndParamsByAttr($attributes)
 {
     $conditionModel = new Condition();
     $conditionModel->attributes = $attributes;
     if ($conditionModel->isIntegerParameter()) {
         $view = 'integerCondition';
     } elseif ($conditionModel->isBooleanParameter()) {
         $view = 'booleanCondition';
     } else {
         $view = 'stringCondition';
     }
     $property = $this->module->getProperties($attributes['parameter']);
     return ['view' => 'forms/' . $view, 'data' => ['conditionModel' => $conditionModel, 'source' => isset($property['source']) ? $property['source'] : null]];
 }
Exemplo n.º 3
0
                    <?php 
echo Html::beginForm(\Yii::$app->urlManager->createUrl('analytics/default/report'), 'post', ['class' => 'analytics-form']);
?>

                    <div class="alert alert-danger" role="alert"></div>

                    <h3><?php 
echo Yii::t('analytics', 'Conditions');
?>
</h3>
                    <div class="panel panel-default analytycs-condition">
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-md-4">
                                    <?php 
$allParametrs = Condition::getParameters();
?>
                                    <?php 
echo Html::dropDownList('condition', '', $allParametrs, ['size' => count($allParametrs), 'id' => 'condition-select']);
?>
                                    <div class="row">
                                        <div class="col-md-12">
                                            <?php 
echo Html::button(Yii::t('analytics', 'Add'), ['class' => 'btn btn-sm btn-block btn-primary']);
?>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-md-8">
                                    <div id="conditionList">
                                        <div class="row">
Exemplo n.º 4
0
<?php

use anmoroz\analytics\models\Condition;
use yii\helpers\Html;
?>
<tr id="parametr_condition_<?php 
echo $conditionModel->parameter;
?>
">
    <td><?php 
echo Condition::getParameters($conditionModel->parameter);
?>
</td>
    <td>
        <?php 
echo Html::dropDownList('condition[' . $conditionModel->parameter . '][condition]', $conditionModel->condition, Condition::getConditionForIntegerType(), ['class' => 'form-control input-small']);
?>
    </td>
    <td><?php 
echo Html::textInput('condition[' . $conditionModel->parameter . '][value]', $conditionModel->value, ['class' => 'form-control']);
?>
</td>
    <?php 
echo $this->render('_deleteButtonCell');
?>
</tr>
Exemplo n.º 5
0
<?php 
use anmoroz\analytics\models\Condition;
use yii\helpers\Html;
?>
<tr id="parametr_condition_<?php 
echo $conditionModel->parameter;
?>
">
    <td><?php 
echo Condition::getParameters($conditionModel->parameter);
?>
</td>
    <td> → </td>
    <td>
        <?php 
echo Html::hiddenInput('condition[' . $conditionModel->parameter . '][condition]', Condition::CONDITION_EQ);
?>
        <?php 
echo Html::dropDownList('condition[' . $conditionModel->parameter . '][value]', $conditionModel->value, Condition::getBooleanValues(), ['class' => 'form-control input-small']);
?>
    </td>
    <?php 
echo $this->render('_deleteButtonCell');
?>
</tr>