コード例 #1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate($id = null)
 {
     $model = new FirstCommunionCertificate();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['FirstCommunionCertificate'])) {
         $model->attributes = $_POST['FirstCommunionCertificate'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id));
         }
     } else {
         $rec = FirstCommunionRecord::model()->findByPk($id);
     }
     $this->render('create', array('model' => $model, 'firstCommunion' => $rec, 'now' => Yii::app()->dateFormatter->formatDateTime(time(), 'short', null)));
 }
コード例 #2
0
 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));
 }
コード例 #3
0
 protected function beforeSave()
 {
     if (parent::beforeSave()) {
         // Format dates based on the locale
         foreach ($this->metadata->tableSchema->columns as $columnName => $column) {
             if ($column->dbType == 'date') {
                 $this->{$columnName} = date('Y-m-d', CDateTimeParser::parse($this->{$columnName}, Yii::app()->locale->getDateFormat('short')));
             }
         }
         if (!isset($this->ref_no)) {
             $year = date_format(new DateTime($this->communion_dt), 'Y');
             $cond = "communion_dt >= '{$year}-01-01' and communion_dt <= '{$year}-12-31'";
             $parms = array();
             if (isset($this->id)) {
                 $parms[':id'] = $this->id;
                 $cond = "{$cond} and id<=:id";
             }
             $recs = FirstCommunionRecord::model()->findAll(array('condition' => $cond, 'params' => $parms));
             $cnt = count($recs);
             if (!isset($this->id)) {
                 ++$cnt;
             }
             $this->ref_no = "{$year}/{$cnt}";
         }
         return true;
     } else {
         return false;
     }
 }
コード例 #4
0
 /**
  * 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 FirstCommunionRecord the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = FirstCommunionRecord::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }