<?php 
ob_start();
session_start();
include ("../_init.php");

// Verificar sesión activa
if (!is_loggedin()) {
  redirect(root_url() . '/index.php?redirect_to=' . url());
}

// Verificar permisos de acceso
if (user_group_id() != 1 && !has_permission('access', 'read_expense')) {
  redirect(root_url() . '/' . ADMINDIRNAME . '/dashboard.php');
}

// Título del documento
$document->setTitle(trans('title_expense'));

// Scripts necesarios
$document->addScript('../assets/itsolution24/angular/modals/ExpenseViewModal.js');
$document->addScript('../assets/itsolution24/angular/modals/ExpenseEditModal.js');
$document->addScript('../assets/itsolution24/angular/controllers/ExpenseController.js');

// Cargar encabezado y barra lateral
include("header.php"); 
include("left_sidebar.php"); 
?>

<!-- Contenido principal -->
<div class="content-wrapper">

  <!-- Encabezado -->
  <section class="content-header" ng-controller="ExpenseController">
    <?php include ("../_inc/template/partials/apply_filter.php"); ?>
    
    <h1>
      <?php echo trans('CHEQUES'); ?>
      <small><?php echo store('name'); ?></small>
    </h1>

    <ol class="breadcrumb">
      <li>
        <a href="dashboard.php">
          <i class="fa fa-dashboard"></i> <?php echo trans('text_dashboard'); ?>
        </a>
      </li>
      <li>
        <?php if (isset($request->get['box_state']) && $request->get['box_state'] == 'open'): ?>
          <a href="expense.php"><?php echo trans('text_expense_title'); ?></a>
        <?php else: ?>
          <?php echo trans('FLUJO DE CHEQUES'); ?>
        <?php endif; ?>
      </li>
      <?php if (isset($request->get['box_state']) && $request->get['box_state'] == 'open'): ?>
        <li class="active"><?php echo trans('text_add'); ?></li>
      <?php endif; ?>
    </ol>
  </section>

  <!-- Contenido -->
  <section class="content">
    <?php if (DEMO): ?>
      <div class="box">
        <div class="box-body">
          <div class="alert alert-info mb-0">
            <p><span class="fa fa-fw fa-info-circle"></span> <?php echo $demo_text; ?></p>
          </div>
        </div>
      </div>
    <?php endif; ?>

    <!-- Sección reutilizada para ver cheques -->
    <div class="box">
      <div class="box-body">
        <?php include('ver_cheques.php'); ?>
      </div>
    </div>

  </section>
  <!-- Fin del contenido -->
</div>

<!-- Pie de página -->
<?php include ("footer.php"); ?>
