예제 #1
1
			<h1>Danh bạ khách sạn</h1>
		</div><!--/.page-header-->
		<div class="row-fluid">
			<div class="span12">
				<a href="<?php 
echo PIUrl::createUrl('/admin/hotel/create/');
?>
" class="btn btn-primary">
					<i class="icon-ok bigger-110"></i>
					<?php 
echo translate('Thêm');
?>
				</a>
				<form method="post">
					<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'hotel-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'htmlOptions' => array(), 'itemsCssClass' => 'table table-striped table-bordered table-hover', 'emptyText' => 'Không có kết quả hiển thị', 'selectableRows' => 2, 'summaryText' => 'Hiển thị {start} - {end} của {count} kết quả ', 'columns' => array(array('id' => 'id', 'class' => 'CCheckBoxColumn'), array('header' => 'STT', 'value' => '$this->grid->dataProvider->pagination->currentPage * $this->grid->dataProvider->pagination->pageSize + ($row+1)'), 'image' => array('name' => 'image', 'type' => 'raw', 'filter' => false, 'value' => 'CHtml::image(getImage($data->image,"80", "60" ))', 'htmlOptions' => array("class" => "image")), 'name', 'type' => array('name' => 'type', 'type' => 'raw', 'filter' => CHtml::dropDownList('Hotel[type]', '', Hotel::model()->getTypeHotel()), 'value' => 'Hotel::model()->getType($data->type)'), 'pro.title' => array('name' => 'provinces', 'type' => 'raw', 'value' => 'isset($data->pro->title) ? $data->pro->title :  ""', 'filter' => CHtml::dropDownList('Hotel[provinces]', '', Provinces::model()->getData())), 'ward.title' => array('name' => 'wards', 'type' => 'raw', 'value' => 'isset($data->ward->title) ? $data->ward->title :  ""', 'filter' => CHtml::dropDownList('Hotel[wards]', '', Wards::model()->getData())), 'address' => array('name' => 'address', 'type' => 'raw', 'value' => '$data->address', 'filter' => false), array('header' => '<input type="button" name="deleteAll" class="deleteAll btn btn-mini btn-danger icon-trash bigger-120" value="Xóa" />', 'class' => 'CButtonColumn', 'template' => '{update}{delete}', 'buttons' => array('update' => array('options' => array('class' => 'btn btn-mini btn-info icon-edit bigger-120', 'title' => 'Sửa tin tức'), 'imageUrl' => false, 'label' => false), 'delete' => array('label' => false, 'options' => array('class' => 'btn btn-mini btn-danger icon-trash bigger-120', 'title' => 'Xóa tin tức'), 'imageUrl' => false)), 'deleteConfirmation' => 'Bạn có muốn xóa tin tức này không?'))));
?>
			</form>	
			</div><!--/.span-->
		</div><!--/.row-fluid-->
	</div><!--/.page-content-->
</div><!--/.main-content-->
<style>
.grid-view .filters input, .grid-view .filters select {
    width: 92%;
}
.image img{
	width:80px;
	height:60px;
}
.btn-info{margin-right:3px;}
예제 #2
0
 public function actionDeleteAll($id)
 {
     $arrIdNew = explode(",", $id);
     for ($i = 0; $i < count($arrIdNew); $i++) {
         $model = $this->loadModel($arrIdNew[$i]);
         if (!empty($model)) {
             $ward = new Wards();
             $cri = new CDBCriteria();
             $cri->addCondition("province_id = " . $arrIdNew[$i]);
             $ward->deleteAll($cri);
         }
         $model->delete();
     }
     Yii::app()->user->setFlash('success', translate('Xóa thành công.'));
     $this->redirect(isset($_Provinces['returnUrl']) ? $_Provinces['returnUrl'] : array('index'));
 }
예제 #3
0
 public function loadModel($id)
 {
     $model = Wards::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
예제 #4
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Beds::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $bed = new Beds();
     //  $ward = new Wards();
     $ward = Wards::find(Input::get('ward'));
     $bed->ward_id = $ward->id;
     //            $bed->save();
     $bed->ward_type = \Illuminate\Support\Facades\Input::get('type');
     //            $bed->Ward_id = Input::get('ward');
     //            $bed->save();
     $bed->bed_no = Input::get('bedno');
     //            $bed->save();
     $bed->status = 'active';
     //            $bed->status= \Illuminate\Support\Facades\Input::get('status');
     $bed->save();
     return Redirect::route('adminipd.index');
 }
예제 #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy()
 {
     $id = $_GET['id'];
     $ward = Wards::find($id);
     $ward->delete();
     return Redirect::route('wards.index');
 }
예제 #6
0
 public function getData()
 {
     $data = Wards::model()->findALl();
     $result = array();
     $result[''] = '-- chọn quận/huyện --';
     foreach ($data as $dt) {
         $result[$dt->id] = $dt->title;
     }
     return $result;
 }
예제 #7
0
 /**
  * Show the form for editing the specified patient.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $patient = Patient::find($id);
     $ward = Wards::lists('ward_name', 'id');
     //$bed = Beds::lists('bed_no','id');
     $bed = DB::table('beds')->where('status', 'active')->lists('bed_no', 'id');
     return View::make('ipd.edit', compact('patient', 'ward', "bed"));
     // return View::make('ipd.edit', compact('patient'));
 }
예제 #8
0
 public function actionUpdate($id = null)
 {
     $model = Hotel::model()->findByPk($id);
     $flag = 0;
     $image_old = $model->attributes['image'];
     if (!empty($_POST['Hotel'])) {
         if (!empty(CUploadedFile::getInstance($model, 'image')->name)) {
             $image_old = $model->attributes['image'];
             $path = realpath(Yii::app()->basePath . '/../upload/images/' . $image_old);
             if (file_exists($path) && !empty($image_old)) {
                 unlink($path);
             }
             $model->attributes = $_POST['Hotel'];
             $model->image = CUploadedFile::getInstance($model, 'image');
             $image = $model->image;
             $imageType = explode('.', $model->image->name);
             $imageType = $imageType[count($imageType) - 1];
             $imageName = md5(uniqid()) . '.' . $imageType;
             $model->image = $imageName;
             $images_path = Yii::getPathOfAlias('webroot') . '/upload/images/' . $imageName;
             $flag = 1;
         } else {
             $model->attributes = $_POST['Hotel'];
             $model->image = $image_old;
         }
         $model->provinces = $_POST['provinces'];
         $model->wards = $_POST['wards'];
         $model->created = time();
         $model->alias = alias($_POST['Hotel']['name']);
         if ($model->save()) {
             Yii::app()->user->setFlash('success', translate('Cập nhập khách sạn thành công.'));
             if ($flag == 1) {
                 $image->saveAs($images_path);
             }
             $this->redirect(PIUrl::createUrl('/admin/hotel/'));
         }
     }
     $criteria = new CDBCriteria();
     $criteria->select = "id, title";
     $provinces = Provinces::model()->findAll($criteria);
     $ward = new Wards();
     $wards = $ward->getWards($model->provinces);
     $typeHotel = Hotel::model()->getTypeHotel();
     $this->render('update', array('model' => $model, 'provinces' => $provinces, 'wards' => $wards, 'typeHotel' => $typeHotel));
 }