VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: lanthan on August 03, 2013, 19:54:03 PM

Title: different invoice and delivery note .pdf
Post by: lanthan on August 03, 2013, 19:54:03 PM
VM 2.0.22a, J2.5.X

Hi,
I want to share my solution with you for individuell invoice and delivery note. The current version displays invoice and delivery note from the invoice.php. Usually you don´t display prices and total aswell as invoice date and so on on your delivery note. I think this is a temporary solution because it is very easy to improve this with the next VM update.

1. step (invoice override)
copy
invoice.php, invoice_items.php, invoice_order.php and invoice_history,php in your invoice template override folder and rename these 4 files into
delivery.php, delivery_items.php, delivery_order.php and delivery_history.php

2. step change ../component/com_virtuemart/views/invoice/view.html.php


case 'deliverynote':
$this->doctype = $layout;
$layout = 'delivery';
$title = JText::_('COM_VIRTUEMART_DELIVERYNOTE');
break;


change $layout='invoice'; into $layout='delivery';

With this little change VM searchs for delivery.php and so on and if "deliverynote" is selected in the BE.

Customize your delivery.php and so on as you like. By the way, you can get the delivery address easily with that code (deliver_order.php)


$field = $this->shipmentfields['fields'];
echo $field["company"]['value'].'<br />';
echo $field["title"]['value'].' ';
if (empty($field["company"]['value'])) {
echo '<br />';
}
echo $field["first_name"]['value'].' ';
echo $field["last_name"]['value'].'<br />';
echo $field["address_1"]['value'].'<br />';
echo $field["zip"]['value'].' ';
echo $field["city"]['value'].'<br />';
echo $field["virtuemart_country_id"]['value'].'<br />';


Hope this helps some of you.
Title: Re: different invoice and delivery note .pdf
Post by: lanthan on January 31, 2014, 13:01:55 PM
I am quite suprised, they didn´t changed it while the last updates. So still 2.0.26d is using the invoice output for the delivery note  :o
Title: Re: different invoice and delivery note .pdf
Post by: jenkinhill on January 31, 2014, 13:47:36 PM
It is exactly as I require in 2.0.26d, similar to invoice with prices and order status removed. But easy to override if you wish.
Title: Re: different invoice and delivery note .pdf
Post by: reinhold on January 31, 2014, 15:34:52 PM
The deliverynotes use the same layout as the invoices, because they typically have the same structure/layout. However, the deliverynote in the layout is implemented so that it does not print out the prices...
If your delivery note displays prices, maybe you use a template with an override for the invoice that has not been updated to be usable with deliverynotes?


You can customize the deliverynote in a template override. To distinguish between deliverynote and invoice mode in the template or layout, simply check the $this->doctype variable (see e.g. invoice_order.php or invoice_items.php in the components/com_virtuemart/views/invoice/tmpl/ directory):

In invoice_order.php, the title of the invoice/deliverynote is done conditional on that variable:

if ($this->doctype == 'invoice') {
  if ($this->invoiceNumber) { ?>
<h1><?php echo JText::_('COM_VIRTUEMART_INVOICE').' '.$this->invoiceNumber?> </h1>
<?php }
} elseif (
$this->doctype == 'deliverynote') { ?>

<h1><?php echo JText::_('COM_VIRTUEMART_DELIVERYNOTE'); ?> </h1>
<?php } elseif ($this->doctype == 'confirmation') { ?>
<h1><?php echo JText::_('COM_VIRTUEMART_CONFIRMATION'); ?> </h1>

<?php ?>


Similarly, the prices of the items (invoice_items.php) are only printed out if $this->doctype=='invoice'.

So, I don't really see a need to have a separate deliverynote layout, unless you want/need to use completely different layouts for your invoices and your deliverynotes...
If you want a similar layout, then use the $this->doctype in the layout template to detect whether the document is for invoice or deliverynote mode...

Reinhold
Title: Re: different invoice and delivery note .pdf
Post by: lanthan on February 01, 2014, 12:32:04 PM
;-) didn´t see it. thx for advice.