SHOW:
|
|
- or go back to the newest paste.
| 1 | //******Model*************************************************************************************************** | |
| 2 | ||
| 3 | ||
| 4 | <?php | |
| 5 | ||
| 6 | /** | |
| 7 | * This is the model class for table "h_lpu_register". | |
| 8 | * | |
| 9 | * The followings are the available columns in table 'h_lpu_register': | |
| 10 | * @property integer $id | |
| 11 | * @property string $reg_id | |
| 12 | * @property string $name | |
| 13 | * @property string $name_s | |
| 14 | * @property string $name_f | |
| 15 | * @property string $inn | |
| 16 | * @property string $ogrn | |
| 17 | * @property string $kpp | |
| 18 | * @property string $post_index_u | |
| 19 | * @property string $address_u | |
| 20 | * @property string $okopf | |
| 21 | * @property double $id_ved | |
| 22 | * @property double $org_lvl | |
| 23 | * @property string $gv_fam | |
| 24 | * @property string $gv_im | |
| 25 | * @property string $gv_ot | |
| 26 | * @property string $phone | |
| 27 | * @property string $fax | |
| 28 | * @property string $email | |
| 29 | * @property string $www | |
| 30 | * @property string $mp | |
| 31 | * @property string $last_update | |
| 32 | * @property string $okato_reg | |
| 33 | * @property integer $parent_id | |
| 34 | * @property string $gv_initials_r | |
| 35 | * @property string $usl_set | |
| 36 | * @property double $uet_usl | |
| 37 | * @property string $name_work | |
| 38 | * @property integer $is_hc | |
| 39 | * | |
| 40 | * The followings are the available model relations: | |
| 41 | * @property KsgPlan[] $ksgPlans | |
| 42 | * @property HLpuDoc[] $hLpuDocs | |
| 43 | * @property Rpn[] $rpns | |
| 44 | * @property HLpuRegInfo[] $hLpuRegInfos | |
| 45 | * @property RpnFileData[] $rpnFileDatas | |
| 46 | * @property HMesLpu[] $hMesLpus | |
| 47 | */ | |
| 48 | class HLpuRegister extends CActiveRecord | |
| 49 | {
| |
| 50 | ||
| 51 | public $dateInput; | |
| 52 | ||
| 53 | public function getDbConnection() {
| |
| 54 | return Yii::app()->db2; | |
| 55 | } | |
| 56 | /** | |
| 57 | * @return string the associated database table name | |
| 58 | */ | |
| 59 | public function tableName() | |
| 60 | {
| |
| 61 | return 'h_lpu_register'; | |
| 62 | } | |
| 63 | ||
| 64 | /** | |
| 65 | * @return array validation rules for model attributes. | |
| 66 | */ | |
| 67 | public function rules() | |
| 68 | {
| |
| 69 | // NOTE: you should only define rules for those attributes that | |
| 70 | // will receive user inputs. | |
| 71 | return array( | |
| 72 | array('dateInput', 'required'),
| |
| 73 | array('dateInput','date','format'=>'dd.MM.yyyy','message'=>'tyrtyrtyr".'),
| |
| 74 | array('id, parent_id, is_hc', 'numerical', 'integerOnly'=>true),
| |
| 75 | array('id_ved, org_lvl, uet_usl', 'numerical'),
| |
| 76 | array('reg_id, post_index_u', 'length', 'max'=>6),
| |
| 77 | array('name, www', 'length', 'max'=>100),
| |
| 78 | array('name_s, name_f, address_u, name_work', 'length', 'max'=>250),
| |
| 79 | array('inn, kpp', 'length', 'max'=>12),
| |
| 80 | array('ogrn', 'length', 'max'=>15),
| |
| 81 | array('okopf', 'length', 'max'=>2),
| |
| 82 | array('gv_fam, gv_im, gv_ot, phone, fax, gv_initials_r', 'length', 'max'=>40),
| |
| 83 | array('email', 'length', 'max'=>50),
| |
| 84 | array('mp, usl_set', 'length', 'max'=>10),
| |
| 85 | array('last_update', 'length', 'max'=>4),
| |
| 86 | array('okato_reg', 'length', 'max'=>5),
| |
| 87 | ||
| 88 | ||
| 89 | // The following rule is used by search(). | |
| 90 | // @todo Please remove those attributes that should not be searched. | |
| 91 | array('reg_id, name, name_s, name_f, inn, ogrn, kpp, post_index_u, address_u, okopf, id_ved, org_lvl, gv_fam, gv_im, gv_ot, phone, fax, email, www, mp, last_update, okato_reg, parent_id, gv_initials_r, usl_set, uet_usl, name_work, is_hc', 'safe', 'on'=>'search'),
| |
| 92 | ); | |
| 93 | } | |
| 94 | ||
| 95 | /** | |
| 96 | * @return array relational rules. | |
| 97 | */ | |
| 98 | public function relations() | |
| 99 | {
| |
| 100 | // NOTE: you may need to adjust the relation name and the related | |
| 101 | // class name for the relations automatically generated below. | |
| 102 | return array( | |
| 103 | /*'ksgPlans' => array(self::HAS_MANY, 'KsgPlan', 'mo_id'),*/ | |
| 104 | 'hLpuDocs' => array(self::HAS_MANY, 'HLpuDoc', 'lpu'), | |
| 105 | /*'rpns' => array(self::HAS_MANY, 'Rpn', 'mo_id'),*/ | |
| 106 | 'hLpuRegInfos' => array(self::HAS_MANY, 'HLpuRegInfo', 'lpu'), | |
| 107 | /*'rpnFileDatas' => array(self::HAS_MANY, 'RpnFileData', 'mo_id'), | |
| 108 | 'hMesLpus' => array(self::HAS_MANY, 'HMesLpu', 'lpu'),*/ | |
| 109 | 'medHealth'=>array(self::HAS_MANY,'HV008','mp') | |
| 110 | ); | |
| 111 | } | |
| 112 | ||
| 113 | /** | |
| 114 | * @return array customized attribute labels (name=>label) | |
| 115 | */ | |
| 116 | public function attributeLabels() | |
| 117 | {
| |
| 118 | return array( | |
| 119 | 'id' => '#', | |
| 120 | 'reg_id' => 'Код', | |
| 121 | 'name' => 'Наименование', | |
| 122 | 'name_s' => 'Краткое наименование', | |
| 123 | 'name_f' => 'Полное наименование', | |
| 124 | 'inn' => 'ИНН', | |
| 125 | 'ogrn' => 'ОГРН', | |
| 126 | 'kpp' => 'КПП', | |
| 127 | 'post_index_u' => 'Post Index U', | |
| 128 | 'address_u' => 'Address U', | |
| 129 | 'okopf' => 'Okopf', | |
| 130 | 'id_ved' => 'Id Ved', | |
| 131 | 'org_lvl' => 'Org Lvl', | |
| 132 | 'gv_fam' => 'Gv Fam', | |
| 133 | 'gv_im' => 'Gv Im', | |
| 134 | 'gv_ot' => 'Gv Ot', | |
| 135 | 'phone' => 'Телефон', | |
| 136 | 'fax' => 'Факс', | |
| 137 | 'email' => 'Email', | |
| 138 | 'www' => 'Www', | |
| 139 | 'mp' => 'Mp', | |
| 140 | 'last_update' => 'Last Update', | |
| 141 | 'okato_reg' => 'Okato Reg', | |
| 142 | 'parent_id' => 'Parent', | |
| 143 | 'gv_initials_r' => 'Gv Initials R', | |
| 144 | 'usl_set' => 'Usl Set', | |
| 145 | 'uet_usl' => 'Uet Usl', | |
| 146 | 'name_work' => 'Name Work', | |
| 147 | 'is_hc' => 'Is Hc', | |
| 148 | ||
| 149 | 'dateInput'=>'Фильтр по дате', | |
| 150 | ); | |
| 151 | } | |
| 152 | ||
| 153 | /** | |
| 154 | * Retrieves a list of models based on the current search/filter conditions. | |
| 155 | * | |
| 156 | * Typical usecase: | |
| 157 | * - Initialize the model fields with values from filter form. | |
| 158 | * - Execute this method to get CActiveDataProvider instance which will filter | |
| 159 | * models according to data in model fields. | |
| 160 | * - Pass data provider to CGridView, CListView or any similar widget. | |
| 161 | * | |
| 162 | * @return CActiveDataProvider the data provider that can return the models | |
| 163 | * based on the search/filter conditions. | |
| 164 | */ | |
| 165 | public function search() | |
| 166 | {
| |
| 167 | // @todo Please modify the following code to remove attributes that should not be searched. | |
| 168 | ||
| 169 | $criteria=new CDbCriteria; | |
| 170 | ||
| 171 | $criteria->compare('id',$this->id);
| |
| 172 | $criteria->compare('reg_id',$this->reg_id,true);
| |
| 173 | $criteria->compare('name',$this->name,true);
| |
| 174 | $criteria->compare('name_s',$this->name_s,true);
| |
| 175 | $criteria->compare('name_f',$this->name_f,true);
| |
| 176 | $criteria->compare('inn',$this->inn,true);
| |
| 177 | $criteria->compare('ogrn',$this->ogrn,true);
| |
| 178 | $criteria->compare('kpp',$this->kpp,true);
| |
| 179 | $criteria->compare('post_index_u',$this->post_index_u,true);
| |
| 180 | $criteria->compare('address_u',$this->address_u,true);
| |
| 181 | $criteria->compare('okopf',$this->okopf,true);
| |
| 182 | $criteria->compare('id_ved',$this->id_ved);
| |
| 183 | $criteria->compare('org_lvl',$this->org_lvl);
| |
| 184 | $criteria->compare('gv_fam',$this->gv_fam,true);
| |
| 185 | $criteria->compare('gv_im',$this->gv_im,true);
| |
| 186 | $criteria->compare('gv_ot',$this->gv_ot,true);
| |
| 187 | $criteria->compare('phone',$this->phone,true);
| |
| 188 | $criteria->compare('fax',$this->fax,true);
| |
| 189 | $criteria->compare('email',$this->email,true);
| |
| 190 | $criteria->compare('www',$this->www,true);
| |
| 191 | //$criteria->compare('mp',$this->mp,true);
| |
| 192 | $criteria->compare('last_update',$this->last_update,true);
| |
| 193 | $criteria->compare('okato_reg',$this->okato_reg,true);
| |
| 194 | $criteria->compare('parent_id',$this->parent_id);
| |
| 195 | $criteria->compare('gv_initials_r',$this->gv_initials_r,true);
| |
| 196 | $criteria->compare('usl_set',$this->usl_set,true);
| |
| 197 | $criteria->compare('uet_usl',$this->uet_usl);
| |
| 198 | $criteria->compare('name_work',$this->name_work,true);
| |
| 199 | $criteria->compare('is_hc',$this->is_hc);
| |
| 200 | //$criteria->compare('dateInput',$this->dateInput);
| |
| 201 | ||
| 202 | ||
| 203 | $criteria->together = true; | |
| 204 | $criteria->with = array('hLpuRegInfos');
| |
| 205 | $criteria->condition = ':now BETWEEN hLpuRegInfos.date_1 AND hLpuRegInfos.date_2'; | |
| 206 | //$criteria->condition = ':now BETWEEN hLpuDocs.date_1 AND hLpuDocs.date_2'; | |
| 207 | //$criteria->params = array(':now'=>isset($this->dateInput)?$this->dateInput:date('d.m.Y'));
| |
| 208 | $criteria->params = array(':now'=>$this->dateInput);
| |
| 209 | ||
| 210 | return new CActiveDataProvider($this, array( | |
| 211 | 'criteria'=>$criteria, | |
| 212 | 'pagination'=> array( | |
| 213 | 'pageSize'=>50 | |
| 214 | ) | |
| 215 | )); | |
| 216 | } | |
| 217 | ||
| 218 | public function getDocLpu() | |
| 219 | {
| |
| 220 | ||
| 221 | foreach ($this->hLpuDocs as $value) {
| |
| 222 | $array[]=$value->doc_num; | |
| 223 | } | |
| 224 | if(!isset($value->doc_num)){
| |
| 225 | $array[]='нет'; | |
| 226 | } | |
| 227 | //$array=isset($array)?$array:'нет'; | |
| 228 | $result = implode(', ',$array);
| |
| 229 | return $result; | |
| 230 | } | |
| 231 | public function getMedPom() | |
| 232 | {
| |
| 233 | $mp = is_null($this->mp)?'1':chop($this->mp, ','); | |
| 234 | $array = explode(',',$mp);
| |
| 235 | foreach ($array as $value) {
| |
| 236 | $name[]=HV008::model()->find('code=:value',array(':value'=>$value))->name;
| |
| 237 | } | |
| 238 | $result = implode(', ',$name);
| |
| 239 | return $result; | |
| 240 | } | |
| 241 | ||
| 242 | public function coalesce() {
| |
| 243 | $args = func_get_args(); | |
| 244 | foreach ($args as $arg) {
| |
| 245 | if (!empty($arg)) {
| |
| 246 | return $arg; | |
| 247 | } | |
| 248 | } | |
| 249 | return null; | |
| 250 | } | |
| 251 | /** | |
| 252 | * Returns the static model of the specified AR class. | |
| 253 | * Please note that you should have this exact method in all your CActiveRecord descendants! | |
| 254 | * @param string $className active record class name. | |
| 255 | * @return HLpuRegister the static model class | |
| 256 | */ | |
| 257 | public static function model($className=__CLASS__) | |
| 258 | {
| |
| 259 | return parent::model($className); | |
| 260 | } | |
| 261 | } | |
| 262 | ||
| 263 | ||
| 264 | //******Controller************************************************************************************************* | |
| 265 | ||
| 266 | ||
| 267 | ||
| 268 | ||
| 269 | public function actionIndex() | |
| 270 | {
| |
| 271 | //$this->layout = '//layouts/main'; | |
| 272 | $model=new HLpuRegister; | |
| 273 | $model->unsetAttributes(); // clear any default values | |
| 274 | if(isset($_GET['HLpuRegister'])){
| |
| 275 | $model->attributes=$_GET['HLpuRegister']; | |
| 276 | $model->dateInput = $_GET['HLpuRegister']['dateInput']; | |
| 277 | $model->validate(); | |
| 278 | //$this->refresh(); | |
| 279 | } | |
| 280 | ||
| 281 | $this->render('index',array(
| |
| 282 | 'model'=>$model, | |
| 283 | )); | |
| 284 | /* | |
| 285 | $dataProvider=new CActiveDataProvider('HLpuRegister');
| |
| 286 | $this->render('index',array(
| |
| 287 | 'dataProvider'=>$dataProvider, | |
| 288 | ));*/ | |
| 289 | - | } |
| 289 | + | |
| 290 | ||
| 291 | ||
| 292 | //**********View***************** | |
| 293 | ||
| 294 | ||
| 295 | <?php | |
| 296 | $this->breadcrumbs=array( | |
| 297 | 'Реестр МО', | |
| 298 | ); | |
| 299 | ||
| 300 | $this->menu=array( | |
| 301 | array('label'=>'Create HLpuRegister','url'=>array('create')),
| |
| 302 | array('label'=>'Manage HLpuRegister','url'=>array('admin')),
| |
| 303 | ); | |
| 304 | ?> | |
| 305 | ||
| 306 | <h1>Реестр медицинских организаций ЯНАО:</h1> | |
| 307 | ||
| 308 | <div class="alert alert-success"> | |
| 309 | <strong>Реестр медицинских организаций ЯНАО по состоянию на <?php echo isset($model->dateInput)?$model->dateInput:date('d.m.Y') ; ?>:</strong>
| |
| 310 | </div> | |
| 311 | <?php /*$this->widget('bootstrap.widgets.TbListView',array(
| |
| 312 | 'dataProvider'=>$dataProvider, | |
| 313 | 'itemView'=>'_view', | |
| 314 | )); */ | |
| 315 | ?> | |
| 316 | ||
| 317 | ||
| 318 | <div class="search-form"> | |
| 319 | ||
| 320 | <?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
| |
| 321 | 'action'=>Yii::app()->createUrl($this->route), | |
| 322 | 'method'=>'get', | |
| 323 | 'type' => 'inline', | |
| 324 | 'htmlOptions' => array('class' => 'well'),
| |
| 325 | 'enableClientValidation'=>true, | |
| 326 | 'clientOptions'=>array( | |
| 327 | 'validateOnSubmit'=>true, | |
| 328 | ), | |
| 329 | )); ?> | |
| 330 | <?php echo $form->errorSummary($model); ?> | |
| 331 | ||
| 332 | <?php //echo $form->datePickerRow($model,'dateInput',array('options'=>array('format' => 'dd.mm.yyyy','weekStart'=> 1,'autoclose'=>'true',))); ?>
| |
| 333 | <?php echo $form->textFieldRow($model,'dateInput'); ?> | |
| 334 | ||
| 335 | ||
| 336 | <?php $this->widget('bootstrap.widgets.TbButton', array(
| |
| 337 | 'buttonType' => 'submit', | |
| 338 | 'type'=>'primary', | |
| 339 | 'label'=>'Поиск', | |
| 340 | )); ?> | |
| 341 | ||
| 342 | ||
| 343 | <?php $this->endWidget(); ?> | |
| 344 | </div> | |
| 345 | ||
| 346 | ||
| 347 | <?php $this->widget('bootstrap.widgets.TbGridView',array(
| |
| 348 | 'id'=>'hlpu-register-grid', | |
| 349 | 'type'=>'striped bordered condensed', | |
| 350 | 'dataProvider'=>$model->search(), | |
| 351 | 'filter'=>$model, | |
| 352 | //'template'=>'{items}{pager}{summary}',
| |
| 353 | 'columns'=>array( | |
| 354 | //'id', | |
| 355 | 'reg_id', | |
| 356 | //'name', | |
| 357 | 'name_s', | |
| 358 | 'name_f', | |
| 359 | //'inn', | |
| 360 | ||
| 361 | //'ogrn', | |
| 362 | //'kpp', | |
| 363 | /*'post_index_u', | |
| 364 | 'address_u', | |
| 365 | 'okopf',*/ | |
| 366 | array( | |
| 367 | 'header'=>'Руководитель', | |
| 368 | 'value'=>'$data->gv_fam." ".$data->gv_im." ".$data->gv_ot."."' | |
| 369 | ), | |
| 370 | //'id_ved', | |
| 371 | //'org_lvl', | |
| 372 | //'gv_fam', | |
| 373 | //'gv_im', | |
| 374 | //'gv_ot', | |
| 375 | array( | |
| 376 | 'header'=>'Контакты', | |
| 377 | 'value'=>'$data->post_index_u." ".$data->address_u." ".$data->phone." ".$data->fax." ".$data->email." ".$data->www."."' | |
| 378 | ), | |
| 379 | array( | |
| 380 | 'header'=>'Виды медицинской помощи', | |
| 381 | 'value'=>'$data->getMedPom()' | |
| 382 | ), | |
| 383 | array( | |
| 384 | 'header'=>'Разрешительные документы', | |
| 385 | 'value'=>'$data->getDocLpu()' | |
| 386 | ), | |
| 387 | /*'phone', | |
| 388 | 'fax', | |
| 389 | 'email', | |
| 390 | 'www',*/ | |
| 391 | /*'mp', | |
| 392 | 'last_update', | |
| 393 | 'okato_reg', | |
| 394 | 'parent_id', | |
| 395 | 'gv_initials_r', | |
| 396 | 'usl_set', | |
| 397 | 'uet_usl', | |
| 398 | 'name_work', | |
| 399 | 'is_hc', | |
| 400 | */ | |
| 401 | ||
| 402 | ), | |
| 403 | )); ?> |