;statement_details;
Company Name
Actions
ClientID
BulkHourID
Total Hours Purchased
Total Hours Left
Response Time
'; function statement($bulkhourid) { require('fpdf.php'); class PDF extends FPDF { function fancytable($header,$data,$w) { if ($header != '') { //Colors, line width and bold font $this->SetFillColor(204,204,204); $this->SetTextColor(0); $this->SetDrawColor(0); $this->SetLineWidth(.3); $this->SetFont('Arial','B',10); for($i=0;$iCell($w[$i],7,$header[$i],1,0,'C',1); $this->Ln(); } //Color and font restoration $this->SetFillColor(241,241,241); $this->SetTextColor(0); $this->SetFont('Arial','','7'); //Data $fill=0; foreach($data as $row) { if (strlen($row[0]) < 35) { $this->Cell($w[0],6,$row[0],'LR',0,'C',$fill); } else { $this->Y=$this->getY(); $this->X=$this->getX(); $this->Cell($w[0],3,substr($row[0],0,35),'LR',0,'C',$fill); $this->ln(); $this->setX($this->X); $this->Cell($w[0],3,substr($row[0],35,35),'LR',0,'C',$fill); $this->setY($this->Y); $this->setX($this->X+$w[0]); } if (strlen($row[1]) < 65) { $this->Cell($w[1],6,$row[1],'LR',0,'C',$fill); } else { $this->Y=$this->getY(); $this->X=$this->getX(); $this->Cell($w[1],3,substr($row[1],0,65),'LR',0,'C',$fill); $this->ln(); $this->setX($this->X); $this->Cell($w[1],3,substr($row[1],65,65),'LR',0,'C',$fill); $this->setY($this->Y); $this->setX($this->X+$w[1]); } for ($i=2; $i < count($w); $i++) { $this->Cell($w[$i],6,$row[$i],'LR',0,'C',$fill); } $this->Ln(); $fill=!$fill; } $this->Cell(array_sum($w),0,'','T'); } } $pdf=new PDF(); $sql="select * from `clients`,`bulkhour_plans` where bulkhour_plans.bulkhourid='" . $bulkhourid ."' and clients.clientid = bulkhour_plans.clientid"; $result=mysql_query($sql) or die(mysql_error()); $bulkhour_data=mysql_fetch_object($result); $pdf->AddPage(); $pdf->Image('inc/title.jpg',10,10,40); $pdf->SetFont('Arial','B',20); $pdf->setXY(95,10); $pdf->MultiCell(0,8,"Bulk Hour Statement"); $pdf->setXY(10,50); $pdf->setFont('Arial','B',12); $pdf->MultiCell(0,1,$bulkhour_data->companyname); $pdf->setXY(160,50); $pdf->MultiCell(0,1,'Date: '.date('M d,Y')); $pdf->setXY(10,80); $w=array(50,56,42); $columns=array('Total Hours Purchased','Hours Used','Hours Remaining'); $sql_hp = mysql_query("SELECT SUM(xaction_hours) from bulkhour_xactions WHERE bulkhourid = '" . $bulkhourid . "' AND debit = 'No'") or die(mysql_query()); $row_hp = mysql_fetch_array($sql_hp); $hourspurchased = $row_hp['0']; $sql_hu = mysql_query("SELECT SUM(xaction_hours) from bulkhour_xactions WHERE bulkhourid = '" . $bulkhourid . "' AND debit = 'Yes'") or die(mysql_query()); $row_hu = mysql_fetch_array($sql_hu); $hoursused = $row_hu['0']; $hoursleft = round($hourspurchased - $hoursused, 2); $bulkhour_summary=array( array($hourspurchased, $hoursused, $hoursleft ) ); $pdf->fancytable($columns,$bulkhour_summary,$w); $invoice_workorder=array(); $sql="select * from `bulkhour_xactions`,`labour` where bulkhour_xactions.bulkhourid='" . $bulkhourid . "' and labour.labourid=bulkhour_xactions.labourid order by bulkhour_xactions.invoiceid"; $result=mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) != 0) { while ($row = mysql_fetch_object($result)) { $invoice_workorder[]=array($row->invoiceid,$row->desc,$row->quantity); } } else { $invoice_workorder[]=array('','No Invoiced Transactions Have been Processed',''); } //get any adjustments that do not have labour records $sql="select * from `bulkhour_xactions` where bulkhourid = '" . $bulkhourid . "' and invoiceid = '0' and `adjustment` = 'Yes'"; $result=mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) != 0) { while ($row = mysql_fetch_object($result)) { $invoice_workorder[]=array($row->invoiceid,$row->xaction_reason,$row->xaction_hours); } } while (count($invoice_workorder) <= 26) { $invoice_workorder[]=array(); } $pdf->Y=$pdf->getY(); $pdf->setXY(10,$pdf->Y+10); $w=array(50,98,40); $columns=array('Invoice ID','Labour Description','Hours'); $pdf->fancytable($columns,$invoice_workorder,$w); $pdf->output(); } ?>