<!----- setor.index -------->




<?php $__env->startSection('title'); ?>
	
	<tr><td width="80">SETORAN BANK &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo e(tanggal_indonesia(date('Y-m-d'),false)); ?></td>
    	&nbsp;&nbsp;&nbsp;
    	<?php if(Auth::user()->setor_add==1): ?>
    	<a onclick="addForm()" class="btn btn-success"><i class="fa fa-plus-circle"> </i> New Transaksi </a> 
    	<?php endif; ?>
<!--    	<a onclick="printSetor()" class="btn btn-warning"><i class="fa fa-print"> </i> Print Report </a> -->
 
	</tr>	
<?php $__env->stopSection(); ?>

<?php $__env->startSection('breadcrumb'); ?>
   ##parent-placeholder-6e5ce570b4af9c70279294e1a958333ab1037c86##
   <li>setoran</li>
<?php $__env->stopSection(); ?>

<!--
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">

	<meta name="viewport" content="width=device-width, initial-scale=1">
	
	<script src="<?php echo e(asset('public/adminLTE/plugins/jQuery/jquery-2.2.3.min.js')); ?>"></script>
	<script src="<?php echo e(asset('public/adminLTE/bootstrap/js/bootstrap.min.js')); ?>"></script> 
	<script src="<?php echo e(asset('public/adminLTE/plugins/datatables/jquery.dataTables.min.js')); ?>"></script>
	<script src="<?php echo e(asset('public/adminLTE/plugins/datatables/dataTables.bootstrap.min.js')); ?>"></script>
	
</head>
-->

<?php $__env->startSection('content'); ?>   
<div class="row">
	<div class="col-sm-12">
		<div class="box">
			<div class="box-body">  

<form method="post" id="form-setoran">
<?php echo e(csrf_field()); ?>


<input type="hidden" id="mgr" name ="mgr" value="<?php echo e(Auth::user()->group); ?>"> 
<input type="hidden" id="akses" name="akses" value="<?php echo e(Auth::user()->setor_add); ?>">

<table class="table table-striped table-padding table-bordered" id="tblsetoran" style="background: #DCDCDC;" width="100%">
<thead>
   <tr class="tblheader">
   
 	    <th width="10%">Tgl.Setor</th>
 	    <th width="15%">BANK</th>
        <th width="20%">DESKRIPSI</th>
        <th width="10%">Tgl.Terima</th>
	    <th width="10%">TL.SETOR</th>
	    <th width="10%">User</th>
	    <th width="10%">Slip</th>
        <th width="2%"></th> 	  
 
	</tr>
</thead>
<tbody></tbody>

</table>
</form>

			</div>
		</div>
	</div>	
</div>

<?php echo $__env->make('setor.setor_create', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php echo $__env->make('setor.image', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
<?php echo $__env->make('setor.slip', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
<script type="text/javascript">
var table, save_method, mgr,aks;

mgr = $('#mgr').val();
aks = $('#akses').val();

$(function(){
   table = $('#tblsetoran').DataTable({
     "processing" : true,
//     "iDisplayLength": 8,
     "lengthMenu": [[8, 25, 50, -1], [8, 25, 50, "All"]],       //pilihan jumlah record show
     "ajax" : {
       "url" : "<?php echo e(route('setor.header')); ?>",
       "type" : "GET"
     }
   }); 
   
	tblslip = $('.tabel-slip').DataTable({
	    "dom" : 'bt',
        "bSort" : false,
	    "retrieve" : true,	 
        "processing" : true
    });	
	
	$('#modal-slip').on('hidden.bs.modal', function(e) {
		table.ajax.reload();
	});   
   
//submit
	  //$(document).on("submit", function(e) {
      $('#modal-form_create').on("submit", function(e) {	      
      if(!e.isDefaultPrevented()){
		 
		 $('#submit-control').html(' Simpan Create ... ');
		 $('#submit-control').attr('disabled','disabled');
		  
         var id = $('#id').val();
         if(save_method == "add") url = "<?php echo e(route('setor.store')); ?>";
         else url = "setor/"+id;

         $.ajax({
           url : url,
           type : "POST",
           data : $('#modal-form_create form').serialize(),
           dataType: 'JSON',		   
           success : function(data){
				 if(data.msg=="error"){
					$('#submit-control').html('Save');
					$('#submit-control').removeAttr('disabled');
					swal("WARNING", " Gagal menyimpan data !","error");
					$('#cus').focus().select();
				 }else{
					$('#modal-form_create').modal('hide');
					swal("SUCCESS", " Setoran baru berhasil dicreate ! ","success");
					$('#submit-control').html('Save');
					$('#submit-control').removeAttr('disabled');					
					table.ajax.reload();
				 }   
 		   },
           error : function(){
             //alert("Tidak dapat menyimpan data!");
			 swal("WARNING"," DATA tidak dapat disimpan, harap hubungi IT !","error");
			 $('#submit-control').html('Save');
			 $('#submit-control').removeAttr('disabled');			 
           }   
         });
         return false;
	 }
   });
   
})  

/*-------------------------------------------------*/

function addForm(){
    
   save_method = "add";
   $('input[name=_method]').val('POST');
   $('#modal-form_create').modal('show');
   $('#modal-form_create form')[0].reset();            
   $('.modal-title').text('Setoran');

   $('#cus').removeAttr('disabled');
   $('#tipe').removeAttr('disabled');
   $('#tgltrm').removeAttr('disabled');
   
   if(mgr=="MANAGER")
   {
       $('#tgltrx').removeAttr('disabled');  
   }else{
       $('#tgltrx').removeAttr('disabled');  }
} 	 

function batal(id){
    
   if(confirm("  Apakah yakin SETORAN akan dibatalkan ?  ")){
     $.ajax({
       url : "<?php echo e(DIR_APP); ?>setor/"+id+"/batal",
       type : "GET",
       dataType : "JSON",
       success : function(data){
            //alert('berhasil dibatalkan ')
				 if(data.msg=="error"){
					swal("WARNING", " Setoran Gagal dibatalkan karena masih ada transaksi !","error");
				 }else{
					swal("SUCCESS", " Pembatalan berhasil ! ","success");
					table.ajax.reload();	
				 }
       },
           error : function(){
             //alert("Tidak dapat menyimpan data!");
			 swal("WARNING"," DATA tidak dapat disimpan, harap hubungi IT !","error");
			}   
         });
       return false;
	}
}

function editHeader(id){
    
    if(aks!=1){ alert(" Anda tidak punya Akses !"); return false; }
    
   save_method = "edit";

   $('input[name=_method]').val('PATCH');
   $('#modal-form_create form')[0].reset();
   $.ajax({
        
        url : "<?php echo e(DIR_APP); ?>setor/"+id+"/edit",
        type : "GET",
        dataType : "JSON",
        success : function(data){
           $('#modal-form_create').modal('show');
           $('.modal-title').text('Edit Setoran');
           
           $('#id').val(data.id_setor);
    	   
    	   $('#tgltrm').val(data.tgl_terima);
           $('#tgltrm').attr('disabled','disabled');
           $('#tgltrx').val(data.setor_tgl);
           $('#bank').val(data.setor_bank);
           $('#catat').val(data.deskripsi);
    	   
           if(mgr=="MANAGER")
           {
               $('#tgltrx').removeAttr('disabled');  
           }else{
               $('#tgltrx').attr('disabled', 'disabled');  }	   

        },
        error : function(){
            alert("Tidak dapat menampilkan data!");
        }
   });   
}


function uploadImage(id){

	$('#id2').val(id);
	$('#modal-image form')[0].reset();
    $('#modal-image').modal('show');

}

function showImage(id){
    
    $('#modal-slip').modal('show');
	
    tblslip.ajax.url("setor/"+id+"/slip");
	tblslip.ajax.reload();   
}

function removeImage(id){
	
	$.ajax({
		url : "/wawan/setor/"+id+"/removeimage",
		type : "GET",
		dataType : "JSON",
		success : function(data){    
			tblslip.ajax.reload();
			}
		});		

}

</script>

<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/myprojeq/public_html/wawan/resources/views/setor/index.blade.php ENDPATH**/ ?>