Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*VISTA*/
- <?php
- Load::lib('fpdf');
- $pdf=new FPDF();
- $pdf->AliasNbPages();
- $pdf->AddPage();
- $pdf->SetFont('Arial','B',20);
- foreach ($municipio as $var){
- $pdf->Cell(209,18,$var->nombre,0,0,'C');
- foreach ($var->getParroquia() as $parroquia){
- $pdf->Cell(210,18,$parroquia->nombre,0,0,'C')
- }
- $pdf->ln();
- }
- $pdf->Output();
- ?>
- /*CONTROLADOR*/
- <?php
- class PdfController extends ApplicationController {
- public function index(){
- }
- public function reporte(){
- $this->set_response('view');
- $municipio = new Municipio();
- $this->municipio = $municipio->find();
- }
- }
- ?>
- /* INDEX*/
- <? View::content(); ?>
- <?php echo link_to('pdf/reporte', 'Generar PDF')?>
- /*Modelos */
- <?php
- /*
- * Created on 26/10/2010
- *
- * To change the template for this generated file go to
- * Window - Preferences - PHPeclipse - PHP - Code Templates
- */
- class Municipio extends ActiveRecord {
- public function initialize(){
- $this->has_many('parroquia');
- }
- public function getMunicipio($page, $ppage=20){
- return $this->paginate("page: $page", "per_page: $ppage","order: nombre");
- }
- //Validacion antes de crear un registro
- public function before_validation_on_create() {
- $this->validates_uniqueness_of('nombre','message: El nombre ya existe');
- }
- public function validaEliminarMunicipio($id){
- $parroquia = new Parroquia();
- if($parroquia->find_first("municipio_id =".$id)){
- Flash::error("No se puede eliminar este registro ya que esta relacionado con al menos una Parroquia. ");
- Router::route_to('action: index', 'id: 1');
- return true;
- }
- else{
- return false;
- }
- }
- }
- ?>
- /*MODELOS***/
- <?php
- /*
- * Created on 26/10/2010
- *
- * To change the template for this generated file go to
- * Window - Preferences - PHPeclipse - PHP - Code Templates
- */
- class Parroquia extends ActiveRecord {
- public function initialize(){
- $this->belongs_to('municipio');
- $this->has_many('ficha');
- }
- public function getParroquia($page, $ppage=20){
- return $this->paginate("page: $page", "per_page: $ppage","order: nombre");
- }
- //Validacion antes de crear un registro
- public function before_validation_on_create() {
- // $this->validates_uniqueness_of('nombre','message: El nombre ya existe');
- }
- //Busca los estados perteneciente a un pais ($categoriadelito_id)
- public function buscarPorMunicipio($municipio_id){
- return $this->find("municipio_id = $municipio_id", 'order: nombre');
- }
- public function validaEliminarParroquia($id){
- $ficha = new Ficha();
- if($ficha->find_first("parroquia_id=".$id)){
- Flash::error("No se puede eliminar este registro ya que esta relacionado con al menos un Municipio. ");
- Router::route_to('action: index', 'id: 1');
- return true;
- }
- else{
- return false;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement