<div class="modal fade" id="modal-report33" tabindex="-1" role="dialog" aria-labelledby="myExtraLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="max-width: 70rem; ">
        <div class="modal-content">
          
            
            <div class="modal-header">
                <h5 class="modal-title">Add New</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="card mb-4">
<div class="card-body">
    <form action="" method="POST" id="validation-form" novalidate="novalidate" >
<div class="form-row align-items-center">
 
  
<div class="col-md-10">
      <label class="form-label">Description <span class="text-danger">*</span></label>
      <input type="text" name="Description" id="Description2" class="form-control" placeholder="Description" value="">
</div> 
    <input type="hidden" name="OldValue" id="OldValue2" value="">
 <input type="hidden" name="ModalValue" id="ModalValue2" value="">
 <input type="hidden" name="ValueId" id="ValueId2" value="">
 <input type="hidden" name="id" id="descid2" value="">
 <input type="hidden" name="action" id="DescAction2" value="Save">
<div class="col-md-2">
<label class="form-label d-none d-md-block">&nbsp;</label>
<button type="button" id="btn_search2" class="btn btn-primary btn-block" onclick="addDesc2()">Add</button>
</div>
</div>
</form>
</div>
</div>
 
<label class="nav-item navbar-text navbar-search-box p-0 active" style="float:right;">
                                <i class="feather icon-search navbar-icon align-middle"></i>
                                <span class="navbar-search-input pl-2">
                                  <input type="text" id="search_text2" class="form-control navbar-text mx-2" placeholder="Search..." oninput="searchRec2()">
                                </span>
                            </label><br><br>
 <style>

        table.scrolldown {
            width: 100%;
              
            /* border-collapse: collapse; */
            border-spacing: 0;
            /*border: 2px solid black;*/
        }
          
        /* To display the block as level element */
        table.scrolldown tbody, table.scrolldown thead {
            display: block;
        } 
          
       /* thead tr th {
            height: 40px; 
            line-height: 40px;
        }*/
          
        table.scrolldown tbody {
              
            /* Set the height of table body */
            height: 300px; 
              
            /* Set vertical scroll */
            overflow-y: auto;
              
            /* Hide the horizontal scroll */
            overflow-x: hidden; 
        }
    </style>                              
<div class="table-responsive" id="tableresult2">
                                            
</div>

<script type="text/javascript">
function showValue2(){
    var ValueId = $('#ValueId2').val();
    var CurrValue = $('#'+ValueId).val();
    var OldValue = $('#OldValue2').val();
     var ModalValue = $('#ModalValue2').val();
     
     $('#'+ValueId).val(OldValue);
     $('#modal-report33').modal("hide");
     
     if(CurrValue==""){
        $('#'+ValueId).val(OldValue);
        
     }
     else{
       var ConcatValue =  CurrValue+","+OldValue;
       //var ConcatValue = ConcatValue.substring(1);
       //var result = ConcatValue.substr(2);
        $('#'+ValueId).val(ConcatValue); 
     }
    

}
  function desc_lists_2(val){
  var action = 'view';
  var ModalValue = $('#ModalValue2').val();
      $.ajax({
  type: "POST",
  url: "ajax_files/ajax_descriptions2.php",
   data:{action:action,ModalValue:val},  
  success: function(data){
      $('#tableresult2').html(data);
      //desc_lists2(val);

  }
  });
    }

    function desc_lists2_2(val){
     var ValueId = $('#ValueId').val();   
  var action = 'view2';
  var ModalValue = $('#ModalValue').val();
      $.ajax({
  type: "POST",
  url: "ajax_files/ajax_descriptions2.php",
   data:{action:action,ModalValue:val},  
  success: function(data){
    //alert(data);
      $('.'+ValueId).html(data);
      
  }
  });
    }

function addDesc2(){
    var Description = $('#Description2').val();
    var ModalValue = $('#ModalValue2').val();
    var action = $('#DescAction2').val();
    var id = $('#descid2').val()
    if(Description.trim() == ''){
       alert("Please Enter Description");
        $('#Description2').focus();
    }
    else{
     $.ajax({
  type: "POST",
  url: "ajax_files/ajax_descriptions2.php",
   data:{action:action,Description:Description,ModalValue:ModalValue,id:id},  
   beforeSend:function(){
     $('#btn_search2').attr('disabled','disabled');
     $('#btn_search2').text('Please Wait...');
    },
  success: function(data){
    $('#Description2').val('');
    $('#descid2').val('');  
    $('#DescAction2').val('Save');
      desc_lists_2(ModalValue);
      desc_lists2_2(ModalValue);

      $('#btn_search2').attr('disabled',false);
      $('#btn_search2').text('Add');
  }
  });
 }
    }

 
  $(document).ready(function(){
  function load_data2(query)
 {
     var action = 'search';
    var ModalValue = $('#ModalValue2').val();
  $.ajax({
   url:"ajax_files/ajax_descriptions2.php",
   method:"POST",
   data:{query:query,action:action,ModalValue:ModalValue},
   success:function(data)
   {
    $('#tableresult2').html(data);
    
   }
  });
 }
 $('#search_text2').keyup(function(){
  var search = $(this).val();
  if(search != '')
  {
   load_data2(search);
  }
  else
  {
   load_data2();
  }
 });

 
   $(document).on("click", ".update", function(event){
 event.preventDefault();
 event.stopPropagation();
 var id = $(this).attr("data-id");
 var action = "fetch_record";
 $.ajax({  
                url:"ajax_files/ajax_descriptions2.php",  
                method:"POST",  
                data:{action:action,id:id},  
                dataType:"json",  
                success:function(data){  
                $('#Description2').val(data.Description);  
                $('#ModalValue2').val(data.Type);
                $('#descid2').val(id);  
                $('#DescAction2').val('Edit');
                $('#btn_search2').text("Update");   
                $('.modal-title').html("Update <span class='font-weight-light'>Description</span>"); 
                     
                }  
           });
});

   $(document).on("click", ".delete", function(event){
 event.preventDefault();
 var id = $(this).attr("data-id");
 var ModalValue = $('#ModalValue2').val();
 var action = "delete";
    if(confirm("Are you sure you want to delete This Record?"))  
        {
              $.ajax({
          type: "POST",
          url: "ajax_files/ajax_descriptions2.php",
           data:{action:action,id:id},  
           success: function(data){
            alert(data);
            desc_lists_2(ModalValue);
           }
        });
  }

           
 });
   
  });
</script>                
            </div>
        </div>
    </div>
</div>