/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id = null)
 {
     $model = new DeathCertificate();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['DeathCertificate'])) {
         $model->attributes = $_POST['DeathCertificate'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $rec = DeathRecord::model()->findByPk($id);
     $model->cert_dt = Yii::app()->dateFormatter->formatDateTime(time(), 'short', null);
     $this->render('create', array('model' => $model, 'death' => $rec));
 }
Пример #2
0
 public function get_refno()
 {
     $recs = DeathRecord::model()->findAll(array('condition' => 'year(death_dt)=year(:death_dt) and id<=:id', 'params' => array(':death_dt' => $this->death_dt, ':id' => $this->id)));
     return date_format(new DateTime($this->death_dt), 'Y') . '/' . count($recs);
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return DeathRecord the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = DeathRecord::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }