Created
November 6, 2023 13:01
-
-
Save moloy666/fd669b81f20f5fc36b5c3e9a19205b32 to your computer and use it in GitHub Desktop.
search pincode, return locality, officename, district
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function get_pincode_details(pincode){ | |
$.ajax({ | |
type: "GET", | |
url: base_url + controller + '/pincode_details?pincode=' + pincode, | |
success: function (resp) { | |
if(resp.success){ | |
// console.log(resp); | |
let data = resp.data; | |
let view = ``; | |
$.each(data, function(i, value){ | |
view +=` | |
<div class='pincode_area pointer' onclick="autofill_address('${value.locality}', '${value.officename}', '${value.district}')"> | |
<small class="titlecase">${value.locality}, ${value.officename}, ${value.district}</small> | |
</div>`; | |
}); | |
$('#pincode_details').html(view); | |
} | |
else{ | |
$('#pincode_details').html(''); | |
} | |
} | |
}); | |
} | |
function autofill_address(locality, officename, district){ | |
$('#pincode_details').html(''); | |
$('#text_address').html(`<small style="font-size:12px">${locality}, ${officename}, ${district}</small>`); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function pincode_details() | |
{ | |
$pincode = $this->input->get('pincode'); | |
$this->init_vendor_model(); | |
$data = $this->Vendor_model->pincode_details($pincode); | |
$success = (!empty($data)) ? true : false; | |
$this->response([ | |
"success" => $success, | |
"data" => $data | |
], 200); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function pincode_details($pincode){ | |
$query = $this->db | |
->like('pincode', $pincode, 'after') | |
->order_by('locality', 'asc') | |
->get('pincodes') | |
->result_array(); | |
foreach($query as $i=>$val){ | |
$query[$i]['locality'] = strtolower($val['locality']); | |
$query[$i]['officename'] = strtolower($val['officename']); | |
} | |
return(!empty($query))?$query: []; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment