public function updatePromotion(Application_Model_Promotions $offer)
 {
     $data = array("offer_name" => $offer->__get("offer_name"), "offer_clothes" => $offer->__get("offer_clothes"), "offer_service_type" => $offer->__get("offer_service_type"), "no_of_clothes" => $offer->__get("no_of_clothes"), "no_of_pickups" => $offer->__get("no_of_pickups"), "offer_amount" => $offer->__get("offer_amount"), "offer_status" => $offer->__get("offer_status"));
     $where = array("offer_id = ?" => $offer->__get("offer_id"));
     try {
         $updated_records = $this->_db_table->update($data, $where);
         return (object) array("success" => true, "error" => false, "message" => "Record Successfully Updated", "row_affected" => $updated_records);
     } catch (Zend_Exception $e) {
         /* Handle Exception Here  */
         return (object) array("success" => false, "error" => true, "message" => $e->getMessage(), "exception" => true, "exception_code" => $e->getCode());
     }
 }
 public function addAction()
 {
     $this->view->pageHeading = "Add promotion";
     $this->view->buttonTitle = "Add promotion";
     try {
         //$admins = new Application_Model_Admins;
         $promotionsMapper = new Application_Model_PromotionsMapper();
         $promotion = new Application_Model_Promotions();
         $request = $this->getRequest();
         $form = new Application_Form_PromotionForm();
         $this->view->form = $form;
         $elements = $form->getElements();
         if ($request->isPost()) {
             $request_type = $request->getParam("request_type", false);
             $params = $this->getRequest()->getPost();
             if ($form->isValid($params)) {
                 foreach ($params as $param => $value) {
                     $promotion->__set($param, $value);
                 }
                 $isInserted = $promotionsMapper->addNewPromotion($promotion);
                 if (is_object($isInserted) && $isInserted->success) {
                     $this->view->message = "Promotion added successfully";
                     $this->view->hasMessage = true;
                     $this->view->messageType = "success";
                 } else {
                     $this->view->message = "Error occured while updating. Please try again";
                     $this->view->hasMessage = true;
                     $this->view->messageType = "danger";
                 }
             } else {
                 $this->view->message = "Error occured while adding package. Please fill form correctly";
                 $this->view->hasMessage = true;
                 $this->view->messageType = "danger";
             }
         }
         $this->authorised = true;
     } catch (Exception $ex) {
         $this->authorised = false;
         $this->view->hasMessage = true;
         $this->view->messageType = "danger";
         $this->view->message = $ex->getMessage();
     }
 }