Example #1
0
 public function indexAction()
 {
     $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
     $orders = $this->getRequest()->getParam('order_ids');
     $orderId = $this->getRequest()->getParam('order_id');
     if ($orderId) {
         $orders = array($orderId);
     }
     $customers = $this->getRequest()->getParam('customer');
     $customerId = $this->getRequest()->getParam('customer_id');
     if ($customerId) {
         $customers = array($customerId);
     }
     if (!$orders && !$customers && !$data) {
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('amemail')->__('Please select customers'));
         return $this->_redirect('customer/index');
     }
     $template = new Varien_Object();
     if (!empty($data)) {
         $template->setData($data);
     } else {
         $template->setTxt(Mage::getStoreConfig('amemail/general/txt'));
         if ($orders) {
             $template->setOrders(implode(',', $orders));
         } elseif ($customers) {
             $template->setCustomers(implode(',', $customers));
         }
     }
     Mage::register('amemail_template', $template);
     $this->loadLayout();
     $this->_addContent($this->getLayout()->createBlock('amemail/adminhtml_template_edit'));
     $this->renderLayout();
     return $this;
 }