public function searchPropertyAction() { $request = $this->getRequest(); $key = $request->query->get('web_service_key'); if ($key) { $loc = $request->query->get('location'); $price = $request->query->get('price'); $type = $request->query->get('type'); $br = $request->query->get('br'); $dressUp = $request->query->get('dressUp'); $result = array(); if ($type == 'events') { if ($price) { $ePrice = explode('-', $price); $tmpMin = str_replace('k', '000', $ePrice[0]); $min = (int) $tmpMin; if (count($ePrice) > 1) { $tmpMax = str_replace('k', '000', $ePrice[1]); $max = (int) $tmpMax; } } $plcSrch = LeasingEventPlacePeer::getSearchedPlace($loc); foreach ($plcSrch as $p) { if ($price) { if (defined($max)) { if ($min >= $p->getMin() && $max <= $p->getMax()) { array_push($result, $p->getPostId()); } } else { if ($min >= $p->getMin() && $min <= $p->getMax()) { array_push($result, $p->getPostId()); } } } else { array_push($result, $p->getPostId()); } } } else { $locId = null; $typeId = null; $brId = null; $dressUpId = null; if ($loc) { //Location ID $tmpLoc = LeasingLocationPeer::getLocationMatchName($loc); $locId = $tmpLoc->getId(); } if ($type) { //Type ID $tmpType = LeasingUnitTypePeer::getTypeMatchName($type); $typeId = $tmpType->getId(); } if ($br) { //Bedrooms $tmpBr = LeasingUnitNumberBedroomsPeer::getNumberOfBrMatchCode($br); $brId = $tmpBr->getId(); } if ($dressUp) { //Dress Up $tmpDressUp = LeasingUnitDressUpPeer::getDressUpMatchName($dressUp); $dressUpId = $tmpDressUp->getId(); } if ($price) { $ePrice = explode('-', $price); $tmpMin = str_replace('k', '', $ePrice[0]); $min = (int) $tmpMin; if (count($ePrice) > 1) { $tmpMax = str_replace('k', '', $ePrice[1]); $max = (int) $tmpMax; } } /*if ($locId && $typeId && $brId && $dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit($locId, $typeId, $brId, $dressUpId); } elseif ($locId && $typeId && $brId && !$dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit($locId, $typeId, $brId); } elseif ($locId && $typeId && !$brId && $dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit($locId, $typeId, $dressUpId); } elseif ($locId && !$typeId && $brId && $dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit($locId, $brId, $dressUpId); } elseif (!$locId && $typeId && $brId && $dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit($typeId, $brId, $dressUpId); } elseif ($locId && $typeId && !$brId && !$dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit($locId, $typeId); } elseif ($locId && !$typeId && $brId && !$dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit($locId, $brId); } elseif (!$locId && $typeId && $brId && !$dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit(null, $typeId, $brId, null); } elseif ($locId && !$typeId && !$brId && !$dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit($locId); } elseif (!$locId && $typeId && !$brId && !$dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit(null, $typeId, null, null); } elseif (!$locId && !$typeId && $brId && !$dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit(null, null, $brId, null); } elseif (!$locId && !$typeId && !$brId && $dressUpId) { $unitSrch = LeasingUnitPeer::getSearchedUnit(null, null, null, $dressUpId); }*/ $unitSrch = LeasingUnitPeer::getSearchedUnit($locId, $typeId, $brId, $dressUpId); foreach ($unitSrch as $u) { if ($price) { $unitPrice = str_replace('K/mo', '', $u->getPriceRange()); $eUnitPrice = explode('-', $unitPrice); if (count($eUnitPrice) > 1) { if (defined($max)) { if ($min >= $eUnitPrice[0] && $max <= $eUnitPrice[1]) { array_push($result, $u->getPostId()); } } else { if ($min >= $eUnitPrice[0] && $min <= $eUnitPrice[1]) { array_push($result, $u->getPostId()); } } } else { if ($min >= $eUnitPrice[0]) { array_push($result, $u->getPostId()); } } } else { array_push($result, $u->getPostId()); } } } return new JsonResponse($result); } else { throw new AccessDeniedHttpException(); } }