public function actionGetGroceryRate()
 {
     $inquiry = new InquiryForm('api-rate-grocery');
     $req = Yii::app()->request;
     $inquiryMap = new CMap();
     $inquiryMap->add('receiver_postal', $req->getQuery('receiver_postal'));
     $inquiryMap->add('service_code', $req->getQuery('service_code'));
     $inquiry->setAttributes($inquiryMap->toArray());
     if (!$inquiry->validate()) {
         echo CJSON::encode($this->statusError($inquiry->getErrors()));
         Yii::app()->end();
     }
     $service_code = ProductService::model()->findByAttributes(array('code' => strtoupper($inquiry->service_code)));
     if (!$service_code instanceof ProductService) {
         echo CJSON::encode($this->statusError('No Service Available'));
         Yii::app()->end();
     } else {
         if ($service_code->code != 'LSX' && $service_code->code != 'HRX') {
             echo CJSON::encode($this->statusError('This service is not available'));
             Yii::app()->end();
         }
     }
     $routing = IntraCityRouting::model()->findByAttributes(array('postcode' => $inquiry->receiver_postal));
     if ($routing instanceof IntraCityRouting) {
         $area = Area::getZoneID($inquiry->receiver_postal, 'postcode');
         if (!$area) {
             echo CJSON::encode($this->statusError('No Available Service'));
             Yii::app()->end();
         }
         $rates = RateCity::getCityRate(ProductService::ProductCityCourier, $routing->code, 5);
         $rate = array();
         foreach ($rates as $key) {
             if ($key['service_code'] == $inquiry->service_code) {
                 $rate = $key;
             }
         }
         $product = 'City Courier';
         echo CJSON::encode($this->statusSuccess(array('service_type' => $product, 'rate' => $rate)));
         Yii::app()->end();
     } else {
         $result = array('status' => 'success', 'result' => $data);
     }
     echo CJSON::encode($result);
     Yii::app()->end();
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = ProductService::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
echo $form->label($customer_shipping_profile, 'product_id');
?>
		<?php 
echo $form->dropDownList($customer_shipping_profile, 'product_id', CHtml::listData(Product::model()->findAll(), 'id', 'name'), array('prompt' => ''));
?>
		<?php 
echo $form->error($customer_shipping_profile, 'product_id');
?>
	</div>

	<div class="row" id="prid">
		<?php 
echo $form->label($customer_shipping_profile, 'product_service_id');
?>
		<?php 
echo $form->dropDownList($customer_shipping_profile, 'product_service_id', CHtml::listData(ProductService::model()->findAllByAttributes(array('product_id' => $product_id)), 'id', 'name'), array('prompt' => ''));
?>
		<?php 
echo $form->error($customer_shipping_profile, 'product_service_id');
?>
	</div>

	<div class="row" style="float: left;margin-right: 30px">
		<?php 
echo $form->label($customer_shipping_profile, 'origin');
?>
		<?php 
echo $form->textField($customer_shipping_profile, 'origin', array('size' => 3));
?>
		<?php 
echo $form->error($customer_shipping_profile, 'origin');
 public static function getAvailableService($company_service_id)
 {
     $inCondition = array();
     $serviceCompany = RateCompanyService::model()->findByPk($company_service_id);
     if ($serviceCompany->rateCompany->is_city) {
         array_push($inCondition, self::ProductCityCourier);
     }
     if ($serviceCompany->rateCompany->is_domestic) {
         array_push($inCondition, self::ProductDomestic);
     }
     if ($serviceCompany->rateCompany->is_international) {
         array_push($inCondition, self::ProductInternational);
     }
     $criteria = new CDbCriteria();
     $criteria->addInCondition('product_id', $inCondition);
     return ProductService::model()->findAll($criteria);
 }