<?php
ini_set('display_errors', 0);
//error_reporting(E_ALL);
//ini_set('display_errors', 1);

session_start();
ob_start();

require_once('configuration/server_connect.php');
require_once('configuration/all_function.php');


// Common Information

$page_title="Account Class";
$page="01_acc_class.php";	
$table='acc_class';	
$unique='id';

$request_id=$_REQUEST['id'];

$ms_data=mysqli_fetch_object(mysqli_query($conn,'select * from '.$table.' where id="'.$request_id.'"'));

// End Common Information



?>


<?php
if (isset($_POST['submit'])) {
  $name = $_FILES['image']['name'];
  $type = $_FILES['image']['type'];
  $size = $_FILES['image']['size'];
  $tmp_name = $_FILES['image']['tmp_name'];
  
  // Check if file type is allowed
  $allowed_extensions = array('jpg', 'jpeg', 'png', 'gif');
  $allowed_types = array('image/jpeg', 'image/png', 'image/gif');
  $extension = pathinfo($name, PATHINFO_EXTENSION);
  if (!in_array($extension, $allowed_extensions) || !in_array($type, $allowed_types)) {
    die("Error: File type not allowed.");
  }
  
  // Generate unique filename
  $timestamp = 10002;
  $random_string = bin2hex(random_bytes(5)); // generate 10-character random string
  //$new_name = $timestamp . '.' . $extension;
  $new_name = $timestamp . '.jpg';
  
  // Move uploaded file to destination folder
  $destination = 'uploads/' . $new_name;
  if (!move_uploaded_file($tmp_name, $destination)) {
    die("Error: Failed to move file.");
  }
  
  echo "File uploaded successfully.";
}
?>






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

<!-- ======= <head> ======= -->
 <?php require_once('inc_files/inc_head.php'); ?>
<!-- ======= </head> ======= -->

<body>

  <!-- ======= Header ======= -->
  <?php require_once('inc_files/inc_header.php'); ?>
  <!-- End Header -->

  <!-- ======= Sidebar ======= -->
  <aside id="sidebar" class="sidebar">

    <ul class="sidebar-nav" id="sidebar-nav">

      <li class="nav-item">
        <a class="nav-link collapsed" href="home.php">
          <i class="bi bi-grid"></i>
          <span>Dashboard</span>
        </a>
      </li><!-- End Dashboard Nav -->

       <li class="nav-item" >
        <a class="nav-link collapsed" data-bs-target="#components-nav" data-bs-toggle="collapse" href="#">
          <i class="bi bi-menu-button-wide"></i><span>Admin Panel</span><i class="bi bi-chevron-down ms-auto"></i>
        </a>
        <ul id="components-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
          <li>
            <a href="81_user_01.php">
              <i class="bi bi-circle"></i><span>User Register</span>
            </a>
          </li>
          
        </ul>
      </li><!-- End Components Nav -->

      <li class="nav-item">
        <a class="nav-link " data-bs-target="#Ledger-nav" data-bs-toggle="collapse" href="#">
          <i class="bi bi-journal-text"></i><span>General Ledger</span><i class="bi bi-chevron-down ms-auto"></i>
        </a>
        <ul id="Ledger-nav" class="nav-content collapse show" data-bs-parent="#sidebar-nav">
          
          <li>
            <a href="01_acc_class.php" class="active">
             <i class="bi bi-circle"></i><span>Account Class</span>
            </a>
          </li>
          <li>
            <a href="02_acc_sub_class.php">
             <i class="bi bi-circle"></i><span>Account Sub Class</span>
            </a>
          </li>
          <li>
            <a href="03_acc_group.php">
             <i class="bi bi-circle"></i><span>Account Group</span>
            </a>
          </li>
		  <li>
            <a href="04_acc_ledger.php">
             <i class="bi bi-circle"></i><span>GL Account</span>
            </a>
          </li>
		  <li>
            <a href="05_acc_coa_report.php">
             <i class="bi bi-circle"></i><span>Chart of Accounts</span>
            </a>
          </li>
        </ul>
      </li><!-- End Forms Nav -->
	  
	  
	  <li class="nav-item">
        <a class="nav-link collapsed" data-bs-target="#voucher-nav" data-bs-toggle="collapse" href="#">
          <i class="bi bi-layout-text-window-reverse"></i><span>General Voucher</span><i class="bi bi-chevron-down ms-auto"></i>
        </a>
        <ul id="voucher-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
          <li>
            <a href="21_voucher.php">
              <i class="bi bi-circle"></i><span>Receipt Voucher</span>
            </a>
          </li>
          <li>
            <a href="22_voucher.php">
              <i class="bi bi-circle"></i><span>Payment Voucher</span>
            </a>
          </li>
		  <li>
            <a href="23_voucher.php">
              <i class="bi bi-circle"></i><span>Journal Voucher</span>
            </a>
          </li>
		  <li>
            <a href="24_voucher.php">
              <i class="bi bi-circle"></i><span>Contra Voucher</span>
            </a>
          </li>
        </ul>
      </li>
	  
	  
	  <li class="nav-item">
        <a class="nav-link collapsed" data-bs-target="#products-nav" data-bs-toggle="collapse" href="#">
          <i class="bi bi-grid-1x2"></i><span>Products &amp; Services</span><i class="bi bi-chevron-down ms-auto"></i>
        </a>
        <ul id="products-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
          <li>
            <a href="31_product.php">
              <i class="bi bi-circle"></i><span>Category</span>
            </a>
          </li>
          <li>
            <a href="32_product_add.php">
              <i class="bi bi-circle"></i><span>Products &amp; Services</span>
            </a>
          </li>
          <li>
            <a href="37_product_all.php">
              <i class="bi bi-circle"></i><span>All Products &amp; Services</span>
            </a>
          </li>
          
        </ul>
      </li>
	  
	  <li class="nav-item">
        <a class="nav-link collapsed" data-bs-target="#customer-nav" data-bs-toggle="collapse" href="#">
          <i class="bi bi-cart"></i><span>Sales Management</span><i class="bi bi-chevron-down ms-auto"></i>
        </a>
        <ul id="customer-nav" class="nav-content collapse" data-bs-parent="#sidebar-nav">
          <li>
            <a href="41_customer_add.php">
              <i class="bi bi-circle"></i><span>Customer </span>
            </a>
          </li>
          <li>
            <a href="42_customer_all.php">
              <i class="bi bi-circle"></i><span>All Customers</span>
            </a>
          </li>
		  <li>
            <a href="43_customer_so.php">
              <i class="bi bi-circle"></i><span>Sales Invoice </span>
            </a>
          </li>
		  <li>
            <a href="44_customer_receive.php">
              <i class="bi bi-circle"></i><span>Receive Payment</span>
            </a>
          </li>
        </ul>
      </li><!-- End Tables Nav -->
	  
	  

      <li class="nav-item">
        <a class="nav-link collapsed" data-bs-target="#supplier-nav" data-bs-toggle="collapse" href="#">
          <i class="bi bi-handbag"></i><span>Purchase Management</span><i class="bi bi-chevron-down ms-auto"></i>
        </a>
        <ul id="supplier-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
          <li>
            <a href="51_supplier_add.php">
              <i class="bi bi-circle"></i><span>Supplier</span>
            </a>
          </li>
          <li>
            <a href="52_supplier_all.php">
              <i class="bi bi-circle"></i><span>All Suppliers</span>
            </a>
          </li>
		  
		  <li>
            <a href="53_supplier_po.php">
              <i class="bi bi-circle"></i><span>Purchase Bill</span>
            </a>
          </li>
		  <li>
            <a href="54_supplier_pay_bill.php">
              <i class="bi bi-circle"></i><span>Pay Bill</span>
            </a>
          </li>
          
        </ul>
      </li><!-- End Charts Nav -->
	  
	    <li class="nav-item">
        <a class="nav-link collapsed" data-bs-target="#hrm-nav" data-bs-toggle="collapse" href="#">
          <i class="bi bi-people"></i><span>HR Management</span><i class="bi bi-chevron-down ms-auto"></i>
        </a>
        <ul id="hrm-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
          <li>
            <a href="71_employee_03.php">
              <i class="bi bi-circle"></i><span>Generate Payroll</span>
            </a>
          </li>
         
        </ul>
      </li><!-- End Icons Nav -->
	  
	   <li class="nav-item">
        <a class="nav-link collapsed" href="71_employee_01.php">
          <i class="bi bi-person"></i>
          <span>Employee</span>
        </a>
      </li><!-- End Profile Page Nav -->
	  
	  <li class="nav-item">
        <a class="nav-link collapsed" href="61_reports_all.php">
          <i class="bi bi-bar-chart-line"></i>
          <span>Reports</span>
        </a>
      </li>
	  

       <li class="nav-item">
        <a class="nav-link collapsed" href="sign_out.php">
          <i class="bi bi-box-arrow-in-right"></i>
          <span>Sign Out</span>
        </a>
      </li><!-- End Login Page Nav -->


    </ul>

  </aside><!-- End Sidebar-->

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

    <div class="pagetitle">
      <h1><?php echo $page_title;?></h1>
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item"><a href="index.html">Home</a></li>
          <li class="breadcrumb-item">General Ledger</li>
          <li class="breadcrumb-item active"><?php echo $page_title;?></li>
        </ol>
      </nav>
    </div><!-- End Page Title -->
    <section class="section">
      <div class="row">
        <div class="col-lg-8"> 

          <div class="card">
            <div class="card-body">
              <h5 class="card-title"><?php echo $page_title;?></h5>
              

              <!-- Table with stripped rows -->
              <table class="table table-sm datatable">
                <thead>
                  <tr>
                    <th scope="col"><span class="card-title">Code</span></th>
                    <th scope="col"><span class="card-title">Account Class</span></th>
                  </tr>
                </thead>
                <tbody>
					<?php
						 $sql = 'select * from '.$table.' where 1';
						$query = mysqli_query($conn,$sql);
						while ($data = mysqli_fetch_object($query)) {

					?>
				
                 <tr>
                  <td><a href="<?php echo $page;?>?<?php echo $unique;?>=<?php echo $data->id;?>" style="color:#000000"><?php echo $data->id;?></a></td>
                  <td><a href="<?php echo $page;?>?<?php echo $unique;?>=<?php echo $data->id;?>" style="color:#000000"><?php echo $data->class_name;?></a></td>
                  </tr>
				  <?php }?>
                
                </tbody>
              </table>
              <!-- End Table with stripped rows -->

            </div>
          </div>

        </div>

        <div class="col-lg-4">

          <div class="card">
            <div class="card-body">
              <h5 class="card-title"><?php echo $page_title;?> </h5>

              <!-- Multi Columns Form -->
              <form method="post" action="" enctype="multipart/form-data">
  <input type="file" name="image">
  <input type="submit" name="submit" value="Upload">
</form>
<!-- End Multi Columns Form -->

            </div>
          </div>

          

          

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

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

 <!-- ======= Footer ======= -->
 <?php require_once('inc_files/inc_footer.php'); ?>
<!-- ======= Footer ======= -->

</body>

</html>