public function AddSubscribedRestaurant(array $data) { try { $form = $this->getAddSubscribedRestaurantForm(); $stateid = null; $regionid = null; $cityid = null; $cityBd = array(); $regionBd = array(); $ngbhBd = array(); $restService = new Application_Service_Firm(); if ($data['cantfind'] == 1) { $form->cantfindneigh->setRequired(true); $form->resNeighbour->setRequired(false); if ($data['resState']) { $stateid = $data['resState']; $regionBd = $restService->GetRegionByStateId_($stateid); $regionBd[] = array('key' => 'find', 'value' => "Can't Find Your Region"); } if ($data['resRegion']) { $regionid = $data['resRegion']; $cityBd = $restService->GetCityByRegionId_($regionid); $cityBd[] = array('key' => 'find', 'value' => "Can't Find Your City"); } if ($data['resCity']) { $cityid = $data['resCity']; $ngbhBd = $restService->GetNeighborhodByCityId_($cityid); $ngbhBd[] = array('key' => 'find', 'value' => "Can't Find Your Neighbourhood"); } } else { if ($data['cantfind'] == 2) { $form->cantfindcity->setRequired(true); $form->resCity->setRequired(false); $form->cantfindneigh->setRequired(true); $form->resNeighbour->setRequired(false); if ($data['resState']) { $stateid = $data['resState']; $regionBd = $restService->GetRegionByStateId_($stateid); $regionBd[] = array('key' => 'find', 'value' => "Can't Find Your Region"); } if ($data['resRegion']) { $regionid = $data['resRegion']; $cityBd = $restService->GetCityByRegionId_($regionid); $cityBd[] = array('key' => 'find', 'value' => "Can't Find Your City"); } } else { if ($data['cantfind'] == 3) { $form->cantfindregion->setRequired(true); $form->resRegion->setRequired(false); $form->cantfindcity->setRequired(true); $form->resCity->setRequired(false); $form->cantfindneigh->setRequired(true); $form->resNeighbour->setRequired(false); if ($data['resState']) { $stateid = $data['resState']; $regionBd = $restService->GetRegionByStateId_($stateid); $regionBd[] = array('key' => 'find', 'value' => "Can't Find Your Region"); } $cityBd[] = array('key' => 'noCity', 'value' => "Can't Find Your City"); } else { if ($data['cantfind'] == 4) { $form->cantfindstate->setRequired(true); $form->resState->setRequired(false); $form->cantfindregion->setRequired(true); $form->resRegion->setRequired(false); $form->cantfindcity->setRequired(true); $form->resCity->setRequired(false); $form->cantfindneigh->setRequired(true); $form->resNeighbour->setRequired(false); $cityBd[] = array('key' => 'find', 'value' => "Can't Find Your City"); $regionBd[] = array('key' => 'find', 'value' => "Can't Find Your Region"); } else { if ($data['cantfind'] == 0 || $data['cantfind'] == '') { if ($data['resState']) { $stateid = $data['resState']; $regionBd = $restService->GetRegionByStateId_($stateid); $regionBd[] = array('key' => 'find', 'value' => "Can't Find Your Region"); } if ($data['resRegion']) { $regionid = $data['resRegion']; $cityBd = $restService->GetCityByRegionId_($regionid); $cityBd[] = array('key' => 'find', 'value' => "Can't Find Your City"); } } } } } } if ($form->isValid($data)) { $imageadapter = $form->resImage->getTransferAdapter(); $logoadapter = $form->resLogo->getTransferAdapter(); $restname = trim($data['restName']); $paths = $restService->UploadImages($imageadapter, $logoadapter, $restname); // $imagepath = null; // $logopath = null; // if($paths){ // $imagepath = $paths['imagepath']; // $logopath = $paths['logopath']; // } $storage = new Zend_Auth_Storage_Session(); $data = $storage->read(); $formData = $form->getValues(); $restaurant = new FirmManagement_Model_Firm(); $cuisineTypes = $formData['restype']; //$resCusisneType = array(); //foreach($cuisineTypes as $types){ $cusisneTypeObj = new FirmManagement_Model_FirmCuisine(); $cusisneTypeObj->setRestaurantTypeId($cuisineTypes); //$resCusisneType[] = $cusisneTypeObj; //} /*$reservSys = 'FALSE'; if($formData['restSubResSys'] == 1) { $reservSys = 'TRUE'; }*/ $restaddress = $formData['resAddress']; $paymentModes = $formData['resPayment']; $resPaymentMode = array(); foreach ($paymentModes as $types) { $paymentModeObj = new FirmManagement_Model_FirmPaymentOptions(); $paymentModeObj->setRestaurantPaymentTypeId($types); $resPaymentMode[] = $paymentModeObj; } $tagid = array(); $tagidString = ""; $tagidString = $formData['tagId']; if ($tagidString) { $tagid = explode(',', $tagidString); } /* Listed Restaurant $resByIdObj = new FirmManagement_Model_FirmById(); $resByIdObj->setRestaurantId($formData['restId']); $restaurantMapper = new FirmManagement_Model_FirmDataMapper(); $resDetails = $restaurantMapper->getRestaurantById($resByIdObj); $listedMapper = new FirmManagement_Model_ListedRestaurantsDataMapper(); $listedRes = $listedMapper->addRestaurant($resDetails); */ // $paymentModel = new Application_Model_RestaurantPaymentMode(); // $paymentMapper = new Application_Model_RestaurantPaymentModeDataMapper(); // $paymentModel->setId($formData['resPayment']); // $paymentObj = $paymentMapper->getPaymentModeById($paymentModel); if ($formData['restId']) { $restaurant->setRestListedResId($formData['restId']); } $latlong = ''; if ((int) $formData['cantfind'] < 2) { /* Reterving City By Id */ $cityModel = new Application_Model_City(); $cityMapper = new Application_Model_CityDataMapper(); $cityModel->setId($formData['resCity']); $cityObj = $cityMapper->getCityById($cityModel); $restaddress .= ", " . $cityObj->getDescription(); $latlong = Rdine_Geocode_GeocodingAdapter::getGeocodedLatitudeAndLongitude($restaddress); } if (!$formData['restLatitude'] == NULL && !$formData['restLongitude'] == NULL) { $googlemapstatus = 'TRUE'; } else { $googlemapstatus = 'FALSE'; } if ($googlemapstatus == 'TRUE') { $latitude = $formData['restLatitude']; $longitude = $formData['restLongitude']; } else { $latitude = NULL; $longitude = NULL; } $resgoogleimage = Rdine_Geocode_GeocodingAdapter::getGoogleRestaurantImage($latitude, $longitude); $categoryModel = new Application_Model_RestaurantCategory(); $categoryMapper = new Application_Model_RestaurantCategoryDataMapper(); $categoryModel->setCode('SUB'); $categoryObj = $categoryMapper->getIdByCode($categoryModel); if ($data['Usertype'] == "ADM" || $data['Usertype'] == "ADU") { $restaurant->setRestaurantownerid($formData['restowner'])->setcompanyid($data['companyid']); } else { $restaurant->setRestaurantownerid($formData['restowner'])->setcompanyid(1); } $restaurant->setRestaurantname($formData['restName'])->setRescapacity($formData['rescapacity'])->setRestemail($formData['emailAddress'])->setMaxpax($formData['maxpax'])->setRestaddress($formData['resAddress'])->setReststateid($formData['resState'])->setRestRegion($formData['resRegion'])->setRestCity($formData['resCity'])->setCantFindState($formData['cantfindstate'])->setCantFindRegion($formData['cantfindregion'])->setCantFindCity($formData['cantfindcity'])->setCantFindNeighbour($formData['cantfindneigh'])->setCantFind($formData['cantfind'])->setRestPaymentMode($resPaymentMode)->setResttypeid($cusisneTypeObj)->setResttimezone($formData['restimezone'])->setRestPrice($formData['resprice'])->setRestneighboorhood($formData['resNeighbour'])->setRestzipcode($formData['postalCode'])->setres_country_code($formData['countryCode'])->setRestphone($formData['resPhone'])->setRestfax($formData['resFax'])->setRestwebsite($formData['resWebsite'])->setRestmanagername($formData['resManager'])->setRestdesc($formData['resDescription'])->setRestDiningStyle($formData['restDiningStyle'])->setRestParking($formData['restParking'])->setRestParkDetails($formData['restParkDetails'])->setRestPrivParty($formData['restPrivParty'])->setRestPrivPartyContact($formData['restPrivPartyContact'])->setRestAdditDet($formData['restAdditDetails'])->setRestEntertainment($formData['restEntertainment'])->setRestsubforreservation('TRUE')->setReststatus(1)->setRestverifiedstatus(3)->setRestCreatedOn(date('Y-m-d H:i:s'))->setRestLatitude($latitude)->setRestLongtitude($longitude)->setRestGoogleMapStatus($googlemapstatus)->setRestGoogleImage($resgoogleimage)->setRestTimings($formData['restTimings'])->setRestCategory($categoryObj->getId())->setResCreatedDate(date('Y-m-d H:i:s'))->setRestCreatedBy($data['User_Id'])->setreslandmark($formData['restLandMark'])->setres_delevery($formData['restDelevery'])->setreslunch_buffet($formData['restLunchBuffet'])->setresdinner_buffet($formData['restDinnerBuffet'])->setres_wifi($formData['restWifi'])->setres_alcohol($formData['restAlcohol'])->setres_smoking($formData['restSmoke'])->setres_ac($formData['restAC'])->setres_catering($formData['restCatering'])->setres_kids_section($formData['restKidsSection'])->setres_party_allowed($formData['restPrivParty'])->setres_meal_category($formData['restMealType'])->setres_new_tag($formData['restnewtag'])->settag_id($tagid); if ($formData['restAvgMealPriceMax'] == '') { $restaurant->setresavg_mealprice_max(0); } else { $restaurant->setresavg_mealprice_max($formData['restAvgMealPriceMax']); } if ($formData['restAvgMealPriceMin'] == '') { $restaurant->setresavg_mealprice_min(0); } else { $restaurant->setresavg_mealprice_min($formData['restAvgMealPriceMin']); } $mapper = new FirmManagement_Model_FirmDataMapper(); $status = $mapper->addRestaurant($restaurant); $restid = $status['resid']; $ownerid = $restaurant->getRestaurantaownerid(); $mapper = new User_Model_ManagerDataMapper(); $status = $mapper->addPresid($restid, $ownerid); $storage = new Zend_Auth_Storage_Session(); $userdata = $storage->read(); $userdata['RestId'] = $restid; if ($userdata['Usertype'] == 'RSO') { $restNameByOwnObj = new FirmManagement_Model_FirmNamesByOwnerId(); $restNameByOwnObj->setRestOwnerId($userdata['User_Id']); $restMapper = new FirmManagement_Model_FirmDataMapper(); $restList = $restMapper->getRestaurantNamesByOwnerId($restNameByOwnObj); $userdata['restList'] = $restList; } else { $restNameByOwnObj = new FirmManagement_Model_FirmNamesByOwnerId(); $restNameByOwnObj->setRestId($restid); $restMapper = new FirmManagement_Model_FirmDataMapper(); $restList = $restMapper->getRestaurantNamesByOwnerId($restNameByOwnObj); $userdata['restList'] = $restList; } $storage->write($userdata); $folderRename = rename("images/restaurant_images/{$restname}/", "images/restaurant_images/{$restid}/"); $imagepath = null; $logopath = null; if ($paths) { $imagepath = $paths['imagepath']; $logopath = $paths['logopath']; $imagelogoRename = '/' . $restname . '/'; $restid = $restid; $imageRename = str_replace($imagelogoRename, '/' . $restid . '/', $imagepath); $logoRename = str_replace($imagelogoRename, '/' . $restid . '/', $logopath); $mapper1 = new FirmManagement_Model_FirmDataMapper(); $result = $mapper1->Updateimglogo($restid, $imageRename, $logoRename); } return $result; } else { $formData = $form->getValues(); $form->populate($data); if ($regionBd) { $form->resRegion->addMultiOptions($regionBd); } if ($cityBd) { $form->resCity->addMultiOptions($cityBd); } if ($ngbhBd) { $form->resNeighbour->addMultiOptions($ngbhBd); } return false; } } catch (Exception $ex) { Rdine_Logger_FileLogger::info($ex->getMessage()); throw new Exception($ex->getMessage()); } }
private function setModel($row) { $model = new Application_Model_City(); $model->setId($row->id)->setName($row->name)->setRegionId($row->region_id)->setCountryId($row->country_id)->setContinentId($row->continent_id)->setFeaturedTop($row->featured_top)->setFeaturedOther($row->featured_other)->setLatitude($row->latitude)->setLongitude($row->longitude)->setAddress($row->address); return $model; }