public function ajaxgetregionAction()
 {
     if ($_POST['id']) {
         if ($town = new FM_Components_Util_Town(array('id' => $_POST['id']))) {
             print $town->getRegion();
             exit;
         } else {
             print '0';
             exit;
         }
     }
 }
Ejemplo n.º 2
0
 public function __construct($options = null, $users = array())
 {
     parent::__construct($options);
     $this->addElementPrefixPath('FM', 'FM/');
     $states = FM_Components_Util_State::getAll();
     $towns = FM_Components_Util_Town::getAll();
     $allRegions = FM_Components_Util_Region::getAll();
     $allUsers = new Zend_Form_Element_Select(array('label' => 'Administrator :', 'name' => 'admin', 'required' => 1));
     $allUsers->addMultiOption(35, ' Carmine (minodef@aol.com)');
     foreach ($users as $user) {
         if ($user->getId() != 35) {
             $allUsers->addMultiOption($user->getId(), $user->getUserName() . ' (' . $user->getEmail() . ')');
         }
     }
     $allUsers->setDecorators(array(array('ViewScript', array('viewScript' => 'form/users.phtml', 'class' => 'form element'))));
     $allUsers->setRegisterInArrayValidator(false);
     $this->addElement($allUsers);
     $this->addElement('text', 'name', array('label' => 'name :', 'name' => 'name', 'required' => 1));
     $this->addElement('text', 'website', array('label' => 'website :', 'name' => 'website', 'required' => 0));
     $this->addElement('text', 'address1', array('label' => 'address 1 :', 'name' => 'address1', 'required' => 0));
     $this->addElement('text', 'address2', array('label' => 'address 2 :', 'name' => 'address2'));
     $this->addElement('text', 'city', array('label' => 'city :', 'name' => 'city', 'required' => 0));
     $state = new Zend_Form_Element_Select(array('label' => 'state :', 'name' => 'state', 'required' => 1));
     foreach ($states as $key => $stateObj) {
         $state->addMultiOption($stateObj->getAbbr(), $stateObj->getState());
     }
     $state->setValue('NJ');
     $this->addElement($state);
     $town = new Zend_Form_Element_Multiselect(array('label' => 'town :', 'name' => 'town', 'required' => 1, 'onchange' => "FM.Utilities.setRegion(this.value)"));
     foreach ($towns as $key => $townObj) {
         $town->addMultiOption($townObj->getId(), $townObj->getName());
     }
     $this->addElement($town);
     $regions = new Zend_Form_Element_Select(array('label' => 'Region :', 'name' => 'region'));
     //foreach($users as $user) {
     //$regions->addMultiOption($user->getId(), $user->getUserName() . ' (' . $user->getEmail() . ')');
     //}
     $regions->setDecorators(array(array('ViewScript', array('viewScript' => 'form/regions.phtml', 'class' => 'form element', 'regions' => $allRegions))));
     $regions->setRegisterInArrayValidator(false);
     $this->addElement($regions);
     $this->addElement('text', 'zip', array('label' => 'zip :', 'name' => 'zip', 'required' => 0));
     $this->addElement('text', 'phone', array('label' => 'phone :', 'name' => 'phone'));
     $this->addElement('text', 'email', array('label' => 'email :', 'name' => 'email', 'required' => 0));
     $maillist = new Zend_Form_Element_Select(array('label' => 'mailing list? :', 'name' => 'maillist'));
     $maillist->addMultiOption('1', ' Yes! ');
     $maillist->addMultiOption('0', ' No ');
     $this->addElement($maillist);
     $limeCard = new Zend_Form_Element_Select(array('label' => 'lime card? :', 'name' => 'limeCard'));
     $limeCard->addMultiOption('0', ' No ');
     $limeCard->addMultiOption('1', ' Yes! ');
     $this->addElement($limeCard);
     $this->addElement('text', 'slug', array('label' => 'direct link : ', 'name' => 'slug', 'onblur' => 'FM.Client.checkSlug(this)'));
     $this->addElement('textarea', 'description', array('label' => 'description :', 'name' => 'description', 'id' => 'descriptionr', 'rows' => 3));
     $this->addDisplayGroup(array('admin', 'slug', 'limeCard'), 'admingroup');
     $this->addDisplayGroup(array('name', 'website', 'address1', 'address2'), 'bizinfo');
     $this->addDisplayGroup(array('city', 'state', 'town', 'region', 'zip'), 'locationinfo');
     $this->addDisplayGroup(array('phone', 'email', 'maillist'), 'contactinfo');
     $admingroup = $this->getDisplayGroup('admingroup');
     $bizinfo = $this->getDisplayGroup('bizinfo');
     $locationinfo = $this->getDisplayGroup('locationinfo');
     $contactinfo = $this->getDisplayGroup('contactinfo');
     $admingroup->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'h4', 'placement' => 'prepend')), 'Fieldset'));
     $bizinfo->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'h4', 'placement' => 'prepend')), 'Fieldset'));
     $contactinfo->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'h4', 'placement' => 'prepend')), 'Fieldset'));
     $locationinfo->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'h4', 'placement' => 'prepend')), 'Fieldset'));
 }
 function orgsAction()
 {
     $this->view->results = null;
     if ($_POST || $_GET && array_key_exists('all', $_GET)) {
         //print_r($_POST);exit;
         $search = FM_Components_Search::getInstance();
         $search->setType(3);
         if ($_POST) {
             foreach ($_POST as $key => $value) {
                 if (stristr($key, 'region')) {
                     $regionId = explode('_', $key);
                     $search->addRegion($regionId[2]);
                     continue;
                 }
                 if (stristr($key, 'all')) {
                     $regionId = explode('_', $key);
                     $all[] = $regionId[2];
                     continue;
                 }
                 if (stristr($key, 'town')) {
                     $townId = explode('_', $key);
                     if ($townId[2] != 0) {
                         $search->addTown($townId[2]);
                     }
                     continue;
                 }
                 if (stristr($key, 'category')) {
                     $categoryId = explode('_', $key);
                     if ($categoryId[2] != 0) {
                         $search->addCategory($categoryId[2]);
                     }
                     continue;
                 }
                 if ($key == 'keyword') {
                     $search->setKeywords(explode(',', $value));
                     continue;
                 }
                 if ($key == 'zip') {
                     $search->setZipcode($value);
                 }
             }
         }
         $results = $search->doNpSearch();
         $objs = array();
         if ($resultsTotal = count($results)) {
             //print_r($results);
             foreach ($results as $index => $values) {
                 switch ($values['type']) {
                     case 3:
                         $obj = $values;
                         $icon = new FM_Components_Util_Icon(array('orgId' => $values['id']));
                         $obj['icon'] = $icon->getFileName();
                         $objs[] = $obj;
                         break;
                     case 4:
                         $obj = $values;
                         $icon = new FM_Components_Util_Icon(array('orgId' => $values['id']));
                         $obj['icon'] = $icon->getFileName();
                         $obj['type'] = 4;
                         $objs[] = $obj;
                         break;
                 }
             }
             $banners = FM_Components_Banner::getSortedRandomBanners();
             $banners = $this->view->partial('banner/bannerleftindex.phtml', array('banners' => $banners));
             $this->view->results = $this->view->partial('search/results.phtml', array('clients' => $objs, 'total' => $resultsTotal, 'banners' => $banners, 'type' => 'org'));
         } else {
             $this->view->noResults = true;
         }
     }
     $this->_helper->layout->setLayout('singlecolumn');
     $this->view->layout()->cols = 1;
     $this->view->cats = $this->view->partial('search/categories.phtml', array('cats' => FM_Components_Util_Category::getSortedSearchCategories(true)));
     $this->view->towns = $this->view->partial('search/towns.phtml', array('towns' => FM_Components_Util_Town::getAll()));
     $this->view->orgsearch = true;
 }