News:

Looking for documentation? Take a look on our wiki

Main Menu

Tutorial: How to create additional order print forms

Started by arnask, November 03, 2011, 14:33:07 PM

Previous topic - Next topic

arnask

If you need more than one order print form, this tutorial is for you.
Go down and see.

PRO

http://forum.virtuemart.net/index.php?topic=90935.0

administrator/components/com_virtuemart/views/order/tml/print.php

DO an administrator template override


arnask

#2
HOW TO CREATE ADDITIONAL ORDER PRINT FORMS

First of all i want to say, that i'm not a programmer, but i have a little knowledge of how stuff works (i've seen it on TV :-))
Of course this can be done in other way i did, but seems nobody was care about me, i did it myself and now i'm posting for everyone.
So lets begin:

1. Create new controller:
    a) go to \administrator\components\com_virtuemart\controllers\ and copy orders.php file to hard drive;
    b) rename it to orderss.php;
    c) edit orderss.php with notepad and change class VirtuemartControllerOrders extends VmController { to class VirtuemartControllerOrderss extends VmController {

    d) go down and change $view->setLayout('order_print'); to $view->setLayout('order_print2');

    e) copy saved orderss.php file back to \administrator\components\com_virtuemart\controllers\

2.  We need to create additional column for our second print form:
     So add to /administrator/components/com_virtuemart/views/order/tml/orders.php this code:

  line ~47
         <th><?php echo JText::_('COM_VIRTUEMART_PRINT_VIEW_2'); ?></th>

      and

  line ~87
        <!-- Print view 2 -->
<?php
/* Print view URL */
$details_url JURI::base() . "?option=com_virtuemart&view=orderss&task=orderPrint&format=raw&virtuemart_order_id=" $order->virtuemart_order_id;
$details_link "<a href=\"javascript:void window.open('$details_url', 'win2', 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no');\"  >";
$details_link .= '<span class="hasTip print_32" title="' JText::_('COM_VIRTUEMART_PRINT') . '">&nbsp;</span></a>';
?>

<td><?php echo $details_link?></td>


2. Add to \administrator\language\en-GB\en-GB.com_virtuemart.ini this code:

   line ~1164   
     COM_VIRTUEMART_PRINT_VIEW_2="Print View 2"

3. Create your own printing form:
    a) go to /administrator/components/com_virtuemart/views/order/tml/ and copy order_print.php file to hard drive;
    b) rename it to order_print2.php;
    c) edit order_print2.php with notepad and change what you want;
    d) copy order_print2.php file back to /administrator/components/com_virtuemart/views/order/tml/

Thats it!
Now in Virtuemart orders page you should see 2 printer icons. If you press first, you will print standard form, if you press second - you will print your own form (order_print2.php)
If you think you can do better, please share with us.

[attachment cleanup by admin]

URAGANU

arnask

Can you help me do this in VM 2.0.6 ?

Thanks

prehn

Quote from: URAGANU on July 21, 2012, 04:11:34 AM
arnask

Can you help me do this in VM 2.0.6 ?

Thanks

Would also love to see an update guide. The only step that has changed is the "$view->setLayout('order_print');"-step, hope anyone could point us right.