Tryag File Manager
Home
||
Turbo Force
||
B-F Config_Cpanel
Current Path :
/
home
/
ltms.eemo.co.kr
/
public_html
/
super
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/ltms.eemo.co.kr/public_html/super/set-ai.php
<?php include_once("dbconn.php"); $pmode = $_REQUEST["pmode"]; //방역설정 if($pmode == "on"){ $pjson = $_REQUEST["pjson"]; $prevention_type = $_REQUEST["pprevention_type"]; $jsons = json_decode($pjson); //$prevention_type = $jsons->prevention_type; $farm_address = $jsons->farm_address; $prevention_time = $jsons->prevention_time; $lng = $jsons->lng; $lat = $jsons->lat; $sql = "INSERT INTO `egg`.`event_prevention` ( `user_id`, `prevention_type`, `company_code`, `prevention_address`, `lat`, `lng`, `prevention_state`, `prevention_time` ) VALUES ( '{$_COOKIE[uid]}', '{$prevention_type}', '{$_COOKIE[ucompany_no]}', '{$farm_address}', {$lat}, {$lng}, 'on', '{$prevention_time}' ); "; $rs = mysql_query($sql); if($rs){ $arr_rst['rs'] = 0; $arr_rst['msg'] = "Success"; }else{ $arr_rst['rs'] = -1; $arr_rst['msg'] = "Sql Error"; } echo json_encode($arr_rst); }else if($pmode == "list"){//방역 목록 $query = "select * from event_prevention where prevention_state = 'on' order by no desc "; $result = mysql_query($query); while($rsRow=mysql_fetch_assoc($result)) { $arr[] = $rsRow; } echo json_encode($arr); }else if($pmode == "off"){//방역 해제 $pno = $_REQUEST["pno"]; $prevention_endtime = $_REQUEST["pprevention_endtime"]; $query = "UPDATE `egg`.`event_prevention` SET `prevention_state` = 'off' , `prevention_endtime` = '{$prevention_endtime}' WHERE `no` = '{$pno}' ;"; $rs = mysql_query($query); if($rs){ $arr_rst['rs'] = 0; $arr_rst['msg'] = "Success"; }else{ $arr_rst['rs'] = -1; $arr_rst['msg'] = "Sql Error"; } echo json_encode($arr_rst); }else if($pmode == "ai_memo_del"){//메모삭제 $pno = $_REQUEST["pno"]; $update_date = date("Y-m-d H:i"); $query = "UPDATE `egg`.`event_prevention_memo` SET `memo_state` = 'N' , `update_time` = '{$update_date}' WHERE `no` = '{$pno}' ; "; $rs = mysql_query($query); if($rs){ $arr_rst['rs'] = 0; $arr_rst['msg'] = "Success"; }else{ $arr_rst['rs'] = -1; $arr_rst['msg'] = "Sql Error"; } echo json_encode($arr_rst); }else if($pmode == "ai_memo_edit"){//메모수정 $pno = $_REQUEST["pno"]; $pmemo = $_REQUEST["pmemo"]; $update_date = date("Y-m-d H:i"); $query = "UPDATE `egg`.`event_prevention_memo` SET `memo` = '{$pmemo}' , `update_time` = '{$update_date}' WHERE `no` = '{$pno}' ; "; $rs = mysql_query($query); if($rs){ $arr_rst['rs'] = 0; $arr_rst['msg'] = "Success"; }else{ $arr_rst['rs'] = -1; $arr_rst['msg'] = "Sql Error"; } echo json_encode($arr_rst); }else if($pmode == "ai_memo_insert"){//메모작성 $pno = $_REQUEST["pno"]; $pmemo = $_REQUEST["pmemo"]; $query = "INSERT INTO `egg`.`event_prevention_memo` ( `event_prevention_no`, `user_id`, `memo` ) VALUES ( '{$pno}', '{$_COOKIE[uid]}', '{$pmemo}' ); "; $rs = mysql_query($query); if($rs){ $arr_rst['rs'] = 0; $arr_rst['msg'] = "Success"; }else{ $arr_rst['rs'] = -1; $arr_rst['msg'] = "Sql Error"; } echo json_encode($arr_rst); }else if($pmode == "ai_memo_list"){//메모목록 $pno = $_REQUEST["pno"]; $query = "select *, date_format(registered_time, '%Y-%m-%d') as registered_times from event_prevention_memo where event_prevention_no = '{$pno}' and memo_state = 'Y' order by no desc"; $result = mysql_query($query); while($rsRow=mysql_fetch_assoc($result)) { $arr[] = $rsRow; } echo json_encode($arr); }else if($pmode == "get_alram_list"){//이벤트 목록 $sdate = $_REQUEST["psdate"]; $edate = $_REQUEST["pedate"]; $edate = date("Y-m-d", strtotime("{$edate} +1 days")); $addCondition = "register_date >= '{$sdate}' and register_date < '{$edate}' "; //검색 타입(미등록차량, 온도, 습도, 정전) $search_type = $_REQUEST["psearch_type"]; if(count($search_type) > 0){ $addCondition .= " and event_type in ('".implode("', '", $search_type)."') "; } $plimit = $_REQUEST["plimit"]; $query = "select * from control_center_event where {$addCondition} order by no desc limit {$plimit}"; $result = mysql_query($query); while($rsRow=mysql_fetch_assoc($result)) { $arr[] = $rsRow; } echo json_encode($arr); }else if($pmode == "get_event"){//이벤트 목록 $query = "select * from control_center_event order by no desc limit 1"; $result = mysql_query($query); while($rsRow=mysql_fetch_assoc($result)) { $arr[] = $rsRow; } echo json_encode($arr); }else{//mode가 없다면 오류로 판단 $arr_rst['rs'] = -1; $arr_rst['msg'] = "Param Error"; echo json_encode($arr_rst); } ?>