<!doctype html>
<html lang="en">
  <!-- [Head] start -->

  <head>
<?php include 'head.php'; ?>
<?php include 'head-css.php'; ?>
<!-- <?php
$logoFile = !empty($settings->logo_sidebar) ? $settings->logo_sidebar : 'default-logo.svg';
$logoPath = FCPATH . 'uploads/settings/' . $logoFile;
if (!file_exists($logoPath)) {
    $logoFile = 'default-logo.svg'; // fallback
}
?> -->

<?php
$this->load->helper('common_helper');

$current_shift = get_current_shift();

$last_token = $current_shift ? get_last_token_number($current_shift->id) : 0;
$next_token = $current_shift ? get_next_token_number($current_shift->id) : 1;

update_cash_in_hand_session();
?>
  </head>
  <!-- [Head] end -->
  <!-- [Body] Start -->

<body data-pc-preset="preset-1" data-pc-sidebar-theme="dark" data-pc-sidebar-caption="true" data-pc-direction="ltr" data-pc-theme="light" data-pc-header-theme="dark">
    <!-- [ Pre-loader ] start -->
    <!-- [ Pre-loader ] start -->
<!-- <div class="loader-bg">
  <div class="pc-loader">
    <div class="loader-ring"></div>
    <div class="loader-ring ring2"></div>
    <img src="<?= base_url('assets/images/munshi-ji-logo-rounded.svg') ?>" alt="Logo" class="loader-logo">
  </div>
</div> -->
<!-- [ Pre-loader ] End -->
<!-- [ Pre-loader ] End --> 
 <!-- [ Sidebar Menu ] start -->
<nav class="pc-sidebar">
  <div class="navbar-wrapper">
    <div class="m-header">
      <a href="<?php echo base_url(); ?>" class="b-brand text-primary">
        <!-- ========   Change your logo from here   ============ -->










        <img src="<?= base_url('uploads/settings/' . $logoFile) ?>" alt="logo image" class="logo-lg"  style="width: 255px; margin-bottom: 1px;"/>
      </a>
    </div>


    <div class="navbar-content">
      <ul class="pc-navbar">
<!--         <li class="pc-item pc-caption">
          <label>Navigation</label>
        </li> -->

        <li class="pc-item pc-hasmenu">
          <a href="<?php echo base_url(); ?>" class="pc-link">
            <span class="pc-micon">
              <i class="ph-duotone ph-gauge"></i>
            </span>
            <span class="pc-mtext">Dashboard</span>
          </a>
        </li>
        <li class="pc-item pc-hasmenu">
          <a href="<?php echo base_url(); ?>admin/tokens" class="pc-link">
            <span class="pc-micon">
                            <i class="ph-duotone ph-tag"></i>

            </span>
            <span class="pc-mtext">Token Management</span>
          </a>
        </li>


<!--         <li class="pc-item pc-hasmenu">
          <a href="#!" class="pc-link">
            <span class="pc-micon">
              <i class="ph-duotone ph-tag"></i>
            </span>
            <span class="pc-mtext">Token Management</span>
            <span class="pc-arrow"><i data-feather="chevron-right"></i></span>
          </a>
          <ul class="pc-submenu">
            <li class="pc-item"><a class="pc-link" href="<?php echo base_url(); ?>admin/tokens/reports">Tokens Report</a></li>
            <li class="pc-item"><a class="pc-link" href="<?php echo base_url(); ?>admin/tokens">All Tokens</a></li>
            <li class="pc-item"><a class="pc-link" href="<?php echo base_url(); ?>admin/tokens/add">Add New Token</a></li>
          </ul>
        </li> -->


        <li class="pc-item pc-hasmenu">
          <a href="<?php echo base_url(); ?>admin/sub_services" class="pc-link">
            <span class="pc-micon"><i class="ph-duotone ph-first-aid-kit"></i></span>
            <span class="pc-mtext">Services & Fee</span>
          </a>
        </li>




        <li class="pc-item pc-hasmenu">
          <a href="<?php echo base_url(); ?>admin/expense/index" class="pc-link">
            <span class="pc-micon"><i class="ph-duotone ph-currency-dollar"></i></span>
            <span class="pc-mtext">Expense Management</span>
          </a>
        </li>



<?php
// Helper to extract initials from a name
if (!function_exists('get_initials')) {
    function get_initials($name) {
        $parts = preg_split('/\s+/', trim($name));
        $initials = '';
        foreach ($parts as $p) {
            $initials .= mb_substr($p, 0, 1);
        }
        return strtoupper($initials);
    }
}
$fullname = $this->session->userdata('qurbani_fullname');
?>
        


                <li class="pc-item pc-hasmenu">
          <a href="<?php echo base_url(); ?>admin/staff" class="pc-link">
            <span class="pc-micon"><i class="ph-duotone ph-align-left-simple"></i></span>
            <span class="pc-mtext">Staff</span>
          </a>
        </li>
        
        <li class="pc-item pc-hasmenu">
          <a href="#!" class="pc-link">
            <span class="pc-micon">
              <i class="ph-duotone ph-users"></i>
            </span>
            <span class="pc-mtext">Payments</span>
            <span class="pc-arrow"><i data-feather="chevron-right"></i></span>
          </a>
          <ul class="pc-submenu">
            <li class="pc-item"><a class="pc-link" href="<?php echo base_url(); ?>admin/payments">All Payments</a></li>
             <li class="pc-item"><a class="pc-link" href="<?php echo base_url(); ?>admin/payments/add">Add New Payment</a></li>
          </ul>
        </li>

        <li class="pc-item pc-hasmenu">
          <a href="#!" class="pc-link">
            <span class="pc-micon">
              <i class="ph-duotone ph-users"></i>
            </span>
            <span class="pc-mtext">Users</span>
            <span class="pc-arrow"><i data-feather="chevron-right"></i></span>
          </a>
          <ul class="pc-submenu">
            <li class="pc-item"><a class="pc-link" href="<?php echo base_url(); ?>admin/users">All Users</a></li>
             <li class="pc-item"><a class="pc-link" href="<?php echo base_url(); ?>admin/users/add">Add New User</a></li>
          </ul>
        </li>
        


       <li class="pc-item pc-hasmenu">
          <a href="<?php echo base_url(); ?>admin/settings" class="pc-link">
            <span class="pc-micon"><i data-feather="settings"></i></span>
            <span class="pc-mtext">settings</span>
          </a>
        </li>


        <li class="pc-item pc-hasmenu">
          <a href="<?php echo base_url(); ?>admin/reports" class="pc-link">
            <span class="pc-micon"><i data-feather="printer"></i></span>
            <span class="pc-mtext">Reports/Print</span>
          </a>
        </li>

<div class="ticket">


    <div class="ticket-title">NEXT</div>

    <div class="divider-token"></div>

    <div class="label-token" style="text-align:center;">TOKEN NO</div>
    <div class="token"><?php echo $next_token; ?></div>

    <div class="divider-token"></div>

    <div class="footer-token">
        <?php echo htmlspecialchars($current_shift->name . ' Shift'  ?? 'N/A'); ?>
    </div>
</div>

      </ul>
     
    </div>
  </div>
</nav>
<!-- [ Sidebar Menu ] end -->
 <!-- [ Header Topbar ] start -->
<header class="pc-header">
  <div class="header-wrapper"> <!-- [Mobile Media Block] start -->
<div class="me-auto pc-mob-drp">
  <ul class="list-unstyled">
    <!-- ======= Menu collapse Icon ===== -->
    <li class="pc-h-item pc-sidebar-collapse">
      <a href="#" class="pc-head-link ms-0" id="sidebar-hide">
        <i class="ph-duotone ph-list"></i>
      </a>
    </li>
    <li class="pc-h-item pc-sidebar-popup">
      <a href="#" class="pc-head-link ms-0" id="mobile-collapse">
        <i class="ph-duotone ph-list"></i>
      </a>
    </li>
    
    <li class="pc-h-item">
      <a href="<?php echo base_url(); ?>admin/tokens/add" class="pc-head-link ms-0" id="">
        <i class="ph-duotone ph-tag"></i>
      </a>
    </li>



  </ul>
</div>
<!-- [Mobile Media Block end] -->
<div class="ms-auto">
  <ul class="list-unstyled">

    <li class=" pc-h-item bg-primary text-white d-flex align-items-center justify-content-center" style="padding: 0px 25px; margin-right: 2px;">
      <h4 class="text-white mb-0"><i class="ph-duotone ph-wallet"> </i> <span> Rs.<?php echo number_format($this->session->userdata('cash_in_hand')); ?></span></h4>
    </li>
    <li class="bg-primary  dropdown pc-h-item" style="padding: 0px 10px;">
      <a
        class="dropdown-toggle arrow-none me-0"
        data-bs-toggle="dropdown"
        href="#"
        role="button"
        aria-haspopup="false"
        data-bs-auto-close="outside"
        aria-expanded="false"
      >
  <div class="text-white d-flex align-items-center justify-content-center"
       style="width:45px;height:45px;font-weight:bold;">
    <?php echo get_initials($fullname); ?>
  </div>
      </a>
      <div class="dropdown-menu dropdown-user-profile dropdown-menu-end pc-h-dropdown">
        <div class="dropdown-body">
          <div class="profile-notification-scroll position-relative" style="max-height: calc(100vh - 225px)">
            <ul class="list-group list-group-flush w-100">
              <li class="list-group-item">
                <div class="d-flex align-items-center">
                  <div class="flex-shrink-0">
                      <div class="rounded-circle bg-primary text-white d-flex align-items-center justify-content-center"
       style="width:50px;height:50px;font-weight:bold;">
    <?php echo get_initials($fullname); ?>
  </div>
                  </div>
                  <div class="flex-grow-1 mx-3">
                    <h5 class="mb-0"><?php echo $this->session->userdata('qurbani_fullname'); ?></h5>
                    <a class="link-primary" href="mailto:<?php echo $this->session->userdata('qurbani_email'); ?>"><?php echo $this->session->userdata('qurbani_username'); ?></a>
                  </div>
                </div>
              </li>
              <li class="list-group-item">
                <a href="<?php echo base_url() ?>admin/users/edit/<?php echo $this->session->userdata('qurbani_user_id'); ?>" class="dropdown-item">
                  <span class="d-flex align-items-center">
                    <i class="ph-duotone ph-user-circle"></i>
                    <span>Edit profile</span>
                  </span>
                </a>

                <a href="#" class="dropdown-item">
                  <span class="d-flex align-items-center">
                    <i class="ph-duotone ph-key"></i>
                    <span>Change password</span>
                  </span>
                </a>
                <a href="#" class="dropdown-item">
                  <span class="d-flex align-items-center">
                    <i class="ph-duotone ph-gear-six"></i>
                    <span>Settings</span>
                  </span>
                </a>
                <a href="<?php echo base_url() ?>admin/home/logout" class="dropdown-item">
                  <span class="d-flex align-items-center">
                    <i class="ph-duotone ph-power"></i>
                    <span>Logout</span>
                  </span>
                </a>
                <div class="dropdown-item">
                  <span class="d-flex align-items-center">
                    <i class="ph-duotone ph-moon"></i>
                    <span>Dark mode</span>
                  </span>
                  <div class="form-check form-switch form-check-reverse m-0">
                    <input class="form-check-input f-18" id="dark-mode" type="checkbox" onclick="dark_mode()" role="switch" />
                  </div>
                </div>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </li>





        <li class=" pc-h-item bg-primary text-white d-flex align-items-center justify-content-center" style="padding: 0px 10px; margin-left: 2px;">
      <a href="<?php echo base_url(); ?>admin/tokens/add" class="pc-head-link ms-0" id="">
        <i data-feather="settings"></i>
      </a>
    </li>
  </ul>
</div>
 </div>
</header>
<!-- [ Header ] end -->
<!-- [ Main Content ] start -->
    <div class="pc-container">
      <div class="card">
        <div class="card-header">
            <div class="row align-items-center justify-content-between">
              <div class="col-sm-auto">
                  <h4 class="mb-0"><?php echo $title ?></h4>
              </div>
              <div class="col-sm-auto">
                <ul class="breadcrumb">
                  <li class="breadcrumb-item">
                    <a href="<?= base_url() ?>"><i class="ph-duotone ph-gauge"></i></a>
                  </li>
                  <?php if (!empty($breadcrumb) && is_array($breadcrumb)): ?>
                    <?php foreach ($breadcrumb as $bc): ?>
                      <li class="breadcrumb-item">
                        <?php if (!empty($bc['url'])): ?>
                          <a href="<?= $bc['url'] ?>"><?= $bc['label'] ?></a>
                        <?php else: ?>
                          <?= $bc['label'] ?>
                        <?php endif; ?>
                      </li>
                    <?php endforeach; ?>
                  <?php elseif (!empty($breadcrumb)): ?>
                    <li class="breadcrumb-item"><?= $breadcrumb ?></li>
                  <?php endif; ?>
                </ul>
              </div>
            </div>
          </div>
        
      </div>

      <div class="pc-content">
          <?php $this->load->view($mainContent); ?>
     </div>
    </div>
    <!-- [ Main Content ] end -->
    <footer class="pc-footer">
      <div class="footer-wrapper container-fluid">
        <div class="row">
          <div class="col my-1">
            <p class="m-0"
              >Develop &#9829; <a href="#" target="_blank">by Shahid</a></p
            >
          </div>
          <div class="col-auto my-1">
            <ul class="list-inline footer-link mb-0">
              <li class="list-inline-item"><a href="<?php echo base_url(); ?>">Home</a></li>
              <!-- todo link update -->
              <li class="list-inline-item"><a href="#" target="_blank">Documentation</a></li>
              <li class="list-inline-item"><a href="#" target="_blank">Support</a></li>
            </ul>
          </div>
        </div>
      </div>
    </footer>



    <!-- [Page Specific JS] start -->
    <script src="<?php echo base_url(); ?>assets/js/plugins/apexcharts.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/js/pages/dashboard-default.js"></script>
    <!-- [Page Specific JS] end -->
    <!-- Required Js -->
    <?php include 'footer-js.php'; ?>
</body>
  <!-- [Body] end -->
</html>     