$data['tgai_reachdevTime1'] = date("Y-m-d H:i:s", strtotime($_GET[devDateTime])); //print_r($data); //exit; if ($db->query_insert("tb_geoalertinfo", $data)) { $res = 1; } else { $res = 0; } echo "SMS"; } } } } else { //print_r($fetAlertImeiInfo); if ($_GET[inoutFlag] == $_GET[inoutPoint]) { $smsStatus = sendSMSAlert($aid); if ($smsStatus) { $data['tgai_assignDevId'] = $devImei; $data['tgai_geoAssignId'] = $aid; $data['tgai_inoutStatus'] = 0; $data['tgai_alertCount'] = 1; $data['tgai_alertType'] = $_GET[inoutPoint]; $data['tgai_reachdevTime1'] = date("Y-m-d H:i:s", strtotime($_GET[devDateTime])); //print_r($data); //exit; if ($db->query_insert("tb_geoalertinfo", $data)) { $res = 1; } else { $res = 0; } echo "SMS";
function smsmAlertFunc($gid, $aid, $src, $nooftime, $inout, $devDateTime, $devImei, $inorout) { $db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); $db->connect(); //print_r($_GET); //echo "<br><br>"; $getAlertImeiInfo = "SELECT * FROM tb_geoalertinfo WHERE tgai_assignDevId = '" . $devImei . "' AND tgai_createDate like '" . date("Y-m-d", strtotime($devDateTime)) . "%' ORDER BY tgai_id DESC LIMIT 0,1"; $resAlertImeiInfo = $db->query($getAlertImeiInfo); if ($db->affected_rows == 0) { if ($inout == 'in' && $inorout == $inout) { $smsStatus = sendSMSAlert($aid, $devDateTime); if ($smsStatus) { $data['tgai_assignDevId'] = $devImei; $data['tgai_geoAssignId'] = $aid; $data['tgai_inoutStatus'] = 0; $data['tgai_alertCount'] = 1; $data['tgai_alertType'] = $inout; $data['tgai_reachdevTime1'] = date("Y-m-d H:i:s", strtotime($devDateTime)); //print_r($data); if ($db->query_insert("tb_geoalertinfo", $data)) { $res = 1; } else { $res = 0; } echo "SMS"; } } elseif ($inout == 'out' && $inorout != $inout) { $data['tgai_assignDevId'] = $devImei; $data['tgai_geoAssignId'] = $aid; $data['tgai_inoutStatus'] = 0; $data['tgai_alertCount'] = 1; $data['tgai_alertType'] = $inout; $data['tgai_reachdevTime1'] = date("Y-m-d H:i:s", strtotime($devDateTime)); //print_r($data); if ($db->query_insert("tb_geoalertinfo", $data)) { $res = 1; } else { $res = 0; } } } else { $fetAlertImeiInfo = $db->fetch_array($resAlertImeiInfo); $getAlertInfo = "SELECT * FROM tb_geoalertinfo WHERE tgai_geoAssignId = " . $aid . " AND tgai_createDate like '" . date("Y-m-d", strtotime($devDateTime)) . "%'"; $resAlertInfo = $db->query($getAlertInfo); $fetAlertInfo = $db->fetch_array($resAlertInfo); /*echo $fetAlertImeiInfo[tgai_geoAssignId]." ".$aid." ".$fetAlertImeiInfo[tgai_inoutStatus]." ".$nooftime." ".$fetAlertImeiInfo[tgai_alertCount]." ". $inorout." ".$inout; echo "<pre>"; print_r($fetAlertImeiInfo); //print_r($fetAlertInfo); echo "</pre>";*/ if ($fetAlertImeiInfo[tgai_geoAssignId] == $aid && $fetAlertImeiInfo[tgai_inoutStatus] == 0) { //echo $fetAlertImeiInfo[tgai_alertCount]."<".$nooftime."<br>"; if ($inout == 'in' && $inorout != $inout) { $data['tgai_inoutStatus'] = 1; $data['tgai_reachdevTime2'] = date("Y-m-d H:i:s", strtotime($devDateTime)); //print_r($data); //exit; if ($db->query_update("tb_geoalertinfo", $data, "tgai_id=" . $fetAlertInfo[tgai_id])) { $res = 1; } else { $res = 0; } } elseif ($inout == 'out' && $inorout == $inout) { $smsStatus = sendSMSAlert($aid, $devDateTime); if ($smsStatus) { $data['tgai_inoutStatus'] = 1; $data['tgai_reachdevTime2'] = date("Y-m-d H:i:s", strtotime($devDateTime)); //print_r($data); //exit; if ($db->query_update("tb_geoalertinfo", $data, "tgai_id=" . $fetAlertInfo[tgai_id])) { $res = 1; } else { $res = 0; } echo "SMS"; } } } elseif ($fetAlertImeiInfo[tgai_geoAssignId] != $aid && $fetAlertImeiInfo[tgai_inoutStatus] == 1 && $fetAlertInfo[tgai_alertCount] < $nooftime) { //print_r($fetAlertImeiInfo); if ($inout == 'in' && $inorout == $inout) { $smsStatus = sendSMSAlert($aid, $devDateTime); if ($smsStatus) { $data['tgai_assignDevId'] = $devImei; $data['tgai_geoAssignId'] = $aid; $data['tgai_inoutStatus'] = 0; $data['tgai_alertCount'] = $fetAlertInfo[tgai_alertCount] + 1; $data['tgai_alertType'] = $inout; $data['tgai_reachdevTime1'] = date("Y-m-d H:i:s", strtotime($devDateTime)); //print_r($data); if ($db->query_insert("tb_geoalertinfo", $data)) { $res = 1; } else { $res = 0; } echo "SMS"; } } elseif ($inout == 'out' && $inorout != $inout) { $data['tgai_assignDevId'] = $devImei; $data['tgai_geoAssignId'] = $aid; $data['tgai_inoutStatus'] = 0; $data['tgai_alertCount'] = $fetAlertInfo[tgai_alertCount] + 1; $data['tgai_alertType'] = $inout; $data['tgai_reachdevTime1'] = date("Y-m-d H:i:s", strtotime($devDateTime)); //print_r($data); if ($db->query_insert("tb_geoalertinfo", $data)) { $res = 1; } else { $res = 0; } } } } }