model() public static method

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : the
return the static model class
コード例 #1
0
 /**
  * Retrieves all valid OphTrOperationbooking_Operation_Session_UnavailableReason that can be used for this
  * instance (i.e. includes the current value even if its no longer active).
  *
  * @return OphTrOperationbooking_Operation_Session_UnavailableReason[]
  */
 public function getUnavailableReasonList()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'enabled = true';
     $criteria->order = 'display_order asc';
     $reasons = OphTrOperationbooking_Operation_Session_UnavailableReason::model()->findAll($criteria);
     // just use standard list
     if (!$this->unavailablereason_id) {
         return $reasons;
     }
     $all_reasons = array();
     $r_ids = array();
     foreach ($reasons as $reason) {
         $all_reasons[] = $reason;
         $r_ids[] = $reason->id;
     }
     if (!in_array($this->unavailablereason_id, $r_ids)) {
         $all_reasons[] = $this->unavailablereason;
     }
     return $all_reasons;
 }
コード例 #2
0
?>
<div class="box admin">
	<h2>Patient Unavailable Reasons</h2>
	<form id="admin_sessionunavailablereasons">
		<table class="grid">
			<thead>
			<tr>
				<th>Enabled</th>
				<th>Name</th>
			</tr>
			</thead>
			<tbody class="sortable" data-sort-uri="/OphTrOperationbooking/admin/sortsessionunavailablereasons">
			<?php 
$criteria = new CDbCriteria();
$criteria->order = 'display_order asc';
foreach (OphTrOperationbooking_Operation_Session_UnavailableReason::model()->findAll() as $i => $sessionunavailablereason) {
    ?>
				<tr class="clickable" data-attr-id="<?php 
    echo $sessionunavailablereason->id;
    ?>
" data-uri="OphTrOperationbooking/admin/editsessionunavailablereason/<?php 
    echo $sessionunavailablereason->id;
    ?>
">
					<td>
						<input type="checkbox" name="sessionunavailablereason[]" value="<?php 
    echo $sessionunavailablereason->id;
    ?>
" 
							   class="sessionunavailablereasons-enabled" 
							    <?php 
コード例 #3
0
ファイル: AdminController.php プロジェクト: openeyes/openeyes
 /**
  * Disable or enable a OphTrOperationbooking_ScheduleOperation_PatientUnavailableReason.
  *
  * @throws Exception
  */
 public function actionSwitchEnabledSessionUnavailableReason()
 {
     if (!($reason = OphTrOperationbooking_Operation_Session_UnavailableReason::model()->findByPk(@$_POST['id']))) {
         throw new Exception('Session 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 Session Unavailable Reason ' . print_r($reason->getErrors(), true));
     }
     Audit::add('admin', $action, serialize($_POST), false, array('module' => 'OphTrOperationbooking', 'model' => 'OphTrOperationbooking_Operation_Session_UnavailableReason'));
 }