public function actionIndex()
 {
     /*
     $model = Yii::app()->db->createCommand()
         ->select('tbl_doctor_rubrics.*')
         ->from('{{doctor_specialization}}')
         ->leftJoin('{{doctor_rubrics}}', '{{doctor_rubrics}}.id = {{doctor_specialization}}.doctor_rubrics_id')
         ->leftJoin('{{doctor_elements}}', '{{doctor_elements}}.id = {{doctor_specialization}}.doctor_elements_id')
         ->where('{{doctor_rubrics}}.`status` = 1')
         ->order('{{doctor_rubrics}}.name')
         ->queryAll();
     */
     $model = array();
     //получаем список специализаций где есть врачи
     $arrayID = array();
     foreach (DoctorSpecialization::model()->findAll() as $data) {
         $arrayID[] = $data->doctor_rubrics_id;
     }
     if (empty($arrayID)) {
         throw new CHttpException(404, 'The page can not be found.');
     }
     $model['group'] = DoctorRubrics::model()->findAll(array("condition" => "id in(" . implode(",", $arrayID) . ") AND `status`=1 ", "order" => "name ASC"));
     //получаем врачей в группах
     $model['element'] = array();
     //И список всех специализаций врача
     $model['spec'] = array();
     foreach ($model['group'] as $data) {
         $arrayID = array();
         foreach (DoctorSpecialization::model()->findAll('doctor_rubrics_id=' . $data->id) as $dataSpec) {
             $arrayID[] = $dataSpec->doctor_elements_id;
         }
         $model['element'][$data->id] = DoctorElements::model()->findAll("id in(" . implode(",", $arrayID) . ") AND `status`=1");
         foreach ($model['element'][$data->id] as $dataSpec) {
             $model['spec'][$dataSpec->id] = Yii::app()->db->createCommand()->select('{{doctor_rubrics}}.name, {{doctor_rubrics}}.url')->from('{{doctor_specialization}}')->leftJoin('{{doctor_rubrics}}', '{{doctor_rubrics}}.id = {{doctor_specialization}}.doctor_rubrics_id')->leftJoin('{{doctor_elements}}', '{{doctor_elements}}.id = {{doctor_specialization}}.doctor_elements_id')->where('{{doctor_rubrics}}.`status` = 1 AND {{doctor_elements}}.id = ' . $dataSpec->id)->order('{{doctor_rubrics}}.name ')->queryAll();
         }
     }
     $this->render('index', array('model' => $model));
 }
 /**
  * Manages all models.
  */
 public function actionIndex()
 {
     $model = new DoctorElements('search');
     $model->attachBehavior('dateComparator', array('class' => 'DateComparator'));
     $model->unsetAttributes();
     // clear any default values
     // set attributes from get
     if (isset($_GET['DoctorElements'])) {
         $model->attributes = $_GET['DoctorElements'];
     }
     $param = null;
     if (!empty($_GET['doctor_rubrics_id']) && (int) $_GET['doctor_rubrics_id'] > 0) {
         $arr = array();
         foreach (DoctorSpecialization::model()->findAll('doctor_rubrics_id = ' . (int) $_GET['doctor_rubrics_id']) as $data) {
             $arr[] = $data->doctor_elements_id;
         }
         $param = ' id in (' . implode(",", $arr) . ') ';
     }
     $this->render('list', array('model' => $model, 'param' => $param));
 }
示例#3
0
<legend><?php 
echo Yii::t("Bootstrap", "LIST.DoctorRubrics");
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = DoctorRubrics::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'doctor-rubrics-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["name"], 'name' => "name"), array('header' => $labels["url"], 'name' => "url"), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) {
    return '
                    <a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '">
                        <div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div>
                    </a>
                ';
}, 'filter' => ''), array('name' => "Элементов", 'type' => 'raw', 'value' => function ($data) {
    $count_elenemts = DoctorSpecialization::model()->count('doctor_rubrics_id=:field', array("field" => $data->id));
    return '
                    <a href="/admin/doctor/doctorelements/index?doctor_rubrics_id=' . $data->id . '">
                       ' . (!empty($count_elenemts) ? (int) $count_elenemts : "нет") . '
                    </a>
                ';
}, 'filter' => ''), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}  {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
?>


<a href="/admin/<?php 
echo Yii::app()->controller->module->id;
?>
/<?php 
echo Yii::app()->controller->id;
?>
示例#4
0
 /**
  * @param $model
  * Получить специализации. Если $model != null - проверяем выбрана ли была эта специализация ранее
  */
 public function getSpecialization($model = null)
 {
     $return['data'] = array();
     $return['selected'] = array();
     foreach (DoctorRubrics::model()->findAll('status = 1') as $data) {
         $return['data'][$data->id] = $data->name;
         if (!empty($model) && ($dataSpec = DoctorSpecialization::model()->find('doctor_rubrics_id = ' . $data->id . ' AND doctor_elements_id = ' . $model->id))) {
             $return['selected'][$data->id] = array('selected' => 'selected');
         }
     }
     return $return;
 }
示例#5
0
echo Yii::t("Bootstrap", "LIST.DoctorElements");
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = DoctorElements::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'doctor-elements-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search($param), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => 'Картинка', 'name' => "image", 'type' => 'raw', 'value' => function ($dataProvider) {
    $url_img = '/images/nophoto_100_100.jpg';
    if (file_exists(YiiBase::getPathOfAlias('webroot') . '/../uploads/filestorage/doctor/elements/admin-' . $dataProvider->id . '.' . $dataProvider->image)) {
        $url_img = '/../uploads/filestorage/doctor/elements/admin-' . $dataProvider->id . '.' . $dataProvider->image;
    }
    return '<img src="' . $url_img . '" style="width:80px" />';
}, 'filter' => ''), array('header' => $labels["name"], 'name' => "name"), array('name' => 'Специализация', 'type' => 'raw', 'value' => function ($data) {
    $spec = '';
    foreach (DoctorSpecialization::model()->findAll('doctor_elements_id = ' . $data->id) as $dataSpec) {
        $spec .= '<a href="/admin/doctor/doctorrubrics/index?DoctorRubrics[id]=' . $dataSpec->doctor_rubrics_id . '" target="_blank">' . DoctorRubrics::model()->findByPk($dataSpec->doctor_rubrics_id)->name . '</a><BR>';
    }
    return $spec;
}, 'filter' => ''), array('header' => 'Порядок', 'name' => 'order_id', 'value' => function ($data) {
    return CHtml::textField('order_' . $data->id, $data->order_id, array("class" => "order", "data-id" => $data->id, "data-order" => $data->order_id));
}, 'type' => 'raw'), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) {
    return '
                    <a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '">
                        <div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div>
                    </a>
                ';
}, 'filter' => ''), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}  {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
?>

<table>