FrontendPdfInvoice - Version 1.0.0

Version Notes

27.06.2016 - Initial release packaged

Download this release

Release Info

Developer Modules4U
Extension FrontendPdfInvoice
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Modules4U/FrontendPdfInvoice/controllers/IndexController.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright (C) 2016 modules4u.biz
4
+ * All Rights Reserved
5
+ *
6
+ * NOTICE OF LICENSE
7
+ * Permitted Use
8
+ * One license grants the right to perform one installation of the Software. Each additional installation of the Software requires an additional purchased license,
9
+ * please contact us at magento@modules4u.biz for details.
10
+ *
11
+ * Restrictions
12
+ * It is not allowed to:
13
+ * Reproduce, distribute, or transfer the Software, or portions thereof, to any third party.
14
+ * Use the Software in violation of any international law or regulation.
15
+ * Display of Copyright Notices
16
+ * All copyright and proprietary notices and logos within the Software files must remain intact.
17
+
18
+ *
19
+ * Indemnity
20
+ * You agree to indemnify and hold harmless Modules4U for any third-party claims, actions or suits, as well as any related expenses, liabilities, damages, settlements or fees arising from your use or misuse of the Software, or a violation of any terms of this license.
21
+ *
22
+ * Disclaimer Of Warranty
23
+ * THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF QUALITY, PERFORMANCE, NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. FURTHER, Modules4U DOES NOT WARRANT THAT THE SOFTWARE OR ANY RELATED SERVICE WILL ALWAYS BE AVAILABLE.
24
+ *
25
+ * Limitations Of Liability
26
+ * YOU ASSUME ALL RISK ASSOCIATED WITH THE INSTALLATION AND USE OF THE SOFTWARE. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS OF THE SOFTWARE BE LIABLE FOR CLAIMS, DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE. LICENSE HOLDERS ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USE AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE, INCLUDING BUT NOT LIMITED TO THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS.
27
+ *
28
+ * You can download the full license text here: http://modules4u.biz/shop/license/
29
+ *
30
+ * @author Modules4U
31
+ */
32
+
33
+ class Modules4U_FrontendPdfInvoice_IndexController extends Mage_Core_Controller_Front_Action
34
+ {
35
+
36
+ public function downloadInvoiceAction()
37
+ {
38
+ $orderId = (int) $this->getRequest()->getParam('order_id');
39
+ $order = Mage::getModel('sales/order')->load($orderId);
40
+
41
+ if ($this->_isAllowed($order))
42
+ {
43
+ $invoices = Mage::getResourceModel('sales/order_invoice_collection')
44
+ ->setOrderFilter($order->getId())
45
+ ->load();
46
+ if ($invoices->getSize() > 0)
47
+ {
48
+ $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices);
49
+
50
+ return $this->_prepareDownloadResponse
51
+ (
52
+ 'invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(),
53
+ 'application/pdf'
54
+ );
55
+
56
+ }
57
+ }
58
+ }
59
+
60
+ protected function _isAllowed($order)
61
+ {
62
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
63
+ $availableStates = Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates();
64
+ if (
65
+ $order->getId() && $order->getCustomerId() && ($order->getCustomerId() == $customerId)
66
+ && in_array($order->getState(), $availableStates, $strict = true)
67
+ )
68
+ {
69
+ return true;
70
+ }
71
+ return false;
72
+ }
73
+ }
74
+
75
+ ?>
app/code/community/Modules4U/FrontendPdfInvoice/etc/config.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Modules4U_FrontendPdfInvoice>
5
+ <version>1.0.0</version>
6
+ </Modules4U_FrontendPdfInvoice>
7
+ </modules>
8
+
9
+ <frontend>
10
+ <routers>
11
+ <pdf>
12
+ <use>standard</use>
13
+ <args>
14
+ <module>Modules4U_FrontendPdfInvoice</module>
15
+ <frontName>pdf</frontName>
16
+ </args>
17
+ </pdf>
18
+ </routers>
19
+ <translate>
20
+ <modules>
21
+ <Modules4U_EuVatIdChecker>
22
+ <files>
23
+ <default>Modules4U_FrontendPdfInvoice.csv</default>
24
+ </files>
25
+ </Modules4U_EuVatIdChecker>
26
+ </modules>
27
+ </translate>
28
+
29
+ </frontend>
30
+ </config>
app/design/frontend/default/default/template/sales/order/history.phtml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2006-2016 X.commerce, Inc. and affiliates (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php echo $this->getMessagesBlock()->toHtml() ?>
28
+ <?php $_orders = $this->getOrders(); ?>
29
+ <div class="page-title">
30
+ <h1><?php echo $this->__('My Orders') ?></h1>
31
+ </div>
32
+ <?php echo $this->getPagerHtml(); ?>
33
+ <?php if($_orders->getSize()): ?>
34
+ <table class="data-table" id="my-orders-table">
35
+ <col width="1" />
36
+ <col width="1" />
37
+ <col />
38
+ <col width="1" />
39
+ <col width="1" />
40
+ <col width="1" />
41
+ <thead>
42
+ <tr>
43
+ <th><?php echo $this->__('Order #') ?></th>
44
+ <th><?php echo $this->__('Date') ?></th>
45
+ <th><?php echo $this->__('Ship To') ?></th>
46
+ <th><span class="nobr"><?php echo $this->__('Order Total') ?></span></th>
47
+ <th><span class="nobr"><?php echo $this->__('Order Status') ?></span></th>
48
+ <th>&nbsp;</th>
49
+ </tr>
50
+ </thead>
51
+ <tbody>
52
+ <?php $_odd = ''; ?>
53
+ <?php foreach ($_orders as $_order): ?>
54
+ <tr>
55
+ <td><?php echo $_order->getRealOrderId() ?></td>
56
+ <td><span class="nobr"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></span></td>
57
+ <td><?php echo $_order->getShippingAddress() ? $this->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
58
+ <td><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
59
+ <td><em><?php echo $_order->getStatusLabel() ?></em></td>
60
+ <td class="a-center">
61
+
62
+ <span><a href="<?php echo $this->getViewUrl($_order) ?>"><?php echo $this->__('View Order') ?></a>
63
+ <?php /*<span>|</span><a href="<?php echo $this->getTrackUrl($_order) ?>"><?php echo $this->__('Track Order') ?></a>&nbsp;*/ ?>
64
+ <?php if ($this->helper('sales/reorder')->canReorder($_order)) : ?>
65
+ <span>|</span> <a href="<?php echo $this->getReorderUrl($_order) ?>"><?php echo $this->__('Reorder') ?></a>
66
+ <?php endif ?>
67
+ <strong><span>|</span></strong>
68
+ <strong><a href="<?php echo $this->getUrl('pdf/index/downloadInvoice', array('order_id' => $_order->getId())) ?>"><?php echo $this->__('PDF Invoice') ?></a></strong>
69
+ </span>
70
+
71
+ </td>
72
+ </tr>
73
+ <?php endforeach; ?>
74
+ </tbody>
75
+ </table>
76
+ <script type="text/javascript">decorateTable('my-orders-table');</script>
77
+ <?php echo $this->getPagerHtml(); ?>
78
+ <?php else: ?>
79
+ <p><?php echo $this->__('You have placed no orders.'); ?></p>
80
+ <?php endif ?>
app/etc/modules/Modules4U_FrontendPdfInvoice.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Modules4U_FrontendPdfInvoice>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Modules4U_FrontendPdfInvoice>
8
+ </modules>
9
+ </config>
app/locale/en_US/Modules4U_FrontendPdfInvoice.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ "PDF Invoice","PDF Invoice"
2
+
3
+
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>FrontendPdfInvoice</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://modules4u.biz/shop/license/">Modules4U Software License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>This extension allows your registered customers to download invoices as PDF</summary>
10
+ <description>This extension adds a PDF download link to the order history of your registered customers. &lt;br&gt;&#xD;
11
+ Your customers will now be able to download invoices as PDF once they are logged in.&lt;br&gt;&#xD;
12
+ The PDF is exactly the same as the one in admin backend - no more clumsy HTML printouts for your customers.</description>
13
+ <notes>27.06.2016 - Initial release packaged</notes>
14
+ <authors><author><name>Modules4U</name><user>Modules4U</user><email>extensions@modules4u.biz</email></author></authors>
15
+ <date>2016-06-28</date>
16
+ <time>03:34:42</time>
17
+ <contents><target name="magecommunity"><dir name="Modules4U"><dir name="FrontendPdfInvoice"><dir name="controllers"><file name="IndexController.php" hash="c252704d3ef33892ee3e134574e52d97"/></dir><dir name="etc"><file name="config.xml" hash="b1e26d7cb4989d7b187a7d292c1e696c"/></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Modules4U_FrontendPdfInvoice.csv" hash="f181154ec8d4da82501478e504292efd"/></dir></target><target name="mageetc"><dir name="modules"><file name="Modules4U_FrontendPdfInvoice.xml" hash="0fc2dc96ba0efd058961891948df04e9"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="sales"><dir name="order"><file name="history.phtml" hash="4c0b33928f09aaba21d0c2b748e34a69"/></dir></dir></dir></dir></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>