<head>
    <style>
        #tblpenjualan th, tr, td {
            border-bottom:1px black solid; border-top:1px black solid;
        }        
    </style>
</head>



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

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


<?php $__env->startSection('content'); ?>   
<div class="row">
	<div class="container-fluid">
		<div class="card">
			<div class="card-block">  
			
<!--h6>History Penjualan</h6-->			

<div class="row">
    <div class="col-sm-8 col-md-8">
        <div class="form-group">
     		<div class="col-md-6">
    		    <label>Tgl. Awal</label>
    			<input id="awal" type="date" class="form-control" name="awal" value="<?php echo e($tglawal); ?>" autofocus required>
    		</div>
    		<div class="col-md-6">
    		    <label>Tgl. Akhir</label>
    			<input id="akhir" type="date" class="form-control" name="akhir" value="<?php echo e($tglakhir); ?>" autofocus required>
    		</div>
        </div>
    </div>
    <div class="col-sm-4 col-md-4">
        <div class="col-md-12 text-center">	
        	<br>
    		<button type="button" class="btn btn-primary btn-sm" onclick="viewHistory()"><i class="fa fa-table"></i> View History </button>
    		<a href="<?php echo e(route('home')); ?>" class="btn btn-warning btn-sm"><i class="fa fa-home"></i> Home </a>
            <br>
    	</div>        
    </dvi>
</div>    	
  
<table class="table table-padding table-striped table-responsive" id="tblhistory" width="100%">
<thead>
   <tr class="tblheader">
   
        <th width="100px">No.Faktur</th>
        <th width="20">GDG</th>
        <th width="50px">Tgl.Faktur</th>
        <th width="50px">Jt.Tempo</th>
        <th width="150px">Customer</th>
        <th width="80px">Sales</th>
        <th width="15px">Disc</th>
        <th width="15px">PPN</th>
        <th width="70px">Total</th>
        <th width="25px">LNS</th>
        <th width="10px"></th>
 
	</tr>
</thead>
<tbody></tbody>

</table>


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

<?php echo $__env->make('sales.form_detail', \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;

viewHistory();

function viewHistory(){
    
    var tg1=$('#awal').val();
    var tg2=$('#akhir').val();


    $(function(){
        table = $('.table').DataTable({
            "processing" : true,
            "lengthMenu": [[8, 25, 50, -1], [8, 25, 50, "All"]],       //pilihan jumlah record show
            "order" : [0,'DESC'],
            "destroy": true,
            "ajax" : {
                "url" : "<?php echo e(DIR_APP); ?>sales/"+tg1+"/"+tg2+"/datahistory",
                "type" : "GET",
            }
        }); 
    });   

}

function showDetail(id){

   $('#form-detail').modal('show');
   $('#form-detail form')[0].reset();   
   tampilHeader(id);
   tampilDetail(id);
   loadSummary();
}

function tampilHeader(id){
    $('#idsale').val(id);
    $('#idsale2').val(id);    
    $.ajax({
        url : "<?php echo e(DIR_APP); ?>sales/"+id+"/edit",
        type : "GET",
        dataType : "JSON",
        success : function(data){

            $('#cust').text(data.cus_name+" - "+data.cus_address);
            $('#nofaktur').text("NO.Faktur: "+data.sale_no);
            $('#keterangan').text("Disc Faktur: "+data.sale_disc+"%"+'\xa0\xa0\xa0\xa0\xa0\xa0\xa0'+"PPN: "+data.sale_ppn+"%");
            $('#btndetail').addClass('hide');
            $('#btnposting').addClass('hide');
	    },
        error : function(){
            alert("Tidak dapat menampilkan data!");
        }
    });   
}

function loadSummary(){
    
    var id=$('#idsale').val();
    
    $.ajax({
        url : "<?php echo e(DIR_APP); ?>sales/"+id+"/loadsummary",
        type : "GET",
        dataType : "JSON",
        success : function(data){

            $('#totalftr').text("Total incl PPN : \xa0\xa0\xa0"+data.totalftr);

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

    tbdetail = $('#tbldetail').DataTable({
        "scrollY": '55vh',
        "scrollCollapse": true,
        "bSort": false,
        "destroy": true,
        "processing" : true,
	    "paging" : false,
	    "dom" : 'bti',
    });
    
function tampilDetail(id){

    tbdetail.ajax.url("<?php echo e(DIR_APP); ?>sales/"+id+"/datadetail");
	tbdetail.ajax.reload();
}    

function tampil_Detail(id){
    tbldetail = $('#tbldetail').DataTable({
        "processing" : true,
        "lengthMenu": [[8, 25, 50, -1], [8, 25, 50, "All"]],       //pilihan jumlah record show
        "ajax" : {
            "url" : "<?php echo e(DIR_APP); ?>sales/"+id+"/datadetail",
            "type" : "GET"
        }
    });     
}


function printFaktur(){
    var id = $('#idsale').val();
    window.location="<?php echo e(DIR_APP); ?>sales/"+id+"/printfaktur";
}


function printDO(){
    $('#modal-form_do').modal('show');
    $('#modal-form_do form')[0].reset();            
    //$('.modal-title').text('Print DO Keluar');
}

</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/sriayu/resources/views/sales/history.blade.php ENDPATH**/ ?>