I'm having a dilemma on how to pass a JS variable value to my model.php where my query resides. To make it short. here's my code:
in the PHP file under views, I have RP_Report.php in the HTML body resides:
<p>From Date: <input type="text" id="fromdate">
From Date: <input type="text" id="todate"> </br></br>
<button onclick="myFunction()">GENERATE</button> </br>
<p id="body">
in the same file's HTML header:
function myFunction(){
//document.getElementById("body").innerHTML=d ocument.getElementById("fromdate").value;
var fromDate = document.getElementById("fromdate").value;
var ToDate = document.getElementById("todate").value;
}
So the button calls the JS block up top to get the value of the datepicker fields.
What I wanted to happen is to get var fromDate and var ToDate and use it in the query inside Models db_model.php for the whereclause
public function rp_total_attempts_stmt()
{
$stmt = $this->db->query("SELECT phone_number,
DATE(LEFT(CAST(call_date AS CHAR),LENGTH(CAST(call_date AS CHAR)) - 9)) AS call_date,
COUNT(*) AS total_call_attempts FROM vicidial_log
WHERE (SELECT lead_id FROM vicidial_list WHERE vicidial_log.lead_id = vicidial_list.`lead_id`)
GROUP BY phone_number ORDER BY call_date desc");
return $stmt->result_array();
}