public function uploadcouponAction()
 {
     if ($this->_request->isPost()) {
         $_FILES['userfile']['name'] = $_POST['id'] . '_' . date('YmdHis', time()) . str_ireplace(array(' ', '_', '-'), '', strtolower($_FILES['userfile']['name']));
         $fileHandler = new FM_Components_Util_UploadHandler($_FILES['userfile']);
         $folder = $fileHandler->setFolder('coupons');
         if ($fileHandler->move()) {
             FM_Components_Coupon::updateCoupon(array('id' => $_POST['id']), array('file' => $_FILES['userfile']['name']));
             print $_FILES['userfile']['name'];
         } else {
             print '0';
         }
     } else {
         print '0';
     }
     exit;
 }
 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 getProfile()
 {
     $coupons = FM_Components_Coupon::getOrgCoupons($this->_orgId, true, true);
     return $coupons;
 }
 public function ajaxdeletecouponAction()
 {
     if ($_POST && array_key_exists('id', $_POST) && $_POST['id'] != '') {
         if (FM_Components_Coupon::deleteCoupon(array('id' => $_POST['id']))) {
             print $_POST['id'];
         } else {
             print '0';
         }
     } else {
         print '0';
     }
     exit;
 }
 function indexAction()
 {
     $this->_helper->layout->setLayout('layout2col');
     $this->view->layout()->cols = 2;
     if ($this->_request->getParam('id') == 0 || !($this->_business = new FM_Components_Sports(array('id' => $this->_request->getParam('id'))))) {
         $this->_redirect('/');
     }
     //print_r($this->_business);exit;
     if (!$this->_business->getId()) {
         $this->_redirect('/');
     }
     if ($this->_business->getType() == 2) {
         $this->_redirect('/merchant/' . $this->_request->getParam('id'));
     }
     if ($this->_business->getType() == 3) {
         $this->_redirect('/org/' . $this->_request->getParam('id'));
     }
     if (!$this->_user && !$this->_business->getActive()) {
         $this->_redirect('/');
     }
     if (!$this->_business->getActive() && !($this->_user->isRoot() || $this->_user->frontEndAdmin())) {
         $this->_redirect('/');
     }
     $this->view->orgId = $this->_request->getParam('id');
     $myNamespace = new Zend_Session_Namespace('sportsuser');
     $sportsuser = false;
     if (isset($myNamespace->auth) && $myNamespace->auth == true) {
         //print_r(unserialize($myNamespace->auth));exit;
         $sportsuser = unserialize($myNamespace->auth);
         $this->view->sportsuser = unserialize($myNamespace->auth);
     }
     $orgConfig = $this->_business->getOrgConfig();
     $common = $orgConfig->getTabs();
     $siteAdmin = false;
     if ($this->_user && ($this->_user->inOrg($this->_request->getParam('id')) || $this->_user->isRoot())) {
         //user is admin for this group, show edit
         $siteAdmin = $this->_user;
     }
     $banners = FM_Components_Banner::getSortedRandomBanners();
     $this->view->layout()->banners = $this->view->partial('banner/bannerleftindex.phtml', array('banners' => $banners));
     $this->view->layout()->leftcol = $this->view->partial('b2b/leftcol.phtml', array('orgdata' => $this->view->partial('widgets/profile/synop.phtml', array('org' => $this->_business)), 'banners' => $banners));
     $tg = new FM_Components_Tabs_TabGroup();
     if ($sportsuser || !$this->_business->isProtected() || $siteAdmin) {
         $tab = new FM_Components_Tabs_Profile();
         $tab->setProfile($this->_business->get('description'));
         $tg->addTab($tab, 'profile', 'profile', true);
         $gallery = new FM_Components_Widgets_PhotoGallery($this->view, $this->_request->getParam('id'), 'photogallery', $siteAdmin);
         $media = new FM_Components_Tabs_Media($this->_request->getParam('id'), true);
         $media->setProfile('This is the profile tab');
         $tg->addTab($media, 'media', 'media', false);
         $calendarTab = new FM_Components_Tabs_Calendar($this->_request->getParam('id'));
         $tg->addTab($calendarTab, 'events', 'calendar', false);
         if ($common['forum']) {
             $forum = new FM_Components_Tabs_Forum($this->_request->getParam('id'), $siteAdmin, $sportsuser);
             $tg->addTab($forum, 'forum', 'forum', false);
         }
         if ($common['directions']) {
             $dir = new FM_Components_Tabs_Directions($this->_business);
             $dir->setProfile('these are directions');
             $tg->addTab($dir, 'directions', 'directions', false);
         }
         $spsch = new FM_Components_Tabs_SportsSchedule($this->_business);
         $tg->addTab($spsch, 'schedule', 'schedule', false);
         if ($common['contact']) {
             $dir = new FM_Components_Tabs_Contact($this->_request->getParam('id'));
             $dir->setProfile('these are directions');
             $tg->addTab($dir, 'contact us', 'contact', false);
         }
         $this->view->video = false;
         $this->view->photo = false;
         if ($common['media']) {
             $this->view->layout()->photo = true;
             $gallery = new FM_Components_Widgets_PhotoGallery($this->view, $this->_request->getParam('id'), 'photogallery', $siteAdmin);
         }
         if ($common['video']) {
             $this->view->layout()->video = true;
             $videoGallery = new FM_Components_Widgets_VideoGallery($this->view, $this->_request->getParam('id'), 'videogallery', $siteAdmin);
         }
     }
     if (!$sportsuser) {
         $signIn = new FM_Components_Tabs_SportsSignIn($this->_request->getParam('id'), $this->_business->isProtected() && !$this->_user);
         $tg->addTab($signIn, 'signin', 'signin', $this->_business->isProtected() && !$this->_user);
     }
     if ($siteAdmin) {
         $adminTab = new FM_Components_Tabs_Admin();
         $admin = new FM_Components_Widgets_Admin($this->view, $this->_business->getOrgConfig(), $this->_business);
         $adminTab->setProfile($admin->toHTML());
         $tg->addTab($adminTab, 'admin', 'admin');
     }
     $this->view->layout()->profiletab = $tg->toHTML();
     $this->view->crumb = 'home >> sports >> ' . $this->_business->getName();
     $this->view->content = new FM_Forms_Login();
     $this->view->layout()->logo = $this->_business->getLogoObj()->getFileName();
     $this->view->layout()->miniwebBanner = $mw = $this->_business->getMiniWebBannerObj()->getFileName();
     $this->view->coupons = $coupons = FM_Components_Coupon::getOrgCoupons($this->_request->getParam('id'));
     $this->view->pageId = 'sports';
 }
 public function indexAction()
 {
     $this->_helper->layout->setLayout('layout2col');
     $this->view->layout()->cols = 2;
     if ($this->_request->getParam('id') == 0 || !($this->_business = new FM_Components_Business(array('id' => $this->_request->getParam('id'))))) {
         $this->_redirect('/');
     }
     if (!$this->_business->getId()) {
         $this->_redirect('/');
     }
     if ($this->_business->getType() == 4) {
         $this->_redirect('/sports/' . $this->_request->getParam('id'));
     }
     if ($this->_business->getType() == 3) {
         $this->_redirect('/org/' . $this->_request->getParam('id'));
     }
     if (!$this->_business->getCategory()) {
         //$this->_redirect ( '/' );
     }
     //print_r($this->_business);exit;
     $this->view->orgId = $this->_request->getParam('id');
     $orgConfig = $this->_business->getOrgConfig();
     $common = $orgConfig->getTabs();
     $siteAdmin = false;
     //print_r($this->_user->getOrgId());exit;
     if ($this->_user && ($this->_user->inOrg($this->_request->getParam('id')) || $this->_user->isRoot() || $this->_user->frontEndAdmin() && !stristr($_SERVER['REQUEST_URI'], 'root'))) {
         //user is admin for this group, show edit
         $siteAdmin = true;
     }
     if (!$this->_user && !$this->_business->getActive()) {
         $this->_redirect('/');
     }
     if (!$this->_business->getActive() && !($this->_user->isRoot() || $this->_user->frontEndAdmin())) {
         $this->_redirect('/');
     }
     //print_r($this->_business->getCategories()); exit;
     $banners = FM_Components_Banner::getSortedRandomBanners($this->_business->getCategories());
     //exit;
     $this->view->layout()->banners = $this->view->partial('banner/bannerleftindex.phtml', array('banners' => $banners));
     $gallery = new FM_Components_Widgets_PhotoGallery($this->view, $this->_request->getParam('id'), 'photogallery', $siteAdmin);
     $this->view->layout()->leftcol = $this->view->partial('b2b/leftcol.phtml', array('orgdata' => $this->view->partial('widgets/profile/synop.phtml', array('org' => $this->_business)), 'banners' => $banners));
     $tg = new FM_Components_Tabs_TabGroup();
     $tab = new FM_Components_Tabs_Profile();
     $tab->setProfile($this->_business->get('description'));
     $tg->addTab($tab, 'profile', 'profile', true);
     if ($common['menu']) {
         $menu = new FM_Components_Tabs_Menu($this->_request->getParam('id'), $siteAdmin);
         $tg->addTab($menu, 'menu', 'mmenu', false);
     }
     if ($common['services']) {
         $services = new FM_Components_Tabs_Services($this->_request->getParam('id'));
         $tg->addTab($services, 'services', 'mservices', false);
     }
     if ($common['products']) {
         $pl = new FM_Components_Tabs_ProductList($this->_request->getParam('id'), $siteAdmin);
         $tg->addTab($pl, 'products', 'products', false);
     }
     if ($common['realestate']) {
         $rel = new FM_Components_Tabs_RealEstateList($this->_request->getParam('id'), $siteAdmin);
         $tg->addTab($rel, 'r/e listings', 'realestate', false);
     }
     if ($common['coupons']) {
         $coupons = new FM_Components_Tabs_Coupons($this->_request->getParam('id'));
         $tg->addTab($coupons, 'coupons', 'coupons', false);
         if ($this->_user) {
             $b2bcoupons = new FM_Components_Tabs_B2BCoupons($this->_request->getParam('id'));
             $tg->addTab($b2bcoupons, 'b2bcoupons', 'b2bcoupons', false);
         }
     }
     if ($common['media']) {
         $media = new FM_Components_Tabs_Media($this->_request->getParam('id'));
         $media->setProfile('This is the profile tab');
         $tg->addTab($media, 'media', 'media', false);
     }
     if ($common['events']) {
         // CALENDAR TAB!!!!
         $calendarTab = new FM_Components_Tabs_Calendar($this->_request->getParam('id'));
         $tg->addTab($calendarTab, 'events', 'calendar', false);
     }
     if ($common['reviews']) {
         $dir = new FM_Components_Tabs_Testimonials($this->_request->getParam('id'));
         $dir->setProfile('these are directions');
         $tg->addTab($dir, 'reviews', 'testimonials', false);
     }
     /**
     		if($common['forum']) {
     			$forum = new FM_Components_Tabs_Forum($this->_request->getParam ( 'id' ), $siteAdmin);
     			$tg->addTab($forum, 'forum', 'forum', false);
     		}
     		**/
     if ($common['directions']) {
         $dir = new FM_Components_Tabs_Directions($this->_business);
         $dir->setProfile('these are directions');
         $tg->addTab($dir, 'directions', 'directions', false);
     }
     if ($common['contact']) {
         $dir = new FM_Components_Tabs_Contact($this->_request->getParam('id'));
         $dir->setProfile('these are directions');
         $tg->addTab($dir, 'contact us', 'contact', false);
     }
     $this->view->video = false;
     $this->view->photo = false;
     if ($common['media']) {
         $this->view->layout()->photo = true;
         $gallery = new FM_Components_Widgets_PhotoGallery($this->view, $this->_request->getParam('id'), 'photogallery', $siteAdmin);
     }
     if ($common['video']) {
         $this->view->layout()->video = true;
         $videoGallery = new FM_Components_Widgets_VideoGallery($this->view, $this->_request->getParam('id'), 'videogallery', $siteAdmin);
     }
     if ($siteAdmin) {
         $adminTab = new FM_Components_Tabs_Admin();
         $admin = new FM_Components_Widgets_Admin($this->view, $this->_business->getOrgConfig(), $this->_business);
         $adminTab->setProfile($admin->toHTML());
         $tg->addTab($adminTab, 'admin', 'admin');
     }
     $this->view->layout()->profiletab = $tg->toHTML();
     $this->view->layout()->logo = $this->_business->getLogoObj()->getFileName();
     $this->view->layout()->miniwebBanner = $mw = $this->_business->getMiniWebBannerObj()->getFileName();
     $this->view->crumb = 'home >> business >> ' . $this->_business->getName();
     $this->view->content = new FM_Forms_Login();
     $this->view->coupons = $coupons = FM_Components_Coupon::getOrgCoupons($this->_request->getParam('id'));
     $this->view->pageId = 'b2b';
 }
 public function printcouponsAction()
 {
     $this->_helper->layout->setLayout('cssonly');
     if ($_GET['coupons']) {
         $coupons = explode('_', $_GET['coupons']);
         $c = FM_Components_Coupon::getSelectedCoupons($coupons);
         $this->view->coupons = $c;
     }
 }