/**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($mid = null)
 {
     $model = new MarriageCertificate();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['MarriageCertificate'])) {
         $model->attributes = $_POST['MarriageCertificate'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     }
     $data = MarriageRecord::model()->findByPk($mid);
     $now = Yii::app()->dateFormatter->formatDateTime(time(), 'short', null);
     $this->render('create', array('model' => $model, 'now' => $now, 'data' => $data));
 }
 public function actionParishProfile()
 {
     $fams = Families::model()->findAll();
     $ppl = People::model()->findAll();
     $baptised1 = BaptismRecord::model()->findAll('baptism_dt > NOW() - INTERVAL 1 YEAR AND dob > NOW() - INTERVAL 1 YEAR');
     $baptised7 = BaptismRecord::model()->findAll('baptism_dt > NOW() - INTERVAL 1 YEAR AND dob BETWEEN NOW() - INTERVAL 7 YEAR AND NOW() - INTERVAL 1 YEAR');
     $baptised7p = BaptismRecord::model()->findAll('baptism_dt > NOW() - INTERVAL 1 YEAR AND dob < NOW() - INTERVAL 7 YEAR');
     $baptised = BaptismRecord::model()->findAll();
     $confirmed = ConfirmationRecord::model()->findAll('confirmation_dt > NOW() - INTERVAL 1 YEAR ');
     $firstComm = FirstCommunionRecord::model()->findAll('communion_dt > NOW() - INTERVAL 1 YEAR ');
     $married = MarriageRecord::model()->findAll('marriage_dt > NOW() - INTERVAL 1 YEAR');
     $married_cath = MarriageRecord::model()->findAll('marriage_dt > NOW() - INTERVAL 1 YEAR AND marriage_type <= 2');
     $married_nc = MarriageRecord::model()->findAll('marriage_dt > NOW() - INTERVAL 1 YEAR AND marriage_type > 2');
     $schedule = MassSchedule::model()->findAll(array('order' => 'day, time'));
     $pp = Pastors::model()->find('role = 1');
     $apps = Pastors::model()->findAll('role != 1');
     $this->render('parish-profile', array('families' => count($fams), 'members' => count($ppl), 'baptised' => count($baptised), 'baptised1' => count($baptised1), 'baptised7' => count($baptised7), 'baptised7p' => count($baptised7p), 'confirmed' => count($confirmed), 'firstComm' => count($firstComm), 'married' => count($married), 'married_nc' => count($married_nc), 'married_cath' => count($married_cath), 'pp' => $pp, 'apps' => $apps, 'schedule' => $schedule));
 }
 /**
  * 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 MarriageRecord the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = MarriageRecord::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public function get_refno()
 {
     $recs = MarriageRecord::model()->findAll(array('condition' => 'year(marriage_dt)=year(:marriage_dt) and id<=:id', 'params' => array(':marriage_dt' => $this->marriage_dt, ':id' => $this->id)));
     return date_format(new DateTime($this->marriage_dt), 'Y') . '/' . count($recs);
 }