/** * Get city info by zip * */ public function actionGetCityInfoByZip($zipCode) { $city = USCity::model()->find('city_zip=:zipcode', array(':zipcode' => $zipCode)); if (!$city) { echoJson(array('error' => at('Sorry, That zip code does not exists.'))); } // Get state id $state = USState::model()->find('short=LOWER(:short)', array(':short' => strtolower($city->city_state))); // Get us country $country = Country::model()->find('short=LOWER(:short)', array(':short' => 'us')); $info = array('city_name' => $city->city_name, 'city_zip' => $city->city_zip, 'city_state' => $state ? $state->id : 0, 'country' => $country ? $country->id : 0); $text = at("Zip Code Exists.\nCity Name: {cityname}, State: {state}", array('{cityname}' => $city->city_name, '{state}' => $city->city_state)); echoJson(array('info' => $info, 'text' => $text)); }
/** * Delete state action */ public function actionDelete() { // Check Access checkAccessThrowException('op_usstates_deletepages'); if (isset($_GET['id']) && ($model = USState::model()->findByPk($_GET['id']))) { alog(at("Deleted State Record '{name}'.", array('{name}' => $model->name))); $model->delete(); fok(at('State Record Deleted.')); $this->redirect(array('state/index')); } else { $this->redirect(array('state/index')); } }
echo CHtml::activeTextField($model, 'shipping_zip', array('class' => 'shipping_info shipping_zip')); ?> <?php echo CHtml::error($model, 'shipping_zip'); ?> </div> <div class="clear"></div> <hr /> <div class="grid-4-12"><?php echo CHtml::activeLabelEx($model, 'shipping_state'); ?> </div> <div class="grid-8-12"> <?php echo CHtml::activeDropDownList($model, 'shipping_state', CHtml::listData(USState::model()->byOrder()->findAll(), 'id', 'name'), array('data-placeholder' => at('Please select one...'), 'prompt' => '', 'class' => 'chzn-select shipping_info shipping_state')); ?> <?php echo CHtml::error($model, 'shipping_state'); ?> </div> <div class="clear"></div> <hr /> <div class="grid-3-12"><?php echo CHtml::activeLabelEx($model, 'shipping_country'); ?> </div> <div class="grid-9-12"> <?php echo CHtml::activeDropDownList($model, 'shipping_country', CHtml::listData(Country::model()->byOrder()->findAll(), 'id', 'name'), array('data-placeholder' => at('Please select one...'), 'prompt' => '', 'class' => 'chzn-select shipping_info shipping_country'));
echo CHtml::activeTextField($model, 'city_name', array('class' => 'validate[required]')); ?> <?php echo CHtml::error($model, 'city_name'); ?> </div> <div class="clear"></div> <hr /> <div class="grid-3-12"><?php echo CHtml::activeLabelEx($model, 'city_state'); ?> </div> <div class="grid-9-12"> <?php echo CHtml::activeDropDownList($model, 'city_state', CHtml::listData(USState::model()->byOrder()->findAll(), 'short', 'name'), array('data-placeholder' => at('Please select one...'), 'prompt' => '', 'class' => 'chzn-select validate[required]')); ?> <?php echo CHtml::error($model, 'city_state'); ?> </div> <div class="clear"></div> <hr /> <div class="grid-3-12"><?php echo CHtml::activeLabelEx($model, 'city_county'); ?> </div> <div class="grid-9-12"> <?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array('model' => $model, 'attribute' => 'city_county', 'sourceUrl' => $this->createUrl('GetCityCountyNames'), 'options' => array('minLength' => '2'), 'htmlOptions' => array('class' => 'validate[required]')));