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 ajaxremovetextadAction()
 {
     if (FM_Components_Util_TextAd::deleteTextAd(array('id' => $_POST['id']))) {
         print $_POST['id'];
         exit;
     }
     print '0';
     exit;
 }
 /**
 
 	public static function getRandom($total = 1) {
 		$model = new FM_Models_FM_TextAd();
 		$adr = $model->getRandom(array(), $total);
 		$rs = '<table width="60%" style="margin-top:1em;"><tr>';
 		$i = 0;
 		if(count($adr)) {
 			foreach ($adr as $index=>$ad) {
 				if($i == 3){$rs .= '</tr><tr>';$i = 0;}
 				$text = new FM_Components_Util_TextAd(array('id'=>$ad['id']));
 				$rs .= '<td border="1" padding="3" valign="top" width="33%" >' . $text->getFormattedContent() . '</td>';
 				$i++;
 			}
 		}
 		if($i < 3){
 			while($i < 3) {
 				$rs .= '<td >&nbsp</td>';
 				$i++;
 			}
 			$rs .= '</tr>';
 		}
 		$rs .= '</tr></table>';
 		return $rs;
 	}
 	**/
 public static function getRandom($total = 1)
 {
     $model = new FM_Models_FM_TextAd();
     $adr = $model->getRandom(array(), $total);
     $rs = '<table width="80%" style="margin-top:1em;"><tr><td colspan="4" style="padding:5px;color:white;background:green;font-size:14pt;">Support Our Local Businesses. Thank You.</td><tr>';
     $i = 0;
     if (count($adr)) {
         foreach ($adr as $index => $ad) {
             $text = new FM_Components_Util_TextAd(array('id' => $ad['id']));
             $rs .= '<td border="1" padding="3" valign="top" width="25%" >' . $text->getFormattedContent() . '</td>';
         }
         $rs .= '</tr>';
     }
     $rs .= '</tr></table>';
     return $rs;
 }
 public function ajaxaddeventAction()
 {
     if ($this->_user && ($this->_user->getOrgId() || $this->_user->isRoot())) {
         //user is admin for this group, show edit
         if ($_POST['datetag']) {
             $_POST['starttime'] = $_POST['stimeh'] . ':' . $_POST['stimem'];
             $_POST['endtime'] = $_POST['etimeh'] . ':' . $_POST['etimem'];
             $_POST['id'] = $_POST['ceid'];
             $_POST['frontPage'] = array_key_exists('frontPage', $_POST) ? 1 : 0;
             if ($id = FM_Components_Events::saveNewEvent($_POST)) {
                 $c = new FM_Components_Events(array('eventId' => $id));
                 $rv = $c->toArray();
                 $rv['time'] = $c->getFormattedTime();
                 if (FM_Components_Organization::getOrgType($_POST['orgId']) == 4) {
                     $sport = new FM_Components_Organization(array('id' => $_POST['orgId']));
                     $users = FM_Components_SportsUser::getAll($_POST['orgId']);
                     foreach ($users as $index => $user) {
                         $headers = 'MIME-Version: 1.0' . "\r\n";
                         $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
                         $headers .= 'From: ' . $sport->getName() . ' administrator @ 4Monmouth.com' . "\r\n" . 'Reply-To: nobody@4monmouth.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();
                         $ad = FM_Components_Util_TextAd::getRandom(6);
                         $content = $_POST['content'] . "\n" . $ad;
                         mail($user->getEmail(), 'A New Event Has Been Posted', FM_Components_EmailFormatter::sendSportsEvent($_POST, $c->getFormattedTime(), $sport), $headers);
                     }
                 }
                 $rv['date'] = date('m-d-Y', strtotime($_POST['datetag']));
                 print Zend_Json::encode($rv);
                 exit;
             } else {
                 print '0';
             }
         }
     }
     exit;
 }