<?php require_once('../Connections/BE2.php'); ?>
<?php
//  
mysql_select_db($database_BE2, $BE2);
//sum(if(a.as11="Y",a.a6,NULL) ) 
$query_Rt2 = sprintf("SELECT sum(e_ival) as e_i, sum(if(e_flag='Y',e_ival,0)) as e_u,sum(e_oval) as e_o FROM order_point WHERE euid='%s' group by euid ",$_SESSION['login_memid']);

$Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error());
$row_Rt2 = mysql_fetch_assoc($Rt2);

// SELECT sum(e_ival) as e_i,sum(e_oval) as e_o FROM order_point WHERE euid='16' group by euid;

?>	
		<!-- start: Content -->
		<div class="main ">
		
			<div class="row">
				<div class="col-lg-12">
					<h3 class="page-header"><i class="fa fa-indent"></i>雲點數來源記錄</h3>
					<ol class="breadcrumb">
						<li><i class="fa fa-home"></i><a href="index.html">首頁</a></li>
						<li><i class="fa fa-list-alt"></i><a href="#">雲點數<?= $_SESSION['login_memid'] ?></a></li>
						<li><i class="fa fa-indent"></i>可用點數</li>				
					</ol>
				</div>
			</div>



			<div class="row">	
				<div class="col-md-12">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h2><i class="fa fa-list red"></i><span class="break"></span><strong>雲點數 目前可用點數1</strong></h2>
						</div>


						<div class="panel-body">

					<h3 class="panel-title">&nbsp;</h3>
					            <div class="clearfix"></div>  
                    
                     <div style="overflow:scroll;">
				 <table class="table table-bordered table-striped table-condensed table-hover" style="min-width:600px;">
	<thead>
		<tr>
			<th class="center">目前累積總點數</th>
			<th class="center">可用點數</th>
			<th class="center">已使用點數</th>
			<th class="center">剩餘點數(未結算)</th>
		  </tr>
	</thead>
	<tbody>
  <?php 
  $sky_point=0;
  do {  
   $diff_point=$row_Rt2['e_u']-$row_Rt2['e_o'];
   ?>
  <tr align="center">
    <td><?= $row_Rt2['e_i'];?></td> 
    <td><?= $row_Rt2['e_u'];?></td>
    <td><?= $row_Rt2['e_o'];?></td>
    <td><? 
	$sky_point +=$diff_point;
	echo $diff_point?></td>
    </tr>
    <?php } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); ?>
    <tbody>
</table>
			<? if($diff_point>0){?>
            <div class="form-group form-actions">
									<input type="button" name="Sub1" value="轉移 雲點數" class="btn btn-3d btn-black btn-md" onclick="location.href='sharepoint.html'">
				              
              </div>   				      
            <? }?>       
<div class="form-group form-actions">
									<input type="button" name="Sub2" value="更新 雲點數" class="btn btn-3d btn-black btn-md" onclick="renew_point();">
				              
              </div>   
              
                   </div>



					  </div>
					</div>
				</div><!--/col-->
			
			</div><!--/row-->

    
		</div>
		 
		<!-- end: Content -->
 <script type="text/javascript">
 function renew_point()
 {
 
   var pname=$('#pname').val();	
   $.ajax({
		method: "POST",
		url: "ajax_renew_point.php",
		data: {'MM_update': 'form1'}
		}).done(function( data ) {
 	      alert('OK..');
      });
 
  }
</script>     
 <?php
mysql_free_result($Rt2);
  
?>        
        