public function actionIndex() { // Residents::model()->deleteAll(); foreach (range(0, 5) as $key => $value) { $fakerObj = Faker\Factory::create(); $model = new Residents('createNewRecord'); $model->salutation = $fakerObj->title; $model->firstname = $fakerObj->firstName; $model->lastname = $fakerObj->lastName; $model->middle_name = $fakerObj->firstName; $model->blood_type = "O"; $model->house_number = $fakerObj->buildingNumber; $model->street_name = $fakerObj->streetName; $model->barangay_name = $fakerObj->streetName; $model->mobile_phone_number = "0906" . rand(1111111, 9999999); $model->town = "Solano"; $model->province = "Nueva Vizcaya"; $model->country = "Philippines"; $model->birthdayYear = date("Y"); $model->birthdayMonth = date("m"); $model->birthdayDate = date("d"); $model->residentSinceYear = date("Y"); $model->residentSinceMonth = date("m"); $model->residentSinceDate = date("d"); $model->employment_type = "Full-time"; if ($model->save()) { echo "New record created \r\n"; } else { echo CHtml::errorSummary($model); die; } } }
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')); }