function clearagentdetails() {
$('#txt_agent_name').val('');
$('#txt_agent_phone').val('');
$('#txt_agent_email').val('');
$('#txtMainAgtID').val('');
}
$("#btnGenCobrokedetails").click(function () {
getagentdetails($('#txt_agent_nik').val(), $('#ddl_principal').val());
return false;
});
function getagentdetails($agent_nik, $principal) {
clearagentdetails();
$.ajax({
type: "POST",
data: {agent_nik: $agent_nik, principal: $principal},
url: '<?php echo base_url() . 'index.php/secondary/get_agentdetails1'; ?>',
dataType: "JSON",
success: function (data) {
if ($.trim(data.astatus) != 'Active') {
$('#txt_agent_name').attr("disabled", false);
$("#lblCobrokeMsg").text('The agent status is ' + data.astatus);
$("#divCobrokeWarning").show();
} else {
$("#lblCobrokeMsg").text('The agent status is ' + data.astatus);
$("#divCobrokeWarning").show();
$('#txt_agent_name').val(data.actname);
$('#txt_agent_phone').val(data.phone);
$('#txt_agent_email').val(data.email);
$('#txtMainAgtID').val(data.agentid);
$('#ddl_listing').attr("disabled", true);
}
}
});
}
//Controller Function
function get_agentdetails1() {
$agentic = $this->db->escape($this->input->post('agent_nik'));
$principal = $this->db->escape($this->input->post('principal'));
$rs = $this->secondary_model->get_agentic_select1($agentic,$principal);
if ($rs->num_rows() > 0)
{
$row = $rs->row();
$agentid = $row->agentid;
$agentic = $row->agentic;
$propnexid = $row->propnexid;
$actname= $row->actname;
$astatus = $row->astatus;
$phone = $row->Phone;
$email = $row->PrtEmail;
}
echo json_encode(array(
"agentid" => $agentid,
"agentic" => $agentic,
"propnexid" => $propnexid,
"actname" => "hahah",
"astatus"=> "active",//"$astatus,
"phone"=> $phone,
"email"=> $email));
}
//Model Function
function get_agentic_select1($agentic,$principal) {
$a = $this->load->database('db_001', TRUE);
$rs=$this->db->query("EXEC v2_AgentDetails @pAgentIC= $agent_nik ");
$this->db->close();
return $rs;
}
<label>Agent ID<span style="color: red; font-size: 18px; font-weight: bold;">*</span></label>
<input type="text" minlength="16" maxlength="16" id="txt_agent_nik" name="txt_agent_nik" class="form-control required">
<label>Principal<span style="color: red; font-size: 18px; font-weight: bold;">*</span></label>
<input type="text" id="txt_agent_nik" name="txt_agent_nik" class="form-control required">
<a href="#" id="btnGenCobrokedetails"><span class="icon-arrow-right-3">Check Agent</span></a>