Jump to content

Is there a one click invoice printing option ? without saving first.


Recommended Posts

I wish to print invoices directly from the order page without first having to save them to the computer.

 

There is a "view invoice" button, which saves the invoice. I'd like it to perform like the "print order" button next to it, and just directly print.

 

It seems a waste of time to have to save the invoice, then negotiate to the folder it was saved in, open then select print.

 

Anyone have a solution for this ?

 

Cheers

Jamie

Link to comment
Share on other sites

Hi Dh42,  Thanks, I read it but I'm not sure I understand how to apply this in the way I want.

 

Just to be clear, I want the button to appear in the back office orders page. 

 

Where would I find the prestashop back office orders page ? I might be able to change the way the current "view invoice" button works.??

Link to comment
Share on other sites

  • 2 weeks later...

I'm not sure I follow you, but under orders you should see an icon under the PDF column which by clicking will automatically save a copy of the invoice to your computer.

 

This incidentally is what I want to make open, not save. It seems a waste of time to have to save each invoice before printing.

 

Hope this helps.

Link to comment
Share on other sites

Hi

 

change the generatePDF method in  controllers/admin/AdminPdfController.php near line 186.

 

public function generatePDF($object, $template)
{
     $pdf = new PDF($object, $template, Context::getContext()->smarty);
     $pdf->render('I');   // this open the pdf in browser instead of provide to download.
}
Edited by webdev0008 (see edit history)
  • Thanks 2
Link to comment
Share on other sites

yes..i get your point.but i am creating a new module here.so,i dont know what all files i need to copy in to my module...that my prb..exactly what i need is,when i click "print",it open a new tab and display pdf invoice....

This sounds like what I also want to do.

Link to comment
Share on other sites

Hi

 

Its work for me. Try it after clear cache or in different browser. btw what is the version of your prestashop.

 

 

Thanks

OK. I'm using 1.5.6.2.

 

Cleared cache.

 

Also using google chrome. I found that I can ask chrome to open the pdf instead of downloading it only. So I think chrome was partly to blame.

 

So thank you this has been very helpful. Final step now is to open it in a new tab, not adobe reader. Any thoughts ?

 

Thanks

Jamie

Link to comment
Share on other sites

to open in new tab edit the _print_pdf_icon.tpl file in  ADMIN_FOLDER/themes/default/template/controllers/orders in line nnumber 29

{if ($order_state->invoice || $order->invoice_number)}
	<a href="{$link->getAdminLink('AdminPdf')|escape:'htmlall':'UTF-8'}&submitAction=generateInvoicePDF&id_order={$order->id}" target="_blank"><img src="../img/admin/tab-invoice.gif" alt="invoice" /></a>
{else}
Link to comment
Share on other sites

"$this->context->link->getAdminLink('AdminPdf').'&submitAction=generateDeliverySlipPDF&id_order='.$row['vc_id'];".......this is my href for print..when i click this link,it open a new tab..but it not displays  anything.i copy AdminPdfController.php in to my invoice folder....what all chages i need to do in this page,so that i can get my invoice in my required format

Edited by Dipi.k (see edit history)
Link to comment
Share on other sites

plzz......anyone plz help me..this is my href link

 

"$this->context->link->getModuleLink('invoice','AdminPdf').'&submitAction=generateDeliverySlipPDF&id_order='.$row['vc_id'];"

 

 

when i click this,it open a new tab and redirect to AdminPdf controller..but it display blank page.

here my code id:

 

<?php
class AdminPdf extends invoice
{
public function postProcess()
{
parent::postProcess();
// We want to be sure that displaying PDF is the last thing this controller will do
exit;
}
 
public function initProcess()
{
Tools::displayError('You do not have permission to view this.');
      parent::initProcess();
if ($action = Tools::getValue('submitAction'))
$this->action = $action;
else
$this->errors[] = Tools::displayError('You do not have permission to view this.');
}
 
public function processGenerateInvoicePdf()
{
if (Tools::isSubmit('id_order'))
$this->generateInvoicePDFByIdOrder(Tools::getValue('id_order'));
else
die (Tools::displayError('The order ID  is missing.'));
}
 
public function generateInvoicePDFByIdOrder($id_order)
{
$order = new Order((int)$id_order);
if (!Validate::isLoadedObject($order))
die(Tools::displayError('The order cannot be found within your database.'));
 
$order_invoice_list = $order->getInvoicesCollection();
$this->generatePDF($order_invoice_list, PDF::TEMPLATE_INVOICE);
}
 
public function generatePDF($object, $template)
{
$pdf = new PDF($object, $template, Context::getContext()->smarty);
$pdf->render();
}
}
Link to comment
Share on other sites

webdev0008

 

Thanks. This opens a new tab, but then closes it and opens the pdf in adobe reader again. Getting closer!

 

Cheers

Jamie

 

To open the Pdf in browser you also need to modify generatePDF method in controllers/admin/AdminPdfController.php as i write in above post. This tell the browser to open the PDF not to download and also need setting in browser to open the PDF. May be this link help you http://helpx.adobe.com/acrobat/using/display-pdf-browser-acrobat-xi.html 

public function generatePDF($object, $template)
{
     $pdf = new PDF($object, $template, Context::getContext()->smarty);
     $pdf->render('I');   // this open the pdf in browser instead of provide to download.
}
  • Like 1
Link to comment
Share on other sites

Hi Dipi.k

 

This link help to create a controller in module:

 

http://doc.prestashop.com/display/PS15/New+Developers+Features+In+PrestaShop+1.5#NewDevelopersFeaturesInPrestaShop1.5-NewFile-treeAndOperations 

 

If you want to modify core classes or controllers of prestashop then go through this link:

http://doc.prestashop.com/display/PS15/Overriding+default+behaviors 

 

 

Thanks

Link to comment
Share on other sites

this is my url

"http://localhost/prestashop_1.6.0.2/index.php?fc=module&module=invoice&controller=show_invoice&id_order=1"

 

 

my module name is : invoice (create "invoice" module inside module folder)

 

how to build "class" from above url..

 

WHEN I FOLLOW THIS  SYNTAX ITS NOT WORKING

 

That "class" name must be built using the following syntax:
class ModuleNamePageName extends ModuleFrontController.

Edited by Dipi.k (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...