public function search($params)
 {
     $query = Organization::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'body', $this->body])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'phone2', $this->phone2])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'region', $this->region]);
     return $dataProvider;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Organization::find();
     $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;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'org_name', $this->org_name])->andFilterWhere(['like', 'position', $this->position]);
     return $dataProvider;
 }
 public function actionFeedback()
 {
     $model = new FeedbackForm();
     // Отправка запроса + валидация
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($model->sendEmail(Yii::$app->params['adminEmail'])) {
             Yii::$app->session->setFlash('success', 'Спасибо за ваше обращение, оно будет рассмотрено в ближайшее время.');
         } else {
             Yii::$app->session->setFlash('error', 'Произошла ошибка при отправке email.');
         }
         return $this->refresh();
     } else {
         $orgList = Organization::find()->select('*')->asArray()->all();
         $productList = Product::find()->select('*')->asArray()->all();
         return $this->render('feedback', ['model' => $model, 'orgList' => $orgList, 'productList' => $productList]);
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrganization0()
 {
     return $this->hasOne(Organization::className(), ['org_name' => 'organization']);
 }
 /**
  * Finds the Organization model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Organization the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Organization::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
          <del><?php 
    echo $product['price_format'];
    ?>
&nbsp;₽</del>
      </p>
      <h4><?php 
    echo $product['organization']['title'];
    ?>
</h4>
      <p>
          <?php 
    echo $product['organization']['address'];
    ?>
<br />
          <?php 
    foreach ((array) Organization::getPhones($product['organization']) as $phone) {
        ?>
              <span class="phone"><?php 
        echo $phone;
        ?>
</span><br />
          <?php 
    }
    ?>
      </p>
      <p>
          <?php 
    echo $product['title'];
    ?>
      </p>
      <a href="/product/<?php 
 /**
  * Получаем организацию
  */
 public function getOrganization()
 {
     return $this->hasOne(Organization::className(), ['id' => 'organization_id']);
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrgs()
 {
     return $this->hasMany(Organization::className(), ['id' => 'org_id'])->viaTable('tbl_specialist_has_hospital', ['spec_id' => 'id']);
 }
<?php

use yii\helpers\ArrayHelper;
use common\models\Specialist;
use common\models\SpecialistType;
use common\models\Product;
use common\models\ProductType;
use common\models\ProductCat;
use common\models\Diagnos;
use common\models\Organization;
use kartik\widgets\ActiveForm;
use kartik\builder\Form;
//Заболевания диагноз parent_id > 0
$catList = ArrayHelper::index(ProductCat::find()->where(['>', 'parent_id', 0])->asArray()->all(), 'id');
//Список организаций
$orgList = ArrayHelper::index(Organization::find()->asArray()->all(), 'id');
$specList = ArrayHelper::index(Specialist::find()->asArray()->all(), 'id');
$specTypeList = ArrayHelper::index(SpecialistType::find()->asArray()->all(), 'id');
$diagnosList = ArrayHelper::index(Diagnos::find()->asArray()->all(), 'id');
$css = <<<CSS

select.search_select {
  border: 0 none;
  width: 100%; border-bottom: 1px solid #A52024;
  border-left: 1px solid #A52024;
  padding: 3px 10px;
}

.select2-container--krajee .select2-selection {
    -webkit-box-shadow: none;
    box-shadow: none;
 /**
  * Страница поиска
  */
 public function actionSearch()
 {
     $this->showSearchBlock = true;
     $this->openAdvSearchBlock = true;
     $searchQuery = Yii::$app->request->get('q');
     $searchQueryPrice_min = (int) Yii::$app->request->get('price_min');
     $searchQueryPrice_max = (int) Yii::$app->request->get('price_max');
     $searchQueryCat = (int) Yii::$app->request->get('cat');
     $searchQueryOrg = (array) Yii::$app->request->get('org');
     $searchQuerySpec = (int) Yii::$app->request->get('spec');
     $searchQuerySpecType = (int) Yii::$app->request->get('spec_type');
     $searchQueryDiagnos = (int) Yii::$app->request->get('diagnos');
     $query = Product::find()->joinWith(['type']);
     // Поисковой запрос
     if ($searchQuery) {
         $query->where(['like', 'keywords', $searchQuery]);
     } else {
         $query->where([]);
     }
     if ($searchQuerySpecType) {
         $query->joinWith(['specType'])->andFilterWhere(['tbl_specialist_has_type.spec_type_id' => $searchQuerySpecType, 'tbl_specialist_type.id' => $searchQuerySpecType]);
     }
     if ($searchQueryDiagnos) {
         $query->joinWith(['diagnos'])->andFilterWhere(['tbl_product_type_has_diagnos.diagnos_id' => $searchQueryDiagnos, 'tbl_diagnos.id' => $searchQueryDiagnos]);
     }
     //если указана цена
     if ($searchQueryPrice_min > 0 && $searchQueryPrice_max > 0) {
         $query->andFilterWhere([">", 'price_discount', $searchQueryPrice_min]);
         $query->andFilterWhere(["<", 'price_discount', $searchQueryPrice_max]);
     }
     //если указана категория или тип заболевания
     if ($searchQueryCat > 0) {
         $query->andFilterWhere(['cat_id' => $searchQueryCat]);
     }
     //Если указаны организации
     if (count($searchQueryOrg) > 0) {
         $query->andFilterWhere(['in', 'organization_id', $searchQueryOrg]);
     }
     //если указан специалист
     if ($searchQuerySpec) {
         $query->andFilterWhere(['specialist_id' => $searchQuerySpec]);
     }
     //http://ihealthdev.upmc.ru/search?q=%D0%BB%D0%B5%D1%87%D0%B5%D0%BD%D0%B8%D0%B5&price_min=1000&price_max=200000&cat=21&org=7&spec_type=2&spec=2
     //echo $query->createCommand()->getRawSql();
     //die;
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 20]);
     $_productList = $query->offset($pages->offset)->limit($pages->limit)->with(['type', 'organization', 'specialist'])->asArray()->all();
     //Получаем новые поля price_format и price_discount_format в виде number_format
     Product::format($_productList);
     //Заболевания диагноз parent_id > 0
     //$catList = ArrayHelper::index( ProductCat::find()->where(['>','parent_id',0])->asArray()->all(), 'id' );
     //Список организаций
     //$orgList = ArrayHelper::index(Organization::find()->asArray()->all(), 'id');
     //Список специалистов
     //$specList = ArrayHelper::index(Specialist::find()->asArray()->all(), 'id');
     $productList = ['diagnost' => ['title' => 'Диагностика', 'desc' => 'Уточните свой диагноз и проблемную область', 'list' => []], 'program' => ['title' => 'Программы лечения', 'desc' => 'Посмотрите программы лечения и выберите свой курс лечения', 'list' => []], 'spec' => ['title' => 'Специалисты', 'desc' => 'Проконсультируйтесь с ведущими специлистами', 'list' => []]];
     foreach ($_productList as $item) {
         if ($item['type']) {
             if ($item['specialist_id'] > 0) {
                 $productList['spec']['list'][$item['id']] = $item;
             } elseif ($item['type']['type_index'] == 1) {
                 $productList['diagnost']['list'][$item['id']] = $item;
             } elseif ($item['type']['type_index'] == 2) {
                 $productList['program']['list'][$item['id']] = $item;
             }
         }
     }
     /*print '<pre>';
       echo count($productList['spec']['list']);
       print_r ($productList['spec']['list']);
       print '</pre>';
       die;*/
     // RightBlock data
     $typeIds = ArrayHelper::getColumn($_productList, 'type_id');
     $blockData['productList'] = Product::LoadList('*', 'priority > 0', 'priority desc', 3);
     $blockData['orgList'] = Organization::LoadList('*', 'priority > 0', 'priority desc', 2);
     return $this->render('search', ['query' => $searchQuery, 'productList' => $productList, 'productPages' => $pages, 'blockData' => $blockData]);
 }
Example #11
0
" alt="" /></p>
                <h3><?php 
    echo $org['title'];
    ?>
</h3>
                <p>
                  <?php 
    echo $org['intro'];
    ?>
                  <br />
                  <?php 
    echo $org['address'];
    ?>
                  <br />
                  <?php 
    foreach ((array) Organization::getPhones($org['id']) as $phone) {
        ?>
                        <?php 
        echo $phone;
        ?>
<br />
                  <?php 
    }
    ?>
                </p>
                <a href="/organization/<?php 
    echo $org['id'];
    ?>
" class="but">Подробнее</a>
              </div>
              <?php 
 public function actionAbout()
 {
     return $this->render('about', ['orgList' => Organization::loadList(), 'productList' => Product::loadList(), 'specList' => Specialist::loadList()]);
 }
" alt="" />
          </p>
          <h3><?php 
echo $randOrg[0]['title'];
?>
</h3>
            <p><?php 
echo $randOrg[0]['intro'];
?>
</p>
              <?php 
echo $randOrg[0]['address'];
?>
<br />
              <?php 
foreach ((array) Organization::getPhones($randOrg[0]) as $phone) {
    ?>
                  <?php 
    echo $phone;
    ?>
<br />
              <?php 
}
?>
            </p>
          <a href="/organization/7<?php 
echo $randOrg[0]['id'];
?>
" class="but">Подробнее</a>
        </div>