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;
 }
Exemple #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')));
    ?>
Exemple #3
0
 public function getServices()
 {
     return $this->hasMany(Service::className(), ['id' => 'service_id'])->viaTable('service_to_complex', ['complex_id' => 'id']);
 }
 public function actionGetCalculateServiceFormAjax($id)
 {
     $calculateService = Service::findOne($id);
     return $this->renderAjax('calculate_service_widget_ajax', ['name' => $calculateService->name, 'settings' => $calculateService->settings]);
 }
Exemple #5
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);