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/chulha_magam_confirm_do.php
<? session_cache_limiter('no-cache, must-revalidate'); session_start(); header("Pragma: no-cache"); header("Cache-Control: no-cache,must-revalidate"); header("Content-Type: text/html; charset=utf-8"); include_once("dbconn.php"); include_once("lib.php"); foreach($_GET as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } foreach($_POST as $key => $value) { ${$key}=mysql_real_escape_string(trim($value)); } $arr_rst=array(); $rs_parts=RS("select * from farm_contract_parts where no='$parts_no' "); $rs_farm=RS("select * from farm where no='{$rs_parts[farm_no]}' "); $rs_contract=RS("select * from farm_contract where no='{$rs_parts[contract_no]}' "); mysql_query("update farm_contract set ltms_status='100', chulha_status='0' where no='{$rs_parts[contract_no]}' ") or die(mysql_error()); mysql_query("update farm_contract_parts set is_magam='1', is_magam_date=now() where no='$parts_no' ") or die(mysql_error()); mysql_query("update farm_chulha_plan_input set company_no='{$rs_contract[contractor_company_no]}' where parts_no='$parts_no' ") or die(mysql_error()); $arr_dong_name=array(); $arr_plan_nos=array(); $result_c=mysql_query("select a.*, b.dong_name from farm_chulha_plan_input a, farm_dong_info b where a.parts_no='$parts_no' and a.dong_no=b.no group by a.dong_no order by CAST(b.dong_name AS DECIMAL(10,2)) asc ") or die(); while($rs_c=mysql_fetch_array($result_c)) { $arr_dong_name[]=$rs_c[dong_name]; $arr_plan_nos[]=$rs_c[no]; } $str_dong_name=implode(",",$arr_dong_name); asort($arr_plan_nos); $str_plan_nos=implode(",",$arr_plan_nos); $msg=$str_dong_name." 이 최종 출하 마감처리 되었습니다."; $query="insert into farm_msg_alarm set farm_no='{$rs_farm[no]}', contract_no='{$rs_parts[contract_no]}', msg_gubun='사육관리', title='출하마감처리알림', cont='$msg', is_confirm_msg='0', confirm_msg_type='5', str_chulha_plan_nos='$str_plan_nos', regdate=now() "; mysql_query($query) or die(mysql_error()); $title="출하마감처리알림"; $cont=$msg; $tts_cont=$cont; $mode="notice"; $mode="notice"; $result_mem=mysql_query("select * from member where farm_no='{$rs_farm[no]}' and fcm_token is not null ") or die(); while($rs_mem=mysql_fetch_array($result_mem)) { $tokens = array(); $tokens[]=$rs_mem[fcm_token]; $istts=$rs_farm[set_alarm_tts]; //$is_sound=$rs_farm[set_alarm_tts]==1?"0":$rs_farm[set_alarm_sound]; $is_sound=0; $isvib=$rs_farm[alarm_vibrate]; $ispopup=$rs_farm[alarm_popup]; $message = array("message" => $cont,"title" => $title,"mode" => $mode,"sound" => $is_sound=="1"?"1":'-1',"tts" => $tts_cont,"istts" => $istts=="1"?"1":'-1',"isvib" => $isvib=="1"?"1":'-1',"ispopup" => $ispopup=="1"?"1":'-1'); $rst=send_notification($tokens, $message); if($rst=="success") { $str_val=implode("&",$tokens); mysql_query("insert into push_send_log set arr_mem_no='{$rs_mem[no]}', title='$title', cont='$cont', tts_cont='$tts_cont', is_tts='$istts', mode='$mode', is_sound='$is_sound', regdate=now(), mode2='2' ") or die(mysql_error()); } else { } } //담당자에게 메시지 보내기 $rs_damdang=RS("select * from ltman_member where no='{$rs_contract[damdang_ltman_member_no]}' "); $s_title=$rs_farm[farm_name]." 농가 출하마감처리 알림"; $s_title2="출하마감처리 알림"; $s_msg=$rs_farm[farm_name]." 농가 ".$str_dong_name." 이 최종 출하 마감처리되었습니다."; $query="insert into ltman_member_rcv_msg set ltman_no='{$rs_damdang[no]}', title='$s_title', msg='$s_msg', farm_no='{$rs_farm[no]}', parts_no='$parts_no', regdate=now() "; mysql_query($query) or die(mysql_error()); if($rs_damdang[fcm_token]) { $tokens = array(); $tokens[]=$rs_damdang[fcm_token]; $istts=$rs_damdang[set_alarm_tts]; $is_sound=0; $isvib=1; $ispopup=1; $message = array("message" => $s_msg,"title" => $s_title2,"mode" => $mode,"sound" => $is_sound=="1"?"1":'-1',"tts" => $tts_cont,"istts" => $istts=="1"?"1":'-1',"isvib" => $isvib=="1"?"1":'-1',"ispopup" => $ispopup=="1"?"1":'-1'); $rst=send_notification_damdang($tokens, $message); if($rst=="success") { $str_val=implode("&",$tokens); mysql_query("insert into push_send_log set title='$s_title', cont='$s_msg', tts_cont='$tts_cont', is_tts='$istts', mode='$mode', is_sound='$is_sound', regdate=now(), mode2='2', is_ltman='1' ") or die(mysql_error()); } else { } } //--담당자에게 메시지 보내기 $arr_rst['rst']='1'; echo json_encode($arr_rst); function send_notification($tokens, $message) { $url = 'https://fcm.googleapis.com/fcm/send'; $fields = array( 'registration_ids' => $tokens, 'data' => $message ); $key = "AIzaSyCG6QsJex8nT-CVCMaDQL7vKxclJl3_XwI"; $headers = array( 'Authorization:key =' . $key, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $response = curl_exec($ch); curl_close($ch); $json=json_decode($response,true); //NotRegistered = 앱삭제 if($json["success"]) { return "success"; } else { return $response; } } function send_notification_damdang($tokens, $message) { $url = 'https://fcm.googleapis.com/fcm/send'; $fields = array( 'registration_ids' => $tokens, 'data' => $message ); $key = "AIzaSyDPwEji5aP554CMy6ILk0w3F4L09T5mxaY"; $headers = array( 'Authorization:key =' . $key, 'Content-Type: application/json' ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields)); $response = curl_exec($ch); curl_close($ch); $json=json_decode($response,true); //NotRegistered = 앱삭제 if($json["success"]) { return "success"; } else { return $response; } } ?>