<?php 
session_start();
include '../db.php';
 include("../all_query.php");
//error_reporting(03

  	$page='';
	if(isset($_GET['page']))
	{
		$page=$_GET['page'];
	}

//echo $_SESSION['role'];
if($_SESSION['loan_crm_username'] && $_SESSION['loan_crm_password']){
	
		$page_name=$page;
	
	  
?>

	
	
<!DOCTYPE html>
 
<html lang="en" class="light-style layout-navbar-fixed layout-menu-fixed " dir="ltr" data-theme="theme-bordered" data-assets-path="../assets/" data-template="vertical-menu-template-bordered">
 
<head>
   <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />

    <title>CRM</title>
    
     <meta name="description" content="Start your development with a Dashboard for Bootstrap 5" />
    <meta name="keywords" content="dashboard, bootstrap 5 dashboard, bootstrap 5 design, bootstrap 5">
    <!-- Canonical SEO -->
    <link rel="canonical" href="https://1.envato.market/frest_admin">
    
    <!-- Favicon -->
    <link rel="icon" type="image/x-icon" href="https://pixinvent.com/demo/frest-clean-bootstrap-admin-dashboard-template/assets/img/favicon/favicon.ico" />

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com/">
    <link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&amp;family=Rubik:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&amp;display=swap" rel="stylesheet">

    <!-- Icons -->
    <link rel="stylesheet" href="../assets/vendor/fonts/boxicons.css" />
    <link rel="stylesheet" href="../assets/vendor/fonts/fontawesome.css" />
    <link rel="stylesheet" href="../assets/vendor/fonts/flag-icons.css" />

    <!-- Core CSS -->
    <link rel="stylesheet" href="../assets/vendor/css/rtl/core.css" class="template-customizer-core-css" />
    <link rel="stylesheet" href="../assets/vendor/css/rtl/theme-bordered.css" class="template-customizer-theme-css" />
    <link rel="stylesheet" href="../assets/css/demo.css" />

    <!-- Vendors CSS -->
    <link rel="stylesheet" href="../assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.css" />
    <link rel="stylesheet" href="../assets/vendor/libs/typeahead-js/typeahead.css" />
    <link rel="stylesheet" href="../assets/vendor/libs/datatables-bs5/datatables.bootstrap5.css">
<link rel="stylesheet" href="../assets/vendor/libs/datatables-responsive-bs5/responsive.bootstrap5.css">
<link rel="stylesheet" href="../assets/vendor/libs/datatables-checkboxes-jquery/datatables.checkboxes.css">
<link rel="stylesheet" href="../assets/vendor/libs/datatables-buttons-bs5/buttons.bootstrap5.css">
<link rel="stylesheet" href="../assets/vendor/libs/flatpickr/flatpickr.css" />
<!-- Row Group CSS -->
<link rel="stylesheet" href="../assets/vendor/libs/datatables-rowgroup-bs5/rowgroup.bootstrap5.css">
<!-- Form Validation -->
<link rel="stylesheet" href="../assets/vendor/libs/formvalidation/dist/css/formValidation.min.css" />


    <!--! Template customizer & Theme config files MUST be included after core stylesheets and helpers.js in the <head> section -->
    <!--? Template customizer: To hide customizer set displayCustomizer value false in config.js.  -->
     <!--? Config:  Mandatory theme config file contain global vars & default theme options, Set your preferred theme option in this file.  -->
    <script src="../assets/js/config.js"></script>
	
	
	 <link rel="stylesheet" href="../assets/vendor/libs/toastr/toastr.css" />
	 <link rel="stylesheet" href="../assets/vendor/libs/animate-css/animate.css" />


<?php
 if(isset($_POST['add_category']))
 {
	 
	 $category_name = mysqli_real_escape_string($conn,$_POST['category_name']);
	 $password = mysqli_real_escape_string($conn,$_POST['password']);
	 $mobile = mysqli_real_escape_string($conn,$_POST['mobile']);
	   
 $check_rights="";
		 if(!empty($_POST['check_rights'])) {
			 
		 $check_rights=implode(",",$_POST['check_rights'] );
    
	
    }
	
	
	//	$check_rights=str_replace(' ', '', $check_rights);
	
		
	 
	 $qry = "INSERT INTO `admin` (`username`,`password`,`mobile`,`role`,`rights`) VALUES ( '$category_name','$password','$mobile','normal','$check_rights')";
	 $res=mysqli_query($conn,$qry);
	 
 }
 
 
 if (isset($_POST['del_rest']))
 {
	 $del_id= $_POST['del_id'];
	 $qry = "delete from `admin` where id = $del_id";
	 $res=mysqli_query($conn,$qry);
	 
  }
  
    if (isset($_POST['active_decative']))
 {
	 $del_id= $_POST['del_id'];
	 $status= $_POST['active_decative'];
	 $qry = "update `admin` set `status`='$status'  where id = $del_id";
	 $res=mysqli_query($conn,$qry);
	 
  }
   if (isset($_POST['edit_category']))
   {
	   $cat_id= $_POST['cat_id'];
	$category_name = mysqli_real_escape_string($conn,$_POST['category_name']);
	 $password = mysqli_real_escape_string($conn,$_POST['password']);
	 $mobile = mysqli_real_escape_string($conn,$_POST['mobile']);
			 
 $check_rights="";
		 if(!empty($_POST['check_rights'])) {
			 
		 $check_rights=implode (",",$_POST['check_rights'] );
    
	
    }
	
	
	
	 
	//$check_rights=str_replace(' ', '', $check_rights); 
	 
	 
	 
	 
	
	  mysqli_query($conn,"Update `admin` set `username`='$category_name' , `password`='$password' , mobile='$mobile',`rights`='$check_rights'  where id=$cat_id ");
	  
   }
   
  
  
  
?> 
 
   				 
   

    
    <!-- Page CSS -->
    	 <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
   
   
   
   
  <link rel="stylesheet" href="../assets/vendor/libs/select2/select2.css" />

		 
	  <script src="http://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.min.js" integrity="sha384-FzT3vTVGXqf7wRfy8k4BiyzvbNfeYjK+frTVqZeNDFl8woCbF0CYG6g2fMEFFo/i" crossorigin="anonymous"></script>
   <script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-JAW99MJVpJBGcbzEuXk4Az05s/XyDdBomFqNlM3ic+I=" crossorigin="anonymous"></script>
	
	
	
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert-dev.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.css">
  

  
  
  
    <!-- Helpers -->
    <script src="../assets/vendor/js/helpers.js"></script>

 
    <script src="../assets/js/config.js"></script>
    
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async="async" src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
    <script>
    window.dataLayer = window.dataLayer || [];

    function gtag() {
      dataLayer.push(arguments);
    }
    gtag('js', new Date());
    gtag('config', 'GA_MEASUREMENT_ID');
    </script>
    <!-- Custom notification for demo -->
    <!-- beautify ignore:end -->

</head>

<body>

 <?php
 require("phpexcel/php-excel-reader/excel_reader2.php");
	require('phpexcel/SpreadsheetReader.php');
 
   if(isset($_POST['upload_excel']))
   {
	   $filename=$_FILES['excelfile']['name'];
	   move_uploaded_file($_FILES['excelfile']['tmp_name'],'excel/'.$filename);
	   
	   date_default_timezone_set('UTC');

	$StartMem = memory_get_usage();


	try
	{
		$Filepath="excel/".$filename;
		$Spreadsheet = new SpreadsheetReader($Filepath);
		$BaseMem = memory_get_usage();

		$Sheets = $Spreadsheet -> Sheets();


		foreach ($Sheets as $Index => $Name)
		{
			

			$date = microtime(true);

			$Spreadsheet -> ChangeSheet($Index);
			
			
            $line=0;
			foreach ($Spreadsheet as $Key => $Row)
			{
				$line++;
				
				if($line!=1) {
				if ($Row)
				{
					
					$data= get_all_column($conn,$page);
					  $p=0;
				
				$RECORD=array();
				 foreach($data as $field)
					  {    
											 
					if($field!='id' && $field!='date_time' && $field!='status' )
					  {  
					
					 
					$RECORD[$field] = $Row[$p];
					
					  $p++;
					
					  }
					  
					  }
				
				
				$save = 1;
					if(isset($RECORD['name']))
				 {
					 
                //$_POST['name']=str_replace('\' ', '\'', ucwords(str_replace('\'', '\' ', strtolower(mysqli_real_escape_string($conn,$_POST['name'])))));

				
                  $name = $RECORD['name'];
				
				   $alreadyQ=mysqli_query($conn,"select *from `$page`  where `name` ='$name' ");	
                    if(mysqli_num_rows($alreadyQ) > 0)	
					{
						
						$save = 0;
						
					}						
		
				

				}	

               if($save == 1)
			   {
				 insertTable($conn,$page,$RECORD,'add_submit');
					 
			   }
					
	 
					
				}
				}
				
			}
		
			
		}
		
	}
	catch (Exception $E)
	{
		die("Invalid Excel Format");
	}
	   
	   
	   
   }
  
 
 
 ?>
 
 
   <script>
   
   	 $(function () {
  const select2 = $('.select2');

  // Select2 Country
  if (select2.length) {
    select2.each(function () {
      var $this = $(this);
      $this.wrap('<div class="position-relative"></div>').select2({
        dropdownParent: $this.parent()
      });
    });
  }
});

 

 function selectIds(id)
   {
	   
	   
	   <?php $data= get_all_column($conn,$page_name);
                                    
                                 
                                    // print_r($data);
                                    foreach($data as $field)
                                    {    
									
									if (strpos($field, '_ids') !== false ||  strpos($field, '_access') !== false ||  $field == 'user_access' ||  $field == 'under_stage' ) {
                                      ?>
	     var dataArr<?php echo $field; ?> = [];
	 
	   $("#select_<?php echo $field; ?>_"+id+" option:selected").each(function()
{
    // Add $(this).val() to your list
	 dataArr<?php echo $field; ?>.push($(this).val()); 
});
var jsonString<?php echo $field; ?> = JSON.stringify(dataArr<?php echo $field; ?>);

   document.getElementById('<?php echo $field; ?>'+id).value=jsonString<?php echo $field; ?>;

									<?php } }  ?>


 
   }


   
   </script>
   
   
   <script>
 
 function deleteSelected(table)
 {
	 
	 if(confirm('Are you sure?'))
	 {
		   var dataArr = [];
		   
		 $("input:checkbox[name=delete_checkbox]:checked").each(function(){
    dataArr.push($(this).val());
});
		 
		 
		  var jsonString = JSON.stringify(dataArr);
		  
		  
		   if(dataArr.length == 0)
			  
			  {
				  toastr.warning("Please Select Record!"); 
			  }
			  else {
				  
				  
		    $.ajax({
      type: "POST",
      url: 'delete_records_ajax.php',
	    data: {record_ids:jsonString,table:table},
      success: function(data) {
	
	    // toastr.warning(data.trim()); 
		  
		 window.location="";
		 
		
		 }
		  // <- this turns it into synchronous

		  }
	   );
			  }
		  
		  
	 }
	 
	 
 }
 
 
 
 function selectAll()
 {
	 
	 if($("input:checkbox[name=delete_checkbox]").prop('checked') == true)
	 {
		  $("input:checkbox[name=delete_checkbox]").prop('checked', false);
	 }
	 
	 else{
	 $("input:checkbox[name=delete_checkbox]").prop('checked', true);
	 }
 }


</script>	

   
   				 
   
   <script>
   $(document).ready(function(){

     $('#myTable').DataTable( {
			  "ordering": false,
        dom: 'Bfrtip',

        buttons: 
		[
			
	  	  
	  {
        extend: 'copy',
       
		
      } , 
	  {
        extend: 'csv',
       
		
      } ,			
	  {
        extend: 'excel',
      
		
      },			
	  {
        extend: 'pdf',
       
		
      } , {
        extend: 'print',
		       

		
      } 
	  
	  
	  
	  ]
    } );
});
   </script>
  <!-- Layout wrapper -->
<div class="layout-wrapper layout-content-navbar  ">
  <div class="layout-container">

    
    




<!-- Menu -->

<?php include('left_sidebar.php'); ?>

<!-- / Menu -->

    

    <!-- Layout container -->
    <div class="layout-page">
      
      



<!-- Navbar -->

  
<?php include('header.php'); ?>



  
<!-- / Navbar -->

      

      <!-- Content wrapper -->
      <div class="container-xxl ">

        <!-- Content -->
        
  
	<h4 class="py-3 breadcrumb-wrapper mb-4"><?php echo  ucfirst(str_replace('_',' ',$page)); ?></h4>


							<div class="row" style="    margin-bottom: 10px;">
							
							 <div class="col-md-2">
								<button    type="button" class="btn btn-primary  " data-bs-toggle="modal" data-bs-target="#myModal" ><i class="fa fa-plus"></i>Add</button>
							
							</div>
		 
			
			 
					   
					</div>							
						 
			 
					<!-- Modal -->
		  <div class="modal fade" id="myModal" role="dialog">
									<div class="modal-dialog">
			<!-- Modal content-->
		  <div class="modal-content">
				<div class="modal-header">
				
			  <h4 class="modal-title">Add New </h4>
			  	<a href=""><button type="button" class="btn-close" ></button></a>
			</div>
							<form style="padding:20px;" role="form" action="" enctype="multipart/form-data"  method ="POST">
														
								<div class="form-group">
					<label>UserName</label>
					<input type="text" autofocus class="form-control" name="category_name" required >
					               </div>
								 
								 <Br/>
								 
									<div class="form-group">
					<label>Password</label>
					<input type="password"  class="form-control" name="password" required >
					               </div>
								   
								   
								   <div class="form-group">
					<label>Mobile</label>
					<input type="text"  class="form-control" name="mobile"   >
					               </div>
								   
								   
								   
								 
								 <Br/> <Br/>   
								 
								   
								   
				 <button  onclick="selectInst('0');"  type="submit" name="add_category" class="btn btn-primary">Submit</button>
							</form>
			<div class="modal-footer">
		  
				</div>
			  </div>
		   </div>
					</div>
				 	
			
					
			
		 
				 
				 
 
			
				 <div class="card card-datatable table-responsive text-nowrap" style="padding:10px;zoom:90%;">
                             	 <table id="myTable" class="table display table-bordered table-striped no-wrap">
                                      <thead>
							<tr>
								<th>Sr Num</th>
							
								<th>Username</th>
								<th>Password</th>
								<th>Mobile</th>
								<th>Role</th>
								<th>Lead Owner</th>
								<th>Rights</th>
							
								 
								<th></th>
							</tr>
						</thead>
						 <tbody>
								<?php
								 $ret=mysqli_query($conn,"select *from `admin`");
								 $i=0;   while($row=mysqli_fetch_assoc($ret))
										{
											$i++;
									?>
							<tr>
								<td><?php  echo $i; ?></td>
						
								
								<td> <?php  echo $row['username']; ?></td>
								<td> <?php  echo $row['password']; ?></td>
								<td> <?php  echo $row['mobile']; ?></td>
								<td> <?php  echo $row['role']; ?></td>
								 
								<td> <?php   $RArray = explode(',', $row['rights']); 
								
								   $n=0;
								  foreach($RArray as $r)
								  {
									$n++;
                                         echo $n.' : '.$r."<br/>";									
								  }
								
								?></td>
						
								
										<td>	
									
									<button type="button" class="btn btn-primary" data-bs-toggle="modal"  data-bs-target="#myModal<?php echo  $row['id']; ?>">Edit</button>
									
									  <div class="modal fade" id="myModal<?php echo  $row['id']; ?>" role="dialog">
									<div class="modal-dialog">
									<!-- Modal content-->
									  <div class="modal-content">
										<div class="modal-header">
											  
											  <h4 class="modal-title">Edit</h4>
											  <a><button type="button" class="close" data-bs-dismiss="modal">&times;</button></a>
											</div>
												<div class="modal-body">
							<form role="form" action="" enctype="multipart/form-data" method ="POST">
								<input type="hidden" name="cat_id" value="<?php echo $row['id']; ?>"/>	
								
								<div class="form-group">
					             <label>Username</label>
					             <input type="text" autofocus class="form-control" name="category_name" value="<?php echo $row['username']; ?>" required >
					               </div>
								
								<div class="form-group">
					             <label>Password</label>
					             <input type="password"  class="form-control" name="password" value="<?php echo $row['password']; ?>" required >
					               </div>
								   
								   	<div class="form-group">
					             <label>Mobile</label>
					             <input type="text"  class="form-control" name="mobile" value="<?php echo $row['mobile']; ?>"   >
					               </div>
								   
								   
								   
								    
								    	   <div class="form-group" style="margin-top:20px;     padding: 20px;">
								    <label>Rights</label>
									
									<div class="row">
					
				
										<?php if($row['role']=='super')  { ?>
										
										 <div class="col-md-6">	 
								     <input type="checkbox" <?php if(in_array("all", $RArray)) { echo "checked"; } ?> name="check_rights[]" value="all">
                                     all</div>
										
										<?php  } else {
											
											
								// $righstArray = array('Masters','Lead Management','Sale Management','Accounts','Open API Leads','CRS Calculator','Lead Age','Website','Client Feedback');
											
								$moduleQ = mysqli_query($conn,"select *from `crm_modules` ");
								
								while($moduleData = mysqli_fetch_assoc($moduleQ))
								{
								
									 $rights = $moduleData['name'];


											?>
										
									 <div class="col-md-6">	 
								     <input type="checkbox" <?php if(in_array($rights, $RArray)) { echo "checked"; } ?> name="check_rights[]" value="<?php echo $rights; ?>">
                                     <?php echo $rights; ?></div>
								 
								 
											<?php  } ?>
							          
									  
									 
										<?php }  ?>
					               </div> 
					               </div> 
								  
								   
								  
								   
								 
								   
								    


													
														
														   <button onclick="selectInst('<?php echo $row['id']; ?>');"  type="submit" name="edit_category" class="btn btn-primary">Submit</button>
														</form>
												</div>
											 
									  </div>
								   </div>
								</div>
							
									
								</td>
									
								 <td>
								 <?php if($row['role']=='super')  { ?> <?php } else { ?>
									<form action="" method="post" onsubmit="return confirm('Are You Sure?');">		
									
											 <input type="hidden" value="<?php echo $row['id']; ?> " name="del_id" />	
                                              	
											<?php  if($row['status']=='' || $row['status']==null || $row['status']=='Activate' ) { ?>	
											<label>Activated</label>
											<input type="submit" name="active_decative" class="btn btn-danger" Value="Deactivate"/>
											
											<?php } else {   ?>
											<label>Deactivated</label>
											<input type="submit" name="active_decative" class="btn btn-success" Value="Activate"/>
										<?php }   } ?>
											
									</form>
								</td>
							</tr>	
							<?php  }  ?>
						</tbody>
					</table>
                               
                                </div>
                              
						
			
			
			
 
          
      
         </div>
        <!-- Content wrapper -->
      </div>
      <!-- / Layout page -->
    </div>

    
    			
			
<script>
			 $(function () {
				 sub();
				 function sub(){
					 
					 
					 
					 
$('#add_form').submit(function() {
	
	 $(':button[type="submit"]').prop('disabled', true);
	var form=$("#add_form");
 
    var vcfData = new FormData($('#add_form')[0]); 
	
	//alert(rem);
	 //alert("hello");
        $.ajax({ 
            
            type:"post",
            url:"save_master_form_ajax.php?table=<?php echo $page; ?>",
			data:vcfData,
			 contentType: false,
            cache: false,
            processData:false,
            success: function(data) {
				//alert(data);
           		
				
				if(data.trim() == '1')
				{
             
				 document.getElementById("message").innerHTML="Record Added Successfully!";
				 document.getElementById("message").style.display = "block";
				 document.getElementById("add_form").reset();
				 $(':button[type="submit"]').prop('disabled', false);
				 $('#add_form').find('input[type=text],textarea,select').filter(':visible:first').focus();
    
				setTimeout(function() {
						$('#message').hide();
						//$("#purity").focus();
					}, 1000); // <-- time in milliseconds

				}
				if(data.trim() == '0')
				{
					 document.getElementById("message").innerHTML="Duplicate Name Found ";
				 document.getElementById("message").style.display = "block";
				 document.getElementById("add_form").reset();
				 $(':button[type="submit"]').prop('disabled', false);
				 $('#add_form').find('input[type=text],textarea,select').filter(':visible:first').focus();
    
				setTimeout(function() {
						$('#message').hide();
						//$("#purity").focus();
					}, 1000); // <-- time in milliseconds

					
					
				}
				
				
				window.location='';
			
			   
            }
        });
        return false; 
    });
				 }
			 });
</script>			
				
						
    
  </div>
  <!-- / Layout wrapper -->

 

 <!-- Core JS -->
  <!-- build:js assets/vendor/js/core.js -->
  <script src="../assets/vendor/libs/jquery/jquery.js"></script>
  <script src="../assets/vendor/libs/popper/popper.js"></script>
  <script src="../assets/vendor/js/bootstrap.js"></script>
  <script src="../assets/vendor/libs/perfect-scrollbar/perfect-scrollbar.js"></script>
  <script src="../assets/vendor/libs/hammer/hammer.js"></script>
  <script src="../assets/vendor/libs/i18n/i18n.js"></script>
  <script src="../assets/vendor/libs/typeahead-js/typeahead.js"></script>
  
  <script src="../assets/vendor/js/menu.js"></script>
  <script src="../assets/vendor/libs/select2/select2.js"></script>
  
    <script src="../assets/vendor/libs/toastr/toastr.js"></script>

     <script src="../assets/js/ui-toasts.js"></script>


  <!-- endbuild -->

  <!-- Vendors JS -->
  <script src="../assets/vendor/libs/datatables/jquery.dataTables.js"></script>
<script src="../assets/vendor/libs/datatables-bs5/datatables-bootstrap5.js"></script>
<script src="../assets/vendor/libs/datatables-responsive/datatables.responsive.js"></script>
<script src="../assets/vendor/libs/datatables-responsive-bs5/responsive.bootstrap5.js"></script>
<script src="../assets/vendor/libs/datatables-checkboxes-jquery/datatables.checkboxes.js"></script>
<script src="../assets/vendor/libs/datatables-buttons/datatables-buttons.js"></script>
<script src="../assets/vendor/libs/datatables-buttons-bs5/buttons.bootstrap5.js"></script>
<script src="../assets/vendor/libs/jszip/jszip.js"></script>
<script src="../assets/vendor/libs/pdfmake/pdfmake.js"></script>
<script src="../assets/vendor/libs/datatables-buttons/buttons.html5.js"></script>
<script src="../assets/vendor/libs/datatables-buttons/buttons.print.js"></script>
<!-- Flat Picker -->
<script src="../assets/vendor/libs/moment/moment.js"></script>
<script src="../assets/vendor/libs/flatpickr/flatpickr.js"></script>
<!-- Row Group JS -->
<script src="../assets/vendor/libs/datatables-rowgroup/datatables.rowgroup.js"></script>
<script src="../assets/vendor/libs/datatables-rowgroup-bs5/rowgroup.bootstrap5.js"></script>
<!-- Form Validation -->
<script src="../assets/vendor/libs/formvalidation/dist/js/FormValidation.min.js"></script>
<script src="../assets/vendor/libs/formvalidation/dist/js/plugins/Bootstrap5.min.js"></script>
<script src="../assets/vendor/libs/formvalidation/dist/js/plugins/AutoFocus.min.js"></script>

  <!-- Main JS -->
  <script src="../assets/js/main.js"></script>

  <!-- Page JS -->
  <script src="../assets/js/tables-datatables-basic.js"></script>
</body>

 
</html>
  <?php  }  else { header("Location:login.php");  } ?>