/** * Retrieves all valid OphTrOperationBooking_ScheduleOperation_PatientUnavailableReason that can be used for this * instance (i.e. includes the current value even if its no longer active). * * @return OphTrOperationBooking_ScheduleOperation_PatientUnavailableReason[] */ public function getPatientUnavailbleReasons() { $criteria = new CDbCriteria(); $criteria->condition = 'enabled = true'; $criteria->order = 'display_order asc'; $reasons = OphTrOperationbooking_ScheduleOperation_PatientUnavailableReason::model()->findAll($criteria); // just use standard list if (!$this->reason_id) { return $reasons; } $all_reasons = array(); $r_ids = array(); foreach ($reasons as $reason) { $all_reasons[] = $reason; $r_ids[] = $reason->id; } if (!in_array($this->reason_id, $r_ids)) { $all_reasons[] = $this->reason; } return $all_reasons; }
/** * Disable or enable a OphTrOperationbooking_ScheduleOperation_PatientUnavailableReason. * * @throws Exception */ public function actionSwitchEnabledPatientUnavailableReason() { if (!($reason = OphTrOperationbooking_ScheduleOperation_PatientUnavailableReason::model()->findByPk(@$_POST['id']))) { throw new Exception('Patient Unavailable Reason not found: ' . @$_POST['id']); } if ($reason->enabled) { $reason->enabled = 0; $action = 'disabled'; } else { $reason->enabled = 1; $action = 'enabled'; } if (!$reason->save()) { throw new Exception('Unexpected error changing enabled status for Patient Unavailable Reason ' . print_r($reason->getErrors(), true)); } Audit::add('admin', $action, serialize($_POST), false, array('module' => 'OphTrOperationbooking', 'model' => 'OphTrOperationbooking_ScheduleOperation_PatientUnavailableReason')); }
?> <div class="box admin"> <h2>Patient Unavailable Reasons</h2> <form id="admin_patientunavailablereasons"> <table class="grid"> <thead> <tr> <th>Enabled</th> <th>Name</th> </tr> </thead> <tbody class="sortable" data-sort-uri="/OphTrOperationbooking/admin/sortpatientunavailablereasons"> <?php $criteria = new CDbCriteria(); $criteria->order = 'display_order asc'; foreach (OphTrOperationbooking_ScheduleOperation_PatientUnavailableReason::model()->findAll() as $i => $patientunavailablereason) { ?> <tr class="clickable" data-attr-id="<?php echo $patientunavailablereason->id; ?> " data-uri="OphTrOperationbooking/admin/editpatientunavailablereason/<?php echo $patientunavailablereason->id; ?> "> <td><input type="checkbox" name="patientunavailablereason[]" value="<?php echo $patientunavailablereason->id; ?> " class="patientunavailablereasons-enabled" <?php if ($patientunavailablereason->enabled) { echo 'checked'; }