BaseEventTypeController::printInit PHP Method

printInit() protected method

Initialise print action.
protected printInit ( integer $id )
$id integer event id
    protected function printInit($id)
    {
        if (!($this->event = Event::model()->findByPk($id))) {
            throw new CHttpException(403, 'Invalid event id.');
        }
        $this->patient = $this->event->episode->patient;
        $this->site = Site::model()->findByPk(Yii::app()->session['selected_site_id']);
        $this->setOpenElementsFromCurrentEvent('print');
    }

Usage Example

Esempio n. 1
0
 /**
  * marks the prescription as printed. So this is the 3rd place this can happen, but not sure
  * if this is every called.
  *
  * @param int $id
  *
  * @throws Exception
  */
 public function printInit($id)
 {
     parent::printInit($id);
     if (!($prescription = Element_OphDrPrescription_Details::model()->find('event_id=?', array($id)))) {
         throw new Exception('Prescription not found: ' . $id);
     }
     $prescription->printed = 1;
     if (!$prescription->save()) {
         throw new Exception('Unable to save prescription: ' . print_r($prescription->getErrors(), true));
     }
     $this->event->info = $prescription->infotext;
     if (!$this->event->save()) {
         throw new Exception('Unable to save event: ' . print_r($this->event->getErrors(), true));
     }
 }
BaseEventTypeController