<?php 
	$header_file=APPPATH.'views/include/header.php';
	require($header_file);
	$sidenav_file=APPPATH.'views/include/sidenav.php';
	require($sidenav_file);	
?>
<!-- BEGIN: Content-->
<div class="app-content content">
    <div class="content-overlay"></div>
    <div class="content-wrapper">
        <div class="content-header row">
            <div class="content-header-left col-md-12 col-12 mb-2 breadcrumb-new">
                <h3 class="content-header-title mb-0 d-inline-block"><?php echo $sub_ModuleName;?></h3>
                <div class="row breadcrumbs-top d-inline-block float-right">
                    <div class="breadcrumb-wrapper col-12">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="<?php echo site_url('User/dashboard');?>">Home</a></li>
                            <li class="breadcrumb-item"><a href="#"><?php echo $moduleName;?></a></li>
                            <li class="breadcrumb-item active"><?php echo $sub_ModuleName;?></li>
                        </ol>
                    </div>
                </div>
            </div> 
        </div>
        <div class="content-body"><!-- Basic form layout section start -->
            <section id="basic-form-layouts">
            	<div class="row justify-content-md-center">
            		<div class="col-md-12">
            			<div class="card">
            				<div class="card-content collapse show">
            					<div class="card-body">
            						<div class="row justify-content-md-center cardbody">	
            							<div class="col-md-4">
            								<form class="form" autocomplete="off" action="<?php echo site_url('Eshanya/export_Stock1');?>" method="post">
            									<div class="form-body">
            										<div class="form-group">
            										<?php $cur_date = date("d-m-Y"); 
            										$branch_id = $_SESSION['branch_id'];
            										$branch_name = $_SESSION['branch_name'];
            										$full_name = $_SESSION['full_name'];	?>	
            										<input class="form-control" type="hidden" name="branchname" id="branchname" value="<?php echo $_SESSION['branch_name']; ?>">
            											<input type="submit" name="export_stk_format" class="btn btn-primary" value="Download File">
            										</div>
            									</div>
            								</form>
            							</div>
            							<div class="col-md-8">
                							<form class="form" autocomplete="off" action="<?php echo site_url('Eshanya/import_StockESH');?>"  method="post" enctype="multipart/form-data">
                								<div class="row">
                    								<div class="col-md-6">
                        								<div class="form-group">
                    										<!--<label>UPLOAD</label>-->
                    										<input type="file" name="stk_upload" id="stk_upload" class="form-control" required />
                    										<input class="form-control" type="hidden" name="up_type" id="up_type" value="Raw Material" >
                    									</div>
                    								</div>
                    								<div class="col-md-2">
                    									<div class=" text-right">
                    										<input type="submit" name="upload" id="rstk" onclick="return confirm('Are you sure you want to submit this form?')"  class="btn btn-primary" value="Upload">
                    									</div>
                    								</div>	
                    							</div>
                							</form>
            							</div>
                					</div>
                				</div>
                			</div>
                		</div>
                	</div>
                </div>
            </section>
        </div>
    </div>
</div>
<?php 
    $footer_file=APPPATH.'views/include/footer.php';
	require($footer_file);
?>
<script>
$('#rstk').click(function(){
	function containsWord(haystack, needle) {
		return (" " + haystack + " ").indexOf(" " + needle + " ") !== -1;
	}
	var br = $('#branchname').val();
	var filename = $('#stk_upload').val();
	var flname = filename.split('\\').pop().split('/').pop();
	//alert(flname);
    if(flname.includes("Stock_Update(RM)_"+br+"_"))
    {
        //alert("yes");
        return true;
    }
    else
    {
        alert("Please choose the proper file");
        return false;
    }
});
</script>
<script>
   $("form").submit(function() {
        // submit more than once return false
        $(this).submit(function() {
            return false;
        });
        // submit once return true
        return true;
    });
</script>
</body>
</html>