Advertisement
reynierpm

pdf.php

Oct 9th, 2012
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.69 KB | None | 0 0
  1. <?php
  2. /*
  3. * 2007-2012 PrestaShop
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-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@prestashop.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 PrestaShop to newer
  18. * versions in the future. If you wish to customize PrestaShop for your
  19. * needs please refer to http://www.prestashop.com for more information.
  20. *
  21. *  @author PrestaShop SA <contact@prestashop.com>
  22. *  @copyright  2007-2012 PrestaShop SA
  23. *  @version  Release: $Revision: 14002 $
  24. *  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
  25. *  International Registered Trademark & Property of PrestaShop SA
  26. */
  27.  
  28. define('_PS_ADMIN_DIR_', getcwd());
  29. define('PS_ADMIN_DIR', _PS_ADMIN_DIR_); // Retro-compatibility
  30.  
  31. include(PS_ADMIN_DIR.'/../config/config.inc.php');
  32.  
  33. /* Header can't be included, so cookie must be created here */
  34. $cookie = new Cookie('psAdmin');
  35. if (!$cookie->id_employee)
  36.     Tools::redirectAdmin('login.php');
  37.  
  38. $functionArray = array(
  39.     'pdf' => 'generateInvoicePDF',
  40.     'id_order_slip' => 'generateOrderSlipPDF',
  41.     'id_delivery' => 'generateDeliverySlipPDF',
  42.     'invoices' => 'generateInvoicesPDF',
  43.     'invoices2' => 'generateInvoicesPDF2',
  44.     'slips' => 'generateOrderSlipsPDF',
  45.     'deliveryslips' => 'generateDeliverySlipsPDF'
  46. );
  47.  
  48. foreach ($functionArray as $var => $function)
  49.     if (isset($_GET[$var]))
  50.     {
  51.         call_user_func($function);
  52.         die;
  53.     }
  54.  
  55. function generateInvoicePDF()
  56. {
  57.     if (!isset($_GET['id_order']))
  58.         die (Tools::displayError('Missing order ID'));
  59.     $order = new Order((int)($_GET['id_order']));
  60.  
  61.     if (!Validate::isLoadedObject($order))
  62.         die(Tools::displayError('Cannot find order in database'));
  63.     PDF::invoice($order);
  64. }
  65.  
  66. function generateOrderSlipPDF()
  67. {
  68.     $orderSlip = new OrderSlip((int)($_GET['id_order_slip']));
  69.     $order = new Order((int)($orderSlip->id_order));
  70.     if (!Validate::isLoadedObject($order))
  71.         die(Tools::displayError('Cannot find order in database'));
  72.     $order->products = OrderSlip::getOrdersSlipProducts($orderSlip->id, $order);
  73.     $tmp = NULL;
  74.     PDF::invoice($order, 'D', false, $tmp, $orderSlip);
  75. }
  76.  
  77. function generateDeliverySlipPDF()
  78. {
  79.     $order = Order::getByDelivery((int)($_GET['id_delivery']));
  80.     if (!Validate::isLoadedObject($order))
  81.         die(Tools::displayError('Cannot find order in database'));
  82.     $tmp = NULL;
  83.     PDF::invoice($order, 'D', false, $tmp, false, $order->delivery_number);
  84. }
  85.  
  86. function generateInvoicesPDF()
  87. {
  88.     $orders = Order::getOrdersIdInvoiceByDate($_GET['date_from'], $_GET['date_to'], NULL, 'invoice');
  89.     if (!is_array($orders))
  90.         die (Tools::displayError('No invoices found'));
  91.     PDF::multipleInvoices($orders);
  92. }
  93.  
  94. function generateInvoicesPDF2()
  95. {
  96.     $allOrders = array();
  97.     foreach (explode('-', Tools::getValue('id_order_state')) as $id_order_state)
  98.         if (is_array($orders = Order::getOrderIdsByStatus((int)$id_order_state)))
  99.             $allOrders = array_merge($allOrders, $orders);
  100.     PDF::multipleInvoices($allOrders);
  101. }
  102.  
  103. function generateOrderSlipsPDF()
  104. {
  105.     $orderSlips = OrderSlip::getSlipsIdByDate($_GET['date_from'], $_GET['date_to']);
  106.     if (!count($orderSlips))
  107.         die (Tools::displayError('No order slips found'));
  108.     PDF::multipleOrderSlips($orderSlips);
  109. }
  110.  
  111. function generateDeliverySlipsPDF()
  112. {
  113.     $slips = unserialize(urldecode($_GET['deliveryslips']));
  114.     if (is_array($slips))
  115.         PDF::multipleDelivery($slips);
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement