public static function regionSearch($searchTerm) { if ($searchTerm == 25) { return FM_Components_Util_LimeCard::statenIslandSearch(); } if ($searchTerm == 26) { return FM_Components_Util_LimeCard::oceanCountySearch(); } $regions = array(); $towns = FM_Components_Util_Region::getTownIdsByRegion($searchTerm); foreach ($towns as $index => $town) { $regions[] = $town['id']; } $model = new FM_Models_FM_LimeCard(); $nonOrg = $model->regionSearch($searchTerm); $orgDataModel = new FM_Models_FM_Orgdata(); $orgs = $orgDataModel->regionSearch($regions); $orgArray = array(); foreach (array_merge($orgs, $nonOrg) as $index => $org) { if (array_key_exists($org['name'], $orgArray)) { $orgArray[$org['name']]['categories'][] = $org['catName']; } else { $orgArray[$org['name']]['record'] = $org; $orgArray[$org['name']]['categories'][] = $org['catName']; } } return $orgArray; }
public function limecardAction() { $this->view->util = true; $this->view->sidenav = $this->view->partial('root/parts/sidenavs/utils.phtml', array('selected' => 'limecard')); $form = new FM_Forms_Root_LimeCard(); if ($this->_getParam('id') != 0 && $this->_getParam('do') == 'delete') { FM_Components_Util_LimeCard::delete(array('id' => $this->_getParam('id'))); $this->_redirect('/root/limecard'); } if ($this->_getParam('id') != 0 && $this->_getParam('do') == 'edit') { $limecard = FM_Components_Util_LimeCard::getRecord(array('id' => $this->_getParam('id'))); //print_r($limecard);exit; foreach ($limecard as $index => $value) { if (is_object($form->getElement($index))) { $form->getElement($index)->setValue($value); } } } if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $uploadedData = $form->getValues(); if ($uploadedData['id'] == 0) { FM_Components_Util_LimeCard::insert($uploadedData); } else { $id = $uploadedData['id']; unset($uploadedData['id']); FM_Components_Util_LimeCard::update(array(id => $id), $uploadedData); } $this->_redirect('/root/limecard'); } } $this->view->form = $form; $this->view->current = $current = FM_Components_Util_LimeCard::getNonMember(); }
public function limecardAction() { $this->view->form = new FM_Forms_LimeCard(); $this->view->regionsForm = new FM_Forms_LimeCardRegion(); $this->view->results = false; if ($this->_getParam('var') === '0') { $this->view->searchTerm = 'ALL'; $orgs = FM_Components_Util_LimeCard::alphaSearch(''); //print_r($orgs); $this->view->selected = '0'; $this->view->results = $final = FM_Components_Util_LimeCard::sort($orgs, 'name'); } elseif ($this->_getParam('do') == 'alph') { $this->view->searchTerm = $this->_getParam('var'); $orgs = FM_Components_Util_LimeCard::alphaSearch($this->_getParam('var')); $this->view->selected = $this->_getParam('var'); $this->view->results = $final = FM_Components_Util_LimeCard::sort($orgs, 'name'); } elseif ($this->_getParam('do') == 'cat') { $orgs = FM_Components_Util_LimeCard::catSearch($this->_getParam('var')); $this->view->results = $final = FM_Components_Util_LimeCard::sort($orgs, 'name'); $this->view->searchTerm = ucwords(strtolower(FM_Components_Util_Category::getCategoryName($this->_getParam('var'), false))); } elseif ($this->_getParam('do') == 'region') { $orgs = FM_Components_Util_LimeCard::regionSearch($this->_getParam('var')); $this->view->results = $final = FM_Components_Util_LimeCard::sort($orgs, 'name'); $region = new FM_Components_Util_Region(array('id' => $this->_getParam('var'))); $this->view->searchTerm = ucwords(strtolower($region->getName())); if ($this->_getParam('var') == 25) { $this->view->searchTerm = 'Staten Island'; } if ($this->_getParam('var') == 26) { $this->view->searchTerm = 'Ocean County'; } } else { if ($_POST['limecardsearch']) { $this->view->searchTerm = $_POST['limecardsearch']; $bzOrgsModel = new FM_Models_FM_SearchPrimaryCategories(); $npOrgsModel = new FM_Models_FM_SearchPrimaryCategoriesOrgs(); $bzResults = $bzOrgsModel->searchByCat($_POST['limecardsearch']); $npResults = $npOrgsModel->searchByCat($_POST['limecardsearch']); $orgIds = array(); foreach (array_merge($bzResults, $npResults) as $key => $value) { $orgIds[] = $value['orgId']; } $orgDataModel = new FM_Models_FM_Orgdata(); $orgs = $orgDataModel->limecardSearch(array_values($orgIds), $_POST['limecardsearch']); $orgDataModel->alphabeticalSearch(); $nonOrgs = FM_Components_Util_LimeCard::search($_POST['limecardsearch']); $this->view->results = $final = FM_Components_Util_LimeCard::sort(array_merge($orgs, $nonOrgs), 'name'); } } }