	<div class="btn--wrapper col-12 d-flex justify-content-center mt-5">
		<button type="button" class="btn btn-secondary list--btn" style="width:190px; height:65px;" id="btn_list">목록</button>
	<?php if($ds_status_contract_sale == 'B0') { ?>
		<button type="button" class="btn btn-primary ms-2" style="width:120px;" id="btn_fail_proc">거래실패 처리</button>
		<button type="button" class="btn btn-primary ms-2" style="width:120px;" id="btn_underway_proc">거래재개 처리</button>
	<?php } ?>
	</div>

<script>
function go_list() {
	var url  = "<?=$list_url?>";
	var params = {
		ListPageNo : "<?=$PageNo?>",
		PageSort : "<?=$PageSort?>",
		searchtype : "<?=$searchtype?>",
		searchword : "<?=$searchword?>",
	}
	link(url+"?"+$.param(params));
}

$(function() {
	$("#btn_list").on("click", function() {
		go_list();
	});


	$("#btn_fail_proc").on("click", function() {
		var custom_opts = {
			title : '',
			btn_close_show : false,
		}

		custom_opts.title = '거래실패 처리 하겠습니까?';
		custom_modal_confirm(custom_opts, function(confirm) {
			if(confirm) {
				$("#btn_fail_proc").hide();

				var data = {
					mode		: "updateFail"
					, cd_car 	: '<?=$cd_car?>'
					, cd_sale 	: '<?=$cd_sale?>'
				};

				$.post("aap_proc.php", data, function(res) {
					$("#btn_fail_proc").show();

					custom_modal_confirm_close();

					if(res.CODE != "0000"){
						custom_opts.title = "거래실패 처리에 실패했습니다.";
						custom_modal_alert(custom_opts);
						return false;
					}

					custom_opts.title = "거래실패 처리되었습니다.";
					custom_modal_alert(custom_opts, function() {
						reload();
					});
					return false;
				}, "json");

			}else {
				$("#btn_fail_proc").show();
				return false;
			}
		});
	});

	$("#btn_underway_proc").on("click", function() {
		var custom_opts = {
			title : '',
			btn_close_show : false,
		}

		custom_opts.title = '거래재개 처리 하겠습니까?';
		custom_modal_confirm(custom_opts, function(confirm) {
			if(confirm) {
				$("#btn_underway_proc").hide();

				var data = {
					mode		: "updateUnderway"
					, cd_car 	: '<?=$cd_car?>'
					, cd_sale 	: '<?=$cd_sale?>'
				};

				$.post("aap_proc.php", data, function(res) {
					$("#btn_underway_proc").show();

					custom_modal_confirm_close();

					if(res.CODE != "0000"){
						custom_opts.title = "거래재개 처리에 실패했습니다.";
						custom_modal_alert(custom_opts);
						return false;
					}

					custom_opts.title = "거래재개 처리되었습니다.";
					custom_modal_alert(custom_opts, function() {
						reload();
					});
					return false;
				}, "json");

			}else {
				$("#btn_underway_proc").show();
				return false;
			}
		});
	});
});
</script>
