<?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');



$active_id=$_REQUEST['active_id'];
$menu_id=$_REQUEST['menu_id'];


 // Common Information

$page_title="Products & Services";
$page="32_product_add.php?active_id=".$active_id."&menu_id=".$menu_id."";
$table='item_type';	
$unique='id';

//$request_id=$_REQUEST['id'];

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

// End Common Information

if(isset($_POST['insert']))

{		

$_POST['entry_by'] = $_SESSION['user']['id'];
		 
$_POST['entry_at'] = $now=date('Y-m-d H:i:s');

$item_category = $_POST['item_category'];


//$grp_sql="SELECT * FROM ledger_group  WHERE group_id='".$ledger_group_id."'";
//$grp_data = find_all_field_sql($conn,$grp_sql);

//cy_id=mysqli_fetch_object(mysqli_query($conn,'select max(ledger_sl) as ledger_sl from '.$table.' where ledger_group_id="'.$ledger_group_id.'"'));
//$ledger_sl_id=$cy_id->ledger_sl+1;
//$ledger_sl_no = sprintf("%05d", $ledger_sl_id);

//$ledger_id = $ledger_group_id.''.$ledger_sl_no;

  $ins_sql = 'INSERT INTO item_category (item_category, entry_by, entry_at) VALUES

("'.$item_category.'", "'.$_POST['entry_by'].'", "'.$_POST['entry_at'].'")';
	
mysqli_query($conn,$ins_sql);

?>

<!--<script language="javascript">
window.location.href = "03_acc_group.php";
</script>-->

<?php

}



if(isset($_POST['update']))

{		

$_POST['entry_by'] = $_SESSION['user']['id'];
		 
$_POST['entry_at'] = $now=date('Y-m-d H:i:s');

$item_category = $_POST['item_category'];

$id=$request_id;

$up_sql = 'update item_category set item_category="'.$item_category.'", edit_by="'.$_POST['entry_by'].'", edit_at="'.$_POST['entry_at'].'" 
 where id='.$id;
mysqli_query($conn,$up_sql);


?>

<?php /*?><script language="javascript">
window.location.href = "03_acc_group.php";
</script><?php */?>

<?php

}

?>





<!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 ======= -->
   <?php  require_once('inc_files/inc_menu.php'); ?>
   <!-- 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="home.php">Home</a></li>
          <li class="breadcrumb-item">Products &amp; Services</li>
          <li class="breadcrumb-item active"><?php echo $page_title;?></li>
        </ol>
      </nav>
    </div><!-- End Page Title -->
    <section class="section dashboard" >
      <div class="row" style="height:500px;">
         <!-- Sales Card -->
            <div class="col-xxl-3 col-xl-12">
              <div class="card info-card sales-card">

                

                <div class="card-body">
                  <h5 class="card-title"><strong>Inventory</strong> </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-server"></i>
                    </div>
                    <div class="ps-3">
                      <h6><?php echo find_a_field($conn,'item_info','count(item_id)','item_type=1')?></h6>
                      <!--<span class="text-success small pt-1 fw-bold">12%</span>--> <span class="text-muted small pt-2 ps-1">Inventory Item</span>

                    </div>
                  </div>
				  
				  <p class="card-title" align="center">
				   <a href="33_product_service.php?active_id=402&menu_id=4&item_type=1"><button type="button" class="btn btn-primary btn-sm"><i class="bi bi-plus-lg me-1"></i> New Item&nbsp;&nbsp;&nbsp;</button></a> </p>
				  
				  
                </div>

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

            <!-- Revenue Card -->
            <div class="col-xxl-3 col-xl-12">
              <div class="card info-card revenue-card">

                

                <div class="card-body">
                  <h5 class="card-title"><strong>Non-Inventory</strong> </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-stack"></i>
                    </div>
                    <div class="ps-3">
                      <h6><?php echo find_a_field($conn,'item_info','count(item_id)','item_type=2')?></h6>
                     <!-- <span class="text-success small pt-1 fw-bold">8%</span>--> <span class="text-muted small pt-2 ps-1">Non-Inventory Item</span>

                    </div>
                  </div>
				  
				  <p class="card-title" align="center">
				   <a href="34_product_service.php?active_id=402&menu_id=4&item_type=2"><button type="button" class="btn btn-primary btn-sm"><i class="bi bi-plus-lg me-1"></i> New Item&nbsp;&nbsp;&nbsp;</button></a> </p>
				  
				  
                </div>

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

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

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

                

                <div class="card-body">
                  <h5 class="card-title"><strong>Service</strong></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-people"></i>
                    </div>
                    <div class="ps-3">
                      <h6><?php echo find_a_field($conn,'item_info','count(item_id)','item_type=3')?></h6>
                      <!--<span class="text-danger small pt-1 fw-bold">12%</span>--> <span class="text-muted small pt-2 ps-1">Service Item</span>

                    </div>
                  </div>
				  
				  <p class="card-title" align="center">
				   <a href="35_product_service.php?active_id=402&menu_id=4&item_type=3"><button type="button" class="btn btn-primary btn-sm"><i class="bi bi-plus-lg me-1"></i> New Item&nbsp;&nbsp;&nbsp;</button></a> </p>

                </div>
              </div>

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

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

                

                <div class="card-body">
                  <h5 class="card-title"><strong>Fixed Asset</strong></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-house"></i>
                    </div>
                    <div class="ps-3">
                      <h6><?php echo find_a_field($conn,'item_info','count(item_id)','item_type=4')?></h6>
                      <!--<span class="text-danger small pt-1 fw-bold">12%</span>--> <span class="text-muted small pt-2 ps-1">Fixed Asset Item</span>

                    </div>
		
                  </div>
				  
				   <p class="card-title" align="center">
				   <a href="36_product_service.php?active_id=402&menu_id=4&item_type=4"><button type="button" class="btn btn-primary btn-sm"><i class="bi bi-plus-lg me-1"></i> New Item&nbsp;&nbsp;&nbsp;</button></a> </p>

                </div>
					
				
              </div>

            </div>

        
      </div>
    </section>

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

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

</body>

</html>