Total value count Retrieve ajax
On click function
<input type="button" class="clerk" onclick='nosalecount()' data-toggle="modal"
data-target="#clark" value="Clark">
data-target="#clark" value="Clark">
AJAX CODE
// **************************************************************
// * no sale count *
// **************************************************************
function nosalecount(){
$.ajax({
type: "POST",
url: "<?php echo base_url('Sell/nosalecount');?>",
success: function (data) {
let obj = JSON.parse(data);
// console.log(obj.nosale);
$("#nosalecount").text(obj.nosale);
$("#salecount").text(obj.sale);
},
error: function () {
alert('Error occured');
}
});
}
controller
// ********************************************************
// * noSale count *
// ********************************************************
function nosalecount(){
$clarkid=$this->session->userdata('ClarkAccessId');
$terminalid= $this->session->userdata('terminalnumber');
/* No sale count */
$this->db->select("*");
$query = $this->db->get_where('nosale', array('date' => date('Y-m-d'),
'clarkid'=>$clarkid, 'terminalid'=>$terminalid));
'clarkid'=>$clarkid, 'terminalid'=>$terminalid));
$result = $query->result_array();
$count = count($result);
/* Sale count query */
$this->db->select("*");
$query2 = $this->db->get_where('sell', array('date' => date('Y-m-d'),
'clark_id'=>$clarkid, 'terminalnumber'=>$terminalid));
'clark_id'=>$clarkid, 'terminalnumber'=>$terminalid));
$result2 = $query2->result_array();
$salecount = count($result2);
//return $count;
if(empty($count)){
return false;
}
else{
print '{"nosale":'.$count.', "sale":'.$salecount.'}';
}
}
Comments
Post a Comment