00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 class Mage_Adminhtml_Controller_Sales_Shipment extends Mage_Adminhtml_Controller_Action
00033 {
00034
00035
00036
00037
00038 protected function _construct()
00039 {
00040 $this->setUsedModuleName('Mage_Sales');
00041 }
00042
00043
00044
00045
00046
00047
00048 protected function _initAction()
00049 {
00050 $this->loadLayout()
00051 ->_setActiveMenu('sales/order')
00052 ->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
00053 ->_addBreadcrumb($this->__('Shipments'),$this->__('Shipments'));
00054 return $this;
00055 }
00056
00057
00058
00059
00060 public function indexAction()
00061 {
00062 $this->_initAction()
00063 ->_addContent($this->getLayout()->createBlock('adminhtml/sales_shipment'))
00064 ->renderLayout();
00065 }
00066
00067
00068
00069
00070 public function viewAction()
00071 {
00072 if ($shipmentId = $this->getRequest()->getParam('shipment_id')) {
00073 $this->_forward('view', 'sales_order_shipment', null, array('come_from'=>'shipment'));
00074 } else {
00075 $this->_forward('noRoute');
00076 }
00077 }
00078
00079 public function pdfshipmentsAction(){
00080 $shipmentIds = $this->getRequest()->getPost('shipment_ids');
00081 if (!empty($shipmentIds)) {
00082 $shipments = Mage::getResourceModel('sales/order_shipment_collection')
00083 ->addAttributeToSelect('*')
00084 ->addAttributeToFilter('entity_id', array('in' => $shipmentIds))
00085 ->load();
00086 if (!isset($pdf)){
00087 $pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments);
00088 } else {
00089 $pages = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments);
00090 $pdf->pages = array_merge ($pdf->pages, $pages->pages);
00091 }
00092
00093 return $this->_prepareDownloadResponse('packingslip'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf');
00094 }
00095 $this->_redirect('*/*/');
00096 }
00097
00098
00099 public function printAction()
00100 {
00101
00102 if ($shipmentId = $this->getRequest()->getParam('invoice_id')) {
00103 if ($shipment = Mage::getModel('sales/order_shipment')->load($shipmentId)) {
00104 if ($shipment->getStoreId()) {
00105 Mage::app()->setCurrentStore($shipment->getStoreId());
00106 }
00107 $pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf(array($shipment));
00108 $this->_prepareDownloadResponse('packingslip'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf');
00109 }
00110 }
00111 else {
00112 $this->_forward('noRoute');
00113 }
00114 }
00115
00116 protected function _isAllowed()
00117 {
00118 return Mage::getSingleton('admin/session')->isAllowed('sales/shipment');
00119 }
00120 }