/**
  * 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));
 }
Esempio n. 3
0
 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);
 }
 /**
  * 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 actionIndex($file)
 {
     $rfile = preg_replace('/\\.csv$/', '-rej.csv', $file);
     if (($fh = fopen($file, 'r')) !== FALSE) {
         $proc = false;
         $rej = 0;
         $num = 0;
         while (($data = fgetcsv($fh, 1000)) !== FALSE) {
             if ($proc) {
                 ++$num;
                 try {
                     $rec = new MarriageRecord();
                     $col = 0;
                     $rec->marriage_dt = FormatHelper::dateConv($data[$col++]);
                     $rec->groom_name = $data[$col++];
                     $rec->groom_dob = FormatHelper::dateConv($data[$col++]);
                     try {
                         $rec->groom_baptism_dt = FormatHelper::dateConv($data[$col++]);
                     } catch (Exception $e) {
                     }
                     $rec->groom_status = FieldNames::find_value('marital_status', $data[$col++]);
                     $rec->groom_rank_prof = $data[$col++];
                     $rec->groom_fathers_name = $data[$col++];
                     $rec->groom_mothers_name = $data[$col++];
                     $rec->groom_residence = $data[$col++];
                     $rec->bride_name = $data[$col++];
                     $rec->bride_dob = FormatHelper::dateConv($data[$col++]);
                     try {
                         $rec->bride_baptism_dt = FormatHelper::dateConv($data[$col++]);
                     } catch (Exception $e) {
                     }
                     $rec->bride_status = FieldNames::find_value('marital_status', $data[$col++]);
                     $rec->bride_rank_prof = $data[$col++];
                     $rec->bride_fathers_name = $data[$col++];
                     $rec->bride_mothers_name = $data[$col++];
                     $rec->bride_residence = $data[$col++];
                     $rec->marriage_type = FieldNames::find_value('marriage_type', $data[$col++]);
                     $rec->banns_licence = $data[$col++];
                     $rec->minister = $data[$col++];
                     $rec->witness1 = $data[$col++];
                     $rec->witness2 = $data[$col++];
                     $rec->remarks = $data[$col++];
                     if (!$rec->save()) {
                         throw new Exception("Unable to save record");
                     }
                 } catch (Exception $e) {
                     if (1 == ++$rej) {
                         if (($rej_fh = fopen($rfile, 'w')) === FALSE) {
                             echo "File {$rfile} cannot be opened in write mode. Do you have write permissions?";
                             echo "Printing rejected records to STDOUT";
                             $rej_fh = STDOUT;
                         }
                         fputcsv($rej_fh, $hdr);
                     }
                     echo "Caught exception Record #{$num}: " . $e->getMessage() . ". Saved to rejects file\n";
                     fputcsv($rej_fh, $data);
                 }
             } else {
                 $proc = true;
                 $hdr = $data;
             }
         }
     }
     fclose($fh);
     echo "Import complete. Total records: {$num}, success: " . ($num - $rej);
     if (isset($rej_fh)) {
         fclose($rej_fh);
         echo ", rejected: {$rej}.\nRejects saved to: {$rfile}";
     }
     echo ".\n";
 }