VirtueMart Invoice, Delivery Note and Receipt Addon (VM IDnR Addon)
VM IDnR addon is a "package" of components, plugins and small hacks which allow creating PDF Invoice, PDF Delivery Note, PDF Receipt and sending them through email to customers (Email feauture is available for users who are regularly active in Phoca Forum, are regularly translating Phoca Extensions or have donated to Phoca Project - get more info about how to contribute and get the Email feature on info[at]phoca[dot]cz).
Features:
- Creating Delivery (Partial delivery possible)
- Creating PDF of Invoice, Delivery Note or Receipt
- Sending PDF of Invoice, Delivery Note or Receipt through emal to customers (Phoca PDF VirtueMart Email plugin)
- Displaying PDF of Invoice, Delivery Note or Receipt in frontend in Account Maintenance (VirtueMart hack needed)
- Creating Delivery, PDF of Invoice, Delivery Note or Receipt, sending them through the email - all automatically after changing order status (Phoca PDF VirtueMart Email plugin, VirtueMart hack needed)
- Changing the PDF output in parameters (Changing header, footer height, fonts, etc.)
- Changing the PDF output with help of CSS styles in parameters
- Changing the PDF output easily in PDF templates (With help of HTML or CSS)
- Changing the Email output (Email template) in parameters (Phoca PDF VirtueMart Email plugin)
- Setting default values for creating Invoice, Delivery Note or Receipt in parameters (Phoca PDF VirtueMart Email plugin)
- Product attributes are displayed in PDF document
- Additional information like Bank Account Nr., VAT, etc. can be added in parameters (e.g. to header or footer area)
Basic requirements:
- Joomla! 1.5 (tested on 1.5.21)
- VirtueMart (tested on 1.1.9)
Installation
1. Install Phoca PDF component (1.0.9 or later version, Phoca PDF component download link) in Joomla! Extension Manager. It is good to test, if you are able to create PDF documents on your site (e.g. with help of Phoca PDF Content plugin).
2. Install Phoca PDF VirtueMart plugin (or Phoca PDF VirtueMart Email plugin) in Joomla! Extension Manager. Enable this plugin in Joomla! Plugin Manager (Phoca PDF VirtueMart plugin download site).
3. Install Phoca Install - VirtueMart component (Phoca Install - VirtueMart component download link) in Joomla! Extension Manager. Check "Ignore SQL query" in case, on your site there is installed previously version of VM IDnR addon (to not lose data). Before you install files and data with help of this component, VirtueMart must allready be installed on your site.
(4). If you are using Phoca PDF VirtueMart Email plugin, install Phoca Email Component (it must be installed before making following modifications - Phoca Email component download link).
Basic Modification
1. Displaying Delivery tab in detail of an order
Modify the following file:
administrator/components/com_virtuemart/html/order.order_print.php
FROM (line cca 191):
$tab->endTab();
$tab->endPane();
TO:
$tab->endTab();
// Delivery
$lang =& JFactory::getLanguage();
$lang->load('plg_phocapdf_virtuemart', JPATH_ADMINISTRATOR, null, true);
$tab->startTab( JText::_('PLG_PHOCAPDF_VM_DELIVERY_TAB_LBL'), "delivery_pane" );
require_once(CLASSPATH.'ps_order_delivery.php');
$tab->endTab();
// End Delivery
$tab->endPane();
Now the basic addon is installed. Go to "Order List" in your VirtueMart and click on some order (to edit it). Now the "Delivery" tab will be displayed in detail of an order.
If you click on "New delivery" button, you will be able to create new delivery.
You can create Invoice or Receipt. Delivery Note will be created automatically. After saving delivery, you will be able to display Invoice or Receipt and Delivery Note as PDF.
If you are using Phoca PDF VirtueMart Email plugin, you can send emails to your customers.
Advanced Modifications (Phoca PDF VirtueMart plugin)
1. Displaying Invoice, Delivery Note or Receipt in frontend, in Account Maintenance
Modify the following file:
administrator/components/com_virtuemart/classes/ps_order.php
FROM (line cca 23)
class vm_ps_order {
TO:
jimport('joomla.filesystem.file');
if (JFile::exists(JPATH_ROOT.DS.'plugins'.DS.'phocapdf'.DS.'virtuemart'.DS.'virtuemarthelper.php')) {
require_once(JPATH_ROOT.DS.'plugins'.DS.'phocapdf'.DS.'virtuemart'.DS.'virtuemarthelper.php');
} else {
return JError::raiseError('Include Error', 'Plugin: Phoca PDF VirtueMart Helper class not found');
}
class vm_ps_order {
FROM (line cca 729):
$listObj->addCell( $tmp_cell );
TO:
$listObj->addCell( $tmp_cell );
$delivery = PhocaPDFVirtueMartHelper::renderPDFIconAccount($sess, URL, $db->f("order_id"));
$listObj->addCell($delivery);
Then your customers will see PDF icon to Invoice, Delivery Note or Receipt (if created) in Account Maintenance view.
2. Fixing tab bug in detail window of an order (if you click on e.g. "New delivery" in delivery tab, the site is redirecting but not the delivery tab will be displayed - the first tab is displayed instead). The site should be redirecting back to delivery tab
Modify the following file:
administrator/components/com_virtuemart/classes/htmlTools.class.php
FROM (line cca 407):
function endPane() {
echo "</div>";
TO:
function endPane() {
echo "</div>";
$d = JRequest::get('request');
if(isset($d['delivery_pane']) && $d['delivery_pane'] == 1) {
$activeTab = 2;
} else {
$activeTab = 0;
}
FROM: (line cca 421):
activeTab: 0,
TO:
activeTab: {$activeTab},
Advanced Modifications (Phoca PDF VirtueMart Email plugin)
1. Creating Delivery, Creating PDF of Invoice, Delivery Note or Receipt, Sending email with the Invoice, Delivery Note or Receipt automatically after changing Order status
E.g. if you will change the order status from pending to confirmed, then the delivery will be automatically created, PDF document (Invoice, Delivery Note or Receipt) will be created and sent through email to customer.
Modify:
administrator/components/com_virtuemart/classes/ps_order.php,
If you didn't do with some previous hack, then you should paste the following code:
FROM (line cca 23)
class vm_ps_order {
TO:
jimport('joomla.filesystem.file');
if (JFile::exists(JPATH_ROOT.DS.'plugins'.DS.'phocapdf'.DS.'virtuemart'.DS.'virtuemarthelper.php')) {
require_once(JPATH_ROOT.DS.'plugins'.DS.'phocapdf'.DS.'virtuemart'.DS.'virtuemarthelper.php');
} else {
return JError::raiseError('Include Error', 'Plugin: Phoca PDF VirtueMart Helper class not found');
}
class vm_ps_order {
and then:
FROM (line cca 281):
if( !empty($notify_customer) ) {
$this->notify_customer( $d );
}
TO:
$PhocaSend = 0;
if( $curr_order_status=="P" && $d["order_status"]=="C" && $notify_customer == 1) {
PhocaPDFVirtueMartHelper::createDeliveryAndPDFandSendEmail($vmLogger, $VM_LANG, CLASSPATH);
$PhocaSend = 1;
}
if( !empty($notify_customer) ) {
if ($PhocaSend != 1) {
$this->notify_customer( $d );
}
}
PDF templates are created in HTML and CSS so they can be stylized in Phoca PDF VirtueMart (Email) plugin parameters or they can be modified directly in template files which are located in the follwing folder:
plugins/phocapdf/virtuemart/ (in your Joomla! site root folder)
- tmpl.deliverynote.php
- tmpl.invoice.php
- tmpl.receipt.php
You can set default settings for creating of a delivery:
- If receipt or invoice will be created
- Due days
- Delay interest
PDF document needs to have header without any error, sometimes it can happen, that some error is rendered before the document header. Then PDF cannot be displayed in browser. In such case check out your Joomla! and VirtueMart installation if it does not produce php errors.
Mostly this is caused by wrong encoding of the files - e.g. language file. Check if your langauge file is saved as UFT-8 without BOM encoding. You can check it with text editor like e.g. Notepad++ is. Open the language file (e.g. administrator/components/com_virtuemart/languages/common/english.php) in Notepad++, click on Encoding and select Encoding in UFT-8 without BOM. And save the file. Check out other modified files.
- Phoca PDF VirtueMart plugin (Phoca PDF VirtueMart Email plugin) - en-GB.plg_phocapdf_virtuemart.ini
- Phoca PDF component - en-GB.com_phocapdf.ini
- Phoca Email component - en-GB.com_phocaemail.ini
Translation files can be translated to other languages and used on Joomla! site. See article: How to create translation for Joomla! extensions
Phoca Install VirtueMart component is specific file needed for installation only (designed for developers or administrators), so it does not include translation (it is only in English available).