<!DOCTYPE html>
<?php $admin = 'Master'; $nama = 'Client';?>
<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", ".UploadButton", function () {
						var eventId = $(this).data('id');					
						$('#myModal').modal('show');
						$("#idlist").val(eventId);
				});		
					$(document).on("click", ".UploadButtonEdit", function () {
						var eventId = $(this).data('id');						
						$('#idHolder').html( eventId );
						$('#myModal2').modal('show');
						var str = eventId;
						var res = str.split("*");
						var idlist = res[0];
						var namalist = res[1];
					    var deskripsi = res[2];
						var namafile = res[3];
						var idfile = res[4];
						var status = res[5];

						//$("#idedit").val(eventId);
						$("#idlist1").val(idlist);
						$("#namalist1").val(namalist);
						$("#deskripsi1").val(deskripsi);
						$("#namafile").val(namafile);
						$("#idfile").val(idfile);
						$("#status1").val(status);
						if(status ==1){
						$("#status1").prop('checked', true);
						}
						if(status ==0){
						$("#status1").prop('checked', false);						
						}						
				});
				$(document).on("click", ".GambarButton", function () {
						var eventId = $(this).data('id');					
						$('#myModal3').modal('show');
						//$("#gambar").val(eventId);
						//var myImageId = $(this).data('id');
						$("#gambar").attr("src", eventId);
				});					
			</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="clearfix">
					<button type="button" class="btn btn-success btn-sm UploadButton" data-id="slide"  data-dismiss="modal" title="Detail">
					  Tambah Data
					</button>
					</div>					
				  <div class="widget-box">
					<div class="widget-body">										
					<div class="table-header">
						<?php echo $admin.' <i class="ace-icon fa fa-angle-double-right"></i> '.$nama; ?>
					</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="60%" style="text-align: center;">Nama</th>								
								<th width="10%" style="text-align: center;">Gambar</th>								
								<th width="10%" style="text-align: center;">Aktif</th>								
								<th width="10%" style="text-align: center;">Aksi</th>								
							</tr>
						</thead>
						<tbody>		
						<?php $no=0; foreach($client->result() as $row){ $no++;?>
							<tr>		
								<?php $attribute = array('role' => 'form', 'class' => 'form-horizontal' );
								echo form_open(base_url().'admin/client/edit', $attribute); ?>								
								<td align="center"><input type="hidden" name="id" value="<?php echo $row->idlist;?>"><?php echo $no;?></td>							
								<td align="left"><?php echo $row->namalist;?></td>
								<td align="center"><button  type="button" style="padding: 0px 0px;border: none;" class="GambarButton" data-id="<?php  echo base_url().'images/'.$row->filename;?>"  data-dismiss="modal" > <img src="<?php echo base_url().'images/'.$row->filename;?>" style="width:50px;height:50px"></button></td>
								<td align="center"><?php if($row->status=='1'){ echo '<span class="label label-info arrowed-right arrowed-in">Ya</span>' ;}else{ echo '<span class="label label-danger arrowed-right arrowed-in">Tidak</span>' ; }?></td>								
								<td align="center">
									<button  type="button"  class="btn-primary UploadButtonEdit" data-id="<?php echo cetak($row->idlist.'*'.$row->namalist.'*'.$row->deskripsi.'*'.$row->filename.'*'.$row->idfile.'*'.$row->status);?>"  data-dismiss="modal" title="Detail"><i class="ace-icon fa fa-pencil "></i> </button>				
									<a href="<?php echo base_url().'admin/client/delimage/'.$row->idlist .'/'.$row->idfile;?>"><button  type="button" name="hapus" value="hapus" class="btn-danger"  onclick="return confirm(' Apakah anda yakin akan menghapus data <?php echo $row->namalist;?> ?')">
									<i class="ace-icon fa fa-trash-o "></i></button>	</a></td>
								<?php echo form_close();?>	
							</tr>
						<?php }?>	
						</tbody>
					</table>						
					</div>
				  </div>
				</div>
				<!-- /.span -->
			  </div>
			  <!-- /.main-content -->
			</div>
			
			<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/client/upload', $attribute); 
					?>		
					<br />
					<input type="hidden" id="idlist" name="idlist" />
					<input type="hidden"  name="act" value="save" />
					<input type="hidden" id="deskripsi" name="deskripsi"   />
					  <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="namalist"   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">Status</label>
						<div class="col-sm-10">
							  <label class="radio-inline"><input type="radio" name="status" id="status1" value="1">Ya</label>
							  <label class="radio-inline"><input type="radio" name="status" id="status1" value="0">Tidak</label>						 
						</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/client/upload', $attribute); 
					?>		
					<br />
					<input type="hidden" id="idlist1" name="idlist" />
					<input type="hidden" id="idfile" name="idfile" />
					<input type="hidden"  name="act" value="edit" />		
					<input type="hidden" id="deskripsi1" name="deskripsi"   />
					  <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="namalist1" name="namalist"   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;" >	  	
						</div>
					  </div>	
					  <div class="form-group">
						<label class="col-sm-2 control-label no-padding-right" for="form-field-1">Status</label>
						<div class="col-sm-10">
							  <label class="radio-inline"><input type="radio" name="status" id="status1" value="1">Ya</label>
							  <label class="radio-inline"><input type="radio" name="status" id="status1" value="0">Tidak</label>						 
						</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="myModal3" 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>
				  </div>
				  <div class="modal-body">
						<img id="gambar" style="width:100%;height:30%">
				  </div>
				  <div class="modal-footer">
					<button type="button" class="btn btn-default btn-sm "  data-dismiss="modal">Close</button>
				  </div>
				</div>
			  </div>
			</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>