protected function _prepareMassaction() { $this->setMassactionIdField('affiliate_history'); $this->getMassactionBlock()->setFormFieldName('mw_history_id'); $statuses = MW_Affiliate_Model_Status::getOptionAction(); $this->getMassactionBlock()->addItem('status', array('label' => Mage::helper('catalog')->__('Change status'), 'url' => $this->getUrl('affiliate/adminhtml_affiliatehistory/updateStatus', array('_current' => true)), 'additional' => array('visibility' => array('name' => 'status', 'type' => 'select', 'class' => 'required-entry', 'label' => Mage::helper('catalog')->__('Status'), 'values' => $statuses)))); return $this; }
protected function _prepareForm() { $form = new Varien_Data_Form(); $this->setForm($form); $fieldset = $form->addFieldset('affiliatehistory_form', array('legend' => Mage::helper('affiliate')->__('Update Affiliate Transactions via CSV'))); $fieldset->addField('status_update', 'select', array('label' => Mage::helper('affiliate')->__('Update Status'), 'required' => true, 'name' => 'status_update', 'values' => MW_Affiliate_Model_Status::getOptionAction())); $fieldset->addField('filename', 'file', array('label' => Mage::helper('affiliate')->__('Upload CSV File'), 'required' => true, 'name' => 'filename')); return parent::_prepareForm(); }
protected function _prepareColumns() { $this->addColumn('withdrawn_id', array('header' => Mage::helper('affiliate')->__('ID'), 'align' => 'left', 'index' => 'withdrawn_id', 'name' => 'withdrawn_id', 'width' => 15)); $this->addColumn('withdrawn_time', array('header' => Mage::helper('affiliate')->__('Withdrawal Time'), 'type' => 'datetime', 'align' => 'center', 'index' => 'withdrawn_time', 'width' => 100)); $this->addColumn('withdrawn_amount', array('header' => Mage::helper('affiliate')->__('Withdrawal Amount'), 'align' => 'left', 'type' => 'price', 'index' => 'withdrawn_amount', 'currency_code' => Mage::app()->getBaseCurrencyCode())); $this->addColumn('fee', array('header' => Mage::helper('affiliate')->__('Payment Processing Fee'), 'align' => 'left', 'type' => 'price', 'index' => 'fee', 'currency_code' => Mage::app()->getBaseCurrencyCode())); $this->addColumn('amount_receive', array('header' => Mage::helper('affiliate')->__('Net Amount'), 'align' => 'center', 'type' => 'price', 'index' => 'amount_receive', 'currency_code' => Mage::app()->getBaseCurrencyCode())); $this->addColumn('status', array('header' => Mage::helper('affiliate')->__('Status'), 'align' => 'center', 'index' => 'status', 'type' => 'options', 'options' => MW_Affiliate_Model_Status::getOptionArray(), 'width' => 100)); return parent::_prepareColumns(); }
public function getInvitationStatus($order_id, $status) { if ($status == MW_Affiliate_Model_Statusinvitation::PURCHASE) { $collection = Mage::getModel('affiliate/affiliatehistory')->getCollection()->addFieldToFilter('order_id', array('eq' => $order_id)); foreach ($collection as $item) { $orderStatus = $item->getStatus(); break; } return MW_Affiliate_Model_Status::getLabel($orderStatus); } else { return Mage::helper('affiliate')->__('Completed'); } }
protected function _prepareColumns() { $this->addColumn('withdrawn_id', array('header' => Mage::helper('affiliate')->__('ID'), 'align' => 'left', 'index' => 'withdrawn_id', 'name' => 'withdrawn_id', 'width' => 15)); $this->addColumn('email', array('header' => Mage::helper('affiliate')->__('Affiliate Account'), 'align' => 'left', 'index' => 'email', 'width' => '250px', 'type' => 'text', 'renderer' => 'affiliate/adminhtml_renderer_emailaffiliatemember')); $this->addColumn('payment_gateway', array('header' => Mage::helper('affiliate')->__('Payment Method'), 'align' => 'left', 'index' => 'payment_gateway', 'type' => 'options', 'options' => $this->_getPaymentGatewayArray(), 'filter' => false, 'sortable' => false)); $this->addColumn('payment_email', array('header' => Mage::helper('affiliate')->__('Payment Email'), 'align' => 'left', 'index' => 'payment_email', 'type' => 'text')); $this->addColumn('withdrawn_time', array('header' => Mage::helper('affiliate')->__('Withdrawal Time'), 'type' => 'datetime', 'align' => 'center', 'index' => 'withdrawn_time')); $this->addColumn('withdrawn_amount', array('header' => Mage::helper('affiliate')->__('Withdrawal Amount'), 'align' => 'left', 'type' => 'price', 'index' => 'withdrawn_amount', 'currency_code' => Mage::app()->getBaseCurrencyCode())); $this->addColumn('fee', array('header' => Mage::helper('affiliate')->__('Payment Processing Fee'), 'align' => 'left', 'type' => 'price', 'index' => 'fee', 'currency_code' => Mage::app()->getBaseCurrencyCode())); $this->addColumn('amount_receive', array('header' => Mage::helper('affiliate')->__('Net Amount'), 'align' => 'center', 'type' => 'price', 'index' => 'amount_receive', 'currency_code' => Mage::app()->getBaseCurrencyCode())); $this->addColumn('status', array('header' => Mage::helper('affiliate')->__('Status'), 'align' => 'center', 'index' => 'status', 'type' => 'options', 'options' => MW_Affiliate_Model_Status::getOptionArray(), 'width' => 100)); $this->addExportType('*/*/exportCsv', Mage::helper('affiliate')->__('CSV')); $this->addExportType('*/*/exportXml', Mage::helper('affiliate')->__('XML')); return parent::_prepareColumns(); }
public function render(Varien_Object $row) { if (empty($row['status'])) { return ''; } if ($row['status'] == MW_Affiliate_Model_Statusinvitation::PURCHASE) { $orderId = $row['order_id']; $collection = Mage::getModel('affiliate/affiliatehistory')->getCollection()->addFieldToFilter('order_id', array('eq' => $orderId)); foreach ($collection as $item) { $orderStatus = $item->getStatus(); break; } return MW_Affiliate_Model_Status::getLabel($orderStatus); } else { return Mage::helper('affiliate')->__('Completed'); } }
public function getStatusText($status) { return MW_Affiliate_Model_Status::getLabel($status); }
public function updateStatusAction() { $history_ids = (array) $this->getRequest()->getParam('mw_history_id'); $status = (int) $this->getRequest()->getParam('status'); if (!is_array($history_ids)) { Mage::getSingleton('adminhtml/session')->addError(Mage::helper('affiliate')->__('Please select affiliate history(s)')); } else { try { $count_success = 0; $count_error = 0; foreach ($history_ids as $history_id) { $history = Mage::getModel('affiliate/affiliatetransaction')->load($history_id); $order_id = $history->getOrderId(); $status_order = (int) $history->getStatus(); if ($status == MW_Affiliate_Model_Status::CANCELED) { if ($status_order == MW_Affiliate_Model_Status::PENDING) { $count_success = $count_success + 1; MW_Affiliate_Model_Observer::saveOrderCanceled($order_id); } else { $count_error = $count_error + 1; } } else { if ($status == MW_Affiliate_Model_Status::COMPLETE) { if ($status_order == MW_Affiliate_Model_Status::PENDING) { $count_success = $count_success + 1; MW_Affiliate_Model_Observer::saveOrderComplete($order_id); } else { $count_error = $count_error + 1; } } else { if ($status == MW_Affiliate_Model_Status::CLOSED) { if ($status_order == MW_Affiliate_Model_Status::COMPLETE) { $count_success = $count_success + 1; MW_Affiliate_Model_Observer::saveOrderClosed($order_id); } else { $count_error = $count_error + 1; } } } } } $status_label = MW_Affiliate_Model_Status::getLabel($status); if ($count_success > 0) { $this->_getSession()->addSuccess($this->__('%s order(s) have been %s', $count_success, $status_label)); } if ($count_error > 0) { $this->_getSession()->addError($this->__('%s order(s) cannot be %s', $count_error, $status_label)); } } catch (Mage_Core_Model_Exception $e) { $this->_getSession()->addError($e->getMessage()); } catch (Exception $e) { $this->_getSession()->addError($e->getMessage()); } } $this->_redirect('*/*/index'); }