mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-07 07:17:43 -04:00
Small refactoring of pdf invoice
This commit is contained in:
@@ -423,11 +423,11 @@ class Sales extends Secure_Controller
|
||||
$html = $this->load->view('sales/invoice_email', $sale_data, TRUE);
|
||||
// load pdf helper
|
||||
$this->load->helper(array('dompdf', 'file'));
|
||||
$file_content = pdf_create($html, '', FALSE);
|
||||
$filename = sys_get_temp_dir() . '/' . $this->lang->line('sales_invoice') . '-' . str_replace('/', '-' , $sale_data['invoice_number']) . '.pdf';
|
||||
write_file($filename, $file_content);
|
||||
|
||||
$result = $this->email_lib->sendEmail($to, $subject, $text, $filename);
|
||||
if(file_put_contents($filename, pdf_create($html)) !== FALSE)
|
||||
{
|
||||
$result = $this->email_lib->sendEmail($to, $subject, $text, $filename);
|
||||
}
|
||||
|
||||
$message = $this->lang->line($result ? 'sales_invoice_sent' : 'sales_invoice_unsent') . ' ' . $to;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
function pdf_create($html, $filename = '', $stream = TRUE)
|
||||
function pdf_create($html, $filename = '')
|
||||
{
|
||||
// need to enable magic quotes for the
|
||||
$magic_quotes_enabled = get_magic_quotes_runtime();
|
||||
|
||||
if(!$magic_quotes_enabled)
|
||||
{
|
||||
ini_set("magic_quotes_runtime", true);
|
||||
ini_set('magic_quotes_runtime', TRUE);
|
||||
}
|
||||
|
||||
$dompdf = new Dompdf\Dompdf();
|
||||
$dompdf->loadHtml($html);
|
||||
$dompdf->render();
|
||||
|
||||
ini_set("magic_quotes_runtime", $magic_quotes_enabled);
|
||||
|
||||
if ($stream)
|
||||
if(!$magic_quotes_enabled)
|
||||
{
|
||||
$dompdf->stream($filename.".pdf");
|
||||
ini_set('magic_quotes_runtime', $magic_quotes_enabled);
|
||||
}
|
||||
|
||||
if($filename != '')
|
||||
{
|
||||
$dompdf->stream($filename . '.pdf');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user