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

include "../connection/config.php";

$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);

$sq="select * from company where id='1' ";
$ex=mysqli_query($con,$sq);
$fetch=mysqli_fetch_assoc($ex);


$squery="select state_name from state_mst";
$exsquery=mysqli_query($con,$squery);

$dquery="select dist_name from district_mst";
$exdquery=mysqli_query($con,$dquery);

if(isset($_POST['submit']))
{
  $company=$_POST['name'];
  //$regno=$_POST['regno'];
  // $rdate=$_POST['rdate'];
  //$head=$_POST['head'];
  $address=$_POST['address'];
  // $country=$_POST['country'];
  // $state=$_POST['state'];
  // $district=$_POST['dist'];
  // $pincode=$_POST['pin'];
  $phone=$_POST['mob1'];
  $mobile=$_POST['mob2'];
  $email=$_POST['email'];

  $csql="select * from company where id='1'";
  $cexe=mysqli_query($con,$csql);
  $cf=mysqli_fetch_assoc($cexe);
  $rdate=$cf['regdate'];

  $expiry = strtotime($rdate . ' +1 year');
  $ex = date('Y-m-d', $expiry);

  if(empty($_FILES['img']['name']))
  {
  $image=$fetch['logo'];	
  }
  else
  {
  $image=$_FILES['img']['name'];
  move_uploaded_file($_FILES['img']['tmp_name'],"public/assets/images//".$image);
  }

  $sql=" update company set company='$company',address='$address',phone='$phone',mob='$mobile',email='$email',logo='$image',expiry='$ex' where id='1'";
  $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>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  </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: 700px;">
        <!-- Content Header (Page header) -->
        <section class="content-header">
         </section>
        <!-- Main content -->
        <section class="content">

		 <div class="row">
            <div class="col-md-12">
              <div class="box" id="box_edit">
                 <div class="box-header with-border">
                  <h3 class="box-title">Company</h3>
                </div>
                 <form class="form-horizontal" action="<?php $_SERVER['PHP_SELF']?>" method="post" enctype="multipart/form-data" name="form1" autocomplete="off">
                  <div class="box-body">

                            

                            <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">Company Name</label>
                            <div class="col-sm-6"><input type="text" class="form-control" name="name"  readonly value="<?php echo $fetch['company']; ?>" ></div> </div>
                       
                            
                            <!-- <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">GST Number</label>
                            <div class="col-sm-6"><input type="text" class="form-control" name="regno"  value="<?php echo $fetch['regno']; ?>"></div></div> -->

							              <!-- <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">Registration Date</label>
                            <div class="col-sm-6"><input type="date" class="form-control"  name="rdate"  value="<?php echo $fetch['regdate'] ?>"></div></div> -->

                            <!-- <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">Owner</label>
                            <div class="col-sm-6"><input type="text" class="form-control" name="head"  value="<?php echo $fetch['head']; ?>" ></div> </div>
                        -->
                            
                            <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label"> Address</label>
                            <div class="col-sm-6"><input type="text" class="form-control" name="address" value="<?php echo $fetch['address'] ?>"></div></div>

                            <!-- <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">Country</label>
                            <div class="col-sm-6"><input type="text" class="form-control" name="country" readonly value="<?php echo $fetch['country'] ?>"></div></div>

                            <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">State</label>
                            <div class="col-sm-6"><select class="form-control" name="state">
                                <option><?php echo $fetch['state'] ?></option>
                                <?php while($sf=mysqli_fetch_assoc($exsquery)){ ?>
                                <option><?php echo $sf['state_name']; ?></option>
                                <?php } ?>
                                </select></div></div> -->

                            <!-- <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">District</label>
                            <div class="col-sm-6"><select class="form-control" name="dist">
                                <option><?php echo $fetch['district'] ?></option>
                                <?php while($df=mysqli_fetch_assoc($exdquery)){ ?>
                                <option><?php echo $df['dist_name']; ?></option>
                                <?php } ?>
                                </select> </div></div>

                            <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">Pincode</label>
                            <div class="col-sm-6"><input type="number" class="form-control" name="pin" value="<?php echo $fetch['pin'] ?>"></div></div> -->

							             
							              <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">Phone Number</label>
                            <div class="col-sm-6"><input type="tel" class="form-control" name="mob1"  value="<?php echo $fetch['phone'] ?>"></div></div>

							              <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">Mobile Number</label>
                            <div class="col-sm-6"><input type="tel" class="form-control" name="mob2"  value="<?php echo $fetch['mob'] ?>"></div></div>

							              <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">Email</label>
                            <div class="col-sm-6"><input type="email" class="form-control" name="email" value="<?php echo $fetch['email'] ?>"></div></div>

                            <div class="form-group">
                            <label for="exampleInputEmail1" class="col-sm-2 control-label">Logo</label>
                            <div class="col-sm-6"><input type="file" class="form-control" name="img"><img src="public/assets/images/<?php echo $clf['logo']; ?>" style="height:60px; margin-top:10px;"></div></div>


                            <div class="form-group"> <div class="col-sm-6">
                            <button type="submit" name="submit" class="btn btn-info" style="background-color:#4d6c9c; border-color:#4d6c9c; margin-left:250px;">Save</button></div></div>
                  </div>

                </form>
              </div>
       
            </div>
         </div>
               
         </div> 
         
         <!-- /.box -->
        
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
</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>
 	function displayEdit(id)
	{
		$.ajax({
			type: "POST",
			url: "country_edit.php",
			data:{country_id: id},
			success: function(data){
				$('#box_edit').html(data);
			}
		});
	}
 </script>-->

    
  

</body></html>