public function __construct($view, $orgConfig, $orgObj)
 {
     //print_r($orgObj);exit;
     $this->_view = $view;
     $this->orgConfig = $orgConfig;
     $this->orgObj = $orgObj;
     $testimonialTable = new FM_Models_FM_Testimonials();
     $this->testimonials = $testimonialTable->getTestimonialsByKeys(array('orgId' => $this->orgConfig->getOrgId()));
     //print_r($this->testimonials);exit;
     $this->couponTemplates = FM_Components_Util_CouponTemplate::getActive();
     $this->coupons = FM_Components_Coupon::getAllOrgCoupons($this->orgConfig->getOrgId());
     $this->bannerTemplates = FM_Components_Util_BannerTemplate::getActive();
     $this->banners = FM_Components_Banner::getOrgBanners($this->orgConfig->getOrgId());
     $this->sportsusers = FM_Components_SportsUser::getAll($this->orgConfig->getOrgId());
     $this->sportsemails = FM_Components_Util_Email::getAll($this->orgConfig->getOrgId());
     $sm = new FM_Models_FM_Services();
     $this->services = $sm->getServiceByKeys(array('orgId' => $this->orgConfig->getOrgId()));
     $mm = new FM_Models_FM_Menu();
     $this->menu = $mm->getMenuByKeys(array('orgId' => $this->orgConfig->getOrgId()));
     $ss = new FM_Models_FM_SportsSchedule();
     $this->schedule = $ss->getScheduleByKeys(array('orgId' => $this->orgConfig->getOrgId()));
     $this->textAds = FM_Components_Util_TextAd::getOrgAds($this->orgConfig->getOrgId());
     $this->icon = FM_Components_Util_Icon::getOrgActive($this->orgConfig->getOrgId());
     $view->headScript()->appendFile('/js/widgets/coupon.js', 'text/javascript');
     //$view->headScript()->appendFile(
     //'/js/widgets/admin.js',
     //'text/javascript'
     //);
     $view->headScript()->appendFile('/js/widgets/banner.js', 'text/javascript');
     //$view->headScript()->appendFile(
     //'/js/swfupload/swfupload.js',
     //'text/javascript'
     //);
     $this->_view->headScript()->appendFile('/js/tiny_mce/tiny_mce.js', 'text/javascript');
     //$view->headScript()->appendFile(
     //'/js/widgets/photogallery.js',
     //'text/javascript'
     //);
 }
 public function managecouponsAction()
 {
     $this->view->coupon = 'managecoupon';
     $this->view->search = new FM_Forms_Register_Search();
     //print_r($_POST);exit;
     $this->view->sidenav = $this->view->partial('root/parts/sidenavs/coupon.phtml', array('selected' => 'managecoupon'));
     if (array_key_exists('search', $_POST)) {
         $coupons = array();
         $orgs = FM_Components_Organization::searchOrgs($_POST['search']);
         foreach ($orgs as $org) {
             $coupons[] = FM_Components_Coupon::getAllOrgCoupons($org['id']);
         }
         foreach ($coupons as $coupon) {
             foreach ($coupon as $c) {
                 $rc[] = $c;
             }
         }
         $this->view->coupons = $rc;
     } else {
         if ($this->_getParam('orgid') == 999999999) {
             $this->view->coupons = $coupons = FM_Components_Coupon::getAllCoupons();
         } else {
             $this->view->coupons = $coupons = FM_Components_Coupon::getAllOrgCoupons($this->_getParam('orgid'));
         }
     }
     $this->view->orglist = FM_Components_Business::getActiveRecords();
 }