public function actionGetRates()
 {
     if (Yii::app()->request->isAjaxRequest && isset($_GET['Cek'])) {
         $inquiry = new InquiryForm('api-rate');
         $inquiry->setAttributes($_GET['Cek']);
         $customer_id = null;
         $use_rate = array();
         $rates = array();
         if (isset($_GET['customer_id']) && is_numeric($_GET['customer_id'])) {
             $customer_id = $_GET['customer_id'];
             $customer = Customer::model()->findByPk($customer_id);
             if ($customer instanceof Customer) {
                 $customer_id = $customer->id;
                 $customer_rates = CustomerDiscount::model()->findAllByAttributes(array('customer_id' => $customer->id, 'use_rate' => 1));
                 foreach ($customer_rates as $cus_rate) {
                     array_push($use_rate, $cus_rate->service_id);
                 }
             }
         }
         if (strtolower($inquiry->receiver_country) != 'indonesia') {
             $country = ZoneInternational::model()->findByAttributes(array('country' => strtolower($inquiry->receiver_country)));
             if ($country instanceof ZoneInternational) {
                 $rates = RateInternational::getServices($inquiry->package_weight, $country->zone, $country->transit_time, $customer_id, $use_rate);
                 $product = 'International';
             }
         } else {
             $routing = IntraCityRouting::model()->findByAttributes(array('postcode' => $inquiry->receiver_postal));
             if ($routing instanceof IntraCityRouting) {
                 $rates1 = RateCity::getCityRate(ProductService::ProductCityCourier, $routing->code, $inquiry->package_weight, $customer_id, $use_rate);
                 $rates2 = array();
                 $area = Area::getZoneID($inquiry->receiver_postal, 'postcode');
                 if ($area) {
                     $rates2 = RateDomestic::getServiceList(1, $area['district_id'], $area['zone_id'], $inquiry->package_weight, ProductService::ProductCityCourier, $customer_id, $use_rate);
                     $rates = array_merge($rates1, $rates2);
                 } else {
                     $rates = $rates1;
                 }
                 $product = 'City Courier';
             } else {
                 $area = Area::getZoneID($inquiry->receiver_postal, 'postcode');
                 if ($area) {
                     $rates = RateDomestic::getServiceList(1, $area['district_id'], $area['zone_id'], $inquiry->package_weight, ProductService::ProductDomestic, $customer_id, $use_rate);
                 }
                 $product = 'Domestic';
             }
         }
         $data = new CArrayDataProvider($rates);
         //			CVarDumper::dump($rates,10,true);exit;
         $this->renderPartial('_rates', array('rates' => $data, 'product' => $product, 'customer_id' => $customer_id, 'postal' => $inquiry->receiver_postal, 'country' => $inquiry->receiver_country, 'product' => $product, 'package_weight' => $inquiry->package_weight), false, true);
         Yii::app()->end();
     }
 }