<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?><!DOCTYPE html>
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  
  <title><?php echo $this->company;?> - <?php echo strtolower($this->whname);?> warehouse area</title>
  <base href="<?php echo base_url();?>" />
  <!-- <link rel="manifest" href="manifest.json"> //-->
    
  <!-- Stylesheets -->
  <link rel="stylesheet" href="assets/css/style.css">
  <link rel="stylesheet" href="assets/css/bootstrap.min.css"/>
  <link rel="stylesheet" href="assets/css/font-awesome.min.css"/>
  <link rel="stylesheet" href="assets/css/owl.carousel.min.css"/>
  <link rel="stylesheet" href="assets/css/nice-select.css"/>
  <link rel="stylesheet" href="assets/css/magnific-popup.css"/>
  <link rel="stylesheet" href="assets/css/slicknav.min.css"/>
  <link rel="stylesheet" href="assets/css/animate.css"/>
    
  <link rel="icon" href="favicon.ico" type="image/x-icon">
  <link rel="apple-touch-icon" href="images/logo.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="theme-color" content="white">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-title" content="Web App">
  <meta name="msapplication-TileImage" content="images/logo.png">
  <meta name="msapplication-TileColor" content="#FFFFFF">
  <?php
	if($main_content=="products" || $main_content=="manageproducts" || $main_content=="productsprice"  || $main_content=="purchase"   || $main_content=="managepurchase" || $main_content=="stockstatus" || $main_content=="outletsstock" || $main_content=="managestocktransfer" || $main_content=="managewstocktransfer" || $main_content=="managepurchase" || $main_content=="managewbilling" || $main_content=="itemledger" || $main_content=="wbillingreport" || $main_content=="itemwisebilling" || $main_content=="purchasereport" || $main_content=="itemwisepurchase" || $main_content=="wbilling" || $main_content=="itemtotalreport" || $main_content=="itemtotalpurchase" || $main_content=="stocktransfer" || $main_content=="stockreceivedfromoutlet")
	{
  ?>
<link rel="stylesheet" href="assets/css/select2.min.css"/>
  <?php
	}
  ?>
   <?php
	if($main_content=="managepages")
	{
  ?>
  <script type="text/javascript" src="assets/ckeditor/ckeditor/ckeditor.js"></script>
  <script type="text/javascript" src="assets/ckeditor/ckfinder/ckfinder.js"></script>
  <?php
	}
  ?>
  
  <!-- Add jQuery library -->
  <script type="text/javascript" src="assets/js/jquery-1.10.2.min.js"></script>

	<!-- Add fancyBox main JS and CSS files -->
	<script type="text/javascript" src="assets/js/jquery.fancybox.pack.js?v=2.1.5"></script>
	<link rel="stylesheet" type="text/css" href="assets/css/jquery.fancybox.css?v=2.1.5" media="screen" />
	<script type="text/javascript">
		$(document).ready(function() {
			$('.fancybox').fancybox();
			
			$("#fancybox-manual-b").click(function() {
				$.fancybox.open({
					type : 'iframe',
					padding : 0
				});
			});
			$('.fancybox2-reloadparent').fancybox(
			{
				type: 'iframe',
				afterClose: function () { // USE THIS IT IS YOUR ANSWER THE KEY WORD IS "afterClose"
				parent.location.reload(true);
				}
			});
		});
	</script>
	
	<script type="text/javascript" src="assets/warehouse/js/common_function.js"></script>
  
</head>

<body class="m-0">
    <!-- Header Section -->
    <?php
    if($main_content=="productsprice") // for 100% width
    {
    ?>
  <div class="container_fluid mr-0 p-0">
     <div class="m-auto">
        <div class="header-info border-dark">
          <div class="row">
            <div class="col-md-6 d-sm-block col-sm-4"><a href="warehouse/dashboard" class="d-block mt-2"><?php echo ADMLOGOTITLE;?> </a></div>
        	<div class="p-0 d-sm-none d-flex ml-auto">
                <span class="usrnam ml-0 pt-3">Welcome <?php echo $this->lguserinfo["sessName"];?>! ( <?php echo $this->lguserinfo["sessWHName"];?> Warehouse Manager)</span><a href="warehouse/logout" class="topright-bx" title="Logout"><span class="fa fa-power-off btn"></span></a>
             </div>
          </div>
        </div>
      </div>
     <?php
	}
	else
	{
     ?>
  <div class="container mr-0 p-0">    
     <div class="m-auto">
        <div class="header-info border-dark">
	        <a href="warehouse/dashboard" class="d-block d-sm-block d-md-none mt-2"><?php echo ADMLOGOTITLE;?></a>
        	 <div class="p-0 d-sm-none d-flex ml-auto">
                <span class="usrnam ml-0 pt-3">Welcome <?php echo $this->lguserinfo["sessName"];?>! ( <?php echo $this->lguserinfo["sessWHName"];?> Warehouse Manager)</span><a href="warehouse/logout" class="topright-bx" title="Logout"><span class="fa fa-power-off btn"></span></a>
             </div>
              <input type="checkbox" class="openSidebarMenu" id="openSidebarMenu">
              <label for="openSidebarMenu" class="sidebarIconToggle">
                <div class="spinner diagonal part-1"></div>
                <div class="spinner horizontal"></div>
                <div class="spinner diagonal part-2"></div>
              </label>
              <div id="sidebarMenu">
                <ul class="sidebarMenuInner">
                  <li class="logo d-sm-none border-bottom bg-light border-dark"><a href="warehouse/dashboard"><h4 class="mb-0 mt-1"><?php echo ADMLOGOTITLE;?> </h4></a></li>	              
	              <li><span class="material-icons">list</span><a href="warehouse/brand">Manage Brand </a></li>
                  <li><span class="material-icons">list</span><a href="warehouse/products">Manage Products</a></li>
                  <li><span class="material-icons">list</span><a href="warehouse/productsprice">Manage Products Price</a></li>
				  <li><span class="material-icons">list</span><a href="warehouse/vendors">Manage Vendors </a></li>
				  <li><span class="material-icons">list</span><a href="warehouse/purchase">Manage Purchase </a></li>
				  <li><span class="material-icons">list</span><a href="warehouse/saleclients">Manage Clients </a></li>
				  <li><span class="material-icons">list</span><a href="warehouse/wbilling">Manage Warehouse Billing </a></li>
	              <li><span class="material-icons">list</span><a href="warehouse/wstocktransfer">Stock Transfer To Warehouse </a></li>
	              <li><span class="material-icons">list</span><a href="warehouse/stocktransfer">Stock Transfer To Outlet </a></li>
	              <li><span class="material-icons">list</span><a href="warehouse/stockreceivedfromoutlet">Stock Received From Outlet </a></li>
	              <li><span class="material-icons">list</span><a href="warehouse/stockstatus">Stock Status </a></li>
	              <li><span class="material-icons">list</span><a href="warehouse/itemledger">Item Ledger </a></li>
	              <!--<li><span class="material-icons">list</span><a href="warehouse/outletsstock">Outlets Status </a></li>

	              <li><span class="material-icons">list</span><a href="warehouse/wdemands">Demand To Company </a></li>
	              <li><span class="material-icons">list</span><a href="warehouse/odemands">Outlets Demands </a></li>//-->

                  <li><span class="material-icons">manage_accounts</span><a href="warehouse/updateinfo">Update Info.</a></li>
                  <li><span class="material-icons">password</span><a href="warehouse/changepass">Change Password</a></li>
                  <li><span class="material-icons">logout</span><a href="warehouse/logout">Logout</a></li>
                </ul>
              </div>
        </div>
      </div>
      <?php
	}
      ?>
        <?php $this->load->view("warehouse/" . $main_content); ?>
        
        <div class="clearfix">&nbsp;</div>
      <footer>
    	© <?php echo date("Y");?>, <?php echo WEBNAME;?>
    </footer>
	</div>
    <div class="clearfix"></div>
	
    <!-- <script src="js/main.js"></script> //-->
<?php
	if($this->router->fetch_method()=="report" || $this->router->fetch_method()=="orders" || $main_content=="storders"|| $main_content=="stockstatus"  || $main_content=="outletsstock" || $main_content=="billing" || $main_content=="purchase" || $main_content=="stocktransfer" || $main_content=="customers"  || $main_content=="wdemands" || $main_content=="odemands" || $main_content=="managestocktransfer" || $main_content=="managewstocktransfer" || $main_content=="stockreceivedfromoutlet" || $main_content=="wbilling" || $main_content=="wstocktransfer" || $main_content=="itemledger" || $main_content=="wbillingreport" || $main_content=="itemwisebilling" || $main_content=="purchasereport" || $main_content=="itemwisepurchase" || $main_content=="wbilling" || $main_content=="itemtotalreport" || $main_content=="itemtotalpurchase" || $main_content=="stocktransfer" || $main_content=="stockreceivedfromoutlet") // include date for specific criteria
	{
?>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
    <script>
  	// INCLUDE JQUERY & JQUERY UI 1.12.1
		$( function() {
			$( ".datepicker" ).datepicker({
				dateFormat: "dd-mm-yy",
				maxDate: "<?php echo date("d-m-Y");?>",
				duration: "fast"
			});
			$( ".datepickerfuture" ).datepicker({
				dateFormat: "dd-mm-yy",
				minDate: "<?php echo date("d-m-Y");?>",
				duration: "fast"
			});
		} );
		
	/*$(document).ready(function() {
    $('.js-example-basic-single').select2();
});*/
    $(document).ready(function() {
        function customMatcher(params, data) {
            if ($.trim(params.term) === '') {
                return data;
            }

            // Split the search term by spaces
            const searchTerms = params.term.toUpperCase().split(" ");
            // Split the option text by spaces
            const optionWords = data.text.toUpperCase().split(" ");

            // Check if any part of the search term matches the beginning of any word in the option text
            for (let i = 0; i < searchTerms.length; i++) {
                let matched = false;
                for (let j = 0; j < optionWords.length; j++) {
                    if (optionWords[j].startsWith(searchTerms[i])) {
                        matched = true;
                        break;
                    }
                }
                if (!matched) return null;
            }

            return data;
        }

        $('.js-example-basic-single').select2({
            matcher: customMatcher
        });
    });
    </script>
    <script src="assets/js/select2.min.js"></script>
    
<?php
	}
?>
    
    <script>
    		$(document).ready(function() {
			$('.minus').click(function () {
				var $input = $(this).parent().find('input');
				var count = parseInt($input.val()) - 1;
				count = count < 1 ? 1 : count;
				$input.val(count);
				$input.change();
				return false;
			});
			$('.plus').click(function () {
				var $input = $(this).parent().find('input');
				$input.val(parseInt($input.val()) + 1);
				$input.change();
				return false;
			});
		});
    </script>
<?php
		if($main_content=="products" || $main_content=="manageproducts" || $main_content=="productsprice"  || $main_content=="purchase"   || $main_content=="managepurchase" || $main_content=="stockstatus"  || $main_content=="outletsstock"  || $main_content=="managewbilling"  || $main_content=="wbillingreport"  || $main_content=="itemwisebilling"  || $main_content=="purchasereport"  || $main_content=="itemwisepurchase"  || $main_content=="wbilling"  || $main_content=="purchase"  || $main_content=="itemtotalreport"  || $main_content=="itemtotalpurchase"  || $main_content=="stocktransfer"  || $main_content=="stockreceivedfromoutlet")
	{
?>
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>//-->
<script>
/*$(document).ready(function() {
$('.js-example-basic-single').select2();
//$('.js-example-basic-multiple').select2();
});*/
    $(document).ready(function() {
        function customMatcher(params, data) {
            if ($.trim(params.term) === '') {
                return data;
            }

            // Split the search term by spaces
            const searchTerms = params.term.toUpperCase().split(" ");
            // Split the option text by spaces
            const optionWords = data.text.toUpperCase().split(" ");

            // Check if any part of the search term matches the beginning of any word in the option text
            for (let i = 0; i < searchTerms.length; i++) {
                let matched = false;
                for (let j = 0; j < optionWords.length; j++) {
                    if (optionWords[j].startsWith(searchTerms[i])) {
                        matched = true;
                        break;
                    }
                }
                if (!matched) return null;
            }

            return data;
        }

        $('.js-example-basic-single').select2({
            matcher: customMatcher
        });
    });
</script>
<script src="assets/js/select2.min.js"></script>
<?php
	}
?>
</body>
</html>
