public function actionIndex() { $criteria = new CDbCriteria(); $criteria->compare("username", Yii::app()->user->id); $model = Residents::model()->find($criteria); $this->render('index', compact('model')); }
protected function loadUser($id = null) { if ($this->_model === null) { if ($id !== null) { $criteria->compare("username", $id); $this->_model = Residents::model()->find($criteria); } } return $this->_model; }
public function actionBarangayClearance() { $model = Residents::model()->findByAttributes(array('username' => Yii::app()->user->id)); $criteriaPunongbarangay = new CDbCriteria(); $criteriaPunongbarangay->compare("position", 'punong barangay'); $criteriaPunongbarangay->order = "date_record_created DESC"; $criteriaSecretary = new CDbCriteria(); $criteriaSecretary->compare("position", 'secretary'); $criteriaSecretary->order = "date_record_created DESC"; $punongBarangaMdl = BarangayOfficials::model()->find($criteriaPunongbarangay); $secretary = BarangayOfficials::model()->find($criteriaSecretary); $punongbarangayFull = sprintf("%s %s", $punongBarangaMdl->firstname, $punongBarangaMdl->lastname); $secretaryFull = sprintf("%s %s", $secretary->firstname, $secretary->lastname); header("Content-type:application/pdf"); header("Content-Disposition:attachment;filename='Barangay_Clearance.pdf'"); $dompdf = new DOMPDF(); $output1 = $this->renderPartial("barangayclearance", compact('model', 'punongbarangayFull', 'secretaryFull'), true); $dompdf->load_html($output1); $dompdf->render(); $dompdf->stream("Barangay_Clearance.pdf"); }
/** * 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 Residents the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Residents::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionPicture() { $model = Residents::model()->find(); $this->render('picture', compact('model')); }