public function approveAction($id = null)
 {
     $this->view->disable();
     $businessUpdates = BusinessUpdates::findFirst($id);
     if (!$businessUpdates) {
         return $this->response->redirect('admin/business');
     }
     $businessUpdates->status = 'Approved';
     if ($businessUpdates->update()) {
         $business = Business::findFirst($businessUpdates->business_id);
         if (!empty($businessUpdates->name)) {
             $business->name = $businessUpdates->name;
         }
         if (!empty($businessUpdates->street)) {
             $business->street = $businessUpdates->street;
         }
         if (!empty($businessUpdates->city)) {
             $business->city = $businessUpdates->city;
         }
         if (!empty($businessUpdates->country_id)) {
             $business->country_id = $businessUpdates->country_id;
         }
         if (!empty($businessUpdates->telephone)) {
             $business->telephone = $businessUpdates->telephone;
         }
         if (!empty($businessUpdates->email)) {
             $business->email = $businessUpdates->email;
         }
         if (count($businessUpdates->BusinessCategoryListUpdates)) {
             //BusinessCategoryLists::find('business_id="'.$business->id.'"')->delete();
             foreach ($businessUpdates->BusinessCategoryListUpdates as $key => $businessCategoryListUpdate) {
                 $businessCategoryList = new BusinessCategoryLists();
                 $businessCategoryList->created = date('Y-m-d H:i:s');
                 $businessCategoryList->modified = date('Y-m-d H:i:s');
                 $businessCategoryList->business_id = $business->id;
                 $businessCategoryList->business_category_id = $businessCategoryListUpdate->business_category_id;
                 $businessCategoryList->create();
             }
         }
         $business->update();
     }
     return $this->response->redirect('admin/business/view/' . $business->id);
 }
Beispiel #2
0
 public function update_businessAction($businessId = null)
 {
     $business = Business::findFirst($businessId);
     if (!$business) {
         return $this->response->redirect('biz/business_search');
     }
     if ($this->request->isPost()) {
         $countryId = $this->request->getPost('country_id');
         $country = Countries::findFirst(array('columns' => '*', 'conditions' => 'id LIKE :id:', 'bind' => array('id' => $countryId)));
         $countryName = '';
         if ($country) {
             $countryName = $country->country;
         }
         $address = str_replace(' ', '+', $this->request->getPost('street') . '+' . $this->request->getPost('city') . '+' . $countryName);
         $userSession = $this->session->get("userSession");
         $content = file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address=' . $address . '&key=AIzaSyAbpLPfBH8sNdVSzMULD_BZN9qrAqbL3V8');
         $json = json_decode($content, true);
         $lat = $json['results'][0]['geometry']['location']['lat'];
         $lng = $json['results'][0]['geometry']['location']['lng'];
         $business->modified = date('Y-m-d H:i:s');
         $business->member_id = $userSession['id'];
         $business->name = $this->request->getPost('name');
         $business->website = $this->request->getPost('website');
         $business->telephone = $this->request->getPost('telephone');
         $business->street = $this->request->getPost('street');
         $business->city = $this->request->getPost('city');
         $business->country_id = $this->request->getPost('country_id');
         $business->lat = $lat;
         $business->lng = $lng;
         $opened = '';
         if (!empty($this->request->getPost('opened'))) {
             $opened = 'Opened';
         }
         if (empty($this->request->getPost('opened'))) {
             $opened = 'Opening Soon';
         }
         $business->opened = $opened;
         if ($business->update()) {
             if (!empty($this->request->getPost('business_category_ids'))) {
                 $bCtegories = $this->request->getPost('business_category_ids');
                 $bCtegoryIds = explode(',', $bCtegories);
                 BusinessCategoryLists::find('business_id="' . $businessId . '"')->delete();
                 foreach ($bCtegoryIds as $key => $bCtegoryId) {
                     $businessCategoryLists = new BusinessCategoryLists();
                     $businessCategoryLists->created = date('Y-m-d H:i:s');
                     $businessCategoryLists->business_id = $businessId;
                     $businessCategoryLists->business_category_id = $bCtegoryId;
                     $businessCategoryLists->create();
                 }
             }
             $this->flash->success('<button type="button" class="close" data-dismiss="alert">×</button>Business has been updated');
             return $this->response->redirect('business/view/' . $businessId);
         }
     }
     $this->view->setVar('business', $business);
     $countries = Countries::find();
     $this->view->setVar('countries', $countries);
     $businessCategoryLists = BusinessCategoryLists::find('business_id="' . $businessId . '"');
     $this->view->setVar('businessCategoryLists', $businessCategoryLists);
 }
 public function viewAction($id = null)
 {
     $business = Business::findFirst($id);
     if (!$business) {
         return $this->response->redirect('review/search_business');
     }
     $averageRate = $business->average_rate;
     $businessCategoryLists = BusinessCategoryLists::find('business_id = "' . $id . '"');
     $businessUpdates = BusinessUpdates::findFirst(array('business_id="' . $id . '"', "order" => "id DESC"));
     if ($businessUpdates) {
         $business = $businessUpdates;
         //$businessCategoryLists = BusinessCategoryListUpdates::find('business_update_id = "'.$businessUpdates->id.'"');
         $business->id = $id;
         $business->average_rate = $averageRate;
     }
     $this->view->setVar('business', $business);
     $this->view->setVar('businessCategoryLists', $businessCategoryLists);
     $query = $this->modelsManager->createQuery("SELECT * from BusinessImages where business_id={$id} and primary_pic='yes'");
     //$businessLastImg = $query->execute();
     $businessLastImg = BusinessImages::findFirst(array('business_id="' . $id . '" and primary_pic="Yes"'));
     $businessImgCover = BusinessBackgroundCovers::findFirst(array('business_id="' . $id . '" and primary_pic="Yes"'));
     //$businessLastImg = BusinessImages::findFirst(array('business_id = "'.$id.'"', "order" => "id DESC"));
     $this->view->setVar('businessLastImg', $businessLastImg);
     $businessImages = BusinessImages::find(array('business_id = "' . $id . '"', "order" => "id DESC", "limit" => 7));
     $this->view->setVar('businessImages', $businessImages);
     $reviews = Reviews::find(array('business_id = "' . $id . '"', "order" => "id DESC"));
     $this->view->setVar('reviews', $reviews);
     $this->view->setVar('businessImgCover', $businessImgCover);
     //error_log("WWWWWW ".print_r($businessCategoryLists));
     // $this->view->setVar('businessCategoryLists', $businessCategoryLists);
     // $reviews = Reviews::find('business_id = "'.$id.'"');
     // $this->view->setVar('reviews', $reviews);
 }
 public function viewAction($id = null)
 {
     $business = Business::findFirst($id);
     if (!$business) {
         return $this->response->redirect('review/search_business');
     }
     $averageRate = $business->average_rate;
     $businessCategoryLists = BusinessCategoryLists::find('business_id = "' . $id . '"');
     $businessUpdates = BusinessUpdates::findFirst(array('business_id="' . $id . '"', "order" => "id DESC"));
     if ($businessUpdates) {
         $business = $businessUpdates;
         //$businessCategoryLists = BusinessCategoryListUpdates::find('business_update_id = "'.$businessUpdates->id.'"');
         $business->id = $id;
         $business->average_rate = $averageRate;
     }
     $this->view->setVar('business', $business);
     $this->view->setVar('businessCategoryLists', $businessCategoryLists);
     $businessLastImg = BusinessImages::findFirst(array('business_id = "' . $id . '"', "order" => "id DESC"));
     $this->view->setVar('businessLastImg', $businessLastImg);
     $businessImages = BusinessImages::find(array('business_id = "' . $id . '"', "order" => "id DESC", "limit" => 7));
     $this->view->setVar('businessImages', $businessImages);
     $reviews = Reviews::find(array('business_id = "' . $id . '"', "order" => "id DESC"));
     $this->view->setVar('reviews', $reviews);
     //error_log("WWWWWW ".print_r($businessCategoryLists));
     // $this->view->setVar('businessCategoryLists', $businessCategoryLists);
     // $reviews = Reviews::find('business_id = "'.$id.'"');
     // $this->view->setVar('reviews', $reviews);
 }