Public Member Functions | |
indexAction () | |
gridAction () | |
viewAction () | |
cancelAction () | |
holdAction () | |
unholdAction () | |
addCommentAction () | |
invoicesAction () | |
shipmentsAction () | |
creditmemosAction () | |
commentsHistoryAction () | |
massCancelAction () | |
massHoldAction () | |
massUnholdAction () | |
massStatusAction () | |
massPrintAction () | |
pdfinvoicesAction () | |
pdfshipmentsAction () | |
pdfcreditmemosAction () | |
pdfdocsAction () | |
Protected Member Functions | |
_construct () | |
_initAction () | |
_initOrder () | |
_isAllowed () | |
Protected Attributes | |
$_publicActions = array('view') |
Definition at line 34 of file OrderController.php.
_construct | ( | ) | [protected] |
Additional initialization
Reimplemented from Mage_Core_Controller_Varien_Action.
Definition at line 47 of file OrderController.php.
00048 { 00049 $this->setUsedModuleName('Mage_Sales'); 00050 }
_initAction | ( | ) | [protected] |
Init layout, menu and breadcrumb
Definition at line 57 of file OrderController.php.
00058 { 00059 $this->loadLayout() 00060 ->_setActiveMenu('sales/order') 00061 ->_addBreadcrumb($this->__('Sales'), $this->__('Sales')) 00062 ->_addBreadcrumb($this->__('Orders'), $this->__('Orders')); 00063 return $this; 00064 }
_initOrder | ( | ) | [protected] |
Initialize order model instance
Definition at line 71 of file OrderController.php.
00072 { 00073 $id = $this->getRequest()->getParam('order_id'); 00074 $order = Mage::getModel('sales/order')->load($id); 00075 00076 if (!$order->getId()) { 00077 $this->_getSession()->addError($this->__('This order no longer exists.')); 00078 $this->_redirect('*/*/'); 00079 $this->setFlag('', self::FLAG_NO_DISPATCH, true); 00080 return false; 00081 } 00082 Mage::register('sales_order', $order); 00083 Mage::register('current_order', $order); 00084 return $order; 00085 }
_isAllowed | ( | ) | [protected] |
Reimplemented from Mage_Adminhtml_Controller_Action.
Definition at line 512 of file OrderController.php.
00513 { 00514 if ($this->getRequest()->getActionName() == 'view') { 00515 return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view'); 00516 } 00517 return Mage::getSingleton('admin/session')->isAllowed('sales/order'); 00518 }
addCommentAction | ( | ) |
Add order comment action
Definition at line 191 of file OrderController.php.
00192 { 00193 if ($order = $this->_initOrder()) { 00194 try { 00195 $response = false; 00196 $data = $this->getRequest()->getPost('history'); 00197 $notify = isset($data['is_customer_notified']) ? $data['is_customer_notified'] : false; 00198 $order->addStatusToHistory($data['status'], $data['comment'], $notify); 00199 $comment = trim(strip_tags($data['comment'])); 00200 00201 $order->sendOrderUpdateEmail($notify, $comment); 00202 $order->save(); 00203 00204 $this->loadLayout('empty'); 00205 $this->renderLayout(); 00206 } 00207 catch (Mage_Core_Exception $e) { 00208 $response = array( 00209 'error' => true, 00210 'message' => $e->getMessage(), 00211 ); 00212 } 00213 catch (Exception $e) { 00214 $response = array( 00215 'error' => true, 00216 'message' => $this->__('Can not add order history.') 00217 ); 00218 } 00219 if (is_array($response)) { 00220 $response = Zend_Json::encode($response); 00221 $this->getResponse()->setBody($response); 00222 } 00223 } 00224 }
cancelAction | ( | ) |
Cancel order
Definition at line 122 of file OrderController.php.
00123 { 00124 if ($order = $this->_initOrder()) { 00125 try { 00126 $order->cancel() 00127 ->save(); 00128 $this->_getSession()->addSuccess( 00129 $this->__('Order was successfully cancelled.') 00130 ); 00131 } 00132 catch (Mage_Core_Exception $e) { 00133 $this->_getSession()->addError($e->getMessage()); 00134 } 00135 catch (Exception $e) { 00136 $this->_getSession()->addError($this->__('Order was not cancelled.')); 00137 } 00138 $this->_redirect('*/sales_order/view', array('order_id' => $order->getId())); 00139 } 00140 }
commentsHistoryAction | ( | ) |
Generate order history for ajax request
Definition at line 262 of file OrderController.php.
00263 { 00264 $this->_initOrder(); 00265 $this->getResponse()->setBody( 00266 $this->getLayout()->createBlock('adminhtml/sales_order_view_tab_history')->toHtml() 00267 ); 00268 }
creditmemosAction | ( | ) |
Generate creditmemos grid for ajax request
Definition at line 251 of file OrderController.php.
00252 { 00253 $this->_initOrder(); 00254 $this->getResponse()->setBody( 00255 $this->getLayout()->createBlock('adminhtml/sales_order_view_tab_creditmemos')->toHtml() 00256 ); 00257 }
gridAction | ( | ) |
Order grid
Definition at line 100 of file OrderController.php.
00101 { 00102 $this->loadLayout(); 00103 $this->getResponse()->setBody( 00104 $this->getLayout()->createBlock('adminhtml/sales_order_grid')->toHtml() 00105 ); 00106 }
holdAction | ( | ) |
Hold order
Definition at line 145 of file OrderController.php.
00146 { 00147 if ($order = $this->_initOrder()) { 00148 try { 00149 $order->hold() 00150 ->save(); 00151 $this->_getSession()->addSuccess( 00152 $this->__('Order was successfully put on hold.') 00153 ); 00154 } 00155 catch (Mage_Core_Exception $e) { 00156 $this->_getSession()->addError($e->getMessage()); 00157 } 00158 catch (Exception $e) { 00159 $this->_getSession()->addError($this->__('Order was not put on hold.')); 00160 } 00161 $this->_redirect('*/sales_order/view', array('order_id' => $order->getId())); 00162 } 00163 }
indexAction | ( | ) |
Orders grid
Definition at line 90 of file OrderController.php.
00091 { 00092 $this->_initAction() 00093 ->_addContent($this->getLayout()->createBlock('adminhtml/sales_order')) 00094 ->renderLayout(); 00095 }
invoicesAction | ( | ) |
Generate invoices grid for ajax request
Definition at line 229 of file OrderController.php.
00230 { 00231 $this->_initOrder(); 00232 $this->getResponse()->setBody( 00233 $this->getLayout()->createBlock('adminhtml/sales_order_view_tab_invoices')->toHtml() 00234 ); 00235 }
massCancelAction | ( | ) |
Cancel selected orders
Definition at line 273 of file OrderController.php.
00274 { 00275 $orderIds = $this->getRequest()->getPost('order_ids', array()); 00276 $countCancelOrder = 0; 00277 foreach ($orderIds as $orderId) { 00278 $order = Mage::getModel('sales/order')->load($orderId); 00279 if ($order->canCancel()) { 00280 $order->cancel() 00281 ->save(); 00282 $countCancelOrder++; 00283 } 00284 } 00285 if ($countCancelOrder>0) { 00286 $this->_getSession()->addSuccess($this->__('%s order(s) successfully canceled', $countCancelOrder)); 00287 } 00288 else { 00289 // selected orders is not available for cancel 00290 } 00291 $this->_redirect('*/*/'); 00292 }
massHoldAction | ( | ) |
Hold selected orders
Definition at line 297 of file OrderController.php.
00298 { 00299 $orderIds = $this->getRequest()->getPost('order_ids', array()); 00300 $countHoldOrder = 0; 00301 foreach ($orderIds as $orderId) { 00302 $order = Mage::getModel('sales/order')->load($orderId); 00303 if ($order->canHold()) { 00304 $order->hold() 00305 ->save(); 00306 $countHoldOrder++; 00307 } 00308 } 00309 if ($countHoldOrder>0) { 00310 $this->_getSession()->addSuccess($this->__('%s order(s) successfully put on hold', $countHoldOrder)); 00311 } 00312 else { 00313 // selected orders is not available for hold 00314 } 00315 $this->_redirect('*/*/'); 00316 }
massPrintAction | ( | ) |
Print documents for selected orders
Definition at line 353 of file OrderController.php.
00354 { 00355 $orderIds = $this->getRequest()->getPost('order_ids'); 00356 $document = $this->getRequest()->getPost('document'); 00357 }
massStatusAction | ( | ) |
massUnholdAction | ( | ) |
Unhold selected orders
Definition at line 321 of file OrderController.php.
00322 { 00323 $orderIds = $this->getRequest()->getPost('order_ids', array()); 00324 $countUnholdOrder = 0; 00325 foreach ($orderIds as $orderId) { 00326 $order = Mage::getModel('sales/order')->load($orderId); 00327 if ($order->canUnhold()) { 00328 $order->unhold() 00329 ->save(); 00330 $countUnholdOrder++; 00331 } 00332 } 00333 if ($countUnholdOrder>0) { 00334 $this->_getSession()->addSuccess($this->__('%s order(s) successfully released from holding status', $countUnholdOrder)); 00335 } 00336 else { 00337 // selected orders is not available for hold 00338 } 00339 $this->_redirect('*/*/'); 00340 }
pdfcreditmemosAction | ( | ) |
Definition at line 422 of file OrderController.php.
00422 { 00423 $orderIds = $this->getRequest()->getPost('order_ids'); 00424 $flag = false; 00425 if (!empty($orderIds)) { 00426 foreach ($orderIds as $orderId) { 00427 $order = Mage::getModel('sales/order')->load($orderId); 00428 00429 $creditmemos = Mage::getResourceModel('sales/order_creditmemo_collection') 00430 ->addAttributeToSelect('*') 00431 ->setOrderFilter($orderId) 00432 ->load(); 00433 if ($creditmemos->getSize()) { 00434 $flag = true; 00435 if (!isset($pdf)){ 00436 $pdf = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($creditmemos); 00437 } else { 00438 $pages = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($creditmemos); 00439 $pdf->pages = array_merge ($pdf->pages, $pages->pages); 00440 } 00441 } 00442 } 00443 if ($flag) { 00444 return $this->_prepareDownloadResponse('creditmemo'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf'); 00445 } else { 00446 $this->_getSession()->addError($this->__('There are no printable documents related to selected orders')); 00447 $this->_redirect('*/*/'); 00448 } 00449 } 00450 $this->_redirect('*/*/'); 00451 }
pdfdocsAction | ( | ) |
Definition at line 453 of file OrderController.php.
00453 { 00454 $orderIds = $this->getRequest()->getPost('order_ids'); 00455 $flag = false; 00456 if (!empty($orderIds)) { 00457 foreach ($orderIds as $orderId) { 00458 $order = Mage::getModel('sales/order')->load($orderId); 00459 00460 $invoices = Mage::getResourceModel('sales/order_invoice_collection') 00461 ->addAttributeToSelect('*') 00462 ->setOrderFilter($orderId) 00463 ->load(); 00464 if ($invoices->getSize()){ 00465 $flag = true; 00466 if (!isset($pdf)){ 00467 $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices); 00468 } else { 00469 $pages = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices); 00470 $pdf->pages = array_merge ($pdf->pages, $pages->pages); 00471 } 00472 } 00473 00474 $shipments = Mage::getResourceModel('sales/order_shipment_collection') 00475 ->addAttributeToSelect('*') 00476 ->setOrderFilter($orderId) 00477 ->load(); 00478 if ($shipments->getSize()){ 00479 $flag = true; 00480 if (!isset($pdf)){ 00481 $pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments); 00482 } else { 00483 $pages = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments); 00484 $pdf->pages = array_merge ($pdf->pages, $pages->pages); 00485 } 00486 } 00487 00488 $creditmemos = Mage::getResourceModel('sales/order_creditmemo_collection') 00489 ->addAttributeToSelect('*') 00490 ->setOrderFilter($orderId) 00491 ->load(); 00492 if ($creditmemos->getSize()) { 00493 $flag = true; 00494 if (!isset($pdf)){ 00495 $pdf = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($creditmemos); 00496 } else { 00497 $pages = Mage::getModel('sales/order_pdf_creditmemo')->getPdf($creditmemos); 00498 $pdf->pages = array_merge ($pdf->pages, $pages->pages); 00499 } 00500 } 00501 } 00502 if ($flag) { 00503 return $this->_prepareDownloadResponse('docs'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf'); 00504 } else { 00505 $this->_getSession()->addError($this->__('There are no printable documents related to selected orders')); 00506 $this->_redirect('*/*/'); 00507 } 00508 } 00509 $this->_redirect('*/*/'); 00510 }
pdfinvoicesAction | ( | ) |
Definition at line 359 of file OrderController.php.
00359 { 00360 $orderIds = $this->getRequest()->getPost('order_ids'); 00361 $flag = false; 00362 if (!empty($orderIds)) { 00363 foreach ($orderIds as $orderId) { 00364 $order = Mage::getModel('sales/order')->load($orderId); 00365 00366 $invoices = Mage::getResourceModel('sales/order_invoice_collection') 00367 ->addAttributeToSelect('*') 00368 ->setOrderFilter($orderId) 00369 ->load(); 00370 if ($invoices->getSize() > 0) { 00371 $flag = true; 00372 if (!isset($pdf)){ 00373 $pdf = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices); 00374 } else { 00375 $pages = Mage::getModel('sales/order_pdf_invoice')->getPdf($invoices); 00376 $pdf->pages = array_merge ($pdf->pages, $pages->pages); 00377 } 00378 } 00379 } 00380 if ($flag) { 00381 return $this->_prepareDownloadResponse('invoice'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf'); 00382 } else { 00383 $this->_getSession()->addError($this->__('There are no printable documents related to selected orders')); 00384 $this->_redirect('*/*/'); 00385 } 00386 00387 } 00388 $this->_redirect('*/*/'); 00389 00390 }
pdfshipmentsAction | ( | ) |
Definition at line 392 of file OrderController.php.
00392 { 00393 $orderIds = $this->getRequest()->getPost('order_ids'); 00394 $flag = false; 00395 if (!empty($orderIds)) { 00396 foreach ($orderIds as $orderId) { 00397 $order = Mage::getModel('sales/order')->load($orderId); 00398 $shipments = Mage::getResourceModel('sales/order_shipment_collection') 00399 ->addAttributeToSelect('*') 00400 ->setOrderFilter($orderId) 00401 ->load(); 00402 if ($shipments->getSize()) { 00403 $flag = true; 00404 if (!isset($pdf)){ 00405 $pdf = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments); 00406 } else { 00407 $pages = Mage::getModel('sales/order_pdf_shipment')->getPdf($shipments); 00408 $pdf->pages = array_merge ($pdf->pages, $pages->pages); 00409 } 00410 } 00411 } 00412 if ($flag) { 00413 return $this->_prepareDownloadResponse('packingslip'.Mage::getSingleton('core/date')->date('Y-m-d_H-i-s').'.pdf', $pdf->render(), 'application/pdf'); 00414 } else { 00415 $this->_getSession()->addError($this->__('There are no printable documents related to selected orders')); 00416 $this->_redirect('*/*/'); 00417 } 00418 } 00419 $this->_redirect('*/*/'); 00420 }
shipmentsAction | ( | ) |
Generate shipments grid for ajax request
Definition at line 240 of file OrderController.php.
00241 { 00242 $this->_initOrder(); 00243 $this->getResponse()->setBody( 00244 $this->getLayout()->createBlock('adminhtml/sales_order_view_tab_shipments')->toHtml() 00245 ); 00246 }
unholdAction | ( | ) |
Unhold order
Definition at line 168 of file OrderController.php.
00169 { 00170 if ($order = $this->_initOrder()) { 00171 try { 00172 $order->unhold() 00173 ->save(); 00174 $this->_getSession()->addSuccess( 00175 $this->__('Order was successfully released from holding status.') 00176 ); 00177 } 00178 catch (Mage_Core_Exception $e) { 00179 $this->_getSession()->addError($e->getMessage()); 00180 } 00181 catch (Exception $e) { 00182 $this->_getSession()->addError($this->__('Order was not unholded.')); 00183 } 00184 $this->_redirect('*/sales_order/view', array('order_id' => $order->getId())); 00185 } 00186 }
viewAction | ( | ) |
View order detale
Definition at line 111 of file OrderController.php.
00112 { 00113 if ($order = $this->_initOrder()) { 00114 $this->_initAction() 00115 ->renderLayout(); 00116 } 00117 }
$_publicActions = array('view') [protected] |
Reimplemented from Mage_Adminhtml_Controller_Action.
Definition at line 41 of file OrderController.php.