public static function getMembersByOrgType($orgType = 0)
 {
     $orgs = array();
     switch ($orgType) {
         case 2:
             $orgs = FM_Components_Business::getAll();
             break;
         case 3:
             $orgs = FM_Components_NonProfit::getAll();
             break;
         case 4:
             $orgs = FM_Components_Sports::getAll();
             break;
         default:
             return FM_Components_Member::getAll();
     }
     if (!count($orgs)) {
         return $orgs;
     }
     //no data send empty array
     $ids = array();
     foreach ($orgs as $org) {
         $ids[] = $org->getId();
     }
     $userOrgTable = new FM_Models_FM_UserOrg();
     $users = $userOrgTable->getRecordsByDataSet('oid', $ids, 'uid');
     $allUsers = array();
     if (count($users)) {
         foreach ($users as $user) {
             $allUsers[$user['uid']] = new FM_Components_Member(array('id' => $user['uid']));
         }
         return $allUsers;
     } else {
         return $users;
         //empty data set send empty array
     }
     return false;
     //everything failed
 }
 public function ajaxupdateprofileAction()
 {
     if ($_POST['orgId'] && $_POST['ot']) {
         $result = false;
         switch ($_POST['ot']) {
             case 2:
                 $result = FM_Components_Business::updateBusiness($_POST);
                 break;
             case 3:
                 $result = FM_Components_NonProfit::update($_POST);
                 break;
             case 4:
                 $result = FM_Components_Sports::update($_POST);
                 break;
         }
         print $result ? '1' : '0';
         exit;
     }
 }
 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();
 }