<?php
include "../connection/config.php";
session_start();

 if(!isset($_SESSION['aid']))
 {
   	echo '<script>location.href="../index.php"</script>';
 }

include "../connection/config.php";
$num=$_SESSION['aid'];
//for header
$clquery="select * from company";
$clex=mysqli_query($con,$clquery);
$clf=mysqli_fetch_assoc($clex);

$dateString=$expiry=$clf['expiry'];
$de = new DateTime($dateString);
$formattedDate = $de->format('d/m/Y');

$regdate=$clf['regdate'];
$date= date( 'Y-m-d' );
//for expiry day
$date1 = new DateTime($date);
$date2 = new DateTime($expiry);
$interval = $date1->diff($date2);
$days= $interval->format('%a days');

//get ip
$ipsql="select * from adminlog";
$ipexe=mysqli_query($con,$ipsql);
$ipf=mysqli_fetch_assoc($ipexe);


if(isset($_POST['submit']))
{
$p=$_POST['new_password'];
$c=$_POST['confirm_password'];

$sql="update adminlog set password='$c' where aid='$num'";
$exe=mysqli_query($con,$sql);
}
?>

<html><head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Admin Console</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
     <!-- DataTables -->
    <link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="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="dist/css/skins/_all-skins.min.css">
    <link rel="stylesheet" href="dist/css/style.css">
    <link rel="stylesheet" href="css/print.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]-->
    <script>
	function isNumeric(evt){
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 46)
		return false;
	
	 return true;
	}

	</script>
	 <style>
         @font-face {
         font-family: "Kerala";
         src: url("KERALI_1.TTF") format("truetype"); 
    }
	</style>
  </head>
 
  <body class="skin-green  sidebar-mini">
    <!-- Site wrapper -->
    <div class="wrapper">

      <!-- =============================================== -->

      <!-- Left side column. contains the sidebar -->
      
<header class="main-header">

<div class="row" style="background-color:#4d6c9c; color:#E1EBEE; text-align:center">
<div class="col-md-12"  style="margin-top:10px; ">

<div class="col-md-2"><b style="font-size:20px; float:left;">Billing Software<span style="font-size:10px;">ver1.23</span></b></div>  

<div class="col-md-2">License To : <?php echo $clf['company']; ?> <span style="float:right;">|<span></div>

<div class="col-md-2">Left : <?php echo $days;  ?><span style="float:right;">|<span></div>

<div class="col-md-2">Expiry : <?php echo $formattedDate; ?> <span style="float:right;">|<span></div>

<div class="col-md-2">Powered By : PROGRAMERS Inc <span style="float:right;">|<span></div>

<div class="col-md-1"> Ip - <?php echo $ipf['ip']; ?> </div>
</div><div>

</header>

<aside class="main-sidebar">
        <!-- sidebar: style can be found in sidebar.less -->
        <section class="sidebar" style="height: auto;">
          <!-- Sidebar user panel -->
          <div class="user-panel"></div>
         
          <ul class="sidebar-menu">
          
          <li class="treeview "> 
          <a href="home.php"><span>Home</span><i class="fa fa-angle-left pull-right"></i></a></li>

          <li class="treeview "> 
            <a href="#"><span>Master</span><i class="fa fa-angle-left pull-right"></i></a>
            <ul class="treeview-menu">
            <li class=""><a href="item_category.php">Item Category</a></li>
            <li class=""><a href="item_details.php">Item Details</a></li>
            <li class=""><a href="customer.php">Customer Details</a></li>
            </ul> </li> 

            <li class="treeview "> 
            <a href="#"><span>Transaction</span><i class="fa fa-angle-left pull-right"></i></a>
            <ul class="treeview-menu">
            <li class=""><a href="stock_input.php">Stock Input</a></li>
            <li class=""><a href="billing.php">Billing</a></li>
            <!--<li class=""><a href="sales_return.php">Sales Return</a></li>-->
            </ul> </li> 

            <li class="treeview "> 
            <a href="#"><span>Reports</span><i class="fa fa-angle-left pull-right"></i></a>
            <ul class="treeview-menu">
            <li class=""><a href="item_report.php">Item List</a></li>  
            <li class=""><a href="sales_report.php">Sales Register</a></li>  
            <!-- <li class=""><a href="sales_return_report.php">Sales Return Register</a></li>   -->
            <li class=""><a href="stock_input_register.php">Stock Translation Register</a></li>   
            <li class=""><a href="stock_register.php">Stock Register</a></li>
            <li class=""><a href="stock_reorder.php">Item Reorder Register</a></li> 
            <li class=""><a href="dead_stock_register.php">Dead Stock Register</a></li>    
            </ul>
            </li> 

            
            <li class="treeview "> 
            <a href="#"><span>Settings</span><i class="fa fa-angle-left pull-right"></i></a>
            <ul class="treeview-menu">
            <li class=""><a href="company.php">Company Setup</a></li>  
            <li class=""><a href="password.php">Password Reset</a></li>  
            <li class=""><a href="logout.php">Logout</a></li>   
            </ul>
            </li>
            
          </ul>
        </section>
        <!-- /.sidebar -->
      </aside>
      <!-- =============================================== -->

      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper" style="min-height: 486px;">
      <section class="content-header">
      </section>
        
    <section class="content">
    <div class="box box-info">
    <div class="box-header with-border">
    <h3 class="box-title"></h3><h3 class="box-title"> Change Password</h3>
    <!-- <a href="javascript:history.back()" class="pull-right"><img src="images/back-button.png"></a> -->
    </div>

    <form class="form-horizontal" action="" method="post" enctype="multipart/form-data" name="form1" onsubmit="return Validate();">
    <div class="box-body">
    <div class="form-group">
    <label for="exampleInputEmail1" class="col-sm-4 control-label">New Password</label>
    <div class="col-sm-5">
    <input type="password" class="form-control" placeholder="New Password" name="new_password" id="password" onkeyup="reEnter()" required="">
    </div> </div>

    <div class="form-group">
    <label for="exampleInputEmail1" class="col-sm-4 control-label">Confirm Password</label>
    <div class="col-sm-5">
    <input type="password" class="form-control" placeholder="Confirm Password" name="confirm_password" id="confirm_password" required="">
    <span id="message" style="display:none;font-size:13px;line-height: 2.5;padding-left:3px;"></span><br>

    <button type="submit" name="submit" style="background-color:#4d6c9c; border-color:#4d6c9c;" id="submit_but" class="btn btn-info pull-left" disabled="">Submit</button>
    </div> 
    </div> 
    </div>
   
  </form>
  </div>
  </section>
  </div>
	</div>

  <footer class="main-footer">
  <strong>Copyright © 2023 <a href="javascript:void(0)"> Perfect Uniform Llc </a></strong> All rights reserved. </footer>

    <!-- ./wrapper -->

    <!-- jQuery 2.1.4 -->
    <script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <!-- SlimScroll -->
    <script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="dist/js/app.min.js"></script>      <script>
		$('#confirm_password').on('change', function () {
		  if ($(this).val() == $('#password').val()) {}
		  else { $("#confirm_password").val(""); }
	  });
	  </script>
	  
	  <script>
		$('#confirm_password').on('keyup', function () {
		  if ($(this).val() == $('#password').val()) {
			  $('#message').show();
			  $('#message').html('<i class="fa fa-check-circle" aria-hidden="true"></i> Matching').css('color', 'green');
			  jQuery('#confirm_password').css("margin-bottom","6px");
			  $("#submit_but").removeAttr("disabled");
			  
		  } else {
		  $('#message').show();
		  $('#message').html('<i class="fa fa-exclamation-circle" aria-hidden="true"></i> Not Matching !').css('color', '#a91716');
		  jQuery('#confirm_password').css("margin-bottom","6px");
		  $("#submit_but").attr("disabled", "true");
		  }
	  });
	  function reEnter()
	  {
		$("#submit_but").attr("disabled", "true"); 
		$("#confirm_password").val(""); 
		$('#message').show();
		$('#message').html('<i class="fa fa-exclamation-circle" aria-hidden="true"></i> Not Matching !').css('color', '#a91716');
	    jQuery('#confirm_password').css("margin-bottom","6px");
	  }
	  </script>
  
</body></html>