function shipping_accepted_rule($country, $weight, $shipping_type, $max_length, $max_width, $total_height)
{
    $accepted_result = shipping_accepted_result($country, $weight, $max_length, $max_width, $total_height);
    $pattern = "({$shipping_type})";
    $rule_matched = NULL;
    foreach ($accepted_result as $row) {
        $rule = $row['type'];
        $code = $rule->code;
        if ($code == $shipping_type) {
            $rule_matched = $row;
            break;
        }
    }
    return $rule_matched;
}
 public function calculate_shipping_price()
 {
     $country = $this->input->post('country');
     $weight = $this->input->post('weight');
     $accepted_result = shipping_accepted_result($country, $weight);
     $data = array('accepted_result' => $accepted_result, 'country' => $country, 'weight' => $weight);
     $this->template->write_view('content', 'shipping/calculate_shipping_price', $data);
     $this->template->add_js('static/js/sorttable.js');
     $this->template->render();
 }