<!DOCTYPE html>
<?php $home = 'Master'; $nama = 'Fasilitas'; ?>
<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){}
				$(document).on("click", ".FasilitasButton", function () {
						var eventId = $(this).data('id');
					
						$('#myModal').modal('show');
						$("#idfasilitas").val(eventId);

				});	
					$(document).on("click", ".FasilitasEdit", function () {
						var eventId = $(this).data('id');
						
						$('#idHolder').html( eventId );
						$('#myModal2').modal('show');
						var str = eventId;
						var res = str.split("*");
						var idfasilitas = res[0];
						var idfile = res[1];
						var deskripsi = res[2];
						//$("#idedit").val(eventId);
						$("#idfasilitas1").val(idfasilitas);
						$("#idfile1").val(idfile);
						$("#deskripsi1").val(deskripsi);
				});					
			</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">Fasilitas</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>     				
					  <div class="widget-main">
						<?php 
						if($cek!=''){
							foreach($edit->result() as $row){
							$idfasilitas = $row->idfasilitas;
							$namafasilitas = $row->namafasilitas;
							$harga = $row->harga;
							$deskripsi = $row->deskripsi;
							$status = $row->status;
							$idkategori = $row->idkategori;
							$umum = $row->umum;
							$waktu = $row->waktu;
							$batasmax = $row->batasmax;
							}
						}
						$attribute = array('role' => 'form', 'class' => 'form-horizontal' );
						echo form_open(base_url().'admin/fasilitas/save', $attribute); 
						?>	
						<input type="hidden" id="form-field-1" name="act" value="<?php if($cek!=''){ echo 'edit' ; }else{ echo 'save'; }?>" class="form-control" required />
						<input type="hidden" id="form-field-1" name="idfasilitas" value="<?php if($cek!=''){ echo $idfasilitas; }else{ echo ''; }?>" class="form-control" />												
						  <div class="form-group">
							<label class="col-sm-1 control-label no-padding-right" for="form-field-1">Nama</label>
							<div class="col-sm-11">
							  <input type="text" id="form-field-1" name="namafasilitas"  value="<?php if($cek!=''){echo $namafasilitas; }?>" placeholder="Nama fasilitas"  class="form-control" required <?php if($cek!='') { if($namafasilitas=='Kamar / Asrama'){ echo 'readonly' ;} }?> />
							</div>
						  </div>	
						  <div class="form-group">
							<label class="col-sm-1 control-label no-padding-right" for="form-field-1">Harga</label>
							<div class="col-sm-11">
							  <input type="number" id="form-field-1" name="harga"  value="<?php if($cek!=''){echo $harga; }?>" placeholder="Harga"  class="form-control" required />
							</div>
						  </div>
						  <div class="form-group">
							<label class="col-sm-1 control-label no-padding-right" for="form-field-1">Batas Maksimal</label>
							<div class="col-sm-11">
							  <input type="number" id="form-field-1" name="batasmax" min="1" value="<?php if($cek!=''){echo $batasmax; }?>" placeholder="Batas Maksimal"  class="form-control" required />
							</div>
						  </div>						  
						  <div class="form-group">
							<label class="col-sm-1 control-label no-padding-right" for="form-field-1">Kategori</label>
							<div class="col-sm-11">
								  <select class="form-control" name="idkategori" required>								  
									<option value="">Pilih Kategori</option>
									<?php
									foreach($kategori->result() as $row2){ ?>
									<option value="<?php echo $row2->idkategori;?>" <?php if($row2->idkategori==$idkategori){ echo 'selected' ;}?>><?php echo $row2->namakategori;?></option>
									<?php }?>
								  </select>						
							</div>
						  </div>						  
						  <div class="form-group">
							<label class="col-sm-1 control-label no-padding-right" for="form-field-1">Deskripsi</label>
							<div class="col-sm-11">
							<textarea name="deskripsi"  rows="6" class="ckeditor"   tabindex="4" placeholder="judul" required><?php if($cek!=''){echo $deskripsi; }?></textarea>
							</div>
							</div>
						  <div class="form-group">
							<label class="col-sm-1 control-label no-padding-right" for="form-field-1">Waktu</label>
							<div class="col-sm-11">
							  <label class="radio-inline"><input type="radio" name="waktu" <?php if($cek!='' AND $waktu=='0'){echo 'checked'; }?> value="0">Siang</label>
							  <label class="radio-inline"><input type="radio" name="waktu" <?php if($cek!='' AND $waktu=='1'){echo 'checked'; }?> value="1">Malam</label>
							  <label class="radio-inline"><input type="radio" name="waktu" <?php if($cek!='' AND $waktu=='2'){echo 'checked'; }?> value="2">FullDay</label>
							</div>
						  </div>							
						  <div class="form-group">
							<label class="col-sm-1 control-label no-padding-right" for="form-field-1">Aktif</label>
							<div class="col-sm-11">
							  <label class="radio-inline"><input type="radio" name="status" <?php if($cek!='' AND $status=='1'){echo 'checked'; }?> value="1">Ya</label>
							  <label class="radio-inline"><input type="radio" name="status" <?php if($cek!='' AND $status=='0'){echo 'checked'; }?> value="0">Tidak</label>
							</div>
						  </div>		
						  <div class="form-group">
							<label class="col-sm-1 control-label no-padding-right" for="form-field-1">Umum</label>
							<div class="col-sm-11">
							  <label class="radio-inline"><input type="radio" name="umum" <?php if($cek!='' AND $umum=='1'){echo 'checked'; }?> value="1">Ya</label>
							  <label class="radio-inline"><input type="radio" name="umum" <?php if($cek!='' AND $umum=='0'){echo 'checked'; }?> value="0">Tidak</label>
							</div>
						  </div>							  
						  <div class="form-group">
							<label class="col-sm-1 control-label no-padding-right" for="form-field-1">
							</label>
							<div class="col-sm-11">
							<button type="submit" class="btn btn-primary btn-sm" name="button" value="button"  tabindex="1">simpan</button>
							<button type="submit" class="btn btn-success btn-sm" name="kembali" value="kembali"  tabindex="1" formnovalidate >kembali</button>														
							</div>
						  </div>
						<?php echo form_close();?>
					  </div>		
					<?php if($cek!=''){ ?>
					<div class="table-header">
						Upload Gambar Fasilitas					
					</div>     				
					  <div class="widget-main ">
						<div class="col-md-offset-1">
							<button type="button" class="btn btn-success btn-sm FasilitasButton" data-id="<?php echo $idfasilitas;?>"  data-dismiss="modal" title="Detail">
							  Upload
							</button>
						</div>					  
						<ul class="ace-thumbnails clearfix" style="margin-left:8.2%">
							<?php if($cek!=''){ 
							foreach($fileupload->result() as $row){ 
							?>
								<li>
									<a href="#" title="<?php echo $row->filename;?>" data-rel="colorbox">
										<img width="150" height="150" alt="150x150" src="<?php echo base_url().'images/'.$row->filename;?>" />
									</a>
									<div class="tools">
										<a href="#" class="FasilitasEdit" data-toggle="modal" data-id="<?php echo $idfasilitas.'*'.$row->idfile.'*'.$row->deskripsi;?>"  data-dismiss="modal" title="Detail" >
											<i class="ace-icon fa fa-pencil" title="edit" ></i>
										</a>
										<a href="<?php echo base_url().'admin/fasilitas/delimage/'.$idfasilitas.'/'.$row->idfile;?>"   onclick="return confirm(' Apakah anda yakin akan menghapus gambar <?php echo $row->filename;?> ?')">
											<i class="ace-icon fa fa-times red" title="hapus"></i>
										</a>
									</div>
								</li>
							<?php }}?>	
						</ul>
					  			  
					</div>
					<?php }?>
					</div>
				  </div>
				</div>
				<!-- /.span -->
			  </div>
			  <!-- /.main-content -->
			</div>
		<!-- Modal -->
			<div id="myModal" class="modal fade" role="dialog">
			  <div class="modal-dialog">
				<!-- Modal content-->
				<div class="modal-content">
				  <div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">&times;</button>
					<h4 class="modal-title">Upload</h4>
				  </div>
				  <div class="modal-body">
					<?php 
					$attribute = array('role' => 'form', 'class' => 'form-horizontal','enctype'=>'multipart/form-data');
					echo form_open(base_url().'admin/fasilitas/upload', $attribute); 
					?>		
					<br />
					<input type="hidden" id="idfasilitas" name="idfasilitas" />
					  <div class="form-group">
						<label class="col-sm-2 control-label no-padding-right" for="form-field-1">Nama</label>
						<div class="col-sm-10">
						  <input type="text" name="deskripsi"   placeholder="deskripsi"  class="form-control" required />
						</div>
					  </div>					
 					  <div class="form-group">
						<label class="col-sm-2 control-label no-padding-right" for="form-field-1">Upload</label>
						<div class="col-sm-10">
							<input type="file" name="input_gambar"  class="form-control"  accept="image/*"   style="width:100%;border: 1px solid #ccc;display: inline-block;padding: 6px 12px; cursor: pointer;" required>	  
						
						</div>
					  </div>	
					  <div class="form-group">
						<label class="col-sm-2 control-label no-padding-right" for="form-field-1">
						</label>
						<div class="col-sm-10">
						<button type="submit" class="btn btn-primary btn-sm btn-block" name="simpan" value="simpan"  tabindex="1">simpan</button>													
						</div>
					  </div>
					 <?php
					echo form_close();?>
				  </div>
				  <div class="modal-footer">
					<button type="button" class="btn btn-default btn-sm "  data-dismiss="modal">Close</button>
				  </div>
				</div>
			  </div>
			</div>		
			<div id="myModal2" class="modal fade" role="dialog">
			  <div class="modal-dialog">
				<!-- Modal content-->
				<div class="modal-content">
				  <div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">&times;</button>
					<h4 class="modal-title">Upload</h4>
				  </div>
				  <div class="modal-body">
					<?php 
					$attribute = array('role' => 'form', 'class' => 'form-horizontal','enctype'=>'multipart/form-data');
					echo form_open(base_url().'admin/fasilitas/upload', $attribute); 
					?>		
					<br />
					<input type="hidden" id="idfasilitas1" name="idfasilitas" />
					<input type="hidden" id="idfile1" name="idfile" />
					  <div class="form-group">
						<label class="col-sm-2 control-label no-padding-right" for="form-field-1">Nama</label>
						<div class="col-sm-10">
						  <input type="text" id="deskripsi1" name="deskripsi"   placeholder="deskripsi"  class="form-control" required />
						</div>
					  </div>					
 					  <div class="form-group">
						<label class="col-sm-2 control-label no-padding-right" for="form-field-1">Upload</label>
						<div class="col-sm-10">
							<input type="file" name="input_gambar"  class="form-control"  accept="image/*"   style="width:100%;border: 1px solid #ccc;display: inline-block;padding: 6px 12px; cursor: pointer;" required>	  
							<p class="help">Disarankan : width:1302px, height : 873</p>
						</div>
					  </div>	
					  <div class="form-group">
						<label class="col-sm-2 control-label no-padding-right" for="form-field-1">
						</label>
						<div class="col-sm-10">
						<button type="submit" class="btn btn-primary btn-sm btn-block" name="simpan" value="simpan"  tabindex="1">simpan</button>													
						</div>
					  </div>
					 <?php
					echo form_close();?>
				  </div>
				  <div class="modal-footer">
					<button type="button" class="btn btn-default btn-sm "  data-dismiss="modal">Close</button>
				  </div>
				</div>
			  </div>
			</div>			
		<!-- ckeditor-->
		<script src="<?php echo base_url();?>assets_v2/ckeditor/ckeditor.js"></script>					
			<?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>