<!DOCTYPE html>
<html>


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

	<!--
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
	
	<script type="text/javascript" src="/wawan/public/adminLTE/dist/css/sweetalert.min.js"></script>
	-->
	
	<style>
		    #tbl-prdsup th,tr,td { border-bottom: 1px black solid;}
		    
			.tbl_stn {
			    position:absolute;
				top: 110px;
				left: 240px;
				width: 355px;
				height: 520px;
			    //border: 1px solid #543535;
			}				

			.tbl_kms {
			    position:absolute;
				top: 110px;
				right: 10px;
				width: 730px;
				height: 520px;
				//border: 1px solid #543535;
			}	
			
			.wrap {
			  width: 50%;
			  display: inline-block;
			  margin: 10px;
			}
			
		
			.tblheader {
				background: #2F4F4F;
				color: white;
				font-size: 15px;
				alignment: center;
			}

	</style>


</head>

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

<!------------------>

<?php $__env->startSection('content'); ?>
<div class="row">
    
<form class="form-horizontal" data-toggle="validator" method="post" id="form-stock">
<?php echo e(csrf_field()); ?> <?php echo e(method_field('POST')); ?>

    
    <div class="container-fluid">
        <div class="card">
            <div class="card-block">
                
    <div class="row">
        <div class="form-group col-sm-5 col-md-5" style="margin-left:5px;margin-right:5px;margin-bottom:-0px">
            <label>Supplier</label>
            <select type="text" id="sup" name="sup" autofoucs class="form-control">
                <option value="">Pilih Supplier</option>
                <?php $__currentLoopData = $sup; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $list): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <option value="<?php echo e($list->id); ?>"><?php echo e($list->sup_nama); ?></option>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </select>
        </div>        
    </div>
            
    <table class="table table-striped table-padding" id="tbl-prdsup" width="100%">
        <thead>
            <tr class="tblheader">
                <th>Deskripsi</th>
                <th>SATUAN</th>
        	    <th width="70">HARGA</th>
                <th>Act</th> 	  
         	</tr>
        </thead>
        
        <tbody></tbody>	 
    
    </table>
    
            </div>
        </div>
    </div>
</form>

</div>

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

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


<!-------------------------------->

<?php $__env->startSection('script'); ?>

<script type="text/javascript">
var table, tbl_prd, save_method;
    

function showProduct(){
    
    var id=$('#sup').val();
    
	jQuery(document).ready(function($){
	table = $('#tbl-prdsup').DataTable({
        "processing" : true,
        "lengthMenu": [[8, 25, 50, -1], [8, 25, 50, "All"]],
	    "destroy" : true,
	    //"dom" : 'bftip',	 
        "ajax" : {
            "url" : "<?php echo e(DIR_APP); ?>supplier/"+id+"/listprice",
            "type" : "GET"
            }
        });
    });
}

$('#sup').on('change', function(){
    showProduct();
})

function editproduct(id){
    save_method = "edit";
    $('input[name=_method]').val('PATCH');
    $.ajax({
        url : "<?php echo e(DIR_APP); ?>supplier/"+id+"/editlist",
        type : "GET",
        dataType : "JSON",
        success : function(data){
            
            $('#modal-form_edit').modal('show');
            $('#modal-form_edit form')[0].reset();

            $('#id').val(data.id);

            $('#nama').val(data.nama_brg);
            $('#stn').val(data.satuan);
            $('#isi').val(data.isi);
	        $('#harga').val(data.harga);

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

$('#form-editlist').validator().on('submit', function(e){
    if(!e.isDefaultPrevented()){
	    $('#submit-control').html(' data sedang disimpan ... ');
	    $('#submit-control').attr('disabled','disabled');		  
		 
        var id = $('#id').val();
        url = "<?php echo e(DIR_APP); ?>supplier/"+id+"/simpaneditlist";
         
        $.ajax({
            url : url,
            type : "GET",
            dataType: "JSON",
            data : $('#form-editlist').serialize(),
            success : function(data){
             
                if(data.msg =="error"){  
                    swal("WARNING", " Data gagal disimpan ! ","error"); 
                }else{
                    //swal("SUCCESS", " Supplier berhasil disimpan ! ","success");
    			    $('#submit-control').html('<i class="fa fa-floppy-o"></i> Save');
    			    $('#submit-control').removeAttr('disabled');	
                    $('#modal-form_edit').modal('hide');
                    $('#tbl-prdsup').DataTable().ajax.reload(null, false);
                }
            },
          
            error : function(){
                $('#submit-control').html('<i class="fa fa-floppy-o"></i> Save');
			    $('#submit-control').removeAttr('disabled');
                alert("Tidak dapat menyimpan data!");
            }   
        });
        return false;
    }
});

</script>

<?php $__env->stopSection(); ?>
</html>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/u345793601/domains/my-projeq.com/public_html/swa/resources/views/supplier/productsup.blade.php ENDPATH**/ ?>