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
00033
00034 class Mage_Adminhtml_Block_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
00035 {
00036
00037 public function __construct()
00038 {
00039 parent::__construct();
00040 $this->setId('sales_order_grid');
00041 $this->setUseAjax(true);
00042 $this->setDefaultSort('created_at');
00043 $this->setDefaultDir('DESC');
00044 $this->setSaveParametersInSession(true);
00045 }
00046
00047 protected function _prepareCollection()
00048 {
00049
00050 $collection = Mage::getResourceModel('sales/order_collection')
00051 ->addAttributeToSelect('*')
00052 ->joinAttribute('billing_firstname', 'order_address/firstname', 'billing_address_id', null, 'left')
00053 ->joinAttribute('billing_lastname', 'order_address/lastname', 'billing_address_id', null, 'left')
00054 ->joinAttribute('shipping_firstname', 'order_address/firstname', 'shipping_address_id', null, 'left')
00055 ->joinAttribute('shipping_lastname', 'order_address/lastname', 'shipping_address_id', null, 'left')
00056 ->addExpressionAttributeToSelect('billing_name',
00057 'CONCAT({{billing_firstname}}, " ", {{billing_lastname}})',
00058 array('billing_firstname', 'billing_lastname'))
00059 ->addExpressionAttributeToSelect('shipping_name',
00060 'CONCAT({{shipping_firstname}}, " ", {{shipping_lastname}})',
00061 array('shipping_firstname', 'shipping_lastname'));
00062 $this->setCollection($collection);
00063 return parent::_prepareCollection();
00064 }
00065
00066 protected function _prepareColumns()
00067 {
00068
00069 $this->addColumn('real_order_id', array(
00070 'header'=> Mage::helper('sales')->__('Order #'),
00071 'width' => '80px',
00072 'type' => 'text',
00073 'index' => 'increment_id',
00074 ));
00075
00076 if (!Mage::app()->isSingleStoreMode()) {
00077 $this->addColumn('store_id', array(
00078 'header' => Mage::helper('sales')->__('Purchased from (store)'),
00079 'index' => 'store_id',
00080 'type' => 'store',
00081 'store_view'=> true,
00082 'display_deleted' => true,
00083 ));
00084 }
00085
00086 $this->addColumn('created_at', array(
00087 'header' => Mage::helper('sales')->__('Purchased On'),
00088 'index' => 'created_at',
00089 'type' => 'datetime',
00090 'width' => '100px',
00091 ));
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 $this->addColumn('billing_name', array(
00103 'header' => Mage::helper('sales')->__('Bill to Name'),
00104 'index' => 'billing_name',
00105 ));
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 $this->addColumn('shipping_name', array(
00117 'header' => Mage::helper('sales')->__('Ship to Name'),
00118 'index' => 'shipping_name',
00119 ));
00120
00121 $this->addColumn('base_grand_total', array(
00122 'header' => Mage::helper('sales')->__('G.T. (Base)'),
00123 'index' => 'base_grand_total',
00124 'type' => 'currency',
00125 'currency' => 'base_currency_code',
00126 ));
00127
00128 $this->addColumn('grand_total', array(
00129 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
00130 'index' => 'grand_total',
00131 'type' => 'currency',
00132 'currency' => 'order_currency_code',
00133 ));
00134
00135 $this->addColumn('status', array(
00136 'header' => Mage::helper('sales')->__('Status'),
00137 'index' => 'status',
00138 'type' => 'options',
00139 'width' => '70px',
00140 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
00141 ));
00142
00143 if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
00144 $this->addColumn('action',
00145 array(
00146 'header' => Mage::helper('sales')->__('Action'),
00147 'width' => '50px',
00148 'type' => 'action',
00149 'getter' => 'getId',
00150 'actions' => array(
00151 array(
00152 'caption' => Mage::helper('sales')->__('View'),
00153 'url' => array('base'=>'*/*/view'),
00154 'field' => 'order_id'
00155 )
00156 ),
00157 'filter' => false,
00158 'sortable' => false,
00159 'index' => 'stores',
00160 'is_system' => true,
00161 ));
00162 }
00163 $this->addRssList('rss/order/new', Mage::helper('sales')->__('New Order RSS'));
00164
00165 return parent::_prepareColumns();
00166 }
00167
00168 protected function _prepareMassaction()
00169 {
00170 $this->setMassactionIdField('entity_id');
00171 $this->getMassactionBlock()->setFormFieldName('order_ids');
00172
00173 $this->getMassactionBlock()->addItem('cancel_order', array(
00174 'label'=> Mage::helper('sales')->__('Cancel'),
00175 'url' => $this->getUrl('*/*/massCancel'),
00176 ));
00177
00178 $this->getMassactionBlock()->addItem('hold_order', array(
00179 'label'=> Mage::helper('sales')->__('Hold'),
00180 'url' => $this->getUrl('*/*/massHold'),
00181 ));
00182
00183 $this->getMassactionBlock()->addItem('unhold_order', array(
00184 'label'=> Mage::helper('sales')->__('Unhold'),
00185 'url' => $this->getUrl('*/*/massUnhold'),
00186 ));
00187
00188 $this->getMassactionBlock()->addItem('pdfinvoices_order', array(
00189 'label'=> Mage::helper('sales')->__('Print Invoices'),
00190 'url' => $this->getUrl('*/*/pdfinvoices'),
00191 ));
00192
00193 $this->getMassactionBlock()->addItem('pdfshipments_order', array(
00194 'label'=> Mage::helper('sales')->__('Print Packingslips'),
00195 'url' => $this->getUrl('*/*/pdfshipments'),
00196 ));
00197
00198 $this->getMassactionBlock()->addItem('pdfcreditmemos_order', array(
00199 'label'=> Mage::helper('sales')->__('Print Credit Memos'),
00200 'url' => $this->getUrl('*/*/pdfcreditmemos'),
00201 ));
00202
00203 $this->getMassactionBlock()->addItem('pdfdocs_order', array(
00204 'label'=> Mage::helper('sales')->__('Print All'),
00205 'url' => $this->getUrl('*/*/pdfdocs'),
00206 ));
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244 return $this;
00245 }
00246
00247 public function getRowUrl($row)
00248 {
00249 if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
00250 return $this->getUrl('*/*/view', array('order_id' => $row->getId()));
00251 }
00252 return false;
00253 }
00254
00255 public function getGridUrl()
00256 {
00257 return $this->getUrl('*/*/grid', array('_current'=>true));
00258 }
00259
00260 }