<?php 
include 'connect.php';
//include 'internalPage/insertSuratMasuk.php';
session_start();

	$sql = "SELECT * FROM `bahagian/unit`";
	$result = mysqli_query($conn,$sql);
	//$row = mysqli_fetch_array($result);
	
	$sql1 = "select * from `user` where kad_pengenalan = '".$_SESSION['kadPengenalan']."' ";
	$result1 = mysqli_query($conn,$sql1);
	$row1 = mysqli_fetch_array($result1);
	$count = mysqli_num_rows($result1);
	
	echo $_SESSION['kadPengenalan'];
	
	$userID = $row1["id_user"];	
	
	$date = date('Y-m-d');
	$date1 = date('d-m-Y');
	

?>

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta content="width=device-width, initial-scale=1.0" name="viewport">

  <title>Sistem Pendaftaran Surat</title>
  <meta content="" name="description">
  <meta content="" name="keywords">

  <!-- Favicons -->
  <link href="assets/img/logo_tab.png" rel="icon">

  <!-- Google Fonts -->
  <link href="https://fonts.gstatic.com" rel="preconnect">
  <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i|Nunito:300,300i,400,400i,600,600i,700,700i|Poppins:300,300i,400,400i,500,500i,600,600i,700,700i" rel="stylesheet">

  <!-- Vendor CSS Files -->
  <link href="assets/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
  <link href="assets/vendor/bootstrap-icons/bootstrap-icons.css" rel="stylesheet">
  <link href="assets/vendor/boxicons/css/boxicons.min.css" rel="stylesheet">
  <link href="assets/vendor/quill/quill.snow.css" rel="stylesheet">
  <link href="assets/vendor/quill/quill.bubble.css" rel="stylesheet">
  <link href="assets/vendor/remixicon/remixicon.css" rel="stylesheet">
  <link href="assets/vendor/simple-datatables/style.css" rel="stylesheet">

  <!-- Template Main CSS File -->
  <link href="assets/css/style.css" rel="stylesheet">
  
  <!-- Script logout -->
  <script type="text/javascript" src="internalPage/logoutConfirmation.js"></script>
  



  <!-- =======================================================
  * Template Name: NiceAdmin - v2.2.0
  * Template URL: https://bootstrapmade.com/nice-admin-bootstrap-admin-html-template/
  * Author: BootstrapMade.com
  * License: https://bootstrapmade.com/license/
  ======================================================== -->
</head>

<body>

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

  <main id="main" class="main" >

    <div class="pagetitle">
      <h1>Dashboard <?php echo $date1 ?></h1>
      
    </div><!-- End Page Title -->
    <section class="section dashboard">
      <div class="row">
         <!-- Sales Card -->
            <div class="col-xxl-4 col-md-6">
              <div class="card info-card sales-card">

                <div class="card-body">
                  <h5 class="card-title"> BAHAGIAN PENTADBIRAN DAN SUMBER MANUSIA <span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='BAHAGIAN PENTADBIRAN DAN SUMBER MANUSIA' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>
                </div>

              </div>
            </div><!-- End Sales Card -->

            <!-- Revenue Card -->
            <div class="col-xxl-4 col-md-6">
              <div class="card info-card sales-card">

               <div class="card-body">
                  <h5 class="card-title">UNIT PENTADBIRAN TANAH <span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='UNIT PENTADBIRAN TANAH' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>
                </div>

              </div>
            </div><!-- End Revenue Card -->

            <!-- Customers Card -->
            <div class="col-xxl-4 col-xl-12">

              <div class="card info-card sales-card">

                <div class="card-body">
                  <h5 class="card-title">UNIT PEMBANGUNAN <span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='UNIT PEMBANGUNAN' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>

                </div>
              </div>

            </div><!-- End Customers Card -->
			
			<!-- Customers Card -->
            <div class="col-xxl-4 col-xl-12">

              <div class="card info-card sales-card">

                <div class="card-body">
                  <h5 class="card-title">UNIT PENGURUSAN DANA WAKAF <span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='UNIT PENGURUSAN DANA WAKAF' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>

                </div>
              </div>

            </div><!-- End Customers Card -->
			 
			 <!-- Sales Card -->
            <div class="col-xxl-4 col-md-6">
              <div class="card info-card sales-card">

                <div class="card-body">
                  <h5 class="card-title"> UNIT PENGURUSAN DAN PENYELENGGARAAN PREMIS <span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='UNIT PENGURUSAN DAN PENYELENGGARAAN PREMIS' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>
                </div>

              </div>
            </div><!-- End Sales Card -->

            <!-- Revenue Card -->
            <div class="col-xxl-4 col-md-6">
              <div class="card info-card sales-card">

               <div class="card-body">
                  <h5 class="card-title">BAHAGIAN UNDANG-UNDANG <span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='BAHAGIAN UNDANG-UNDANG' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>
                </div>

              </div>
            </div><!-- End Revenue Card -->

            <!-- Customers Card -->
            <div class="col-xxl-4 col-xl-12">

              <div class="card info-card sales-card">

                <div class="card-body">
                  <h5 class="card-title">BAHAGIAN KEWANGAN DAN AKAUN<span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='BAHAGIAN KEWANGAN DAN AKAUN' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>

                </div>
              </div>

            </div><!-- End Customers Card -->
			<!-- Sales Card -->
            <div class="col-xxl-4 col-md-6">
              <div class="card info-card sales-card">

                <div class="card-body">
                  <h5 class="card-title"> UNIT AUDIT DALAM <span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='UNIT AUDIT DALAM' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>
                </div>

              </div>
            </div><!-- End Sales Card -->

            <!-- Revenue Card -->
            <div class="col-xxl-4 col-md-6">
              <div class="card info-card sales-card">

               <div class="card-body">
                  <h5 class="card-title">PENGURUSAN<span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='PENGURUSAN' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>
                </div>

              </div>
            </div><!-- End Revenue Card -->

            <!-- Customers Card -->
            <div class="col-xxl-4 col-xl-12">

              <div class="card info-card sales-card">

                <div class="card-body">
                  <h5 class="card-title">PEJABAT SETIAUSAHA<span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='PEJABAT SETIAUSAHA' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>

                </div>
              </div>

            </div><!-- End Customers Card -->
			<!-- Sales Card -->
            <div class="col-xxl-4 col-md-6">
              <div class="card info-card sales-card">

                <div class="card-body">
                  <h5 class="card-title"> YANG DI PERTUA<span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='YANG DI PERTUA' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>
                </div>

              </div>
            </div><!-- End Sales Card -->

            <!-- Revenue Card -->
            <div class="col-xxl-4 col-md-6">
              <div class="card info-card sales-card">

               <div class="card-body">
                  <h5 class="card-title">SETIAUSAHA<span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='SETIAUSAHA' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>
                </div>

              </div>
            </div><!-- End Revenue Card -->

            <!-- Customers Card -->
            <div class="col-xxl-4 col-xl-12">

              <div class="card info-card sales-card">

                <div class="card-body">
                  <h5 class="card-title">PENGURUS BAITULMAL<span>| Today</span></h5>

                  <div class="d-flex align-items-center">
                    <div class="card-icon rounded-circle d-flex align-items-center justify-content-center">
                      <i class="bi bi-envelope-plus-fill"></i>
                    </div>
                    <div class="ps-3">
					<?php
						$query="SELECT COUNT(`id_surat_masuk`) AS totalSuratMasuk FROM `surat_masuk` WHERE `bahagian`='PENGURUS BAITULMAL' AND tarikh_terima_surat='".$date."'";
						$rslt = mysqli_query($conn,$query);
						$fetch = mysqli_fetch_array($rslt);
					?>
                      <h6><?php echo $fetch['totalSuratMasuk'];?></h6>
                      

                    </div>
                  </div>

                </div>
              </div>

            </div><!-- End Customers Card -->
			 
          </div>     
          </div>
        </div>
      </div>
    </section>

  </main><!-- End #main -->

  <!-- ======= Footer ======= -->
  <footer id="footer" class="footer">
    <div class="copyright">
      &copy; Copyright <strong><span>Majlis Agama Islam Negeri Pulau Pinang @ 2022</span></strong>.
    </div>
  </footer><!-- End Footer -->

  <a href="#" class="back-to-top d-flex align-items-center justify-content-center"><i class="bi bi-arrow-up-short"></i></a>

  <!-- Vendor JS Files -->
  <script src="assets/vendor/apexcharts/apexcharts.min.js"></script>
  <script src="assets/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
  <script src="assets/vendor/chart.js/chart.min.js"></script>
  <script src="assets/vendor/echarts/echarts.min.js"></script>
  <script src="assets/vendor/quill/quill.min.js"></script>
  <script src="assets/vendor/simple-datatables/simple-datatables.js"></script>
  <script src="assets/vendor/tinymce/tinymce.min.js"></script>
  <script src="assets/vendor/php-email-form/validate.js"></script>

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

</body>

</html>