<div class="portlet box purple">
	<div class="modal-content">
		<div class="modal-header bg-red-sunglo">
			<button type="button" class="close" data-dismiss="modal"></button>
			<h4 class="modal-title font-white"><i class="fa fa-calendar-check-o"></i> 公設預約</h4>
		</div>
		<div class="modal-body">
			<div style="margin-bottom:10px;">
				<label class="label label-danger" style="font-size: 18px;">卡片持有人： <?php echo e($user_name->name); ?></label>
				<label class="label label-warning" style="font-size: 18px;margin-left: 5px;">門牌：<?php echo e($user_name->groupid); ?></label>
				<label class="label label-info" style="font-size: 18px;margin-left: 5px;">點數資訊：<?php echo e($point_type); ?></label>
			</div>
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>	
						<th>
							使用
						</th>						
						<th>
							公設名稱
						</th>
						<?php if($inst_type == "reservation"): ?>
						<th>
							開放時間
						</th>
						<?php endif; ?>
						<th>
							需求點數
						</th>
						<?php if($inst_type == "reservation"): ?>
						<th>
							時段最大人數
						</th>
						<?php endif; ?>
						<th>
							詳細
						</th>
					</tr>
				</thead>
				<tbody>
					<?php foreach($inst as $one): ?>
					<tr class="odd gradeX">
						<td>
							<?php if($inst_type == "reservation"): ?>
								<a href="javascript:;" class="btn btn-sm green btn_inst_time" uid="<?php echo e($one->id); ?>"> 預約 </a>
							<?php else: ?>
								<a href="javascript:;" class="btn btn-sm green btn_inst_time" uid="<?php echo e($one->id); ?>"> 進場 </a>
							<?php endif; ?>
						</td>
						<td>
							<?php echo e($one->name); ?>

						</td>
						<?php if($inst_type == "reservation"): ?>
						<td>
							<?php
								$str = array('0','一','二','三','四','五','六','日'); //日期陣列
								$showtxt = "";
								$time = explode(",",$one->time_section);
								//迴圈檢驗，判斷可以預約的時間
								for($i=1;$i<=7;$i++){
									$time_day = explode("=",$time[$i]);
									$open = explode("#",$time[$i]);
									$obj = $time_day[0];
									$op = $open[1];
									for($j=1;$j<=7;$j++){
										$obj_ = $time_day[0];
										if($obj == $obj_){
											if($op == 1){
												$showtxt = $showtxt.',週'.$str[$obj];
												break;
											}
										}else{
											break;
										}
									}
								}
								echo substr($showtxt,1,strlen($showtxt))."<br>"; //最後的星期日期顯示

								$timehour = explode(",", $one->each_section);
								$firsttime = explode("-",$timehour[0]);
								$lasttime = explode("-",array_pop($timehour));
								echo $firsttime[0] . "-" . $lasttime[1]; //開放的時段中最早與最晚
							?>
						</td>
						<?php endif; ?>
						<td>
							<?php
								if($one->point_use == 0){
									echo "不需點數";
								}else{
									if($inst_type == "reservation"){
										if($one->mooncard_point_use != null && $one->mooncard_point_use > 0){
											echo $one->point_use.',月卡'.$one->mooncard_point_use;
										}else{
											echo $one->point_use;
										}
									}else{
										echo $one->point_use;
									}
									
								}
							?>
						</td>
						<?php if($inst_type == "reservation"): ?>
						<td>
							<?php
								if($one->orders_one_section == 0){
									echo "無限制";
								}else{
									echo $one->orders_one_section;	
								}
							?>
						</td>
						<?php endif; ?>
						<td>
							<a href="javascript:;" class="btn btn-sm blue btn_inst_introduction" uid="<?php echo e($one->id); ?>"> 詳細資訊 </a>
						</td>
					</tr>
					<?php endforeach; ?>
				</tbody>
			</table>
			<input type="hidden" id="user_id" value="<?php echo e($user_id); ?>">
			<input type="hidden" id="inst_type" value="<?php echo e($inst_type); ?>">
			<input type="hidden" id="card_token" value=<?php echo e(csrf_token()); ?>>
			<input type="hidden" id="card_type" value="<?php echo e($card_type); ?>">
		</div>
		<div class="modal-footer">
			<button type="button" class="btn default" data-dismiss="modal"><?php echo app('translator')->get('messages.close'); ?></button>
		</div>
	</div>
</div>