Exemple #1
0
 /**
  * 
  */
 public function getCitiesByPoiId($poiId, $languageId)
 {
     // Variabel
     $areaList = array();
     $island = array();
     $city = array();
     $province = array();
     // Model
     $areaDb = new Model_DbTable_Area();
     // Data
     $result = $areaDb->getAllAreaByPoiId($poiId, $languageId);
     // Dapetin semua area dari poi
     // Kumpulkan mana yg masuk island, province dan city
     foreach ($result as $area) {
         if ($area['area_type'] == 0) {
             $island[] = $area['area_id'];
         } elseif ($area['area_type'] == 1) {
             $province[] = $area['area_id'];
         } elseif ($area['area_type'] == 2) {
             $city[] = $area['area_id'];
         }
     }
     // Jika city-nya ada, langsung diambil
     if (count($city) > 0) {
         $areaList = $city;
     } elseif (count($province) > 0) {
         // Jika provinsi ada, cari city-nya
         for ($i = 0; $i < count($province); $i++) {
             $areaCity = $areaDb->getAllAreaIdChildByParent($province[$i]);
             if (is_array($areaCity)) {
                 $areaList = array_merge($areaList, $areaCity);
             }
         }
     } elseif (count($island) > 0) {
         // Jika island ada, cari city-nya
         for ($i = 0; $i < count($island); $i++) {
             $areaProvince = $areaDb->getAllAreaIdChildByParent($island[$i]);
             for ($j = 0; $j < count($areaProvince); $j++) {
                 $areaCity = $areaDb->getAllAreaIdChildByParent($areaProvince[$j]);
                 if (is_array($areaCity)) {
                     $areaList = array_merge($areaList, $areaCity);
                 }
             }
         }
     }
     return $areaList;
 }