[eluser]the_unforgiven[/eluser]
Hi guys,
Having a slight problem I'm hoping one or two of you can help me with.
When generating a PDF with domPDF it does not carry forward the $vars i have set but yet when print_r() or var_dump() is called the vars have data in them so not sure why this. Here is the code for generating the PDF
Code:
function pdf()
{
$this->load->library('parser');
$id = $this->session->userdata('user_id');
$data['orders'] = $this->invoice_model->getInvoiceID();
$data['query'] = $this->account_model->getCurrent($id);
$datestring = "%d/%m/%Y";
$time = time();
$in = mdate($datestring, $time);
$gen = 'Invoice - '.$in;
$filename = $gen;
$data['title']= $gen;
$this->load->vars($data);
// Create the PDF
$html = $this->load->view('account/pdf', $data, TRUE);
pdf_create($html, $filename, $data);
}
View File for account/pdf
Code:
// Posted from <body> tag has there's a lot of inline styling which your guys arent interested in
<body class="pdf">
<div id="tpl-manage">
<div id="main">
<div class="corners">
</div>
<div class="hidden clearfix"></div>
<table id="header" class="default">
<tr>
<td id="logo">
<img src="http://localhost/hb/assets/image/logo.png" alt="" />
</td>
<td id="address">
The Company
Address
</td>
</tr>
</table>
<div id="separator">
<hr />
</div>
<table id="info" class="default">
<tr>
<td id="to">
<div class="c">
<h1 class="title">Invoice</h1>
</div>
<p>
<strong>To:</strong><br />
<?php echo $query['fullname']; ?><br />
<?php echo $query['address1']; ?><br />
<?php echo $query['address2']; ?><br />
<?php echo $query['town']; ?><br />
<?php echo $query['city']; ?><br />
<?php echo $query['postcode']; ?><br />
<?php echo $query['county']; ?><br />
</p>
</td>
<td id="ref">
<h3>
<strong>Invoice #:</strong> <?php echo $orders['order_id']; ?><br />
<strong>Date:</strong> <?php echo $orders['order_date']; ?></h3>
</td>
</tr>
</table>
<table id="body" class="default items">
<tr class="header">
<th class="col1">Item</th>
<th class="col2">Description</th>
<th class="col3" width="75">Unit Cost</th>
<th class="col4" width="40">Quantity</th>
<th class="col6" width="75">Cost (GBP)</th>
</tr>
<tbody id="items" class="itemslist">
<tr id="invoice_items-395310" class="item handle">
<td class="col1">
<span><?php echo $orders['qty']; ?><br /></span>
</td>
<td class="col2">
<span><?php echo $orders['item_ordered']; ?></span>
</td>
<td class="col3">
<span>£<?php echo $orders['order_amount']; ?></span>
</td>
<td class="col4">
<span><?php echo $orders['qty']; ?></span>
</td>
<td class="col6">
<span>£<?php echo $orders['order_amount']; ?></span>
</td>
</tr>
</tbody>
<tr class="totals">
<td colspan="5"><hr /></td>
</tr>
<tr class="totals">
<td>Sub Total:</td>
<td colspan="3"> </td>
<td>
£<span class="subtotal"><?php echo $orders['order_amount']; ?></span>
</td>
</tr>
<tr class="totals">
<td>Total Amount (GBP):</td>
<td colspan="3"> </td>
<td>
£<span class="total"><?php echo $orders['order_amount']; ?></span>
</td>
</tr>
<tr class="totals balance">
<td><strong>Balance:</strong></td>
<td colspan="3"> </td>
<td>
<strong>£<span class="balance"><?php echo $orders['order_amount']; ?></span></strong>
</td>
</tr>
</tbody>
</table>
<div id="due">
<!--<p>Payment due <strong>Dec 20th 2012</strong></p>-->
<p>Status: <strong><?php echo $orders['order_status']; ?></strong></p>
</div>
<div id="footer" class="block">
</div>
<center>
<br class="clear" /><br /><hr />
<p class="powered">Company Name</p>
</center>
</div>
</div>
</body>
</html>
So has you can see all tallys up but doesn't generate in the PDF, if i view it in the browser all works fine, but not PDF, any idea's, suggestions greatly appreciated.
Thanks in advance!