public function search($params)
 {
     $query = Service::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'organization_id' => $this->organization_id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Beispiel #2
0
<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\bootstrap\ActiveForm;
use pistol88\service\models\Service;
use kartik\select2\Select2;
$services = Service::find()->where("parent_id = 0 OR parent_id IS NULL")->all();
$services = ArrayHelper::map($services, 'id', 'name');
?>

<div class="complex-form">

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

    <?php 
echo $form->errorSummary($model);
?>

    <?php 
echo $form->field($model, 'name')->textInput();
?>
    
    <?php 
if (yii::$app->has('organization') && ($organization = yii::$app->get('organization'))) {
    ?>
        <?php 
    echo $form->field($model, 'organization_id')->dropDownList(array_merge(['0' => 'Нет'], ArrayHelper::map($organization->getList(), 'id', 'name')));
    ?>
 public function actionGetPrices()
 {
     $categoryId = (int) yii::$app->request->post('id');
     $categoryModel = Category::findOne($categoryId);
     if (yii::$app->has('organization') && ($organization = yii::$app->organization->get())) {
         $services = Service::find()->where('(calculator = "" OR calculator IS NULL) AND organization_id = :org_id', [':org_id' => $organization->id])->orderBy('sort DESC, id ASC')->all();
         $complexes = Complex::find()->where(['organization_id' => $organization->id])->orderBy('sort DESC, id ASC')->all();
     } else {
         $services = Service::find()->where('calculator = "" OR calculator IS NULL')->orderBy('sort DESC, id ASC')->all();
         $complexes = Complex::find()->orderBy('sort DESC, id ASC')->all();
     }
     $priceModel = new Price();
     $json = [];
     $json['HtmlBlock'] = $this->renderPartial('order-type/net/services', ['priceModel' => $priceModel, 'categoryId' => $categoryId, 'services' => $services, 'complexes' => $complexes, 'categoryModel' => $categoryModel]);
     die(json_encode($json));
 }
Beispiel #4
0
<?php

use yii\helpers\Html;
use yii\helpers\ArrayHelper;
use yii\bootstrap\ActiveForm;
use pistol88\service\models\Service;
$script = <<<EOD
        if (\$('#service-calculator').val()) { \$('#calculate').attr("checked","checked"); \$('#calculateBlock').show().fadeIn();}
        \$('#calculate').on('click',function () {
            if (\$('#calculate').is(':checked')) \$('#calculateBlock').show().fadeIn();
            else \$('#calculateBlock').hide().fadeOut();
    });
EOD;
$this->registerJs($script);
$services = Service::find()->where("id != :id AND (parent_id = 0 OR parent_id IS NULL)", [':id' => (int) $model->id])->all();
$services = ArrayHelper::map($services, 'id', 'name');
$parentServices = $services;
$parentServices[0] = 'Нет';
if (!$model->parent_id) {
    $model->parent_id = 0;
}
?>

<div class="service-form">

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

    <?php 
echo $form->errorSummary($model);