public function deleteAction()
 {
     $request = $this->getRequest();
     $form = new Application_Form_DeleteProduct();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $data = $form->getValues();
             $productMapper = new Application_Model_ProductMapper();
             if (isset($data['product_id'])) {
                 $productMapper->delete($data['product_id']);
             }
             return $this->_helper->redirector('viewall');
         }
     }
 }
 public function dashboardAction()
 {
     $this->view->headScript()->appendFile(JS_DIR . '/' . self::VALIDATE_FORM . '.js');
     $this->view->headScript()->appendFile(JS_DIR . '/' . self::STATE_UPDATE . '.js');
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $currentUser = $auth->getIdentity();
     }
     $productMapper = new Application_Model_ProductMapper();
     $this->view->products = $productMapper->fetchAll();
     $userMapper = new Application_Model_UserMapper();
     $this->view->users = $userMapper->fetchAll();
     $mailMapper = new Application_Model_MailsettingMapper();
     $this->view->mailSettings = $mailMapper->fetchAll();
     $orderMapper = new Application_Model_OrderMapper();
     $this->view->orders = $orderMapper->fetchAll();
     $currencyMapper = new Application_Model_CurrencyMapper();
     $this->view->currencies = $currencyMapper->fetchAll();
     $forms = array();
     foreach ($this->view->mailSettings as $setting) {
         $form = new Application_Form_SubmitButton();
         $form->setAction($this->view->url(array('controller' => 'mailsettings', 'action' => 'delete'), null, true));
         $form->addAttribs(array('id' => 'delSettingForm' . $setting->id, 'onsubmit' => self::VALIDATE_FORM . "('delSettingForm" . $setting->id . "')"));
         $form->getElement('id')->setValue($setting->id);
         $form->getElement('submit')->setAttribs(array('class' => 'btn btn-danger'));
         $form->getElement('submit')->setLabel('Delete');
         $forms['delSettingForm'][] = $form;
         $form = new Application_Form_SubmitButton();
         if ($setting->getDefaultConfig()) {
             $form->getElement('submit')->setAttribs(array('class' => 'btn btn-primary disabled'));
             $form->getElement('submit')->setLabel('Default');
         } else {
             $form->addAttribs(array('id' => 'defSettingForm' . $setting->id, 'onsubmit' => self::VALIDATE_FORM . "('defSettingForm" . $setting->id . "')"));
             $form->setAction($this->view->url(array('controller' => 'mailsettings', 'action' => 'mkdefault'), null, true));
             $form->getElement('submit')->setAttribs(array('class' => 'btn btn-primary'));
             $form->getElement('submit')->setLabel('Make Default');
             $form->getElement('id')->setValue($setting->id);
         }
         $forms['defSettingForm'][] = $form;
     }
     //initialize forms
     foreach ($this->view->users as $user) {
         $form = new Application_Form_SubmitButton();
         if ($user->id == $currentUser->id || $user->getAdminId() == 1) {
             // is current user or is superuser
             $form->getElement('submit')->setAttribs(array('class' => 'btn btn-danger disabled'));
             $form->getElement('submit')->setLabel('Delete');
         } else {
             $form->setAction($this->view->url(array('controller' => 'users', 'action' => 'delete'), null, true));
             $form->addAttribs(array('id' => 'delUserForm' . $user->id, 'onsubmit' => self::VALIDATE_FORM . "('delUserForm" . $user->id . "')"));
             $form->getElement('id')->setValue($user->id);
             $form->getElement('submit')->setAttribs(array('class' => 'btn btn-danger'));
             $form->getElement('submit')->setLabel('Delete');
         }
         $forms['delUserForm'][] = $form;
         $form = new Application_Form_SubmitButton();
         if ($user->id == $currentUser->id || $user->getAdminId() == 1 || !$user->verified) {
             $form->getElement('submit')->setAttribs(array('class' => 'btn btn-primary disabled'));
             $form->getElement('submit')->setLabel('Make Admin');
         } else {
             if ($user->getAdminId()) {
                 $form->addAttribs(array('id' => 'umkUserForm' . $user->id, 'onsubmit' => self::VALIDATE_FORM . "('umkUserForm" . $user->id . "')"));
                 $form->setAction($this->view->url(array('controller' => 'users', 'action' => 'umkadmin'), null, true));
                 $form->getElement('submit')->setAttribs(array('class' => 'btn btn-primary'));
                 $form->getElement('submit')->setLabel('Unmake Admin');
             } else {
                 $form->addAttribs(array('id' => 'mkUserForm' . $user->id, 'onsubmit' => self::VALIDATE_FORM . "('mkUserForm" . $user->id . "')"));
                 $form->setAction($this->view->url(array('controller' => 'users', 'action' => 'mkadmin'), null, true));
                 $form->getElement('submit')->setAttribs(array('class' => 'btn btn-primary'));
                 $form->getElement('submit')->setLabel('Make Admin');
             }
             $form->getElement('id')->setValue($user->id);
         }
         $forms['mkUserForm'][] = $form;
     }
     // initialize forms
     foreach ($this->view->products as $i => $product) {
         $delForm = new Application_Form_DeleteProduct();
         $delForm->setAction($this->view->url(array('controller' => 'products', 'action' => 'delete'), null, true));
         $delForm->addAttribs(array('id' => 'delForm' . $product->id, 'onsubmit' => self::VALIDATE_FORM . "('delForm" . $product->id . "')"));
         $delForm->getElement('product_id')->setValue($product->id);
         $forms['delProductForm'][] = $delForm;
     }
     $this->view->forms = $forms;
 }