AddPage(); $pdf->SetFillColor(232,232,232); $pdf->roundedrect(10,10,196,31,4,'FD','1234'); $pdf->SetFont('Arial','B',12); $pdf->setY(50); $pdf->Cell('25','5','Invoice #','1','','C','1'); $pdf->Cell('27','5','Invoice Date','1','1','C','1'); $pdf->SetFont('Arial','B',10); $pdf->Cell('25','4',$invrow[invoice_id],'1','','C'); $pdf->Cell('27','4',date("m.d.y",$invrow[creation_date]),'1','1','C'); $pdf->SetXY(90,50); $pdf->SetFont('Arial','B',12); $pdf->Cell('30','5','CLIENT NAME','1','','C','1'); $pdf->SetFont('Arial','B',10); $pdf->Cell('85','5',$userinfo[lstnm].','.$userinfo[frstnm],'1','1','L','0'); $where=($pdf->GetY()); $pdf->SetX(90); $pdf->SetFont('Arial','B',12); $pdf->MultiCell('30','5','ADDRESS','LRBT','C','1'); $pdf->SetXY(120,$where); $pdf->SetFont('Arial','B',10); if($userinfo[company_name]!=""){$address = $userinfo[company_name]."\n".$userinfo[addr1]."\n".$userinfo[addr2]."\n".$userinfo[city].",".$userinfo[state]."\n".$userinfo[zip];} if($userinfo[company_name]==""){$address = $userinfo[addr1]."\n".$userinfo[addr2]."\n".$userinfo[city].",".$userinfo[state]."\n".$userinfo[zip];} $pdf->MultiCell('85','4',$address,'LRB','L','0'); $where=($pdf->GetY())+5; $pdf->SetLineWidth(1); $pdf->Line(10,$where,206,$where); $pdf->SetLineWidth(.35); $where=($pdf->GetY())+14; $pdf->Line(15,$where+5,201,$where+5); $pdf->Line(15,$where,201,$where); $pdf->Line(15,$where,15,240); $pdf->Line(201,$where,201,240); $pdf->Line(15,240,201,240); $arraylines = array(25,35,50,65,160,175,185); foreach($arraylines as $lines){ $pdf->Line($lines,$where,$lines,240); } #HEADER CELLS $pdf->SetXY(15,$where); $pdf->SetFont('Times','',8); $pdf->Cell('9.5','5','Job ID','0','','C'); $pdf->Cell('10.8','5','Task ID','0','','C'); $pdf->Cell('15','5','Start Date','0','','C'); $pdf->Cell('15','5','End Date','0','','C'); $pdf->Cell('95','5','Description','0','','C'); $pdf->Cell('15','5','Qnty/hr','0','','C'); $pdf->Cell('10','5','Rate','0','','C'); $pdf->Cell('16','5','Cost','0','','C'); $pdf->Ln(); #END HEADER #BODY LOOP Print Job and Associated Tasks $pdf->SetFont('Times','',9); #Starting Y location $wherey=($pdf->GetY()+1); ##Database loop $invoicequery = mysql_query("SELECT job_ids from invoices where invoice_id='1'"); $row = mysql_fetch_array($invoicequery); if($row[job_ids]!=''){$jobs = explode(':',$row[job_ids]);} foreach($jobs as $jobs){ if($yposmax){$wherey=$yposmax;} $yposmax=0; $job_query = mysql_query("SELECT * from jobs where job_id='$jobs'"); $rowjobs = mysql_fetch_array($job_query); $xlocations = array("14.5"=>array("9.5"=>$rowjobs[job_id]),"24.5"=>array("10.5"=>"--"),"35"=>array("15"=>date("m.d.y",$rowjobs[date_created])),"50"=>array("15"=>"End Date"),"65"=>array("95"=>$rowjobs[job_desc]),"160"=>array("15"=>"--"),"175"=>array("10"=>"--"),"185"=>array("16"=>"--")); foreach($xlocations as $xvalue=>$text){ $pdf->SetXY($xvalue,$wherey); foreach ($text as $width=>$text){ $pdf->MultiCell($width,'3',$text,'0','C'); $ypos=$pdf->GetY(); if($ypos>$yposmax){$yposmax=$ypos;} } } $yposmax=$yposmax+2; ##task loop $tasks_query = mysql_query("SELECT * from tasks where job_id='$jobs' and inv_id='1' order by task_id") or die(mysql_error()); while($rowtask = mysql_fetch_array($tasks_query)){ $xlocations=array("14.5"=>array("9.5"=>"$rowtask[job_id]"),"24.5"=>array("10.5"=>"$rowtask[task_id]"),"35"=>array("15"=>date("m.d.y",$rowtask[start_date])),"50"=>array("15"=>"End Date"),"65"=>array("95"=>$rowtask[task_desc]),"160"=>array("15"=>($rowtask[duration]/60)),"175"=>array("10"=>"$rowtask[rate_cat]"),"185"=>array("16"=>number_format($rowtask[total_cost],2,'.',','))); foreach($xlocations as $xvalue=>$text){ $pdf->SetXY($xvalue,$yposmax); foreach ($text as $width=>$text){ $pdf->MultiCell($width,'3',$text,'0','C'); $ypos=$pdf->GetY(); } } if($ypos>$yposmax){$yposmax=$ypos;} $yposmax=$yposmax+1; } $purchase_query = mysql_query("SELECT * from purchases where job_id='$jobs' and inv_id='1' order by pur_date") or die(mysql_error()); while($rowpur = mysql_fetch_array($purchase_query)){ $xlocations=array("14.5"=>array("9.5"=>"$rowpur[job_id]"),"24.5"=>array("10.5"=>"Item"),"35"=>array("15"=>date("m.d.y",$rowpur[pur_date])),"50"=>array("15"=>"--"),"65"=>array("95"=>$rowpur[pur_desc]),"160"=>array("15"=>"--"),"175"=>array("10"=>"--"),"185"=>array("16"=>number_format($rowpur[pur_cost],2,'.',','))); foreach($xlocations as $xvalue=>$text){ $pdf->SetXY($xvalue,$yposmax); foreach ($text as $width=>$text){ $pdf->MultiCell($width,'3',$text,'0','C'); $ypos=$pdf->GetY(); } } if($ypos>$yposmax){$yposmax=$ypos;} $yposmax=$yposmax+1; } $yposmax=$yposmax+3; } $pdf->Output(); ?>