[SOLVED] Print Invoice from account maintenance

Before you ask about IDnR Addon see the VirtueMart - Invoice, Delivery Note and Receipt Addon
ri2ir
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 20 Dec 2009, 18:52

[SOLVED] Print Invoice from account maintenance

Post by ri2ir »

Hi,
i'm using your component and it work fine, the only thing i need is the possibility to print delivery note and invoice from the frontend by the user. I want that a user can print himself his document in the "View order" page of the account maintenance, there is a way to do that?
Tank so much
and sorry my bad english
Last edited by ri2ir on 20 Dec 2009, 22:01, edited 1 time in total.
ri2ir
Phoca Newbie
Phoca Newbie
Posts: 3
Joined: 20 Dec 2009, 18:52

Re: [SOLVED] Print Invoice from account maintenance

Post by ri2ir »

I've found the solution to my previous post, so I decided to post it here.
The solution is quite simple, this is the step to follow:
  • 1 - Copy the forder
    /administrator/components/com_virtuemart/pdf
    to
    /components/com_virtuemart/pdf
    this need for generate pdf from the frontend

    2 - Modify the file
    /administrator/components/com_virtuemart/classes/ps_order.php
    adding the following code near line 659 after

    Code: Select all

    while ($db->next_record()) {
    			$order_status = ps_order_status::getOrderStatusName($db->f("order_status"));
    			$listObj->newRow();
    insert this code

    Code: Select all

    // Inizio - Delivery - Invoice nella pagina Visualizza Ordini
    			// Select the delivery and the bill ids for the order selected
    			$dbDelivery = new ps_DB;
    			$qDelivery = "SELECT bill_id, delivery_id FROM #__{vm}_bills WHERE order_id=".$db->f("order_id");
    			$dbDelivery->query($qDelivery);
    
    			$dbDelivery->next_record();
    			
    			// Check if there is a generated delivery for the order
    			if($dbDelivery->f('delivery_id'))
    			{
    				// Insert a link and a image (documento.png) for download of the delivery note
    				$tmp_cell = "<a href=\"index2.php?page=order.order_print&func=deliveryNoteAsPDF&format=printpdf&tmpl=component&order_id=".$db->f("order_id")."&no_menu=1&no_html&delivery_id=".$dbDelivery->f('delivery_id')."&option=com_virtuemart&vmtoken=".vmSpoofValue($sess->getSessionId())."&gen=delnote\">";
    				$tmp_cell .= "<img src=\"".IMAGEURL."ps_image/documento.png\" height=\"32\" width=\"32\" align=\"middle\" border=\"0\" />";
    				$tmp_cell .= "<br />DDT</a>";
    				$listObj->addCell($tmp_cell); 
    			}
    			else
    			{
    				// Insert an image (no-documento.png) that rapresent that the delivery was not yet generated
    				$listObj->addCell("<img src=\"".IMAGEURL."ps_image/no-documento.png\" height=\"32\" width=\"32\" align=\"middle\" border=\"0\" />");
    			}
    			
    			// Check if there is a generated bill for the order
    			if($dbDelivery->f('bill_id'))
    			{
    			    // Insert a link and a image (documento.png) for download of the bill 
    				$tmp_cell = "<a href=\"index2.php?page=order.order_print&func=deliveryNoteAsPDF&format=printpdf&tmpl=component&order_id=".$db->f("order_id")."&no_menu=1&no_html&delivery_id=".$dbDelivery->f("bill_id")."&option=com_virtuemart&vmtoken=".vmSpoofValue($sess->getSessionId())."&gen=bill\">";
    				$tmp_cell .= "<img src=\"".IMAGEURL."ps_image/documento.png\" height=\"32\" width=\"32\" align=\"middle\" border=\"0\" />";
    				$tmp_cell .= "<br />Fattura</a>";
    				$listObj->addCell($tmp_cell); 
    			}
    			else
    			{
    			    // Insert an image (no-documento.png) that rapresent that the bill was not yet generated
    				$listObj->addCell("<img src=\"".IMAGEURL."ps_image/no-documento.png\" height=\"32\" width=\"32\" align=\"middle\" border=\"0\" />");
    			}
    			// Fine - Delivery - Invoice nella pagina Visualizza Ordini
    
    3 - Upload to the folder
    /components/com_virtuemart/shop_image/ps_image/
    the file "documento.png" and "no-documento.png"

    4 - Check if all work correctly in "Account Maintenance"->"View Order" page
I think that with this "addon" hte component is better because now each user can print himself the invoice and the delivery note needed if the user need the guarantee and he lose the original email.
I've tried to upload the documento.png and the no-documento.png but I get an error from the server but you can build your own.
I build this modify for site http://www.diveevolution.it and if you have any question you can contact my using the form on my site http://www.riccardovalenti.it
Tanks to all
Bye
User avatar
Jan
Phoca Hero
Phoca Hero
Posts: 48403
Joined: 10 Nov 2007, 18:23
Location: Czech Republic
Contact:

Re: [SOLVED] Print Invoice from account maintenance

Post by Jan »

Hi, thank you for this information.

Jan
If you find Phoca extensions useful, please support the project
diod
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 07 Feb 2010, 19:09

Re: [SOLVED] Print Invoice from account maintenance

Post by diod »

Works like a charm !!!
BUT:
You must allow shoppers to access deliveryNoteAsPDF function or only admin can print his frontend orders.
HERE IT IS:
Virtuemart>Admin menu>List Functions>deliveryNoteAsPDF>Function Perms
Add Shopper to Admin and Storeadmin.
Last edited by diod on 17 Jul 2010, 14:28, edited 1 time in total.
khoyoht
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 05 Aug 2010, 18:36

Re: [SOLVED] Print Invoice from account maintenance

Post by khoyoht »

Hi,
I have exactly the same problem, no idea of a solution?
khoyoht
Phoca Newbie
Phoca Newbie
Posts: 2
Joined: 05 Aug 2010, 18:36

Re: [SOLVED] Print Invoice from account maintenance

Post by khoyoht »

The problem is in the ps_order file, the url in the link to the delivery.pdf file is:
$tmp_cell = "<a href=\"index2.php?page=order.order_print&func=deliveryNoteAsPDF&format=printpdf&tmpl=component&order_id=" .$db->f("order_id")."&no_menu=1&no_html&delivery_id='.$dbb->f('bill_id').'&option=com_virtuemart&vmtoken=".vmSpoofValue($sess->getSessionId())."&gen=bill\" target=\"_blank\">\n";
You have to place the delivery_id in place of the bill_id next to ... &delivery_id= and it will work fine!
VieuxEd
Phoca Newbie
Phoca Newbie
Posts: 6
Joined: 29 Jan 2009, 01:19

Re: [SOLVED] Print Invoice from account maintenance

Post by VieuxEd »

diod wrote:Works like a charm !!!
BUT:
You must allow shoppers to access deliveryNoteAsPDF function or only admin can print his frontend orders.
HERE IT IS:
Virtuemart>Admin menu>List Functions>deliveryNoteAsPDF>Function Perms
Add Shopper to Admin and Storeadmin.

Hy,
Thanks for your clue.
Here is what I did :

In VM admin, module list, Order : functions list -> deliveryNoteAsPDF (ps_delivery and pdf_output), I add shopper to admin and admin store as you suggested.

Now, regular shopper can open a pdf delivery from frontend .. BUT

there is a bug : the bill is empty : no information about their order... why are data missing ?

Accessed by an admin, it works like a charm.

Thanks in advance for your help.
Ed
Post Reply