public function findallAction() { if ($value_id = $this->getRequest()->getParam('value_id')) { $option = $this->getCurrentOptionValue(); $promotion_customer = new Promotion_Model_Customer(); $promotion_customers = $promotion_customer->findAllByValue($option->getId(), $this->getSession()->getCustomerId() | 0); $data = array("promotions" => array()); if ($promotion_customers->count() == 0) { $data['promotions'] = array(); } foreach ($promotion_customers as $promotion_customer) { switch ($option->getLayoutId()) { case 2: case 3: case 4: $data['promotions'][] = array("id" => $promotion_customer->getPromotionId(), "picture" => $promotion_customer->getPictureUrl(), "title" => $promotion_customer->getTitle(), "subtitle" => $promotion_customer->getDescription(), "url" => $this->getPath("promotion/mobile_view", array("value_id" => $value_id, "promotion_id" => $promotion_customer->getPromotionId()))); break; case 1: default: $data['promotions'][] = array("id" => $promotion_customer->getPromotionId(), "picture" => $promotion_customer->getPictureUrl(), "title" => $promotion_customer->getTitle(), "description" => $promotion_customer->getDescription(), "conditions" => $promotion_customer->getConditions(), "is_unique" => $promotion_customer->getIsUnique(), "end_at" => $promotion_customer->getFormattedEndAt($this->_('MMMM dd y')), "unlock_code" => $promotion_customer->getUnlockCode(), "is_used" => $promotion_customer->getIsUsed()); break; } } $data["social_sharing_is_active"] = $option->getSocialSharingIsActive(); $data['page_title'] = $option->getTabbarName(); $tc = new Application_Model_Tc(); $tc->findByType($this->getApplication()->getId(), "discount"); $text = $tc->getText(); $data["tc_id"] = !empty($text) ? $tc->getId() : null; $this->_sendHtml($data); } }
public function findAction() { if ($value_id = $this->getRequest()->getParam('value_id') and $promotion_id = $this->getRequest()->getParam('promotion_id')) { $option = $this->getCurrentOptionValue(); $promotion = new Promotion_Model_Promotion(); $promotion->find($promotion_id); $data["promotion"] = array("id" => $promotion->getPromotionId(), "picture" => $promotion->getPictureUrl(), "title" => $promotion->getTitle(), "description" => $promotion->getDescription(), "conditions" => $promotion->getConditions(), "is_unique" => (bool) $promotion->getIsUnique(), "end_at" => $promotion->getFormattedEndAt($this->_('MMMM dd y'))); $data["confirm_message"] = $this->_("Do you want to use this coupon?"); $data["social_sharing_is_active"] = $option->getSocialSharingIsActive(); $data["page_title"] = $promotion->getTitle(); $tc = new Application_Model_Tc(); $tc->findByType($this->getApplication()->getId(), "discount"); $text = $tc->getText(); $data["tc_id"] = !empty($text) ? $tc->getId() : null; $this->_sendHtml($data); } }
public function findallAction() { if ($this->getRequest()->getParam('value_id')) { $data = array(); $fcc = new LoyaltyCard_Model_Customer(); $customer_id = $this->getSession()->getCustomerId() | 0; $cards = $fcc->findAllByOptionValue($this->getCurrentOptionValue()->getId(), $customer_id); $current_card = new LoyaltyCard_Model_Customer(); $promotions = array(); $cardIsLocked = false; foreach ($cards as $card) { if ($card->getIsLocked()) { $cardIsLocked = true; } elseif ($card->getNumberOfPoints() == $card->getMaxNumberOfPoints()) { $promotions[] = $card; } elseif ($card->getNumberOfPoints() < $card->getMaxNumberOfPoints()) { $current_card = $card; } } $data["promotions"] = array(); foreach ($promotions as $promotion) { $data["promotions"][] = array("id" => $promotion->getId(), "advantage" => $promotion->getAdvantage()); } $data["card"] = array(); if ($current_card->getCardId()) { $data["card"] = array("id" => $current_card->getId(), "is_visible" => (bool) $current_card->getCardId(), "advantage" => $current_card->getAdvantage(), "conditions" => $current_card->getConditions(), "number_of_points" => $current_card->getNumberOfPoints(), "max_number_of_points" => $current_card->getMaxNumberOfPoints()); $data["points"] = $this->_getPoints($current_card); } $data["picto_urls"] = array("normal_url" => $this->_getImage('pictos/point.png'), "validated_url" => $this->_getColorizedImage($this->_getImage('pictos/point_validated.png', true), $this->getApplication()->getBlock('connect_button')->getBackgroundColor())); $data["page_title"] = $this->getCurrentOptionValue()->getTabbarName(); $data["pad_title"] = $this->_("Enter the password"); // $data["pad_title"] = $this->_("Please show your phone to the store person so that he enters his password"); $data["card_is_locked"] = $cardIsLocked; $tc = new Application_Model_Tc(); $tc->findByType($this->getApplication()->getId(), "loyaltycard"); $text = $tc->getText(); $data["tc_id"] = !empty($text) ? $tc->getId() : null; $this->_sendHtml($data); } }