The followings are the available columns in table:
Inheritance: extends BaseActiveRecordVersioned
 /**
  * Helper method to fetch theatres by site ID.
  *
  * @param int $site_id
  *
  * @return array
  */
 protected function getFilteredWards($site_id)
 {
     $criteria = new CDbCriteria();
     $criteria->addCondition('site_id = :site_id');
     $criteria->params[':site_id'] = $site_id;
     $criteria->order = 'name';
     return CHtml::listData(OphTrOperationbooking_Operation_Ward::model()->active()->findAll($criteria), 'id', 'name');
 }
Example #2
0
 /**
  * Reorder the OphTrOperationbooking_Operation_Ward objects.
  *
  * @throws Exception
  */
 public function actionSortWards()
 {
     if (!empty($_POST['order'])) {
         $transaction = Yii::app()->db->beginTransaction();
         try {
             foreach ($_POST['order'] as $i => $id) {
                 if ($ward = OphTrOperationbooking_Operation_Ward::model()->findByPk($id)) {
                     $ward->display_order = $i + 1;
                     if (!$ward->save()) {
                         throw new Exception('Unable to save patient unavailable reason: ' . print_r($ward->getErrors(), true));
                     }
                 }
             }
             Audit::add('admin', 'sort', serialize($_POST), false, array('module' => 'OphTrOperationbooking', 'model' => 'OphTrOperationbooking_Operation_Ward'));
             $transaction->commit();
         } catch (Exception $e) {
             $transaction->rollback();
             throw $e;
         }
     }
 }
Example #3
0
	<form id="admin_wards">
		<table class="grid">
			<thead>
				<tr>
					<th><input type="checkbox" id="checkall" class="wards" /></th>
					<th>Site</th>
					<th>Name</th>
					<th>Code</th>
					<th>Restrictions</th>
				</tr>
			</thead>
			<tbody class="sortable" data-sort-uri="/OphTrOperationbooking/admin/sortwards">
				<?php 
$criteria = new CDbCriteria();
$criteria->order = 'display_order asc';
foreach (OphTrOperationbooking_Operation_Ward::model()->active()->findAll() as $i => $ward) {
    ?>
					<tr class="clickable <?php 
    if ($i % 2 == 0) {
        ?>
even<?php 
    } else {
        ?>
odd<?php 
    }
    ?>
" data-attr-id="<?php 
    echo $ward->id;
    ?>
" data-uri="OphTrOperationbooking/admin/editWard/<?php 
    echo $ward->id;
 public function getWardOptions($session)
 {
     if (!$session || !$session->id) {
         throw new Exception('Session is required.');
     }
     $siteId = $session->theatre->site_id;
     $theatreId = $session->theatre_id;
     $results = array();
     if (!empty($theatreId)) {
         if ($session->theatre->ward) {
             $results[$session->theatre->ward_id] = $session->theatre->ward->name;
         }
     }
     if (empty($results)) {
         // otherwise select by site and patient age/gender
         $patient = $this->getPatient();
         $genderRestrict = $ageRestrict = 0;
         $genderRestrict = 'M' == $patient->gender ? OphTrOperationbooking_Operation_Ward::RESTRICTION_MALE : OphTrOperationbooking_Operation_Ward::RESTRICTION_FEMALE;
         $ageRestrict = $patient->isChild($session->date) ? OphTrOperationbooking_Operation_Ward::RESTRICTION_CHILD : OphTrOperationbooking_Operation_Ward::RESTRICTION_ADULT;
         $criteria = new CDbCriteria();
         $criteria->addCondition('`t`.site_id = :siteId');
         $criteria->addCondition('`t`.restriction & :r1 >0');
         $criteria->addCondition('`t`.restriction & :r2 >0');
         $criteria->params[':siteId'] = $siteId;
         $criteria->params[':r1'] = $genderRestrict;
         $criteria->params[':r2'] = $ageRestrict;
         $criteria->order = 't.display_order asc';
         $results = CHtml::listData(OphTrOperationbooking_Operation_Ward::model()->active()->findAll($criteria), 'id', 'name');
     }
     return $results;
 }