pdf PLUGIN - Change file name

  • Posts: 177
  • Thank you received: 1
10 years 3 months ago #168741

-- 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: 10 years 3 months ago by andreasuriani.

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

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 3 months ago #168747

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

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 177
  • Thank you received: 1
10 years 3 months ago #168795

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.

  • Posts: 26158
  • Thank you received: 4028
  • MODERATOR
10 years 3 months ago #168814

Hi,

You also have to update the _getPDFInvoice function

		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.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 177
  • Thank you received: 1
10 years 3 months ago #168967

Hi Jerome,
i've modified the code in this way, and now it works:

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.048 seconds
Powered by Kunena Forum