/** * Load required classes */ load_class(array("attorney")); $attorney_obj = new attorney(); //if (isset($_GET["zipcode"]) && !empty($_GET["zipcode"])) { $radius = isset($_GET["radius"]) && !empty($_GET["radius"]) ? (int) $_GET["radius"] : 100; $zipcode = isset($_GET["zipcode"]) && !empty($_GET["zipcode"]) ? $_GET["zipcode"] : ''; /** * get latitude logitude of zipcode */ $fields = ''; $having = ''; $order_by = ''; if ($zipcode != '') { $data = getLntByZip($zipcode); if (!empty($data)) { $latitude = $data["lat"]; $longitude = $data["lng"]; /** * * Calculate distance in miles */ $fields .= " , ( 6371 * acos( cos( radians({$latitude}) ) * cos( radians(attorney_latitude ) )"; $fields .= " * cos( radians(attorney_longitude ) - radians({$longitude}) ) + sin( radians({$latitude}) )"; $fields .= " * sin( radians(attorney_latitude ) ) ) )* 0.621371192 AS distance"; $having = " having '{$radius}' >= distance"; $having .= " OR attorney_zipcode = '{$zipcode}'"; $order_by = " order by distance ASC "; } }
if (isset($_POST["method"]) && $_POST["method"] == "attorney_form_method") { $address = $_POST["attorney_address"] . " " . $_POST["attorney_state"] . " " . $_POST["attorney_zipcode"] . " " . $_POST["attorney_zipcode"]; $data = getLntByZip($address); $latitude = $data["lat"]; $longitude = $data["lng"]; $data_array = array("attorney_name" => $_POST["attorney_name"], "attorney_address" => $_POST["attorney_address"], "attorney_country" => $_POST["attorney_country"], "attorney_state" => $_POST["attorney_state"], "attorney_city" => $_POST["attorney_city"], "attorney_zipcode" => $_POST["attorney_zipcode"], "attorney_website" => $_POST["attorney_website"], "attorney_phone_no" => $_POST["attorney_phone"], "is_domestic" => $_POST["is_domestic"], "attorney_status" => $_POST["attorney_status"], "attorney_latitude" => $latitude, "attorney_longitude" => $longitude, "attorney_description" => $_POST["attorney_description"], "created" => currentDate()); $row = $attorney_obj->db->insert($attorney_obj->tableName, $data_array); if ($row) { echo "success"; } else { echo "failed"; } die; } elseif (isset($_POST["method"]) && $_POST["method"] == "attorney_form_edit_method") { $address = $_POST["attorney_address"] . " " . $_POST["attorney_state"] . " " . $_POST["attorney_zipcode"] . " " . $_POST["attorney_zipcode"]; $data = getLntByZip($address); $latitude = $data["lat"]; $longitude = $data["lng"]; $attorney_id = $_POST["attorney_id"]; $data_array = array("attorney_name" => $_POST["attorney_name"], "attorney_address" => $_POST["attorney_address"], "attorney_country" => $_POST["attorney_country"], "attorney_state" => $_POST["attorney_state"], "attorney_city" => $_POST["attorney_city"], "attorney_zipcode" => $_POST["attorney_zipcode"], "attorney_website" => $_POST["attorney_website"], "attorney_phone_no" => $_POST["attorney_phone"], "is_domestic" => $_POST["is_domestic"], "attorney_status" => $_POST["attorney_status"], "attorney_latitude" => $latitude, "attorney_longitude" => $longitude, "attorney_description" => $_POST["attorney_description"], "modified" => currentDate()); $attorney_obj->db->where("attorney_id", $attorney_id); $row = $attorney_obj->db->update($attorney_obj->tableName, $data_array); if ($row) { echo "success"; } else { echo "failed"; } die; } elseif (isset($_GET["edit"]) && !empty($_GET["edit"])) { $edit_id = decode($_GET["edit"]); /**