<!DOCTYPE html>
<html>
<head>
  @include('title')
 
  <!-- Bootstrap 3.3.7 -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/bootstrap/dist/css/bootstrap.min.css')}}">
  <!-- Font Awesome -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/font-awesome/css/font-awesome.min.css')}}">
  <!-- Ionicons -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/Ionicons/css/ionicons.min.css')}}">
  <!-- daterange picker -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/bootstrap-daterangepicker/daterangepicker.css')}}">
  <!-- bootstrap datepicker -->
<link rel="stylesheet" href="{{asset('lte/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css')}}">
  <!-- iCheck for checkboxes and radio inputs -->
  <link rel="stylesheet" href="{{asset('lte/plugins/iCheck/all.css')}}">
  <!-- Bootstrap Color Picker -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css')}}">
  <!-- Bootstrap time Picker -->
  <link rel="stylesheet" href="{{asset('lte/plugins/timepicker/bootstrap-timepicker.min.css')}}">
  <!-- Select2 -->
  <link rel="stylesheet" href="{{asset('lte/bower_components/select2/dist/css/select2.min.css')}}">
  <!-- Theme style -->
  <link rel="stylesheet" href="{{asset('lte/dist/css/AdminLTE.min.css')}}">
  <!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
  <link rel="stylesheet" href="{{asset('lte/dist/css/skins/_all-skins.min.css')}}">

  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
  <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->

  <!-- Google Font -->
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
  
</head>
<body class="hold-transition skin-blue fixed sidebar-mini">
<div class="wrapper">
  
  @include('headertag')
  <!-- Left side column. contains the logo and sidebar -->
  @include('leftside')
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
      <!-- Content Header (Page header) -->
      <section class="content-header">
        <h1>
          Update Notification
        </h1>
        <ol class="breadcrumb">
          <li><a href="{{route('notification.index')}}"><i class="fa fa-dashboard"></i>Notification</a></li>
         <li class="active"><a href="#">Update</a></li>
        </ol>
      </section>
      
      <!-- Main content -->
      <section class="content">
        
        <!-- Main row -->
        <div class="row">
          <!-- Left col -->
          <section class="col-lg-12 connectedSortable">
            <!-- Custom tabs (Charts with tabs)-->
            <div class="nav-tabs-custom">
              <!-- Tabs within a box -->
             
               <!-- right column -->
        
       <!-- Horizontal Form -->
             <div class="box box-info">
              <div class="box-header with-border">
                <div class="form-group">
                <div class="col-sm-6">
                <label style="margin-left: 11%;">Notification Type &nbsp;
                @if($notification->notification_type == 'G')
                  <input type="radio" name="notfn" class="minimal" value="G" checked> General
                @else
                   <input type="radio" name="notfn" class="minimal" value="P" checked=""> Product Wise
                @endif     
                </label>
                </div>
              </div>
                
              </div>
            <!-- /.box-header -->
            <!-- form start -->
            
             <form class="form-horizontal" action="{{route('notification.doupdate')}}" method="POST">
             <input type="hidden" name="_token" value="{{ csrf_token() }}">
             
              <div class="box-body">
               
              <input type="hidden" name="notification_id" id="notification_id" value="{{$notification->id}}">
              <input type="hidden" name="status" value="{{$notification->notification_type}}">
                @if($notification->notification_type == 'P')
                <div id="productWise" >
                <div class="form-group">
                  <label for="inputcategory" class="col-sm-2 control-label">Category<font color="red">*</font></label>
                    <div class="col-sm-4">
                    <select class="form-control unit" name="category" id="category">
                    <option value="">Select</option>
                    @foreach($categories as $category)
                    @if($productNot != NULL && $notCat->category_id == $category->id)
                    <option value="{{$category->id}}" selected="">{{$category->category}}</option>
                    @else
                    <option value="{{$category->id}}">{{$category->category}}</option>
                    @endif
                    @endforeach 
                  </select>
                  </div>
                </div>

                <div class="form-group">
                  <label for="inputcategory" class="col-sm-2 control-label">Product<font color="red">*</font></label>
                    <div class="col-sm-4">
                    <select class="form-control" name="product" id="product">
                    <option value="">Select</option>
                    @if($products != NULL )
                    @foreach($products as $product)
                    @if($productNot->product_id == $product->id)
                    <option value="{{$product->id}}" selected="">{{$product->name}}</option>
                    @else
                    <option value="{{$product->id}}">{{$product->name}}</option>
                     @endif
                    @endforeach
                    @endif
                  </select>
                  </div>
                </div>
                
                <div class="form-group">
                  <label for="inputcategory" class="col-sm-2 control-label">Unit<font color="red">*</font></label>
                    <div class="col-sm-4">
                     <select class="form-control unit" name="unit" id="unit">
                     <option value="0">Select</option>
                     @if($units != NULL )
                     @foreach($units as $unit)
                     @if($productNot->unit_id == $unit->id)
                     <option value="{{$unit->id}}" selected="">{{$unit->unit}}</option>
                     @else
                     <option value="{{$unit->id}}">{{$unit->unit}}</option>
                     @endif
                     @endforeach
                     @endif
                     </select>
                  </div>
                </div>
              

              <div class="form-group">
                  <label for="inputcategory" class="col-sm-2 control-label">Grade<font color="red">*</font></label>
                    <div class="col-sm-4">
                     <select class="form-control grade" name="grade" id="grade">
                     <option value="0">Select</option>
                     @if($grades != NULL )
                     @foreach($grades as $grade)
                     @if($productNot->grade_id == $grade->id)
                     <option value="{{$grade->id}}" selected="">{{$grade->grade}}</option>
                     @else
                     <option value="{{$grade->id}}">{{$grade->grade}}</option>
                     @endif
                     @endforeach
                     @endif
                     </select>
                  </div>
                </div>

                <div class="form-group">
                  <label for="inputcategory" class="col-sm-2 control-label">Packing<font color="red">*</font></label>
                    <div class="col-sm-4">
                     <select class="form-control packing" name="packing" id="packing">
                     <option value="">Select</option>
                     @if($standards != NULL)
                     @foreach($standards as $std)
                     @if($productNot->standard_id == $std->id)
                     <option value="{{$std->id}}" selected="">{{$std->standard}}</option>
                     @else
                     <option value="{{$std->id}}">{{$std->standard}}</option>
                     @endif
                     @endforeach
                     @endif
                     </select>
                  </div>
                </div>

                <div class="form-group">
                  <label for="inputcategory" class="col-sm-2 control-label">Offer Price<font color="red">*</font></label>
                    <div class="col-sm-4">
                    <input type="number" step="0.01" class="form-control" id="price" name="price" placeholder="Enter" value="{{$offer_price}}" >
                  </div>
                <!--    <label for="inputcategory" class="col-sm-2 control-label" style="margin-left: -8%;">Price Type</label>
                    <div class="col-sm-2">
                     <select class="form-control" name="price_type" id="price_type"  
                     style="margin-left: -5%;">
                     <option value="">Select</option>
                     <option value="Percentage(%)" @if($priceType == 'Percentage(%)') selected @endif>Percentage(%)</option>
                     <option value="OMR" @if($priceType == 'OMR') selected @endif>OMR</option>
                     </select>
                </div> -->
                </div>

                <div class="form-group" >
                  <label for="inputcategory" class="col-sm-2 control-label">Message</label>
                    <div class="col-sm-6">
                    <textarea id="message" name="message" rows="3" style="width: 65%;" >{{$message}}</textarea>
                  </div>
                </div>

               @endif

               @if($notification->notification_type == 'G')
                <div class="form-group" id="visibleType" >
                  <label for="inputcategory" class="col-sm-2 control-label">Message<font color="red">*</font></label>
                    <div class="col-sm-6">
                    <textarea id="message" name="message" rows="3" style="width: 65%;" >{{$notification->matter}}</textarea>
                  </div>
                </div>
               @endif

               <div class="form-group">
                  <label for="inputactive" class="col-sm-2 control-label">Type of Notification<font color="red">*</font></label>
                    <div class="col-sm-4">
                     <select class="form-control" name="offerType" id="offerType" required="">
                     <option value="">Select</option>
                     @foreach($offerType as $offer)
                     @if($notification->offer_type == $offer->id)
                     <option value="{{$offer->id}}" selected="">{{$offer->name}}</option>
                     @else
                     <option value="{{$offer->id}}">{{$offer->name}}</option>
                     @endif
                     @endforeach
                     </select>
                  </div>
                </div>

                 <div class="form-group">
                  <label for="inputactive" class="col-sm-2 control-label">Valid From<font color="red">*</font></label>
                    <div class="col-sm-4">
                   <div class="input-group date">
                    <div class="input-group-addon ">
                    <i class="fa fa-calendar"></i>
                  </div>
                  <input type="text" class="form-control datepicker" id="datepicker" name="validFrom" value="{{date('m/d/Y',strtotime($notification->valid_from))}}" placeholder="Choose Date">
                  </div>
                </div> 
                </div>

            
                 <div class="form-group">
                  <label for="inputactive" class="col-sm-2 control-label">Valid To<font color="red">*</font></label>
                  <div class="col-sm-4">
                   <div class="input-group date">
                    <div class="input-group-addon ">
                    <i class="fa fa-calendar"></i>
                  </div>
                  <input type="text" class="form-control datepicker" id="datepicker"  name="validTo" placeholder="Choose Date" value="{{date('m/d/Y',strtotime($notification->valid_to))}}">
                  </div>
                </div> 
                </div>

                

                 <div class="form-group">
                  <label for="inputactive" class="col-sm-2 control-label">Applied For</label>
                    <div class="col-sm-4">
                     <select class="form-control select2" name="apply[]" id="appliedfor" data-placeholder="ALL" multiple="multiple">
                     <option value="">ALL</option>
                     @foreach($customerType as $Type)
                     @if(in_array($Type->id,$notTypes))
                     <option value="{{$Type->id}}" selected="">{{$Type->name}}</option>
                     @else
                     <option value="{{$Type->id}}">{{$Type->name}}</option>
                     @endif
                     @endforeach
                     </select>
                  </div>
                </div>

              <!-- /.box-body -->
              <div class="box-footer">
                <button type="reset" class="btn btn-default pull-left">Refresh</button>
                <button type="submit" class="btn btn-info pull-left" style="margin-left: 8px;">Update</button>
              </div>
              <!-- /.box-footer -->
            </form>
          </div>
          <!-- /.box --> 
                
          </div>
          </div>
        
          
            <!-- /.nav-tabs-custom -->

            <!-- Chat box -->
            
            <!-- /.box (chat box) -->

            
            <!-- quick email widget -->
          </section>
          <!-- /.Left col -->
          
        </div>
        <!-- /.row (main row) -->

      </section>
      <!-- /.content -->
    </div>
  <!-- /.content-wrapper -->
  
  @include('footertag')

  <!-- Control Sidebar -->
  @include('rightside')
  <!-- /.control-sidebar -->

  <!-- Add the sidebar's background. This div must be placed
       immediately after the control sidebar -->
  <div class="control-sidebar-bg"></div>
</div>
<!-- ./wrapper -->

<!-- jQuery 3 -->
<script src="{{asset('lte/bower_components/jquery/dist/jquery.min.js')}}"></script>
<!-- Bootstrap 3.3.7 -->
<script src=".{{asset('lte/bower_components/bootstrap/dist/js/bootstrap.min.js')}}"></script>
<!-- Select2 -->
<script src="{{asset('lte/bower_components/select2/dist/js/select2.full.min.js')}}"></script>
<!-- InputMask -->
<script src="{{asset('lte/plugins/input-mask/jquery.inputmask.js')}}"></script>
<script src="{{asset('lte/plugins/input-mask/jquery.inputmask.date.extensions.js')}}"></script>
<script src="{{asset('lte/plugins/input-mask/jquery.inputmask.extensions.js')}}"></script>
<!-- date-range-picker -->
<script src="{{asset('lte/bower_components/moment/min/moment.min.js')}}"></script>
<script src="{{asset('lte/bower_components/bootstrap-daterangepicker/daterangepicker.js')}}"></script>
<!-- bootstrap datepicker -->
<script src="{{asset('lte/bower_components/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js')}}"></script>
<!-- bootstrap color picker -->
<script src="{{asset('lte/bower_components/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.min.js')}}"></script>
<!-- bootstrap time picker -->
<script src="{{asset('lte/plugins/timepicker/bootstrap-timepicker.min.js')}}"></script>
<!-- SlimScroll -->
<script src="{{asset('lte/bower_components/jquery-slimscroll/jquery.slimscroll.min.js')}}"></script>
<!-- iCheck 1.0.1 -->
<script src="{{asset('lte/plugins/iCheck/icheck.min.js')}}"></script>
<!-- FastClick -->
<script src="{{asset('lte/bower_components/fastclick/lib/fastclick.js')}}"></script>
<!-- AdminLTE App -->
<script src="{{asset('lte/dist/js/adminlte.min.js')}}"></script>
<!-- AdminLTE for demo purposes -->
<script src="{{asset('lte/dist/js/demo.js')}}"></script>
<!-- Page script -->

<script>
  $(function () {
    //Initialize Select2 Elements
    $('.select2').select2()

  })

</script>
<script type="text/javascript">
  $('.datepicker').datepicker({
      autoclose: true
    })
</script>

<script>

$(document).ready(function(){
    $(".minimal").on( "change", function() {
     
     if ($(this).val() == 'G') {
         $("#productWise").hide();
         $("status").val('P');
      }
     
     if ($(this).val() == 'P') {
        
       $("#productWise").show();
       $("status").val('G');
      
      }
    });
  }); 

$(document).ready(function(){
    $("#category").change(function(){
      
     var category = $("#category").val();
     $('#product').empty();
      $.get("{{ url('notification/list/product')}}", 
        { option: category }, 
          function(data) {

           $('#product').append("<option value='"+ 0 +"'>" + "Select" + "</option>");
          $.each(data, function(index, element) {
                  $('#product').append("<option value='"+ element.id +"'>"+element.name+"</option>");
              });
        });

    });
  }); 

$(document).ready(function(){
    $("#product").change(function(){
     
     var product = $("#product").val();
     $('#unit').empty();
     
      $.get("{{ url('notification/list/unit')}}", 
        { option: product }, 
          function(data) {

           $('#unit').append("<option value='"+ 0 +"'>" + "Select" + "</option>");
          $.each(data, function(index, element) {
                  $('#unit').append("<option value='"+ element.id +"'>"+element.unit+"</option>");
              });
        });

    });
  }); 

  $(document).ready(function(){
    $(".unit").change(function(){
     
     var unit = $("#unit").val();
     var product = $('#product').val();
     $('#grade').empty();
      
      $.get("{{ url('notification/list/grade')}}", 
        { option: unit , option1 :product}, 
          function(data) {

           $('#grade').append("<option value='"+ 0 +"'>" + "Select" + "</option>");
          $.each(data, function(index, element) {
                  $('#grade').append("<option value='"+ element.id +"'>"+element.grade+"</option>");
              });
        });

    });

    $(".grade").change(function(){
     
     var grade = $("#grade").val();
     var product = $('#product').val();
     $('#packing').empty();
      
      $.get("{{ url('notification/list/packing')}}", 
        { option: grade , option1 :product }, 
          function(data) {

           $('#packing').append("<option value='"+ 0 +"'>" + "Select" + "</option>");
          $.each(data, function(index, element) {
                  $('#packing').append("<option value='"+ element.id +"'>"+element.standard+"</option>");
              });
        });

    });
    
  }); 

</script>

</body>
</html>
