<div class="footer">
        <div class="footerNav"> </div>
        <div class="copyright"> © Copyright 2017, Orbis. All Rights Reserved </div>
</div>
<div id="lightboxPopup" class="modal fade lightboxCost lightboxPopup" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <div class="modal-content">
            <div class="modal-body">
           
            <form id="add_costcenter2">
            <div class="ajax_msg"></div>
            <div class="row lighboxInner">
                <div class="col-lg-12 img_src">
                    
                </div>
            </div>
            
             <div class="row lighboxInner">
                <div class="col-lg-12 modal_text">
                    <p>r</p>
                </div>
            </div>
            
             <div class="add_more_fields"></div>
 
           
           </form>
            </div>
        </div>
    </div>
</div>


<!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> 
<script src="<?= base_url(); ?>js/jquery-1.11.2.min.js"></script>
<script src="<?= base_url(); ?>js/jquery.validate.min.js"></script>
<script src="<?= base_url(); ?>js/jquery.dataTables.min.js"></script>

<script src="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.10.15/js/dataTables.material.min.js"></script>

<!-- Include all compiled plugins (below), or include individual files as needed --> 
<script src="<?= base_url(); ?>js/bootstrap.js"></script>
<script src="<?= base_url(); ?>js/common.js"></script>
<script src="<?= base_url(); ?>js/material-kit.js"></script>
<script src="<?= base_url(); ?>js/material.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
  <script>
  $( function() {
    $.widget( "custom.combobox", {
      _create: function() {
        this.wrapper = $( "<span>" )
          .addClass( "custom-combobox" )
          .insertAfter( this.element );
 
        this.element.hide();
        this._createAutocomplete();
        this._createShowAllButton();
      },
 
      _createAutocomplete: function() {
        var selected = this.element.children( ":selected" ),
          value = selected.val() ? selected.text() : "";
 
        this.input = $( "<input>" )
          .appendTo( this.wrapper )
          .val( value )
          .attr( "title", "" )
          .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left" )
          .autocomplete({
            delay: 0,
            minLength: 0,
            source: $.proxy( this, "_source" )
          })
          .tooltip({
            classes: {
              "ui-tooltip": "ui-state-highlight"
            }
          });
 
        this._on( this.input, {
          autocompleteselect: function( event, ui ) {
            ui.item.option.selected = true;
            this._trigger( "select", event, {
              item: ui.item.option
            });
          },
 
          autocompletechange: "_removeIfInvalid"
        });
      },
 
      _createShowAllButton: function() {
        var input = this.input,
          wasOpen = false;
 
        $( "<a>" )
          .attr( "tabIndex", -1 )
          .attr( "title", "Show All Items" )
          .tooltip()
          .appendTo( this.wrapper )
          .button({
            icons: {
              primary: "ui-icon-triangle-1-s"
            },
            text: false
          })
          .removeClass( "ui-corner-all" )
          .addClass( "custom-combobox-toggle ui-corner-right" )
          .on( "mousedown", function() {
            wasOpen = input.autocomplete( "widget" ).is( ":visible" );
          })
          .on( "click", function() {
            input.trigger( "focus" );
 
            // Close if already visible
            if ( wasOpen ) {
              return;
            }
 
            // Pass empty string as value to search for, displaying all results
            input.autocomplete( "search", "" );
          });
      },
 
      _source: function( request, response ) {
        var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
        response( this.element.children( "option" ).map(function() {
          var text = $( this ).text();
          if ( this.value && ( !request.term || matcher.test(text) ) )
            return {
              label: text,
              value: text,
              option: this
            };
        }) );
      },
 
      _removeIfInvalid: function( event, ui ) {
 
        // Selected an item, nothing to do
        if ( ui.item ) {
          return;
        }
 
        // Search for a match (case-insensitive)
        var value = this.input.val(),
          valueLowerCase = value.toLowerCase(),
          valid = false;
        this.element.children( "option" ).each(function() {
          if ( $( this ).text().toLowerCase() === valueLowerCase ) {
            this.selected = valid = true;
            return false;
          }
        });
 
        // Found a match, nothing to do
        if ( valid ) {
          return;
        }
 
        // Remove invalid value
        this.input
          .val( " " )
          .attr( "title", value + " didn't match any item" )
          .tooltip( "open" );
        this.element.val( "" );
        this._delay(function() {
          this.input.tooltip( "close" ).attr( "title", "" );
        }, 2500 );
        this.input.autocomplete( "instance" ).term = "";
      },
 
      _destroy: function() {
        this.wrapper.remove();
        this.element.show();
      }
    });
 
    $( ".combobox" ).combobox();
    $( ".toggle" ).on( "click", function() {
      $( ".combobox" ).toggle();
    });
  } );
  </script>

<script type="text/javascript">
	$(document).ready(function() {

      var table=$('#example').DataTable({
        "order": [[ 2, "desc" ]]
      });
	  
	  $(".costcenter").combobox({ 
        select: function (event, ui) { 
		
		     $('.contractfiltersubmit').submit();
        } 
      });
	  
	  $(".costcenteroffice").combobox({ 
        select: function (event, ui) {
			$.ajax({
				  url: "<?php echo base_url()."index.php/office/get_contract_area/" ?>"+$(this).val(),
                  dataType: "json",				  
				  success: function(result){
					    $(".contractareaoffice option").remove();
						$.each(result, function(i, item) {
							 $('.contractareaoffice').append(new Option(item.contractarea_name,item.contractarea_id));
						});
                  }
			  });
              
        } 
      });
	  
	  $('.contractareaoffice').combobox({ 
	     select: function (event, ui) {
			 if($(this).val()!="Select Contract Area") {
				 
				  $('.office').submit();
			 }
			
		 }
	  });
	  
	  $(".costcenterlwd").combobox({ 
        select: function (event, ui) {
			$.ajax({
				  url: "<?php echo base_url()."index.php/office/get_contract_area/" ?>"+$(this).val(),
                  dataType: "json",				  
				  success: function(result){
						$.each(result, function(i, item) {
							 $('.contractarealwd').append(new Option(item.contractarea_name,item.contractarea_id));
						});
                  }
			  });
              
        } 
      });
	  
	  $(".contractarealwd").combobox({ 
	      select: function (event, ui) {
			  $.ajax({
				  url: "<?php echo base_url()."index.php/lwd/get_office/" ?>"+$(this).val(),
                  dataType: "json",				  
				  success: function(result){
					    
						$.each(result, function(i, item) {
							 $('.officelwd').append(new Option(item.office_name,item.office_id));
						});
                  }
			  });
			  
		  }
	  });
	  
	  $('.costcenterpopup').change(function(){
		    if($(this).val()!="") {
				  $.ajax({
						  url: "<?php echo base_url()."index.php/office/get_contract_area/" ?>"+$(this).val(),
						  dataType: "json",				  
						  success: function(result){
								$.each(result, function(i, item) {
									 //$('.contractareapopup').append(new Option(item.contractarea_name,item.contractarea_id));
									$('.contractareapopup').append('<option value="'+item.contractarea_id+'">'+item.contractarea_name+'</option>');
								});
						  }
					  });
			}else{
				 $('#restpartpopup').css('display','none');
			}
	  });
	  
	  $('.contractareapopup').on('change', function() {
		  if($(this).val()!="") {
				 $.ajax({
						  url: "<?php echo base_url()."index.php/lwd/get_office/" ?>"+$(this).val(),
						  dataType: "json",				  
						  success: function(result){
								
								$.each(result, function(i, item) {
									 //$('.officelwd').append(new Option(item.office_name,item.office_id));
									 $('.officepopup').append('<option value="'+item.office_id+'">'+item.office_name+'</option>');
								});
						  }
					  });
		  }else{
			  $('#restpartpopup').css('display','none');
		  }
	  });
	  
	  $('.officepopup').on('change', function() {
		  if($(this).val()!="") {
			  $('#restpartpopup').css('display','block');
		  }else{
			  $('#restpartpopup').css('display','none');
		  }
		  
		  
	  });
	  
	  
	  $(".contractarealwd").combobox({ 
	      select: function (event, ui) {
			  $.ajax({
				  url: "<?php echo base_url()."index.php/lwd/get_office/" ?>"+$(this).val(),
                  dataType: "json",				  
				  success: function(result){
					    
						$.each(result, function(i, item) {
							 $('.officelwd').append(new Option(item.office_name,item.office_id));
						});
                  }
			  });
			  
		  }
	  });
	  
	  $('.officelwd').combobox({ 
	     select: function (event, ui) {
			
			 if($('.costcenterlwd').val()!="Select Cost Center" &&  $('.contractarealwd').val()!="Select Contract Area") {
				 
				  $('.lwd').submit();
			 }
			
		 }
	  });
	  
	  
	$('.burgerMenu').click( function() {
		$(".leftSide").toggle("slide");
		$(".leftSide").toggleClass("active");
	});
	
	$('.cancelButton').click( function() {
		$(".leftSide").toggle("slide");
		$(".leftSide").toggleClass("active");	
	});
	
	
	$('.dropdownList1').on('click', function() {
		 $('.dropdownList1 .listInner1').toggleClass("collapse1"); 
		 if( $('.clickArrow2').is(':hidden') )
         {
            $('.clickArrow2').css('display', 'inline-block');
            $('.clickArrow1').css('display', 'none'); 
         }
         else
         {
            $('.clickArrow1').css('display', 'inline-block');
            $('.clickArrow2').css('display', 'none');  
         }
	});
	
	$('.dropdownList2').on('click', function() {
		 $('.dropdownList2 .listInner2').toggleClass("collapse1"); 
		 if( $('.clickArrow4').is(':hidden') )
         {
            $('.clickArrow4').css('display', 'inline-block');
            $('.clickArrow3').css('display', 'none'); 
         }
         else
         {
            $('.clickArrow3').css('display', 'inline-block');
            $('.clickArrow4').css('display', 'none');  
         }
	});
	
	$('.dropdownList3').on('click', function() {
		 $('.dropdownList3 .listInner3').toggleClass("collapse1"); 
		 if( $('.clickArrow6').is(':hidden') )
         {
            $('.clickArrow6').css('display', 'inline-block');
            $('.clickArrow5').css('display', 'none'); 
         }
         else
         {
            $('.clickArrow5').css('display', 'inline-block');
            $('.clickArrow6').css('display', 'none');  
         }
	});
	
	$(window).load(function() {
		$("#example_length .form-control").addClass("combobox");	
	});
	
	var height=$(".dashboard").height();
			$(".leftSide").css('height',height);
			$(".rightSide").css('height',height);
			
	});
</script>
</body>
</html>
