Tryag File Manager
Home
||
Turbo Force
||
B-F Config_Cpanel
Current Path :
/
home
/
ltman.eemo.co.kr
/
public_html
/
www
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/ltman.eemo.co.kr/public_html/www/cron_chulha_check.php
<? include_once("/home/nonga.eemo.co.kr/public_html/www/dbconn.php"); include_once("/home/nonga.eemo.co.kr/public_html/www/lib.php"); $arr_br=array("육계"=>"1","삼계"=>"2","오리"=>"3","토종닭"=>"4"); $arr_br2=array("1"=>"육계","2"=>"삼계","3"=>"오리","4"=>"토종닭"); $arr_gr=array("GPSSANRAN"=>"GPS산란","GPSYUK"=>"GPS육성","PSSANRAN"=>"PS산란","PSYUK"=>"PS육성","CC"=>"CC"); $arr_gr2=array("GPS산란"=>"GPSSANRAN","GPS육성"=>"GPSYUK","PS산란"=>"PSSANRAN","PS육성"=>"PSYUK","CC"=>"CC"); $result=mysql_query("select * from farm_contract where 1 "); while($rs=mysql_fetch_array($result)) { $c_jong_type=$arr_br[$rs[breed_type]]; $c_breed_type=$arr_gr2[$rs[gps_type]]; $rs_conf=RS("select * from breed_settting_jong where breed_type='$c_breed_type' and jong_type='$c_jong_type' "); $rs_parts=RS("select * from farm_contract_parts where contract_no='{$rs[no]}' order by no desc limit 0,1 "); $rs_sum=RS("select sum(susu) as cnt from farm_ipchu_confirm_log where parts_no='{$rs_parts[no]}' "); $tmp_ipchu_susu=$rs_sum[cnt]; $rs_dote_sum=RS("select sum(dote+pesa) as cnt from farm_dote_input_log where parts_no='{$rs_parts[no]}' "); $rs_dote_sum_today=RS("select sum(dote+pesa) as cnt from farm_dote_input_log where parts_no='{$rs_parts[no]}' and jdate=date(now()) "); $tmp_dopesa_su=$rs_dote_sum[cnt]; if($rs_sum[cnt]) { $tmp_dopesa_rate=($rs_dote_sum_today[cnt]/$rs_sum[cnt])*100; } else { $tmp_dopesa_rate=0; } $rs_last_dote=RS("select * from farm_dote_input_log where parts_no='{$rs_parts[no]}' order by weight desc limit 0,1 "); $tmp_weight=$rs_last_dote[weight]; $rs_last_ipchu=RS("select min(jdate) as vjdate from farm_ipchu_confirm_log where parts_no='{$rs_parts[no]}' "); $sdate = new DateTime($rs_last_ipchu[vjdate]); $edate = new DateTime(date('Y-m-d')); $diff = date_diff($sdate, $edate); $tmp_now_ilyung=($diff->days+1); //echo "contract_no=".$rs[no]." , 일령=".$tmp_now_ilyung.", 출하상태값=".$rs[chulha_status].", ltms_status=".$rs[ltms_status]."\n"; mysql_query("update farm_contract set tmp_dopesa_su='$tmp_dopesa_su', tmp_ipchu_susu='$tmp_ipchu_susu', tmp_dopesa_rate='$tmp_dopesa_rate', tmp_weight='$tmp_weight', tmp_now_ilyung='$tmp_now_ilyung' where no='{$rs[no]}' "); if($rs[ltms_status]==5) { if($tmp_now_ilyung >= $rs_conf[weight_bogo_day]) { $arr_contract[]=$rs[no]; } else if($tmp_weight >= $rs_conf[chulha_weight]) { $arr_contract[]=$rs[no]; } } } foreach($arr_contract as $ak => $av) { echo "update farm_contract set chulha_status='1' where no='$av' and chulha_status='0' \n"; mysql_query("update farm_contract set chulha_status='1' where no='$av' and chulha_status='0' ") or die(); $is_rs=RS("select * from farm_contract where no='$av' and chulha_status='0' "); if($is_rs[no]) { $rs_contract=RS("select * from farm_contract where no='$av' "); $rs_farm=RS("select * from farm where no='{$rs_contract[farm_no]}' "); $query="insert into farm_msg_alarm set farm_no='{$rs_contract[farm_no]}', contract_no='$av', msg_gubun='사육관리', title='출하예정명단 이동', cont='해당 계약건이 출하예정명단으로 이동하였음을 알려드립니다.', regdate=now() "; mysql_query($query) or die(mysql_error()); $title="출하예정명단이동 알림"; $cont="귀하의 농가의 계약건이 출하예정명단으로 이동하였음을 알려드립니다."; $tts_cont=$cont; $mode="notice"; if($rs_farm[set_alarm]==1) { $result_mem=mysql_query("select * from member where farm_no='{$rs_contract[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]; $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 { } } } } } //$str_contract=implode(",",$arr_contract); //echo "select * from farm_contract where no in ( $str_contract ) and contractor_company_no = '{$_COOKIE[ucompany_no]}' and breed_type='{$arr_jongtype[$jong_type]}' and gps_type='$pbreedtype' and chulha_status='0' order by tmp_dopesa_rate desc, tmp_weight desc, tmp_now_ilyung desc "; //$result=mysql_query("select * from farm_contract where no in ( $str_contract ) and contractor_company_no = '{$_COOKIE[ucompany_no]}' and breed_type='{$arr_jongtype[$jong_type]}' and gps_type='$pbreedtype' and chulha_status='0' order by tmp_dopesa_rate desc, tmp_weight desc, tmp_now_ilyung desc ") or die(); 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; } } ?>