<?
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/header.php";

$scale = 10;

if(substr(phpversion(),0,1) == "4") {		// php4 버전 

	require_once "simplexml.class.php";

	if(!function_exists("simplexml_load_file")){
	 function simplexml_load_file($file){
	  $sx = new simplexml;
	  return $sx->xml_load_file($file);
	 }
	}

	$file = "http://intra.website.co.kr:9470/mailsms_list_xml.php?user_id=".$_SITE["POSTMAN_ID"]."&s_date=".$_REQUEST[s_date]."&e_date=".$_REQUEST[e_date]."&scale=".$scale."&offset=".$offset;
	$sxml = new simplexml;
	$xml = $sxml->xml_load_file($file);

} else { 
	
	$xml_string = file_get_contents("http://intra.website.co.kr:9470/mailsms_list_xml.php?user_id=".$_SITE["POSTMAN_ID"]."&s_date=".$_REQUEST[s_date]."&e_date=".$_REQUEST[e_date]."&scale=".$scale."&offset=".$offset);
	$enc = mb_detect_encoding($xml_string, array('EUC-KR', 'UTF-8', 'shift_jis', 'CN-GB'));
	if($enc != 'UTF-8'){
	$xml_string = iconv($enc, 'UTF-8', $xml_string);  //본인 사이트에 맞는 인코딩으로 변경
	}
	$xml = simplexml_load_string($xml_string);

}
?>
<div id="admin-container">
	<div class="admin-snb">
		<div class="snb-title"><h2>메일,문자 발송</h2></div>
		<ul class="snb-menu">
			<li><a href="/backoffice/mailsms1.php">문자/메일 충전</a></li>
			<li><a href="/backoffice/mailsms2.php">문자/메일 발송</a></li>
			<li><a href="/backoffice/mailsms3.php">충전결과</a></li>
		</ul>
		<?include $_SERVER[DOCUMENT_ROOT] . "/backoffice/admin_info.php";?>
	</div>
	<div id="admin-content">
		<h2 class="admin-title">충전 결과</h2>
		<div class="mailsms_head">
			문자와 메일은 충전현황은 요청건별/ 월별 리스트로 확인할 수 있으며, 요청결과에 완료표기가 됩니다.
		</div>
		<div class="mailsms_result">
			<div class="top">
				<div class="search">
					<form name="frm" method="get" action="<?=$_SERVER[DOCUMENT_URI]?>">
						<input type="text" name="s_date" class="input datePicker" style="width:74px;" value="<?=$_REQUEST[s_date]?>" /> ~
						<input type="text" name="e_date" class="input datePicker" style="width:74px;" value="<?=$_REQUEST[e_date]?>" />
						<input type="image" src="/backoffice/images/btn_search.gif" alt="검색" align="absmiddle" />
					</form>
				</div>
				<div class="total"><strong>총 충전금액 : <?=number_format($xml->totalprice)?>원(VAT포함)</strong></div>
			</div>
			<table class="mailsms_result_list">
			  <colgroup>
			  <col width="20%" />
			  <col width="14%" />
			  <col width="11%" />
			  <col width="12%" />
			  <!-- <col width="18%" /> -->
			  <col width="11%" />
			  <col width="*" />
			  </colgroup>
			  <thead>
				<tr>
				  <th scope="col">날짜</th>
				  <th scope="col">충전내용</th>
				  <th scope="col">건수</th>
				  <th scope="col">금액</th>
				  <!-- <th scope="col">요청자</th> -->
				  <th scope="col">요청결과</th>
				  <th scope="col">충전완료일자</th>
				</tr>
			  </thead>
			  <tbody>
				<?
				if($xml->totallist > 0) {
				if($xml->totallist<10) {
					$total = $xml->totallist;
				} else {
					$total = 10;
				}
				for($i=0; $i<$total; $i++) {
				
					if($xml->item[$i]->msgb=="SMS") {
						$bgcolor = "#0a87a6";
					} else if($xml->item[$i]->msgb=="MMS") {
						$bgcolor = "#cb36b1";
					} else if($xml->item[$i]->msgb=="LMS") {
						$bgcolor = "#4ca00f";
					} else {
						$bgcolor = "#000000";
					}
				?>
				<tr>
				  <td scope="row"><?=$xml->item[$i]->wdate?></td>
				  <td><span style="color:<?=$bgcolor?>;"><strong><?=$xml->item[$i]->msgb?> 충전</strong></span></td>
				  <td><?=number_format($xml->item[$i]->pea)?>건</td>
				  <td><?=number_format($xml->item[$i]->price)?>원</td>
				  <!-- <td>admin</td> -->
				  <td><?=$xml->item[$i]->bank=="Y"?"<span style='color:#5170d3;'><strong>충전완료</strong></span>":"요청중"?></td>
				  <td><?=substr($xml->item[$i]->cdate,0,10)=="0000-00-00"?"-":$xml->item[$i]->cdate?></td>
				</tr>
				<?}
				} else {?>
				<tr>
					<td height="100" colspan="9">등록된 정보가 없습니다.</td>
				</tr>
				<?}?>
			  </tbody>
			</table>
			<div class="paginate">
				<?=pageNavigation($xml->total,$scale,$pagescale,$offset,"user_idx=".$_SITE["POSTMAN_ID"]."&s_date=".$_REQUEST[s_date]."&e_date=".$_REQUEST[e_date])?>
			</div>
		</div>
	</div>
</div>	
<?
include $_SERVER[DOCUMENT_ROOT] . "/backoffice/footer.php" ;
?>