コード例 #1
0
 protected function size_unit_converter_to_any($unit_value, $from_unit_type, $to_any_type)
 {
     $MeasurementFactoryObj = MeasurementFactory::build($from_unit_type);
     try {
         return $MeasurementFactoryObj->get_result($to_any_type, $unit_value);
     } catch (Exception $e) {
         $this->set_error("Invalid unit type: " . $from_unit_type);
         $this->set_error($e);
         return FALSE;
     }
 }
コード例 #2
0
 function obtain_search_result()
 {
     // display per page
     $limit = 9;
     //
     $search_result["nav_total_page"] = 0;
     $search_result["total_result"] = 0;
     $search_result["search_result"] = array();
     $ref_tag_list = array();
     // Special handle for property_type_selection
     $property_category_selection = $this->_get_array_value($_GET, "property_category_selection");
     if ($property_category_selection === "All Category") {
         $property_category_selection = NULL;
     }
     $property_type_selection = $this->_get_array_value($_GET, "property_type_selection");
     if ($property_type_selection === "All Type") {
         $property_type_selection = NULL;
     }
     // Process page nav if no pass in
     $page_nav_num = $this->_get_array_value($_GET, "nav_page");
     if ($page_nav_num == NULL || $page_nav_num <= 0) {
         $page_nav_num = 1;
     }
     $origin_max = $this->_get_array_value($_GET, "max_price");
     $origin_min = $this->_get_array_value($_GET, "min_price");
     $origin_currency = $this->_get_array_value($_GET, "currency");
     $measurement_max = $this->_get_array_value($_GET, "max_sqft");
     $measurement_min = $this->_get_array_value($_GET, "min_sqft");
     $origin_measurement_type = $this->_get_array_value($_GET, "measurement_type");
     //$supported_currency = $this->get_currency_list();
     //$val_return = GeneralFunc::CB_SendReceive_Service_Request("CB_Currency:get_currency_list", NULL);
     $supported_currency = $this->get_currency_list();
     //$supported_currency = json_decode($val_return, TRUE)['data']['result'];
     for ($i = 0; $i < count($supported_currency); $i++) {
         $currency_enum_to_string = $this->convert_currency_from_enum_to_string($i);
         for ($j = 0; $j < measurement_type::__len; $j++) {
             $price_range = $this->construct_currency_range($origin_max, $origin_min, $origin_currency, $i);
             $width_range = $this->construct_width_range($measurement_max, $measurement_min, $origin_measurement_type, MeasurementFactory::get_measurement_type_string($j));
             $filter_array = array("limit" => $limit, "offset" => $limit * ($page_nav_num - 1), "filter" => array("activate" => 1, "service_type" => $this->session->userdata('action'), "state" => $this->_get_array_value($_GET, "selected_state"), "country" => $this->_get_array_value($_GET, "selected_country"), "property_category" => $property_category_selection, "property_type" => $property_type_selection, "unit_name" => $this->_get_array_value($_GET, "place_name"), "price <=" => $price_range[1] === "" || $price_range[1] === "0.00" ? NULL : $price_range[1], "price >=" => $price_range[0], "buildup <=" => $width_range[1] === "" || $width_range[1] === "0.00" ? NULL : $width_range[1], "buildup >=" => $width_range[0], "currency" => $currency_enum_to_string, "size_measurement_code" => MeasurementFactory::get_measurement_type_string($j)));
             // Invoke webservice to retrieve filter data
             $service = "CB_Property:filter_listing";
             $val_return = GeneralFunc::CB_SendReceive_Service_Request($service, json_encode($filter_array));
             if ($val_return === NULL) {
                 continue;
             }
             $val_return_json_array = json_decode($val_return, true);
             // @todo - require better error handing
             $val_return_array = $val_return_json_array["data"];
             // Align the data with output requirement
             foreach ($val_return_array["listing"] as $query_data) {
                 if (in_array($query_data["ref_tag"], $ref_tag_list)) {
                     $val_return_array["count"] = $val_return_array["count"] - 1;
                 } else {
                     $data = $this->convert_search_result_to_data($query_data);
                     array_push($search_result["search_result"], $data);
                     array_push($ref_tag_list, $data["ref_tag"]);
                 }
             }
             $search_result["nav_total_page"] += ceil($val_return_array["count"] / $limit);
             $search_result["total_result"] += $val_return_array["count"];
         }
     }
     echo json_encode($search_result);
 }