<?php
/***************************************************************************
 *                                                                          *
 * Copyright (c) 2005 ISPG Technologies (I) Pvt Ltd. All rights reserved.   *
 *                                                                          *
 * This  is  commercial  software,  only  users  who have purchased a valid *
 * license  and  accept  to the terms of the  License Agreement can install *
 * and use this program.                                                    *
 *                                                                          *
 ****************************************************************************
 * PLEASE READ THE FULL TEXT  OF THE SOFTWARE  LICENSE   AGREEMENT  IN  THE *
 * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE.            *
 ****************************************************************************/ //
//$Id: CityController.php, v 1.0 2011/06/14 20:52:11
//
class CityController extends Controller {
    public function indexAction() {
    }
    //LIST STATES WITH AJAX
    public function ajaxStateAction() {
        $objState    = new StateModel();
        $countryID   = isset($_POST['countryID']) ? $_POST['countryID'] : '';
        $languageIDs = $this->ObjView->languageIDs;
        if (isset($_POST['currentLanguageID']) && ($_POST['currentLanguageID'] > 0)) //From Affiliate Add Page, Can be used for setting custom current lang id
            $languageIDs['Current'] = $_POST['currentLanguageID'];
        else
            $languageIDs['Current'] = $languageIDs['Content'];
        $stateID = isset($_POST['stateID']) ? $_POST['stateID'] : '';
        if ($countryID > 0) {
            $statesList = $objState->listStates($languageIDs, $countryID);
        }
        $this->ObjView->assign('stateID', $stateID);
        $this->ObjView->assign('statesList', isset($statesList) ? $statesList : '');
        $this->ObjView->display('CityState.tpl');
    }
    //END OF FUNCTION
	//LIST CITIES WITH AJAX
    public function ajaxCityAction() {
        $objCity    = new CityModel();
        $countryID   = isset($_POST['countryID']) ? $_POST['countryID'] : '';
        $userCity = isset($_POST['cityName']) ? $_POST['cityName'] : '';
        if ($countryID > 0) {
            $citiesList = $objCity->listCitiesFrontend($countryID);
        }
        $this->ObjView->assign('userCity', $userCity);
        $this->ObjView->assign('citiesList', isset($citiesList) ? $citiesList : '');
        $this->ObjView->display('CityAjaxList.tpl');
    }
}
