controller:
$this->layout = 'pdf'; //this will use the pdf.thtml layout
$d=$this->Far->query("Select contractors.name,
fars.item_name,
fars.moulding_nos,
fars.item_category,
fars.item_unit,
fars.item_size,
fars.cast_weight
>From fars Inner Join
contractors On fars.contractor_id = contractors.id where fars.item_type =
'light' AND fars.date = '".$this->data['Far']['date']."'");
$this->set('d',$d);
$this->render();
}
view:
<?php
$fpdf->AddPage('L');
$fpdf->SetFont('Arial','B',12);
$head="************************************************************************
SUPER IRON FUNDRY
*******************************************************************";
$fpdf->Cell(1,1,$head);
$c=array("Contractor Name","Item Name","Moulding Nos","Rejection
NOS","Good Casting NOS","ACT. WT.","ACT. WT.","REMARKS");
$c=implode(" ",$c);
$fpdf->Cell(5,50,$c);
$fpdf->Cell(5,55,'--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------');
$j=count($d);
$tonnage=0;
for($i=0;$i<$j;$i++){
$contractor_name=$d[$i]['contractors']['name'];
$item_name =$d[$i]['fars']['item_name'].'
'.$d[$i]['fars']['item_category'].' ( '.$d[$i]['fars']['item_size'].'
'.$d[$i]['fars']['item_unit'].' )';
$moulding_nos = $d[$i]['fars']['moulding_nos'];
$cast_weight= $d[$i]['fars']['cast_weight'];
//$all_values = implode("
",array($d[$i]['contractors']['name'],$item_name,$d[$i]['fars']['moulding_nos']));
$all_values = $d[$i]['contractors']['name'].' '.$item_name.'
'.$d[$i]['fars']['moulding_nos'];
$fpdf->Cell(.01,($i)*10+60,$all_values);
$fpdf->Cell(.03,($i+.5)*10+60,'--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------');
$tonnage=$tonnage+($moulding_nos*$cast_weight);
}
$fpdf->Cell(.01,($j)*10+60,"Tonnage=".$tonnage);
echo $fpdf->fpdfOutput();
?>
I generate pdf report by this way.This may help you.
Be Smile Always
On Tue, Feb 15, 2011 at 10:21 PM, Antar <[email protected]> wrote:
> The controller redirects to the view which will create the PDF and
> then shows the Notice (8) undefined variable error. The error message
> doesn't appear without the "echo" but all other code in the view is
> commented out at this stage so that all the view is doing is the echo.
>
> On Feb 15, 4:43 pm, John Andersen <[email protected]> wrote:
> > Where does it give you an undefined variable error?
> > Do the error disappear, when you comment out the echo statement?
> > Enjoy,
> > John
> >
> > On 15 Feb., 17:25, Antar <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > In my controller:
> >
> > > $reprint = "SELECT distinct round FROM vw_del_details where date =
> '".$ddate."' AND round BETWEEN ".$r_from." AND ". $r_to;
> >
> > > $this->set('rp',$reprint);
> >
> > > In my view:
> >
> > > echo $rp;
> >
> > > which gives an undefined variable error
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group
> at http://groups.google.com/group/cake-php
>
--
Our newest site for the community: CakePHP Video Tutorials
http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others
with their CakePHP related questions.
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php