Skip to main content

pdf PLUGIN - Change file name

More
12 years 1 month ago - 12 years 1 month ago #168741 by andreasuriani
-- HikaShop version -- : latest

Hi All,
how can i change the filename of attachment invoice?

In attachment of the E.Mail the invoice name is "Invoice.pdf" (And it could be ok), but in the order management,(Order>Show) if i try to print the invoice, the file name is "Invoice_nn.pdf (nn is the order id).

I'd like that the name fot both is "Invoice_nn.pdf" (but nn it will be the invoice sequence id).

How can i do this?
Last edit: 12 years 1 month ago by andreasuriani.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #168747 by Jerome

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #168795 by andreasuriani
Hi Jerome,
this change the invoice name for the email, but not if i try to download invoice from order list.

How can i change this?

Thanks
Andrea

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #168814 by Jerome
Hi,

You also have to update the _getPDFInvoice function
Code:
if(count($orderIds) == 1){ if(empty( $order->order_invoice_number)) $order->order_invoice_number = $order->order_number; $fileName = JText::sprintf('PDF_INVOICE', $order->order_invoice_number); if($fileName == 'PDF_INVOICE') $fileName = JText::_('INVOICE').'_'.reset($orderIds); } $html2pdf->Output($fileName.'.pdf','D');

Regards,

Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Please Log in or Create an account to join the conversation.

More
12 years 1 month ago #168967 by andreasuriani
Hi Jerome,
i've modified the code in this way, and now it works:
Code:
function _getPDFInvoice($orderIds = array()){ $app = JFactory::getApplication(); if(!class_exists('HTML2PDF')) include(dirname(__FILE__).DS.'attachinvoice'.DS.'html2pdf.class.php'); $config =& hikashop_config(); $class = hikashop_get('class.order'); $currencyHelper = hikashop_get('class.currency'); $fields = array(); $null = null; $fieldsClass = hikashop_get('class.field'); $fields['item'] = $fieldsClass->getFields('backend_listing',$null,'item'); if(!empty($order->order_payment_id)){ $pluginsPayment = hikashop_get('type.plugins'); $pluginsPayment->type='payment'; } if(!empty($order->order_shipping_id)){ $pluginsShipping = hikashop_get('type.plugins'); $pluginsShipping->type='shipping'; } //This array stores all pdf pages... $pdfContent = array(); foreach($orderIds as $orderId){ $order = $class->loadFullOrder($orderId,true,false); $fields['order'] = $fieldsClass->getFields('backend',$order,'order'); ob_start(); if(file_exists(HIKASHOP_MEDIA.'plugins'.DS.'invoice.php')){ $file = HIKASHOP_MEDIA.'plugins'.DS.'invoice.php'; }else{ $file = dirname(__FILE__).DS.'attachinvoice'.DS.'invoice.php'; } require($file); $pdfContent[] = ob_get_clean(); } $content = implode('<div style="page-break-before:always"></div>',$pdfContent); $content = hikashop_absoluteURL($content); //$html2pdf = new HTML2PDF('P', 'A4', 'en'); $html2pdf = new HTML2PDF('P', 'A4', 'en',true, 'UTF-8'); $font = $this->params->get('font'); if(!empty($font)){ $html2pdf->setDefaultFont($font); } $html2pdf->pdf->SetDisplayMode('fullpage'); $html2pdf->writeHTML($content); if(count($orderIds) == 1){ if(empty( $order->order_invoice_number)) $order->order_invoice_number = $order->order_number; $fileName = JText::_('INVOICE').(string)$order->order_invoice_number; } $html2pdf->Output($fileName.'.pdf','D'); if(count($orderIds) == 1) $fileName.= '_'.reset($orderIds); $html2pdf->Output($fileName.'.pdf','D'); exit; }

Thanks for your support.

Andrea

Please Log in or Create an account to join the conversation.

Time to create page: 0.172 seconds
Powered by Kunena Forum