Batch 6a: application controllers base
This commit is contained in:
56
application/controllers/tgram/Tracking.php
Normal file
56
application/controllers/tgram/Tracking.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
//ini_set('display_errors', '1');
|
||||
//ini_set('display_startup_errors', '1');
|
||||
//error_reporting(E_ALL);
|
||||
class Tracking extends MY_Controller
|
||||
{
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
function list($date=""){
|
||||
if ($date == "" ) {
|
||||
$date = Date("Y-m-d");
|
||||
}
|
||||
$sql = "select *
|
||||
from
|
||||
wa_tracking
|
||||
where date(created_at) = ? and is_used='N'";
|
||||
$qry = $this->db->query($sql,array($date)) ;
|
||||
$rows = array();
|
||||
if ($qry) {
|
||||
$rows = $qry->result_array();
|
||||
echo json_encode( array("status" => "OK" , "rows" => $rows ));
|
||||
} else {
|
||||
echo json_encode( array("status" => "ERR" , "message" => print_r($this->db->error(),true)));
|
||||
}
|
||||
}
|
||||
function update() {
|
||||
$prm = $this->sys_input;
|
||||
$ids = "0";
|
||||
foreach($prm["data"] as $id) {
|
||||
$ids .= ", $id ";
|
||||
}
|
||||
$sql = "update wa_tracking set is_used='Y' where id in ($ids) ";
|
||||
$qry = $this->db->query($sql);
|
||||
if ($qry) {
|
||||
echo json_encode( array("status" => "OK" , "message" => ""));
|
||||
} else {
|
||||
echo json_encode( array("status" => "ERR" , "message" => print_r($this->db->error(),true)));
|
||||
}
|
||||
}
|
||||
function index() {
|
||||
$prm = $this->sys_input;
|
||||
$uuid = $prm["uuid"];
|
||||
$message_id = $prm["message_id"];
|
||||
$phonenumber = $prm["from"];
|
||||
$description = $prm["description"];
|
||||
$status = $prm["status"];
|
||||
$created_at = $prm["created_at"];
|
||||
$updated_at = $prm["updated_at"];
|
||||
|
||||
$sql = "insert into wa_tracking(uuid, message_id, phonenumber, description, status, created_at, updated_at)
|
||||
values(?,?,?,?,?,?,?)";
|
||||
$query = $this->db->query($sql,array($uuid, $message_id, $phonenumber, $description, $status, $created_at, $updated_at));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user