1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26:
27: 28: 29: 30: 31:
32: class Mage_Adminhtml_Controller_Sales_Shipment extends Mage_Adminhtml_Controller_Action
33: {
34: 35: 36: 37:
38: protected function _construct()
39: {
40: $this->setUsedModuleName('Mage_Sales');
41: }
42:
43: 44: 45: 46: 47:
48: protected function _initAction()
49: {
50: $this->loadLayout()
51: ->_setActiveMenu('sales/order')
52: ->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
53: ->_addBreadcrumb($this->__('Shipments'),$this->__('Shipments'));
54: return $this;
55: }
56:
57: 58: 59:
60: public function indexAction()
61: {
62: $this->_title($this->__('Sales'))->_title($this->__('Shipments'));
63:
64: $this->_initAction()
65: ->_addContent($this->getLayout()->createBlock('adminhtml/sales_shipment'))
66: ->renderLayout();
67: }
68:
69: 70: 71:
72: public function viewAction()
73: {
74: if ($shipmentId = $this->getRequest()->getParam('shipment_id')) {
75: $this->_forward('view', 'sales_order_shipment', null, array('come_from'=>'shipment'));
76: } else {
77: $this->_forward('noRoute');
78: }
79: }
80:
81: public function pdfshipmentsAction(){
82: $shipmentIds = $this->getRequest()->getPost('shipment_ids');
83: if (!empty($shipmentIds)) {
84: $shipments = Mage::getResourceModel('sales/order_shipment_collection')
85: ->addAttributeToSelect('*')
86: ->addAttributeToFilter('entity_id', array('in' => $shipmentIds))
87: ->load();
88: if (!isset($pdf)){
89: $pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments);
90: } else {
91: $pages = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments);
92: $pdf->pages = array_merge ($pdf->pages, $pages->pages);
93: }
94:
95: return $this->_prepareDownloadResponse('packingslip'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf');
96: }
97: $this->_redirect('*/*/');
98: }
99:
100:
101: public function printAction()
102: {
103:
104: if ($shipmentId = $this->getRequest()->getParam('invoice_id')) {
105: if ($shipment = Mage::getModel('sales/order_shipment')->load($shipmentId)) {
106: $pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf(array($shipment));
107: $this->_prepareDownloadResponse('packingslip'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf');
108: }
109: }
110: else {
111: $this->_forward('noRoute');
112: }
113: }
114:
115: protected function _isAllowed()
116: {
117: return Mage::getSingleton('admin/session')->isAllowed('sales/shipment');
118: }
119: }
120: