@extends('layouts.app')

@section('title')
	Edit Master harga 
@endsection

@section('breadcrumb')
   @parent
   <li>price</li>
@endsection

<head>

	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
 
	<script src="{{ asset('public/adminLTE/plugins/jQuery/jquery-2.2.3.min.js') }}"></script>
	<script src="{{ asset('public/adminLTE/bootstrap/js/bootstrap.min.js') }}"></script> 
	<script src="{{ asset('public/adminLTE/plugins/datatables/jquery.dataTables.min.js') }}"></script>
	<script src="{{ asset('public/adminLTE/plugins/datatables/dataTables.bootstrap.min.js') }}"></script>
	<script type="text/javascript" src="public/adminLTE/dist/css/sweetalert.min.js"></script>

</head>

@section('content')     

<div class="row">
  <div class="col-xs-12">
    <div class="box">
<!--
 <form class="form form-horizontal" id="modal-form" data-toggle="validator" method="post" enctype="multipart/form-data">
   {{ csrf_field() }} {{ method_field('POST') }}
   <div class="box-body">
-->
   
    <form class="form-horizontal" data-toggle="validator" method="post" id="modal-form">
   {{ csrf_field() }} {{ method_field('PATCH') }}
   
<!-- <div class="modal-body"> -->
   
   <input type="hidden" id="id" name="id" value="{{ $idprice }}">
   
   <div class="form-group">
      <label for="kode" class="col-sm-3 control-label">SKU </label>
      <div class="col-sm-2">
         <input id="kode" type="text" class="form-control" name="kode" value="{{ $skuprice }}" readonly="true">
      </div>
   </div>

   <div class="form-group">
      <label for="nama" class="col-sm-3 control-label">NAMA BARANG</label>
      <div class="col-sm-8">
         <input id="nama" type="text" class="form-control" name="nama" value="{{ $nmbarang }}" readonly="true">
      </div>
   </div>

 
   <div class="form-group">
      <label for="harga1" class="col-md-3 control-label">PRICE - ZONA 01</label>
      <div class="col-md-4">
         <input id="harga1" type="number" class="form-control" name="harga1" autocomplete="off" value="{{ $prc1 }}" autofocus required>
      </div>
   </div>

   <div class="form-group">
      <label for="harga2" class="col-md-3 control-label">PRICE - ZONA 02</label>
      <div class="col-md-4">
         <input id="harga2" type="number" class="form-control" name="harga2" autocomplete="off" value="{{ $prc2 }}" autofocus required>
      </div>
   </div>

   <div class="form-group">
      <label for="harga3" class="col-md-3 control-label">PRICE - ZONA 03</label>
      <div class="col-md-4">
         <input id="harga3" type="number" class="form-control" name="harga3" autocomplete="off" value="{{ $prc3 }}" autofocus required>
      </div>
   </div>

   <div class="form-group">
      <label for="harga4" class="col-md-3 control-label">PRICE - ZONA 04</label>
      <div class="col-md-4">
         <input id="harga4" type="number" class="form-control" name="harga4" autocomplete="off" value="{{ $prc4 }}" autofocus required>
      </div>
   </div>

   <div class="form-group">
      <label for="harga5" class="col-md-3 control-label">PRICE - ZONA 05</label>
      <div class="col-md-4">
         <input id="harga5" type="number" class="form-control" name="harga5" autocomplete="off" value="{{ $prc5 }}" autofocus required>
      </div>
   </div>

   <div class="form-group">
      <label for="harga6" class="col-md-3 control-label">PRICE - ZONA 06</label>
      <div class="col-md-4">
         <input id="harga6" type="number" class="form-control" name="harga6" autocomplete="off" value="{{ $prc6 }}" autofocus required>
      </div>
   </div>

   <div class="form-group">
      <label for="harga7" class="col-md-3 control-label">PRICE - ZONA 07</label>
      <div class="col-md-4">
         <input id="harga7" type="number" class="form-control" name="harga7" autocomplete="off" value="{{ $prc7 }}" autofocus required>
      </div>
   </div>

   <div class="form-group">
      <label for="harga8" class="col-md-3 control-label">PRICE - ZONA 08</label>
      <div class="col-md-4">
         <input id="harga8" type="number" class="form-control" name="harga8" autocomplete="off" value="{{ $prc8 }}" autofocus required>
      </div>
   </div>   

   <div class="form-group">
      <label for="harga9" class="col-md-3 control-label">PRICE - ZONA 09</label>
      <div class="col-md-4">
         <input id="harga9" type="number" class="form-control" name="harga9" autocomplete="off" value="{{ $prc9 }}" autofocus required>
      </div>
   </div>

<!-- </div> -->		<!-- body -->
   
   <div class="modal-footer">
      <button type="submit" class="btn btn-primary btn-save"><i class="fa fa-floppy-o"></i> Save </button> 
   	  <button type="button" class="btn btn-warning pull-right" onclick="window.history.back()"><i class="fa fa-times-circle"></i> Close </button> 	  
   </div>
      
   </form>

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


@endsection

@section('script')
<script type="text/javascript">
$(function(){
    
   $('.form').validator().on('submit', function(e){
      if(!e.isDefaultPrevented()){ 
		var id = $('#id').val();
         $.ajax({
           url  : "price/"+id+"/simpan",
		   //url  : "update",
           type : "POST",
           data : $('#modal-form form').serialize(),
           dataType: 'JSON',		   
           //data : new FormData($(".form")[0]),
           //async: false,
           //processData: false,
           //contentType: false,
           success : function(data){
			   $('#modal-form').modal('hide');
				//swal("SUCCESS", " Master Harga berhasil disimpan ! ","success");
                //table.ajax.reload();
             //$('.alert').css('display', 'block').delay(2000).fadeOut();
           },
           error : function(){
			 //swal("WARNING", " Gagal menyimpan data !","error");
             alert("Tidak dapat menyimpan data!");
			// $('#harga1').focus().select();
           }   
         });
         return false;
     }
   });

});


</script>
@endsection