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/bunyang_plan_ok_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(); $arr_skips=array(); if(trim($arr_skip_dongs)) { $exp_skip_dongs=explode(",",trim($arr_skip_dongs)); foreach($exp_skip_dongs as $ak => $av) { $exp_cc=explode("_",$av); $v_dong_no=$exp_cc[0]; $v_parts_no=$exp_cc[1]; $is_skip=$exp_cc[2]; $arr_skips[$v_dong_no]=$v_dong_no; $rs_parts=RS("select * from farm_contract_parts where no='$v_parts_no' "); if($is_skip==1) { $is_rs2=RS("select * from hatchery_plan_ok_log where parts_no='$v_parts_no' and dong_no='$v_dong_no' "); $rs_lsum=RS("select sum(b.max_chick_limit) as cnt from farm_contract_dong a, farm_dong_info b where a.farm_contract_no='{$rs_parts[contract_no]}' and a.farm_dong_info_no=b.no "); $rs_vdong=RS("select * from farm_dong_info where no='$v_dong_no' "); mysql_query("delete from hatchery_plan_log where contract_parts_no='$v_parts_no' and dong_no='$v_dong_no' and jong_type='$jong_type' and breedtype='$breedtype' ") or die(mysql_error()); if(!$is_rs2[no]) { $query="insert into hatchery_plan_ok_log set jdate='$jdate', company_no='$company_no', breedtype='$breedtype', jong_type='$jong_type', parts_no='$v_parts_no', farm_no='{$rs_parts[farm_no]}', contract_no='{$rs_parts[contract_no]}', dong_no='$v_dong_no', max_susu='{$rs_vdong[max_chick_limit]}', bunyang_susu='0', is_farm_confirm='0', is_farm_confirm_date=null, is_skip='1', regdate=now() "; mysql_query($query) or die(mysql_error()); } else { if($is_rs2[is_farm_confirm] != 1) { $query="update hatchery_plan_ok_log set jdate='$jdate', max_susu='{$rs_vdong[max_chick_limit]}', bunyang_susu='0', regdate=now(), is_farm_confirm='0', is_farm_confirm_date=null, is_skip='1' where parts_no='$v_parts_no' and dong_no='$v_dong_no' "; mysql_query($query) or die(mysql_error()); } } } else { $prev_rs=RS("select * from hatchery_plan_ok_log where parts_no='$v_parts_no' and dong_no='$v_dong_no' "); if($prev_rs[is_skip]==1) { mysql_query("delete from hatchery_plan_ok_log where parts_no='$v_parts_no' and dong_no='$v_dong_no' "); } } } } $exp_parts_dongs=explode(",",$arr_parts_dongs); foreach($exp_parts_dongs as $ak => $av) { $exp_vv=explode("_",$av); $parts_no=$exp_vv[0]; $dong_no=$exp_vv[1]; $max_susu=$exp_vv[2]; $bunyang_susu=$exp_vv[3]; $vv_jdate=$exp_vv[4]; if($vv_jdate==$jdate) { $rs_parts=RS("select * from farm_contract_parts where no='$parts_no' "); $rs_dong=RS("select * from farm_dong_info where no='$dong_no' "); $rs_farm=RS("select * from farm where no='{$rs_parts[farm_no]}' "); if($bunyang_susu > 0) { mysql_query("update hatchery_plan_log set is_comple='1' where contract_parts_no='$parts_no' and dong_no='$dong_no' and jdate='$jdate' ") or die(mysql_error()); $is_rs=RS("select * from hatchery_plan_ok_log where parts_no='$parts_no' and dong_no='$dong_no' "); if(!$is_rs[no]) { $query="insert into hatchery_plan_ok_log set jdate='$jdate', company_no='$company_no', breedtype='$breedtype', jong_type='$jong_type', parts_no='$parts_no', farm_no='{$rs_parts[farm_no]}', contract_no='{$rs_parts[contract_no]}', dong_no='$dong_no', max_susu='$max_susu', bunyang_susu='$bunyang_susu', is_farm_confirm='0', is_farm_confirm_date=null, regdate=now() "; mysql_query($query) or die(mysql_error()); $ino=mysql_insert_id(); } else { if($is_rs[is_farm_confirm] != 1) { $query="update hatchery_plan_ok_log set jdate='$jdate', max_susu='$max_susu', bunyang_susu='$bunyang_susu', regdate=now(), is_farm_confirm='0', is_farm_confirm_date=null where parts_no='$parts_no' and dong_no='$dong_no' "; mysql_query($query) or die(mysql_error()); } $ino=$is_rs[no]; } } } } mysql_query("update hatchery_jucha_plan_date set janyo_susu_jochi='' where company_no='$company_no' and jdate='$jdate' and jong_type='$jong_type' and breedtype='$breedtype' ") or die(mysql_error()); foreach($_POST as $key => $value) { if(substr($key,0,4)=="chk_") { $exp_vv=explode("_",$key); $plan_date_no=$exp_vv[1]; $janyo=${"janyo_".$plan_date_no}; mysql_query("update hatchery_jucha_plan_date set janyo_susu_jochi='$value', janyo_susu='$janyo' where no='$plan_date_no' ") or die(mysql_error()); } } $arr_jongtype=array("1"=>"육계","2"=>"삼계","3"=>"오리","4"=>"토종닭"); $vv_breed_type=$arr_jongtype[$jong_type]; $result_last_parts=mysql_query("select max(a.no) as ak from farm_contract_parts a, farm_contract b where b.contract_status='1' and b.no=a.contract_no and b.gps_type='$breedtype' and b.breed_type='$vv_breed_type' and b.contractor_company_no='{$_COOKIE[ucompany_no]}' group by a.contract_no ") or die(); $arr_last_parts=array(); while($rs_last_parts=mysql_fetch_array($result_last_parts)) { $arr_last_parts[]=$rs_last_parts[ak]; } $str_last_parts=implode(",",$arr_last_parts); //여기부터 알림 메시지 전송단 if($str_last_parts) { $result_oklog=mysql_query("select * from hatchery_plan_ok_log where jdate='$jdate' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_farm_confirm != '1' and parts_no in ( $str_last_parts ) group by contract_no asc ") or die(mysql_error()); //echo "select * from hatchery_plan_ok_log where jdate='$jdate' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_farm_confirm != '1' and parts_no in ( $str_last_parts ) group by contract_no asc "; } else { $result_oklog=mysql_query("select * from hatchery_plan_ok_log where jdate='$jdate' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_farm_confirm != '1' group by contract_no asc ") or die(mysql_error()); } while($rs_oklog=mysql_fetch_array($result_oklog)) { $rs_farm=RS("select * from farm where no='{$rs_oklog[farm_no]}' "); $rs_contract=RS("select * from farm_contract where no='{$rs_oklog[contract_no]}' "); $rs_dong=RS("select * from farm_dong_info where no='{$rs_oklog[dong_no]}' "); if($str_last_parts) { $rs_plan_all_dong_except_skip=RS("select GROUP_CONCAT(dong_no) as ak from hatchery_plan_ok_log where contract_no='{$rs_oklog[contract_no]}' and jdate='$jdate' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_skip='0' and parts_no in ( $str_last_parts ) order by dong_no asc "); } else { $rs_plan_all_dong_except_skip=RS("select GROUP_CONCAT(dong_no) as ak from hatchery_plan_ok_log where contract_no='{$rs_oklog[contract_no]}' and jdate='$jdate' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_skip='0' order by dong_no asc "); } if($str_last_parts) { $rs_plan_all_dong=RS("select GROUP_CONCAT(no) as ak from hatchery_plan_ok_log where contract_no='{$rs_oklog[contract_no]}' and jdate='$jdate' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_skip='0' and parts_no in ( $str_last_parts ) order by no asc "); } else { $rs_plan_all_dong=RS("select GROUP_CONCAT(no) as ak from hatchery_plan_ok_log where contract_no='{$rs_oklog[contract_no]}' and jdate='$jdate' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_skip='0' order by no asc "); } $rs_condong_name=RS("select GROUP_CONCAT(dong_name) as dname from farm_dong_info where no in ( $rs_plan_all_dong_except_skip[ak] ) order by CAST(dong_name AS DECIMAL(10,2)) asc "); if($str_last_parts) { $rs_sum=RS("select sum(bunyang_susu) as cnt from hatchery_plan_ok_log where jdate='$jdate' and contract_no='{$rs_oklog[contract_no]}' and parts_no in ( $str_last_parts ) "); } else { $rs_sum=RS("select sum(bunyang_susu) as cnt from hatchery_plan_ok_log where jdate='$jdate' and contract_no='{$rs_oklog[contract_no]}' "); } $title2="입추예정내역 알림"; $title="입추예정내역"; $cont=$rs_condong_name[dname]." 에 ".$jdate." 에 ".number_format($rs_sum[cnt])."수가 분양예정입니다."; $tts_cont=$cont; $query="insert into farm_msg_alarm set farm_no='{$rs_oklog[farm_no]}', contract_no='{$rs_oklog[contract_no]}', msg_gubun='사육관리', title='$title2', cont='$cont', is_confirm_msg='1', confirm_msg_type='2', arr_plan_ok_dong_nos='{$rs_plan_all_dong[ak]}', parts_no='{$rs_oklog[parts_no]}', regdate=now() "; //mysql_query($query) or die(mysql_error()); $mode="notice"; if($rs_farm[set_alarm]==1) { $result_mem=mysql_query("select * from member where farm_no='{$rs_oklog[farm_no]}' and fcm_token is not null ") or die(mysql_error()); 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 { } } } // skip 알림 if($str_last_parts) { $rs_skip_parts=RS("select * from hatchery_plan_ok_log where contract_no='{$rs_oklog[contract_no]}' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_skip='1' and parts_no in ( $str_last_parts ) order by parts_no desc limit 0,1 "); $result_skip=mysql_query("select * from hatchery_plan_ok_log where contract_no='{$rs_oklog[contract_no]}' and parts_no='{$rs_skip_parts[parts_no]}' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_skip='1' order by no asc ") or die(); //echo "select * from hatchery_plan_ok_log where contract_no='{$rs_oklog[contract_no]}' and parts_no='{$rs_skip_parts[parts_no]}' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_skip='1' order by no asc "; } else { $rs_skip_parts=RS("select * from hatchery_plan_ok_log where contract_no='{$rs_oklog[contract_no]}' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_skip='1' order by parts_no desc limit 0,1 "); $result_skip=mysql_query("select * from hatchery_plan_ok_log where contract_no='{$rs_oklog[contract_no]}' and parts_no='{$rs_skip_parts[parts_no]}' and company_no='$company_no' and jong_type='$jong_type' and breedtype='$breedtype' and is_skip='1' order by no asc ") or die(); } while($rs_skip=mysql_fetch_array($result_skip)) { //echo "select * from farm_msg_alarm where farm_no='{$rs_skip[farm_no]}' and contract_no='{$rs_skip[contract_no]}' and msg_gubun='사육관리' and is_confirm_msg='1' and confirm_msg_type='2' and arr_plan_ok_dong_nos='{$rs_skip[no]}' and parts_no='{$rs_oklog[parts_no]}' "; $is_rs=RS("select * from farm_msg_alarm where farm_no='{$rs_skip[farm_no]}' and contract_no='{$rs_skip[contract_no]}' and msg_gubun='사육관리' and is_confirm_msg='1' and confirm_msg_type='2' and arr_plan_ok_dong_nos='{$rs_skip[no]}' and parts_no='{$rs_oklog[parts_no]}' order by no desc limit 0,1 "); if(!$is_rs[no] || $is_rs[is_confirm]==-1) { $rs_dong=RS("select * from farm_dong_info where no='{$rs_skip[dong_no]}' "); $title2="입추보류 알림"; $title="입추보류내역"; $cont=$rs_dong[dong_name]." 금번 차수는 입추보류 예정입니다."; $tts_cont=$cont; $query="insert into farm_msg_alarm set farm_no='{$rs_skip[farm_no]}', contract_no='{$rs_skip[contract_no]}', msg_gubun='사육관리', title='$title2', cont='$cont', is_confirm_msg='1', confirm_msg_type='2', arr_plan_ok_dong_nos='{$rs_skip[no]}', parts_no='{$rs_oklog[parts_no]}', regdate=now() "; //mysql_query($query) or die(mysql_error()); $mode="notice"; if($rs_farm[set_alarm]==1) { $result_mem=mysql_query("select * from member where farm_no='{$rs_skip[farm_no]}' and fcm_token is not null ") or die(mysql_error()); 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 { } } } } } } $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; } } ?>