<?php session_start(); include "confiq.php";
	if(isset($_POST['submit_login'])){
	
 $koneksi_reg=open_connection2();
	$email=noninjection($koneksi_reg,$_POST['email']);
	$password=noninjection($koneksi_reg,$_POST['password']);
	
			if(($email<>'') and ($password<>'')){
				$task="34567fghjkl;FGHJK09865fghjs12345@#$@#$!@#";
				$password=md5($password);
				$password=md5($password.$email.$task);
				
				
   
				$qry_cari=mysqli_query($koneksi_reg,"SELECT * FROM `tbregistrasi` WHERE (email='".$email."') and (password='".$password."')");
				$N=mysqli_num_rows($qry_cari);
				if($N<>0)
					{
					$row=mysqli_fetch_array($qry_cari);
					$_SESSION['iduser']=$row['nis'];
					$_SESSION['email']=$row['email'];
					$_SESSION['password']=$row['password'];
					$_SESSION['user_kategori']=$row['kat'];
					$_SESSION['user_nama']=$row['nama_siswa'];
					$_SESSION['npsn']=$row['npns'];
					$_SESSION['client']=$row['nama_sekolah'];
				$_SESSION['sekolah']=$row['nama_sekolah'];
				//	$_SESSION['img_profile']=$row['profile'];
				//	$_SESSION['user_status']=$row['status'];
				//	header("Location: index.php");	
					} else {
					echo '<script>alert("Login Gagal'.$password.'");</script>';
					}
			
			}
	}

?>
<?php if(isset($_SESSION['iduser'])){?>
<!DOCTYPE html>
<html>

<?php include "head.php";?>

<body class="theme-green">
    <!-- Page Loader -->
    <div class="page-loader-wrapper">
        <div class="loader">
            <div class="preloader">
                <div class="spinner-layer pl-red">
                    <div class="circle-clipper left">
                        <div class="circle"></div>
                    </div>
                    <div class="circle-clipper right">
                        <div class="circle"></div>
                    </div>
                </div>
            </div>
            <p>Please wait...</p>
        </div>
    </div>
    <!-- #END# Page Loader -->
    <!-- Overlay For Sidebars -->
    <div class="overlay"></div>
    <!-- #END# Overlay For Sidebars -->
    <!-- Search Bar -->
    <div class="search-bar">
        <div class="search-icon">
            <i class="material-icons">search</i>
        </div>
        <input type="text" placeholder="START TYPING...">
        <div class="close-search">
            <i class="material-icons">close</i>
        </div>
    </div>
    <!-- #END# Search Bar -->
<?php include "topbar.php";?>
    <!-- #Top Bar -->
    <section>
        <!-- Left Sidebar -->
<?php include "left_sidebar.php";?>
        <!-- #END# Left Sidebar -->
   <!-- Right Sidebar -->
 <?php //include "right_sidebar.php";?>
  <!-- #END# Right Sidebar -->   
    </section>

    <section class="content">
  	<!-- CONTENT --> 
   <?php 
   	$koneksi=koneksi_tabungan($_SESSION['npsn']);
   if(isset($_GET['anggota'])){
   	if(($_SESSION['user_kategori']=='Superadmin') or ($_SESSION['user_kategori']=='Petugas')){	
   		if(isset($_GET['mn']))
		{
   		$menu=noninjection($koneksi,$_GET['mn']);
   		if($menu=='anggota_add'){include "./content/anggota_add.php";}
		elseif($menu=='anggota_edit'){include "./content/anggota_add.php";}
		elseif($menu=='anggota_view'){include "./content/anggota_view.php";}
		elseif($menu=='anggota_upload'){include "./content/anggota_upload.php";}
		else {include "./content/anggota.php";}
   		}else {include "./content/anggota.php";}
   	}
       
   }else if(isset($_GET['user'])){
   		if($_SESSION['user_kategori']=='Superadmin'){
   		if(isset($_GET['mn']))
		{
   		$menu=noninjection($koneksi,$_GET['mn']);
   		if($menu=='user_add'){include "./content/user_add.php";}
		elseif($menu=='user_edit'){include "./content/user_add.php";}
		elseif($menu=='user_view'){include "./content/user_view.php";}
		elseif($menu=='user_upload'){include "./content/user_upload.php";}
		else {include "./content/user.php";}
   		}else {include "./content/user.php";}
   		}
	}else if(isset($_GET['transfer_antarpondok'])){
	    if(($_SESSION['user_kategori']=='Superadmin') or ($_SESSION['user_kategori']=='Teller')){
   		if(isset($_GET['mn']))
		{
   		$menu=noninjection($koneksi,$_GET['mn']);
   		if($menu=='transfer_antarpondok_add'){include "./content/transfer_antarpondok_add.php";}
		elseif($menu=='transfer_antarpondok_edit'){include "./content/transfer_antarpondok_add.php";}
		elseif($menu=='transfer_antarpondok_view'){include "./content/transfer_antarpondok_view.php";}
		elseif($menu=='transfer_antarpondok_del'){include "./content/transfer_antarpondok_del.php";}
		else {include "./content/transfer_antarpondok.php";}
   		}else {include "./content/transfer_antarpondok.php";}
	    }
	}else if(isset($_GET['transfer_bank'])){
	    if(($_SESSION['user_kategori']=='Superadmin') or ($_SESSION['user_kategori']=='Teller')){
   		if(isset($_GET['mn']))
		{
   		$menu=noninjection($koneksi,$_GET['mn']);
   		if($menu=='transfer_bank_add'){include "./content/transfer_bank_add.php";}
		elseif($menu=='transfer_bank_edit'){include "./content/transfer_bank_add.php";}
		elseif($menu=='transfer_bank_view'){include "./content/transfer_bank_view.php";}
		elseif($menu=='transfer_bank_del'){include "./content/transfer_bank_del.php";}
		else {include "./content/transfer_bank.php";}
   		}else {include "./content/transfer_bank.php";}
	    }
   }elseif(isset($_GET['setoran'])){
       if(($_SESSION['user_kategori']=='Superadmin') or ($_SESSION['user_kategori']=='Teller')){
   		if(isset($_GET['mn']))
		{
   		$menu=noninjection($koneksi,$_GET['mn']);
   		if($menu=='setoran_add'){include "./content/setoran_add.php";}
		elseif($menu=='setoran_view'){include "./content/setoran_view.php";}
		elseif($menu=='setoran_del'){include "./content/setoran_del.php";}
		elseif($menu=='setoran_upload'){include "./content/setoran_upload.php";}
		else {include "./content/setoran.php";}
   		}else {include "./content/setoran.php";}
       }
   }elseif(isset($_GET['penarikan'])){
       if(($_SESSION['user_kategori']=='Superadmin') or ($_SESSION['user_kategori']=='Petugas_tarik') or ($_SESSION['user_kategori']=='Teller')){
   		if(isset($_GET['mn']))
		{
   		$menu=noninjection($koneksi,$_GET['mn']);
   		if($menu=='penarikan_add'){include "./content/penarikan_add.php";}
		elseif($menu=='penarikan_view'){include "./content/penarikan_view.php";}
		elseif($menu=='penarikan_del'){include "./content/penarikan_del.php";}
		elseif($menu=='penarikan_upload'){include "./content/penarikan_upload.php";}
		else {include "./content/penarikan.php";}
   		}else {include "./content/penarikan.php";}
       }
	   }elseif(isset($_GET['penarikan_kantin'])){
       if(($_SESSION['user_kategori']=='Superadmin') or ($_SESSION['user_kategori']=='Petugas_tarik') or ($_SESSION['user_kategori']=='Teller')){
   		if(isset($_GET['mn']))
		{
   		$menu=noninjection($koneksi,$_GET['mn']);
   		if($menu=='penarikan_kantin_add'){include "./content/penarikan_kantin_add.php";}
		elseif($menu=='penarikan_kantin_view'){include "./content/penarikan_kantin_view.php";}
		else {include "./content/penarikan_kantin.php";}
   		}else {include "./content/penarikan_kantin.php";}
       }
	}elseif(isset($_GET['setjajan'])){
   	if($_SESSION['user_kategori']=='Superadmin'){
   		if(isset($_GET['mn']))
		{
   		$menu=noninjection($koneksi,$_GET['mn']);
   		if($menu=='setjajan_add'){include "./content/setjajan_add.php";}
		
		else {include "./content/setjajan.php";}
   		}else {include "./content/setjajan.php";}
   	}
    }elseif(isset($_GET['profile'])){include "./content/profile.php";
    }elseif(isset($_GET['rekening'])){include "./content/rekening.php";
    }elseif(isset($_GET['hasil_bagi'])){include "./content/hasil_bagi.php";
   } else {include "./content/rekening.php";
   }
   
   ?>
   
    <!-- #END# CONTENT -->  
    </section>
<?php include "jscript.php";?>
   
</body>

</html>
<?php } else {
include "login.php";
}?>
