public function actionIntraCityService()
 {
     if (isset($_POST['ShipmentItem']) && isset($_POST['ShipmentIntracity'])) {
         $weight_to_count = array();
         $shipment_items = $_POST['ShipmentItem'];
         $area_id = $_POST['ShipmentIntracity']['area_id'];
         foreach ($shipment_items as $item => $value) {
             $weight = $value['package_weight'];
             $height = $value['package_height'];
             $width = $value['package_width'];
             $length = $value['package_length'];
             array_push($weight_to_count, ShipmentItem::getStaticWeightToCount($weight, $height, $width, $length));
         }
         $total_weight = array_sum($weight_to_count);
         $services = IntraCityServices::getServices($total_weight, $area_id);
         $this->renderPartial('_rate_city', array('services' => $services));
     }
 }
 /**
  * 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 = IntraCityServices::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
 public static function getRates($type_id, $area_id, $weight)
 {
     $ratePrice = IntraCityServices::model()->findByAttributes(array('type_id' => $type_id, 'area_id' => $area_id, 'weight' => $weight));
     if (!$ratePrice instanceof IntraCityServices) {
         return 0;
     }
     return $ratePrice->price;
 }