<table id="inst_equipment_table" class="table table-striped table-bordered table-hover" >
	<thead>
		<tr>
			<th>
				 #
			</th>
			<th>
				 財產編號
			</th>
			<th>
				 設備名稱
			</th>
			<th>
				 保管人
			</th>
			<th>
				 放置位置
			</th>
			<th>
				 最後一次借用日期
			</th>
			<th>
				 最後一次借用人
			</th>
			<th>
				 已租借天數
			</th>
			<th>
				 狀態
			</th>
			<th>
				 動作
			</th>
		</tr>
	</thead>
	<tbody>
		<?php foreach($inst_equipments as $one): ?>
		<tr class="odd gradeX">
			<td>
				#<?php echo e($one->id); ?>

			</td>
			<td>
				<?php echo e($one->equipment_no); ?>

			</td>
			<td>
				<?php echo e($one->equipment_name); ?>

			</td>
			<td>
				<?php echo e($one->custodian_name); ?>

			</td>
			<td>
				<?php if($one->placement == '無'): ?>
					<?php echo e($one->meeting_room); ?>

				<?php else: ?>
					<?php echo e($one->placement); ?>

				<?php endif; ?>
			</td>
			<td>
				<?php echo e($one->borrowing_time); ?>

			</td>
			<td>
				<a href="javascript:;" class="btn_equipment_cost" value="<?php echo e($one->borrower); ?>"><?php echo e($one->borrower_name); ?></a>
			</td>
			<td>
				<?php
					if($one->borrowing_time != '' || $one->borrowing_time != null)
					{	
						$today_time = strtotime('now');
						$borrower = strtotime($one->borrowing_time);
						$hour = floor(($today_time - $borrower) / 3600);
						if($hour >= 24){
							echo "已租借超過 " . floor($hour / 24) . " 天";
						}else if($hour > 0){
							echo "已租借 " . $hour . " 小時";
						}else{
							echo "租借時間未滿一小時";
						}
					}
				?>
			</td>
			<td>
				<?php if($one->status == '0'): ?>
					<span class="label label-sm label-success"> 未借出 </span>
				<?php elseif($one->status == '1'): ?>
					<span class="label label-sm label-danger"> 借用中 </span>
				<?php endif; ?>
			</td>
			<td>
				<?php if($one->status == '1'): ?>
					<button id="btn_return_equipment_list" class="btn red" style="padding:0px;width:48px;height:23px;vertical-align:baseline;" uid="<?php echo e($one->id); ?>">歸還</button>
				<?php endif; ?>
			</td>
		</tr>
		<?php endforeach; ?>
	</tbody>
</table>


<script type="text/javascript">
	$(document).ready(function(){
		$('#inst_equipment_table').dataTable({
		// Internationalisation. For more info refer to http://datatables.net/manual/i18n
		"language": {
		    "aria": {
		        "sortAscending": ": activate to sort column ascending",
		        "sortDescending": ": activate to sort column descending"
		    },
		    "emptyTable": "No data available in table",
		    "info": "<?php echo app('translator')->get('messages.display_from'); ?> _START_ <?php echo app('translator')->get('messages.display_to'); ?> _END_ <?php echo app('translator')->get('messages.then_total'); ?> _TOTAL_ <?php echo app('translator')->get('messages.records'); ?>",
		    "infoEmpty": "<?php echo app('translator')->get('messages.no_match'); ?>",
		    "infoFiltered": "(filtered1 from _MAX_ total records)",
		    "lengthMenu": "<?php echo app('translator')->get('messages.display'); ?> _MENU_ <?php echo app('translator')->get('messages.records'); ?>",
		    "search": "<?php echo app('translator')->get('messages.quick_filter'); ?>:",
		    "zeroRecords": "<?php echo app('translator')->get('messages.no_data'); ?>",
		    "paginate": {
		        "previous":"<?php echo app('translator')->get('messages.last_page'); ?>",
		        "next": "<?php echo app('translator')->get('messages.next_page'); ?>",
		        "last": "<?php echo app('translator')->get('messages.lastest'); ?>",
		        "first": "<?php echo app('translator')->get('messages.most_previous'); ?>"
		    }
		},
		"aaSorting": [[1,'asc']],
		"lengthMenu": [
		    [10, 20, 50, -1],
		    [10, 20, 50, "All"] // change per page values here
		],
		// set the initial value
		"pageLength": 10,
		"pagingType": "bootstrap_full_number",
	});

	});
</script>