<!DOCTYPE html>
<?php $home = 'Master'; $nama = 'Sewa';?>
<html lang="en">
<?php include("layout/meta.php");?>
	<body class="no-skin">
	<?php include("layout/navbar.php");?>
		<div class="main-container ace-save-state" id="main-container">
			<script type="text/javascript">
				try{ace.settings.loadState('main-container')}catch(e){}
			</script>
			<?php include("layout/sidebar.php");?>
			<div class="main-content">
			  <div class="main-content-inner">
				<div class="col-xs-12">
				<?php if(!empty($pesan)){ ?>
				<div class="alert alert-<?php echo $alert;?>" role="alert" style="text-align:center;">
				 <strong><?php echo validation_errors(); echo $pesan ;?></strong>
				</div><?php }?>					
					<h3 class="header smaller lighter blue"><?php echo $nama;?></h3>					
				  <div class="widget-box">
					<div class="widget-body">										
					<div class="table-header">
						<?php echo $home.' <i class="ace-icon fa fa-angle-double-right"></i> '.$nama; ?>
						<div class="col-md-2 pull-right">
						<?php $attribute = array('role' => 'form', 'class' => 'form-horizontal' );
						echo form_open(base_url().'admin/pesan/status', $attribute); ?>	
						  <div class="form-group">
							<select name="status" class="form-control pull-right" style="height:39px;    background-color: #3A87AD;color:white" onchange='this.form.submit()'>
							  <option>Pilih Status</option>
							  <option value="0" <?php if($status_pilih=='0'){ echo 'selected';}?>>Baru</option>
							  <option value="1" <?php if($status_pilih=='1'){ echo 'selected';}?>>Diterima</option>
							  <option value="2" <?php if($status_pilih=='2'){ echo 'selected';}?>>Ditolak</option>
							</select>
						  </div>
						  <?php echo form_close();?>
							</div>						  
					</div>     			

					<table id="tabel-data" class="table table-striped table-bordered  table-hover" width="100%" cellspacing="0">
						<thead>
							<tr>
								<th width="5%" style="text-align: center;">No</th>							
								<th width="5%" style="text-align: center;">No. Reg</th>							
								<th width="15%" style="text-align: center;">Pemakai</th>							
								<th width="10%" style="text-align: center;">Hp. Pemesan</th>																			
								<th width="10%" style="text-align: center;">Tgl. Pesan</th>							
								<th width="10%" style="text-align: center;">Tgl. Pakai</th>							
								<th width="5%" style="text-align: center;">Waktu</th>														
								<th width="10%" style="text-align: center;">Status</th>														
								<th width="10%" style="text-align: center;">Aksi</th>								
							</tr> 
						</thead>
						<tbody>		
						<?php $no=0; foreach($tampilpesan->result() as $row){ $no++;  $tglsekarang = date('d');?>
							<tr>		
								<?php $attribute = array('role' => 'form', 'class' => 'form-horizontal' );
								echo form_open(base_url().'admin/pesan/cek', $attribute); ?>								
								<td align="center"><input type="hidden" name="idpesan" value="<?php echo $row->idpesan;?>"><?php echo $no;?></td>							
								<td align="center"><?php echo $row->idpesan;?></td>
								<td align="left"><?php echo $row->namapemakai;?></td>
								<td align="left"><?php echo $row->hppesan;?></td>
								<td align="center"><?php echo date('d/F/Y H:i', strtotime($row->tglpesan)); ?><span class="label label-info arrowed-right arrowed-in"><?php   $jttempo = date('d', strtotime('+3 days', strtotime( $row->tglpesan )));  $jthari = date('d'); if($row->status==0 OR $row->status==2){ echo $jttempo - $jthari;}?></span></td>
								<td align="center"><?php echo date('d/F/Y', strtotime($row->tglpakai)); ;?></td>
								<td align="center"><?php  if($row->siangmalam==0){ echo 'Siang';}  if($row->siangmalam==1){ echo 'Malam';}  if($row->siangmalam==2){ echo 'Full Day';}?></td>
								<td align="center">
								<?php							
								if($row->status=='0'){ echo '<span class="label label-info arrowed-right arrowed-in">Baru</span>';} ;
								if($row->status=='1'){ echo '<span class="label label-success arrowed-in arrowed-in-right">Diterima</span>';} ;
								if($row->status=='2'){ echo '<span class="label label-danger arrowed">Ditolak</span>';} ;	
								if($row->disetujui=='1'){ echo '<span class="label label-primay arrowed-in arrowed-in-right">Disetujui</span>';} ;
								if($row->disetujui=='0'){ echo '<span class="label label-danger arrowed-in arrowed-in-right">Belum</span>';} ;
								//pembayaran
								if($row->statusdp=='0'){ echo '<span class="label label-info arrowed-right arrowed-in">Bayar:DP</span>';} ;
								if($row->statusdp=='1'){ echo '<span class="label label-success arrowed-in arrowed-in-right">Bayar:LUNAS</span>';} ;								
								?>	
								</td>
								<td align="center">	

										<div class="inline dropdown-hover">

									  <button class="btn btn-minier dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
										Pilih Aksi
									  </button>										
										<ul class="dropdown-menu dropdown-menu-right dropdown-125 dropdown-lighter dropdown-close dropdown-caret">
										<li class="active">
											<a href="#">
											<i class="ace-icon fa fa-caret-right bigger-110 invisible">&nbsp;</i>
											<button class="dropdown-item" type="submit" name="detail" value="detail" style="padding: 0;border: none;background: none;width:100%;text-align:left">Detail</button>
											</a>
										</li>
										<?php if($status_pilih==2){?>
										<li class="">
											<a href="<?php echo base_url().'/admin/pesan/hapuspesan/'.$row->idpesan;?>">
											<i class="ace-icon fa fa-caret-right bigger-110 invisible">&nbsp;</i>
											<button class="dropdown-item" type="button" name="detail" value="detail" style="padding: 0;border: none;background: none;width:100%;text-align:left"  onclick="return confirm('Yakin Akan Hapus data <?php echo $row->idpesan.' '.$row->namapemakai;?>')">Hapus</button>
											</a>
										</li>
										<?php }?>										
										<!--										
										<li >
											<a href="#">
											<i class="ace-icon fa fa-caret-right bigger-110 invisible">&nbsp;</i>
											<button class="dropdown-item" type="submit" name="button" value="button" style="padding: 0;border: none;background: none;width:100%;text-align:left">Baru</button>
											</a>
										</li>
										<li>
										<a href="#">
										<i class="ace-icon fa fa-caret-right bigger-110 invisible">&nbsp;</i>
										<button class="dropdown-item" type="submit" name="button1" value="button1" style="padding: 0;border: none;background: none;width:100%;text-align:left">Diterima</button>
										</a>
										</li>
										<li>
										<a href="#">
										<i class="ace-icon fa fa-caret-right bigger-110 invisible">&nbsp;</i>
										<button class="dropdown-item" type="submit" name="button2" value="button2" style="padding: 0;border: none;background: none;width:100%;text-align:left">Ditolak</button>
										</a>
										</li>
										<li>
										</li>-->
										</ul>
										</div>
										<?php if($row->disetujui=='1'){ ?>
										<button type="submit" name="lunas" value="lunas" class="success" style="background-color: #349467;color:white">Lunas</button>
										<?php }?>
								</td>
								<?php echo form_close();?>	
							</tr>
						<?php }?>	
						</tbody>
					</table>						
					</div>
				  </div>
				</div>
				<!-- /.span -->
			  </div>
			  <!-- /.main-content -->
			</div>
			<?php include("layout/footer.php");?>
			<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
				<i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
			</a>
		</div><!-- /.main-container -->
		<!-- basic scripts -->
			<?php include("layout/sc_footer.php");?>
	</body>
</html>