include_once(JPATH_BASE.'/components/com_vxc/helpers/manureporthelper.php');
$franchiseName = SiteOptionsHelper::getFranchiseName();
$col1W = 60;
$col2W = 100;
$col3W = 140;
$col4W = 140;
$col5W = 330;
$totalWidth = $col1W + $col2W+$col3W+$col4W +$col5W;
$this->pdf->AliasNbPages();
$html = "";
$pages = array();
$coloumnCount = 4;
$k = 0;
$i=0;
$oldBatch = -1;
foreach ($this->orders as $order)
{
$row = &$order;
$html = '';
if ($oldBatch!=$row->batch)
{
if ($oldBatch!=-1)
$pages[] = $page;
$k=0;
$i=0;
$oldBatch = $row->batch;
$page = array();
$page['content']='';
$page['info'] = $row;
}
$comments = '';
$insoleOptions = array();
$parts = array();
ManuReportHelper::processAttributes($row,$this->abbs, $insoleOptions,$comments,$parts);
if ($row->receiptid && !$row->receiptpaid)
{
if ($comments) $comments .= "\n";
$comments .= JText::_('Receipt not paid');
}
$abs = array();
foreach($insoleOptions as $opt)
$abs[] = $opt['abb'];
$material = implode(', ',$abs);
$backColor = ($i%2==0)?'#FFFFFF':'#E8E8E8';
$html .=
"
| ".$row->id." |
".$row->username." |
".$row->customerfullname." |
".$row->reference." |
".$material." |
";
if ($comments)
{
$html .="
|
".$comments." |
";
}
$page['content'].= $html;
$k = 1 - $k;
$i++;
}
if ($oldBatch!=-1)
$pages[] = $page;
foreach($pages as $page)
{
$this->pdf->AddPage();
$html ='';
$header = array();
$line1 = array();
$line2 = array();
$line3 = array();
$pageInfo =& $page['info'];
if ($pageInfo->batch)
{
$line1[] =JText::_('BATCH_ABB').$pageInfo->batch.'-'.$pageInfo->norders;
}
if ($pageInfo->manufacturing_date)
{
$dateEst = new JDate($pageInfo->manufacturing_date);
$dateEst->setOffset(date('Z')/3600.0);
$line1[] = JText::_('ESTIMATED_MANUFACTURE_DATE_ABB'). ": ". $dateEst->toFormat('%d/%m/%Y');
}
if ($pageInfo->est_shipping_date)
{
$dateEst = new JDate($pageInfo->est_shipping_date);
$dateEst->setOffset(date('Z')/3600.0);
$line1[] = JText::_('ESTIMATED_DELIVERY_DATE_ABB'). ": ". $dateEst->toFormat('%d/%m/%Y');
}
if ($pageInfo->username)
$line2[] = JText::_('User'). ": ". $pageInfo->username;
if ($pageInfo->agencyname)
{
$line3[] = JText::_('Agency').": ". JText::_($pageInfo->agencyname);
if ($pageInfo->payment_methodnameid == 'CASHONDELIVERY')
{
$totalPrice = ManuReportHelper::calculateCashOnDelivery($pageInfo);
$line3[] = JText::_('Cash on delivery'). ": ". sprintf("%0.2f",$totalPrice). " €";
}
}
if (count($line1)) $header[] = $line1;
if (count($line2)) $header[] = $line2;
if (count($line3)) $header[] = $line3;
foreach($header as $line)
{
$lineS = implode(' ',$line);
if ($lineS)
$html .="".$lineS."
";
}
$html .="
";
$html .="
| ".JText::_('Order Id')." |
". JText::_('User')." |
". JText::_('Patient')." |
".JText::_('Reference')." |
". JText::_('Material')." |
";
$html.= $page['content'];
$html .="
";
$this->pdf->writeHTML($html,true);
}
// Añadimos la pagina del resumen de plantillas
$this->pdf->AddPage();
$html ="".JText::_('Summary')."
";
$this->pdf->writeHTML($html,true);
$oldDate = -1;
$totalInsoles = 0;
foreach($this->summaryrows as $row)
{
if ($oldDate!= $row->manufacturing_date)
{
if ($oldDate!=-1)
{
$this->pdf->SetFont('helvetica','B',10);
$this->pdf->Cell(150,0,"TOTAL",1,0,'R');
$this->pdf->SetFont('helvetica','',10);
$this->pdf->Cell(50,0,$totalInsoles,1,1,'C');
$this->pdf->Ln();
$totalInsoles = 0;
}
$this->pdf->SetFont('helvetica','B',10);
$this->pdf->Cell(200,0,$row->manufacturing_date,1,1,'C');
$this->pdf->SetFont('helvetica','',10);
$oldDate = $row->manufacturing_date;
}
$this->pdf->Cell(150,0,$row->username,1,0,'C');
$this->pdf->Cell(50,0,$row->insolecount,1,1,'C');
$totalInsoles += $row->insolecount;
}
if ($oldDate!=-1)
{
$this->pdf->SetFont('helvetica','B',10);
$this->pdf->Cell(150,0,"TOTAL",1,0,'R');
$this->pdf->SetFont('helvetica','',10);
$this->pdf->Cell(50,0,$totalInsoles,1,1,'C');
}
$random = substr(number_format(time() * rand(),0,'',''),0,10);
$this->pdf->Output('report'.$random.'.pdf', 'I');
?>