wilsonj Posted January 17, 2014 Share Posted January 17, 2014 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 More sharing options...
Dh42 Posted January 17, 2014 Share Posted January 17, 2014 I have never done that before, but I know that it can be modified into the order page. You can search for how to print a pdf instead of downloading it. Link to comment Share on other sites More sharing options...
wilsonj Posted January 18, 2014 Author Share Posted January 18, 2014 Thanks for the quick reply. I did a search for "print pdf instead of downloading" but came up blank. Where else can I find info on it? Link to comment Share on other sites More sharing options...
Dh42 Posted January 18, 2014 Share Posted January 18, 2014 This might help, http://www.dynamicdrive.com/forums/archive/index.php/t-53831.html Link to comment Share on other sites More sharing options...
wilsonj Posted January 18, 2014 Author Share Posted January 18, 2014 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 More sharing options...
wilsonj Posted January 20, 2014 Author Share Posted January 20, 2014 Can anyone help me with this ? Link to comment Share on other sites More sharing options...
new_12 Posted February 1, 2014 Share Posted February 1, 2014 anyone plz guide me,how to use pdf in prestashop. Link to comment Share on other sites More sharing options...
wilsonj Posted February 1, 2014 Author Share Posted February 1, 2014 what part ? The invoicing ? Link to comment Share on other sites More sharing options...
new_12 Posted February 2, 2014 Share Posted February 2, 2014 yes.i want to convert my output into invoice,so that i can take printout of it...i dnt knw from where i need to start.i am not getting any idea when i went through previous modules... :-( Link to comment Share on other sites More sharing options...
wilsonj Posted February 3, 2014 Author Share Posted February 3, 2014 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 More sharing options...
webdev0008 Posted February 3, 2014 Share Posted February 3, 2014 (edited) 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 February 3, 2014 by webdev0008 (see edit history) 2 Link to comment Share on other sites More sharing options...
wilsonj Posted February 3, 2014 Author Share Posted February 3, 2014 Thanks webdev0008 I just tried it but it still downloaded the pdf instead of opening in a new window. Was I just to add the 'I' ? Thanks Jamie Link to comment Share on other sites More sharing options...
webdev0008 Posted February 3, 2014 Share Posted February 3, 2014 Hi Its work for me. Try it after clear cache or in different browser. btw what is the version of your prestashop. Thanks Link to comment Share on other sites More sharing options...
new_12 Posted February 3, 2014 Share Posted February 3, 2014 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.... Link to comment Share on other sites More sharing options...
wilsonj Posted February 3, 2014 Author Share Posted February 3, 2014 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 More sharing options...
wilsonj Posted February 3, 2014 Author Share Posted February 3, 2014 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 More sharing options...
new_12 Posted February 3, 2014 Share Posted February 3, 2014 yes....but,my prb is much more worse than your.here i dnt know how to create pdf in prestashop(means,what call file i need to copy.).. Link to comment Share on other sites More sharing options...
webdev0008 Posted February 3, 2014 Share Posted February 3, 2014 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 More sharing options...
new_12 Posted February 3, 2014 Share Posted February 3, 2014 (edited) "$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 February 3, 2014 by Dipi.k (see edit history) Link to comment Share on other sites More sharing options...
wilsonj Posted February 3, 2014 Author Share Posted February 3, 2014 webdev0008 Thanks. This opens a new tab, but then closes it and opens the pdf in adobe reader again. Getting closer! Cheers Jamie Link to comment Share on other sites More sharing options...
new_12 Posted February 3, 2014 Share Posted February 3, 2014 how u did that Link to comment Share on other sites More sharing options...
new_12 Posted February 3, 2014 Share Posted February 3, 2014 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 More sharing options...
webdev0008 Posted February 4, 2014 Share Posted February 4, 2014 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. } 1 Link to comment Share on other sites More sharing options...
webdev0008 Posted February 4, 2014 Share Posted February 4, 2014 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 More sharing options...
new_12 Posted February 4, 2014 Share Posted February 4, 2014 (edited) 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 February 4, 2014 by Dipi.k (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts