Exemplo n.º 1
0
 /**
  * Iterate through the existing brand_purchases and return the one that is linked to this brand.
  * If none exist return NULL
  *
  * @param  Model_Brand $brand
  * @return Model_Brand_Purchase
  */
 public function find_brand_purchase(Model_Brand $brand)
 {
     $brand_purchases = $this->brand_purchases->as_array('brand_id');
     if (isset($brand_purchases[$brand->id()])) {
         return $brand_purchases[$brand->id()];
     }
     return NULL;
 }
Exemplo n.º 2
0
 public function action_catalog()
 {
     $brand = Arr::get($_POST, 'brand');
     $data = array();
     $brand = Arr::get($_POST, 'brand');
     $length = 0;
     $startRec = Arr::get($_POST, 'startRec');
     $endRec = Arr::get($_POST, 'endRec');
     $num = $startRec;
     $center = Arr::get($_POST, 'center');
     $radius = Arr::get($_POST, 'radius');
     $center_lat = $center[1];
     $center_lng = $center[0];
     $barnd = new Model_Brand();
     $buisneses = new Model_Businessadr();
     $locations = $buisneses->getLocations($center_lat, $center_lng, $radius, $startRec, $endRec, $brand);
     $length = $buisneses->getCountLocations($center_lat, $center_lng, $radius, $startRec, $endRec, $brand);
     $json = array();
     if ($locations->count() == 0) {
         $json = array('status' => 666);
     } else {
         $length = $length->count();
         foreach ($locations as $item) {
             $num = $num + 1;
             $barnds = $barnd->getCatalogBrands($item['aid'])->as_array();
             $markers[] = array('id' => $item['id'], 'name' => $item['name'], 'num' => $num, 'lat' => $item['lat'], 'lng' => $item['lng'], 'center' => $radius, 'city' => $item['city'], 'street' => $item['street'], 'aid' => $item['aid'], 'distance' => ceil($item['distance']), 'business_name' => $item['business_name'], 'phones' => $item['phones'], 'email' => $item['email'], 'sites' => $item['sites'], 'brands' => $barnds);
         }
         $json = array('markers' => $markers, 'length' => $length, 'startRec' => $startRec);
     }
     $json = json_encode($json);
     echo $json;
 }