billUtilSend.php 12.6 KB
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/AdminRent.php" ?>
<? include $_SERVER["DOCUMENT_ROOT"] . "/common/classes/AdminOperate.php" ?>
<? include $_SERVER["DOCUMENT_ROOT"] . "/admin/inc/php/popupHeader.php" ?> 
<?
	$obj		= new AdminOperate($_REQUEST, "");
	$info		= $obj->getInfoOfBill();
	$lm_info	= $obj->getInfoOfLMBill();
	$rurl		= pack("H*", $_REQUEST["rurl"]) ;
?>

<script type="text/javascript">
	var _rurl = "<?=$rurl?>";
	var _no = "<?=$_REQUEST[no]?>";


	function getTotal(){
		var totalValue = 0;

		totalValue += $("input[name='electricity_charge']").val() == ""? 0: parseInt($("input[name='electricity_charge']").val());
		totalValue += $("input[name='gas_charge']").val() == ""? 0: parseInt($("input[name='gas_charge']").val());
		totalValue += $("input[name='water_charge']").val() == ""? 0: parseInt($("input[name='water_charge']").val());
		totalValue += $("input[name='community_water_charge']").val() == ""? 0: parseInt($("input[name='community_water_charge']").val());
		totalValue += $("input[name='community_electricity_charge']").val() == ""? 0: parseInt($("input[name='community_electricity_charge']").val());
		
		$("#total").attr("value", totalValue); 
		$("#total2").attr("value", totalValue);
	}

	function getUsage(){
		
		var totalEValue=$("input[name='electricity_usage']").val() == ""? 0: parseInt($("input[name='electricity_usage']").val());
		var totalGValue=$("input[name='gas_usage']").val() == ""? 0: parseInt($("input[name='gas_usage']").val());
		var totalWValue=$("input[name='water_usage']").val() == ""? 0: parseInt($("input[name='water_usage']").val());

		totalEValue -= $("input[name='electricity_usage_lm']").val() == ""? 0: parseInt($("input[name='electricity_usage_lm']").val());
		if($("input[name='electricity_usage_lm']").val() == ""){
			totalEValue=$("input[name='electricity_usage']").val() == ""? 0: parseInt($("input[name='electricity_usage']").val());
		}
		
		totalGValue -= $("input[name='gas_usage_lm']").val() == ""? 0: parseInt($("input[name='gas_usage_lm']").val());
		if($("input[name='gas_usage_lm']").val() == ""){
			totalGValue=$("input[name='gas_usage']").val() == ""? 0: parseInt($("input[name='gas_usage']").val());
		}
		
		totalWValue -= $("input[name='water_usage_lm']").val() == ""? 0: parseInt($("input[name='water_usage_lm']").val());
		if($("input[name='water_usage_lm']").val() == ""){
			totalWValue=$("input[name='water_usage']").val() == ""? 0: parseInt($("input[name='water_usage']").val());
		}
		
		$("#elec_total_usage").attr("value", totalEValue);
		$("#gas_total_usage").attr("value", totalGValue);
		$("#water_total_usage").attr("value", totalWValue);
		
	}

	function getSummationA(){
		var sumA;
		sumA=$("input[id='sum_before_payment']").val() == ""? 0: parseInt($("input[id='sum_before_payment']").val());
		sumA+=$("input[id='current_month_late_fee']").val() == ""? 0: parseInt($("input[id='current_month_late_fee']").val());
		$("#sum_after_payment").attr("value", sumA);		//납기후
		
	}

	function getSummationB(){
		var sumB=$("input[id='unpaid']").val() == ""? 0: parseInt($("input[id='unpaid']").val());
		
		sumB+=$("input[id='total']").val() == ""? 0: parseInt($("input[id='total']").val());
		$("#sum_before_payment").attr("value", sumB);		//납기내
	}
	$(document).ready(function(){

		getTotal();
		getUsage();
		
		getSummationB();
		getSummationA();
		//=====프레입웤 변수들==================================================================================//
		var FORM_TARGET_CLS_NM		= ".data"	;		// 폼을 동적 wrap 할 타겟 ID이름
		var FORM_NAME				= "alf"		;		// 폼이름
		var FORM_METHOD				= "POST"		;		// 폼 메쏘드
		var FORM_USE_FILE			= false		;		// 파일폼 사용 여부
		var FORM_ACTION				= "/action_front.php" ; 
		
		
		var NEXT_CMD				= ""		;		// 다은 수행 할 cmd
		//=====================================================================================================//

		var jForm = $(FORM_TARGET_CLS_NM).mf({ "name" : FORM_NAME , "method" : FORM_METHOD , "action" : FORM_ACTION , "useFile" : FORM_USE_FILE }) ;

		$(".jCancel").click2(function(){
			location.href = _rurl;
		});
		$(".jClose").click2(function(){
			window.close();
		});

		$(".jSend").click2(function(){

			var data = $("#jData").serialize();

			$.ajax({
				url : "/action_front.php?cmd=AdminOperate.saveBill",
				async : false,
				cache : false,
				dataType : "json",
				data : data,
				success : function(data){
					var room_fk=<?=$_REQUEST["no"]?>;
					if(confirm("전송하시겠습니까?"))
					{
					$.ajax({
						url : "/action_front.php?cmd=AdminPush.sendPushForBillSend",
						async : true,
						cache : false,
						dataType : "json",
						data : {
							"room_fk"	: room_fk
						},
						success : function(data){
							alert(data.returnMessage);
							window.opener.location.reload();
							window.close();
						},
						error:function(request,status,error){
						    alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
							location.reload();
						}
					});
					}
					
				},
				error : function(data){
					alert(data.returnMessage);
					}
			});
			
		});

		$(".ws").change(function(e){
			e.preventDefault();
			getTotal();
			getUsage();
			
			getSummationB();
			getSummationA();
			});
		
		$(".wb").change(function(e){
			getSummationA();
			});
		

	}) ;

</script>

<div id="Contents" style="width:500px;">
	<div>
		<span class="btnleft_y">납부기한 : 2016년 <?=date("m")?><?=date("d", $info["billing_date"])?>일까지</span>
		<span class="btnright_y"><?=$info["Bname"]?> <?=$info["name"]?></span>
	</div>
	
	<div class="data" style="width:100%;">
		
		<form id="jData">
		<input type="hidden" name="no" value="<?=$_REQUEST[no]?>" />
		<input type="hidden" name="key" value="<?=$_REQUEST[key]?>" />
		<input type="hidden" name="month" value=" <?=date("m")."-".date("d", $info["billing_date"])?>" />
		<input type="hidden" name="billing_date" value=" <?=$info["billing_date"]?>" />
		<table class="datav" style="width:100%;">
			<colgroup>
				<col width="20%" />
				<col width="30%" />
				<col width="20%" />
				<col width="30%" />
			</colgroup>
			<tr>
				<!-- 전기검침일 -->
				
				<th style="height:25px;">전기검침일</th>
				<td class="center">
					<select name="electricity_check_date" class="ws">
						<? for($i=1; $i<=31; $i++){ ?>
						<option value='<?=$i?>' <?=$info["electricity_check_date"] == $i ? "SELECTED" : ""?>><?=$i?></option>
						<? } ?>
					</select>
				</td>
				<!-- 전기료 -->
				<th style="height:25px;">전기료</th>
				<td class="center">
					<input type="text" name="electricity_charge" class="ws" value="<?=$info["electricity_charge"]?>">
				</td>
			</tr>
			<tr>
				<!-- 가스검침일 -->
				<th style="height:25px;">가스검침일</th>
				<td class="center">
					<select name="gas_check_date" class="ws">
						<? for($i=1; $i<=31; $i++){ ?>
						<option value='<?=$i?>' <?=$info["gas_check_date"] == $i ? "SELECTED" : ""?>><?=$i?></option>
						<? } ?>
					</select>
				</td>
				<!-- 가스료 -->
				<th style="height:25px;">가스료</th>
				<td class="center">
					<input type="text" name="gas_charge" class="ws" value="<?=$info["gas_charge"]?>">
				</td>
			</tr>
			<tr>
				<!-- 수도검침일 -->
				<th style="height:25px;">수도검침일</th>
				<td class="center">
					<select name="water_check_date" class="ws">
						<? for($i=1; $i<=31; $i++){ ?>
						<option value='<?=$i?>' <?=$info["water_check_date"] == $i ? "SELECTED" : ""?>><?=$i?></option>
						<? } ?>
					</select>
				</td>
				<!-- 수도료 -->
				<th style="height:25px;">수도료</th>
				<td class="center">
					<input type="text" name="water_charge" class="ws" value="<?=$info["water_charge"]?>">
				</td>
			</tr>
			<tr>
				<!-- 공용전기검침 -->
				<th style="height:25px;">공용전기검침</th>
				<td class="center">
					<select class="ws" name="community_electricity_check_date">
						<? for($i=1; $i<=31; $i++){ ?>
						<option value='<?=$i?>' <?=$info["community_electricity_check_date"] == $i ? "SELECTED" : ""?>><?=$i?></option>
						<? } ?>
					</select>
				</td>
				<!-- 공용전기료 -->
				<th style="height:25px;">공용전기료</th>
				<td class="center">
					<input type="text" name="community_electricity_charge" class="ws" value="<?=$info["community_electricity_charge"]?>">
				</td>
			</tr>
			<tr>
				<!-- 공용수도검침 -->
				<th style="height:25px;">공용수도검침</th>
				<td class="center">
					<select name="community_water_check_date" class="ws">
						<? for($i=1; $i<=31; $i++){ ?>
						<option value='<?=$i?>' <?=$info["community_water_check_date"] == $i ? "SELECTED" : ""?>><?=$i?></option>
						<? } ?>
					</select>
				</td>
				<!-- 공용수도료 -->
				<th style="height:25px;">공용수도료</th>
				<td class="center">
					<input type="text" name="community_water_charge" class="ws" value="<?=$info["community_water_charge"]?>">
				</td>
			</tr>
			<tr>
				<!-- 소계 -->
				<th style="height:25px;">소계</th>
				<td class="center" colspan="3">
					<input type="text" class="wb" id="total" value="" readonly />
					
				</td>
			</tr>
		</table>
		
		<table class="datav" style="width:100%; margin-top:20px;">
			<colgroup>
				<col width="20%" />
				<col width="27%" />
				<col width="27%" />
				<col width="26%" />
			</colgroup>
			<thead>
				<!-- 항목 제목 -->
				<tr>
					<th style="height:25px;">항목</th>
					<th style="height:25px;">전월</th>
					<th style="height:25px;">당월</th>
					<th style="height:25px;">사용량</th>
				</tr>
			</thead>
			<tbody>
				<!-- 전기 -->
				<tr>
					<th style="height:25px;">전기</th>
					<td class="center">
						<input type="text" class="ws" name="electricity_usage_lm" value="<?=$info["electricity_usage_lm"]?>"  />
					</td>
					<td class="center">
						<input type="text" class="ws" name="electricity_usage" value="<?=$info["electricity_usage"]?>" />
					</td>
					<td class="center">
						<input type="text" class="ws" name="actual_electricity_usage" id="elec_total_usage" readonly />
					</td>
				</tr>
				
				<!-- 가스 -->
				<tr>
					<th style="height:25px;">가스</th>
					<td class="center">
						<input type="text" class="ws" name="gas_usage_lm" value="<?=$info["gas_usage_lm"]?>" />
					</td>
					<td class="center">
						<input type="text" class="ws" name="gas_usage" value="<?=$info["gas_usage"]?>" />
					</td>
					<td class="center">
						<input type="text" class="ws" name="actual_gas_usage" id="gas_total_usage" readonly />
					</td>
				</tr>
				
				<!-- 수도 -->
				<tr>
					<th style="height:25px;">수도</th>
					<td class="center">
						<input type="text" class="ws" name="water_usage_lm" value="<?=$info["water_usage_lm"]?>"/>
					</td>
					<td class="center">
						<input type="text" class="ws" name="water_usage" value="<?=$info["water_usage"]?>" />
					</td>
					<td class="center">
						<input type="text" class="ws" name="actual_water_usage" id="water_total_usage" readonly />
					</td>
				</tr>
			</tbody>
		</table>
		
		<table class="datav" style="width:100%; margin-top:20px;">
			<colgroup>
				<col width="20%" />
				<col width="80%" />
			</colgroup>
			<tr>
				<!-- 당월부과액 -->
				<th style="height:25px;">당월부과액</th>
				<td class="center">
					<input type="text" name="current_month_charge" class="wb"  id="total2" value="" readonly />
				</td>
			</tr>
			<tr>
				<!-- 전월미납액 -->
				<th style="height:25px;">전월미납액</th>
				<td class="center">
					<input type="text" name="name" id="unpaid" class="wb" value="<?=$lm_info["sum_after_payment"]?>" readonly />
				</td>
			</tr>
			<tr>
				<!-- 납기 내 금액 -->
				<th style="height:25px;">납기 내 금액</th>
				<td class="center">
					<input type="text" name="name" class="wb" id="sum_before_payment" value="" readonly />
				</td>
			</tr>
			<tr>
				<!-- 당월연체료 -->
				<th style="height:25px;">당월연체료</th>
				<td class="center">
					<input type="text" name="current_month_late_fee" id="current_month_late_fee" class="wb" value="<?=$info["current_month_late_fee"]?>" />
				</td>
			</tr>
			<tr>
				<!-- 납기 후 금액 -->
				<th style="height:25px;">납기 후 금액</th>
				<td class="center">
					<input type="text" name="sum_after_payment" class="wb" id="sum_after_payment" value="" readonly/>
				</td>
			</tr>
		</table>
		</form>

		<div class="btngroupcenter">
			<span class="button bigrounded blue jSend">확인 발송</span>
			<?if($_REQUEST["key"] == ""){?>
			<span class="button bigrounded blue jClose">닫기</span>
			<?}else{?>
			<span class="button bigrounded blue jCancel">닫기</span>
			<?}?>
		</div>

	</div>
</div>