Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : |
||
return | the static model class |
/** * @param \Patient $patient * @param bool $active * * @return models\Ticket[] */ public function getTicketsForPatient(\Patient $patient, $active = true) { $criteria = new \CDbCriteria(array('order' => 't.created_date desc')); $criteria->addColumnCondition(array('patient_id' => $patient->id)); $tickets = models\Ticket::model()->with('current_queue')->findAll($criteria); if ($active) { $res = array(); foreach ($tickets as $t) { if (!$t->is_complete()) { $res[] = $t; } } return $res; } else { return $tickets; } }
public function actionUndoLastStep($id) { if (!($ticket = models\Ticket::model()->findByPk($id))) { throw new \Exception("Ticket not found: {$id}"); } $queue_assignments = $ticket->queue_assignments; $last_assignment = array_pop($queue_assignments); if (!$last_assignment->delete()) { throw new \Exception('Unable to remove ticket queue assignment: ' . print_r($last_assignment->errors, true)); } echo '1'; }
/** * Returns true if current rules allow the patient to be added to the given queueset. * * @param \Patient $patient * @param $queueset_id * * @return bool */ public function canAddPatientToQueueSet(\Patient $patient, $queueset_id) { $tickets = models\Ticket::model()->with('current_queue')->findAllByAttributes(array('patient_id' => $patient->id)); $q_rs = $this->getQueueSetQueues($this->read($queueset_id), false); $q_ids = array_map(function ($a) { return $a->id; }, $q_rs); foreach ($tickets as $t) { if (in_array($t->current_queue->id, $q_ids)) { return false; } } return true; }
/** * @param $event * * @return mixed */ public function getTicketForEvent($event) { if ($event->id) { return Ticket::model()->findByAttributes(array('event_id' => $event->id)); } }