<?php
$CI = get_instance();
$CI->load->model('setting_model');
$CI->load->model('notification_model');
$CI->load->model('message_model');
$CI->load->model('language_model');
$CI->load->model('tasks_model');
$CI->load->model('attendance_model');

$admin              = $this->session->userdata('admin');
$case_alert         = $CI->setting_model->get_case_alert();
$case_alert_client  = $CI->setting_model->get_case_alert_client();
$setting            = $CI->setting_model->get_setting();
$client_setting     = $CI->setting_model->get_notification_setting_client();
$notification       = $CI->notification_model->get_setting();
$to_do_alert        = $CI->setting_model->get_to_do_alert();
$appointment_alert  = $CI->setting_model->get_appointment_alert();
$admin_messages     = $this->message_model->get_message_count_by_id();
$langs              = $this->language_model->get_all();
$due_tasks          = $this->tasks_model->get_due_tasks();
$my_due_tasks       = $this->tasks_model->get_my_due_tasks();
$leave_notification = $this->attendance_model->get_leave_notification();

$first  = $this->uri->segment(1);
$second = $this->uri->segment(2);
$third  = $this->uri->segment(3);
$fourth = $this->uri->segment(4);

$CI->db->select('A.name action');
$CI->db->join('actions A', 'A.id = RRA.action_id', 'LEFT');
$CI->db->where('RRA.role_id', $admin['user_role']);
$CI->db->order_by('A.name', 'asc');
$actions = $CI->db->get('rel_role_action RRA')->result();

$access = $admin['user_role'];
$parts  = explode(' ', trim($admin['name']));
$iniciais = strtoupper(substr($parts[0],0,1).(isset($parts[1])?substr($parts[1],0,1):''));

$t_total = count((array)$due_tasks) + count((array)$my_due_tasks) + count((array)$to_do_alert);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title><?php echo $setting->name ?></title>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<link href="<?php echo base_url('assets/css/bootstrap.min.css') ?>" rel="stylesheet">
<link href="<?php echo base_url('assets/css/font-awesome.min.css') ?>" rel="stylesheet">
<link href="<?php echo base_url('assets/css/ionicons.min.css') ?>" rel="stylesheet">
<link href="<?php echo base_url('assets/css/morris/morris.css') ?>" rel="stylesheet">
<link href="<?php echo base_url('assets/css/pickmeup.min.css') ?>" rel="stylesheet">
<link href="<?php echo base_url('assets/css/AdminLTE.css') ?>" rel="stylesheet">
<link href="<?php echo base_url('assets/css/redactor.css') ?>" rel="stylesheet">
<script src="<?php echo base_url('assets/js/jquery.js') ?>"></script>

<style>
/* ════════════════════════════════════════════════
   BRENO PAIVA ADVOCACIA — TEMA v4
   ════════════════════════════════════════════════ */
:root {
    --sb-w:        220px;
    --sb-w-mini:   52px;
    --tb-h:        52px;
    --sb-bg:       #2A5286; 
    --sb-dark:     #366AAD; 
    --sb-hover:    rgba(255,255,255,.07);
    --sb-active:   rgba(255,255,255,.13);
    --sb-accent:   #7eb8e8;
    --sb-text:     rgba(255,255,255,.72);
    --sb-dim:      rgba(255,255,255,.35);
    --page-bg:     #f4f6f9;
    --white:       #ffffff;
    --border:      #e2e6ea;
    --radius:      10px;
    --radius-sm:   6px;
    --shadow-sm:   0 1px 4px rgba(0,0,0,.07);
    --shadow-md:   0 2px 10px rgba(0,0,0,.09);
    --transition:  all .25s ease;
}

/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', system-ui, Arial, sans-serif !important;
    font-size: 13px !important;
    background: var(--page-bg) !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow-x: hidden;
}

/* ════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════ */
#bp-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sb-w);
    background: var(--sb-bg);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: 2px 0 8px rgba(0,0,0,.12);
}
#bp-sidebar.mini { width: var(--sb-w-mini); }

/* Logo */
.sb-logo {
    height: var(--tb-h);
    background: var(--sb-dark);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 13px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
    overflow: hidden;
    white-space: nowrap;
    text-decoration: none;
}
.sb-logo-icon {
    width: 26px; height: 26px;
    border-radius: 7px;
    background: rgba(255,255,255,.15);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sb-logo-icon .fa { font-size: 13px; color: #fff; }
.sb-logo-text {
    font-size: 12px; font-weight: 600; color: #fff;
    line-height: 1.3; overflow: hidden;
    transition: var(--transition);
}
#bp-sidebar.mini .sb-logo-text { opacity: 0; width: 0; }

/* User panel */
.sb-user {
    background: var(--sb-dark);
    padding: 10px 10px 10px 12px;
    display: flex; align-items: center; gap: 9px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    flex-shrink: 0;
    overflow: hidden;
    white-space: nowrap;
}
.sb-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg,#4a9fd4,#2e75b6);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.18);
}
.sb-user-info { overflow: hidden; transition: var(--transition); }
.sb-user-info p { font-size: 12px; font-weight: 600; color: #fff; margin: 0 0 1px; }
.sb-user-info span { font-size: 10px; color: var(--sb-dim); }
#bp-sidebar.mini .sb-user-info { opacity: 0; width: 0; }

/* Nav scroll area */
.sb-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px 0 24px;
}
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

/* Section labels */
.sb-label {
    display: block;
    font-size: 9.5px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1.1px;
    color: var(--sb-dim);
    padding: 10px 14px 3px;
    white-space: nowrap; overflow: hidden;
    transition: var(--transition);
}
#bp-sidebar.mini .sb-label { opacity: 0; height: 0; padding: 0; overflow: hidden; }

/* Nav items */
.sb-item {
    display: flex; align-items: center; gap: 9px;
    padding: 8px 13px;
    color: var(--sb-text);
    font-size: 12.5px;
    text-decoration: none;
    border-left: 2px solid transparent;
    transition: background .12s, color .12s, border-color .12s;
    white-space: nowrap; overflow: hidden;
    cursor: pointer; position: relative;
}
.sb-item .fa {
    font-size: 14px; color: var(--sb-dim);
    width: 18px; text-align: center; flex-shrink: 0;
    transition: color .12s;
}
.sb-item .sb-txt { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.sb-item .sb-badge {
    background: #c0392b; color: #fff;
    font-size: 9px; padding: 1px 5px;
    border-radius: 10px; font-weight: 700;
    flex-shrink: 0; margin-left: 2px;
}
.sb-item .fa-angle-left { font-size: 11px !important; color: var(--sb-dim) !important; transition: transform .2s; }
.sb-item:hover { background: var(--sb-hover); color: #fff; border-left-color: rgba(255,255,255,.25); }
.sb-item:hover .fa { color: rgba(255,255,255,.8); }
.sb-item.active { background: var(--sb-active); color: #fff; border-left-color: var(--sb-accent); font-weight: 600; }
.sb-item.active .fa { color: var(--sb-accent); }
#bp-sidebar.mini .sb-txt,
#bp-sidebar.mini .sb-badge,
#bp-sidebar.mini .sb-item .fa-angle-left { display: none; }
#bp-sidebar.mini .sb-item { justify-content: center; padding: 9px 0; }
#bp-sidebar.mini .sb-item .fa { width: auto; }

/* Tooltip no mini mode */
#bp-sidebar.mini .sb-item { position: relative; }
#bp-sidebar.mini .sb-item::after {
    content: attr(data-title);
    position: absolute; left: 54px; top: 50%;
    transform: translateY(-50%);
    background: #1a2535; color: #fff;
    font-size: 11.5px; padding: 4px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap; pointer-events: none;
    opacity: 0; transition: opacity .15s;
    z-index: 1100;
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
#bp-sidebar.mini .sb-item:hover::after { opacity: 1; }

/* Treeview submenu */
.sb-sub {
    background: rgba(0,0,0,.18);
    list-style: none;
    padding: 3px 0;
    display: none;
}
.sb-sub.open { display: block; }
.sb-sub li a {
    display: flex; align-items: center; gap: 7px;
    padding: 6px 13px 6px 38px;
    color: var(--sb-dim);
    font-size: 12px;
    text-decoration: none;
    transition: color .12s, background .12s;
    white-space: nowrap;
}
.sb-sub li a .fa { font-size: 10px; color: rgba(255,255,255,.22); }
.sb-sub li a:hover { color: #fff; background: rgba(255,255,255,.05); }
.sb-sub li.active a { color: #fff; }
.sb-item.open .fa-angle-left { transform: rotate(-90deg); }
#bp-sidebar.mini .sb-sub { display: none !important; }

/* ════════════════════════════════════════════════
   TOPBAR
   ════════════════════════════════════════════════ */
#bp-topbar {
    position: fixed;
    top: 0; left: var(--sb-w); right: 0;
    height: var(--tb-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    z-index: 1040;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    transition: left var(--transition);
}
#bp-topbar.mini { left: var(--sb-w-mini); }

/* Toggle btn */
.tb-toggle {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #f8f9fb;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; flex-shrink: 0;
    transition: background .12s;
    color: #666;
    font-size: 17px;
}
.tb-toggle:hover { background: var(--page-bg); color: var(--sb-bg); }

/* Título página */
#tb-page-title {
    font-size: 14px; font-weight: 600;
    color: #1a2535;
    flex: 1;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Botões topbar direita */
.tb-right {
    display: flex; align-items: center; gap: 6px;
}
.tb-icon-btn {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #f8f9fb;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; position: relative;
    color: #666; font-size: 16px;
    transition: background .12s;
    text-decoration: none;
}
.tb-icon-btn:hover { background: var(--page-bg); color: var(--sb-bg); }
.tb-icon-btn .tb-dot {
    position: absolute; top: 5px; right: 5px;
    width: 7px; height: 7px;
    background: #c0392b; border-radius: 50%;
    border: 1.5px solid var(--white);
}

/* Dropdown topbar */
.tb-right .dropdown-menu {
    background: var(--white) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: 0 6px 20px rgba(0,0,0,.1) !important;
    min-width: 240px !important;
    margin-top: 4px !important;
}
.tb-right .dropdown-menu > .header {
    background: #f8f9fb !important;
    color: #888 !important;
    font-size: 10.5px !important; padding: 8px 14px !important;
    border-radius: var(--radius) var(--radius) 0 0 !important;
    border-bottom: 1px solid var(--border) !important;
    font-weight: 700 !important; text-transform: uppercase !important;
    letter-spacing: .5px !important;
}
.tb-right .dropdown-menu li > a {
    color: #444 !important; padding: 8px 14px !important; font-size: 12.5px !important;
}
.tb-right .dropdown-menu li > a:hover { background: #f4f6f9 !important; color: var(--sb-bg) !important; }
.tb-right .dropdown-menu .footer > a {
    background: #f8f9fb !important; color: #666 !important;
    text-align: center !important; font-size: 12px !important;
    border-top: 1px solid var(--border) !important;
    border-radius: 0 0 var(--radius) var(--radius) !important;
    padding: 8px !important; display: block !important;
}
.tb-right .label-danger {
    background: #c0392b !important; border-radius: 10px !important;
    font-size: 9.5px !important; padding: 2px 5px !important; margin-left: 3px;
}

/* Botão usuário topbar */
.tb-user-btn {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    background: #f8f9fb;
    border: 1px solid var(--border);
    cursor: pointer; height: 34px;
    font-size: 12.5px; color: #333;
    text-decoration: none;
    transition: background .12s;
}
.tb-user-btn:hover { background: var(--page-bg); }
.tb-user-btn:focus, .tb-user-btn:active { color: #333; text-decoration: none; }
.tb-avatar {
    width: 24px; height: 24px; border-radius: 50%;
    background: linear-gradient(135deg,#4a9fd4,#1e3a5f);
    display: flex; align-items: center; justify-content: center;
    font-size: 9.5px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.tb-user-btn .fa-caret-down { font-size: 10px; color: #aaa; }

/* User dropdown header */
.user-header.bg-light-blue {
    background: linear-gradient(135deg,#1e3a5f,#2e75b6) !important;
    padding: 14px !important;
}
.user-header.bg-light-blue p { color: #fff !important; font-weight: 600 !important; margin-top: 8px !important; }

/* ════════════════════════════════════════════════
   CONTEÚDO PRINCIPAL
   ════════════════════════════════════════════════ */
#bp-content {
    margin-left: var(--sb-w);
    margin-top: var(--tb-h);
    min-height: calc(100vh - var(--tb-h));
    background: var(--page-bg);
    transition: margin-left var(--transition);
}
#bp-content.mini { margin-left: var(--sb-w-mini); }

/* Content header (página) */
.content-header {
    padding: 16px 20px 10px !important;
    background: transparent !important;
}
.content-header h1 {
    font-size: 20px !important; font-weight: 700 !important;
    color: #1a2535 !important; margin: 0 !important;
}
.content-header h1 small {
    font-size: 13px !important; color: #888 !important; font-weight: 400 !important;
}
.content-header .breadcrumb {
    background: transparent !important; padding: 3px 0 0 !important;
    margin: 0 !important; font-size: 12px !important;
}
.content-header .breadcrumb > li+li:before { color: #bbb !important; }
.content-header .breadcrumb a { color: var(--sb-bg) !important; }
.content-header .breadcrumb .active { color: #888 !important; }

section.content { padding: 0 20px 20px !important; }

/* ════════════════════════════════════════════════
   COMPONENTES GLOBAIS
   ════════════════════════════════════════════════ */

/* Boxes */
.box {
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-sm) !important;
    border: 1px solid var(--border) !important;
    border-top-width: 3px !important;
    background: var(--white) !important;
    margin-bottom: 18px !important;
}
.box-header { padding: 12px 16px !important; }
.box-header .box-title { font-size: 13.5px !important; font-weight: 600 !important; color: #333 !important; }
.box-body { border-radius: 0 0 var(--radius) var(--radius) !important; }
.box-footer {
    background: #f8f9fb !important; border-top: 1px solid var(--border) !important;
    border-radius: 0 0 var(--radius) var(--radius) !important; padding: 10px 16px !important;
}
.box.box-primary   { border-top-color: #1e3a5f !important; }
.box.box-success   { border-top-color: #2e7d32 !important; }
.box.box-danger    { border-top-color: #c0392b !important; }
.box.box-warning   { border-top-color: #d35400 !important; }
.box.box-info      { border-top-color: #2980b9 !important; }
.box.box-default   { border-top-color: #aaa !important; }

/* Botões */
.btn { border-radius: var(--radius-sm) !important; font-size: 12.5px !important; font-weight: 500 !important; }
.btn-primary { background: #1e3a5f !important; border-color: #1e3a5f !important; color: #fff !important; }
.btn-primary:hover, .btn-primary:focus { background: #162d4a !important; }
.btn-success { background: #2e7d32 !important; border-color: #2e7d32 !important; color: #fff !important; }
.btn-success:hover { background: #256427 !important; }
.btn-danger  { background: #c0392b !important; border-color: #c0392b !important; color: #fff !important; }
.btn-danger:hover  { background: #a93226 !important; }
.btn-warning { background: #d35400 !important; border-color: #d35400 !important; color: #fff !important; }
.btn-warning:hover { background: #b34600 !important; }
.btn-info    { background: #2980b9 !important; border-color: #2980b9 !important; color: #fff !important; }
.btn-default { background: var(--white) !important; border-color: var(--border) !important; color: #444 !important; }
.btn-default:hover { background: #f4f6f9 !important; }
.btn-xs { font-size: 11px !important; padding: 3px 7px !important; border-radius: 4px !important; }
.btn-sm { font-size: 12px !important; padding: 5px 10px !important; }

/* Tabelas */
.table > thead > tr > th {
    background: #f8f9fb !important; font-size: 10.5px !important; font-weight: 700 !important;
    color: #888 !important; text-transform: uppercase !important; letter-spacing: .5px !important;
    border-bottom: 2px solid var(--border) !important; padding: 10px 12px !important;
}
.table > tbody > tr > td {
    padding: 9px 12px !important; vertical-align: middle !important;
    border-bottom: 1px solid #f0f2f5 !important; font-size: 13px !important;
}
.table-hover > tbody > tr:hover { background: #f4f6f9 !important; }
.table-striped > tbody > tr:nth-child(odd) { background: #fafbfc !important; }

/* Forms */
.form-control {
    border-radius: var(--radius-sm) !important; border-color: #d8dce2 !important;
    font-size: 13px !important; height: 34px !important; box-shadow: none !important;
}
.form-control:focus {
    border-color: #2980b9 !important;
    box-shadow: 0 0 0 3px rgba(41,128,185,.12) !important;
}
textarea.form-control { height: auto !important; }
select.form-control { height: 34px !important; }
.form-group label { font-weight: 600 !important; font-size: 12px !important; color: #555 !important; margin-bottom: 5px !important; }

/* Labels */
.label { border-radius: 10px !important; font-size: 10.5px !important; padding: 3px 8px !important; font-weight: 600 !important; }
.label-success { background: #2e7d32 !important; }
.label-danger  { background: #c0392b !important; }
.label-warning { background: #d35400 !important; }
.label-info    { background: #2980b9 !important; }
.label-default { background: #aaa !important; }
.badge { border-radius: 10px !important; font-size: 10px !important; }

/* Alerts */
.alert { border-radius: var(--radius-sm) !important; font-size: 13px !important; border-left-width: 4px !important; }
.alert-success { border-left-color: #2e7d32 !important; }
.alert-danger  { border-left-color: #c0392b !important; }
.alert-warning { border-left-color: #d35400 !important; }
.alert-info    { border-left-color: #2980b9 !important; }

/* Small-box, Info-box */
.small-box { border-radius: var(--radius) !important; box-shadow: var(--shadow-md) !important; transition: transform .18s !important; }
.small-box:hover { transform: translateY(-2px) !important; }
.info-box  { border-radius: var(--radius) !important; box-shadow: var(--shadow-sm) !important; }

/* Pagination */
.pagination > li > a, .pagination > li > span {
    border-radius: var(--radius-sm) !important; margin: 0 2px !important;
    border-color: var(--border) !important; color: var(--sb-bg) !important; font-size: 12.5px !important;
}
.pagination > .active > a { background: var(--sb-bg) !important; border-color: var(--sb-bg) !important; color: #fff !important; }

/* Modal */
.modal-content { border-radius: var(--radius) !important; border: none !important; box-shadow: 0 8px 30px rgba(0,0,0,.15) !important; }
.modal-header { border-radius: var(--radius) var(--radius) 0 0 !important; padding: 14px 18px !important; }
.modal-footer { border-radius: 0 0 var(--radius) var(--radius) !important; background: #f8f9fb !important; padding: 12px 18px !important; }

/* DataTables */
.dataTables_wrapper .dataTables_filter input { border-radius: var(--radius-sm) !important; border-color: var(--border) !important; height: 32px !important; }
.dataTables_wrapper .dataTables_length select { border-radius: var(--radius-sm) !important; border-color: var(--border) !important; height: 32px !important; }

/* Dropdowns do topbar nunca saem da tela */
#bp-topbar .dropdown-menu {
    max-height: 400px;
    overflow-y: auto;
}
#bp-topbar .dropdown { position: static !important; }
#bp-topbar .tb-right { position: relative; }
#bp-topbar .tb-right .dropdown-menu {
    position: absolute !important;
    right: 0 !important;
    left: auto !important;
    top: var(--tb-h) !important;
}

/* ── MOBILE ─────────────────────────────────────── */
@media (max-width: 767px) {
    #bp-sidebar { left: calc(var(--sb-w) * -1); box-shadow: none; }
    #bp-sidebar.mobile-open { left: 0; box-shadow: 4px 0 20px rgba(0,0,0,.3); }
    #bp-topbar { left: 0 !important; }
    #bp-content { margin-left: 0 !important; }
    #tb-page-title { display: none; }
    .sb-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1049; }
    .sb-overlay.on { display: block; }
}
</style>
</head>
<body>

<!-- OVERLAY mobile -->
<div class="sb-overlay" id="sb-overlay"></div>

<!-- ════ SIDEBAR ════════════════════════════════ -->
<aside id="bp-sidebar">

    <!-- Logo -->
    <a href="<?php echo site_url('admin/dashboard') ?>" class="sb-logo">
        <div class="sb-logo-icon"><i class="fa fa-balance-scale"></i></div>
        <div class="sb-logo-text">
            <?php if ($setting->header_setting == 1 && !empty($setting->image)): ?>
            <img src="<?php echo base_url('assets/uploads/images/'.$setting->image) ?>" style="max-height:56px;max-width:260px">
            <?php else: ?>
            <?php echo $setting->name ?>
            <?php endif; ?>
        </div>
    </a>

    <!-- Usuário -->
    <div class="sb-user">
        <div class="sb-avatar"><?php echo $iniciais ?></div>
        <div class="sb-user-info">
            <p><?php echo $admin['name'] ?></p>
            <span><?php echo lang('online') ?></span>
        </div>
    </div>

    <!-- Navegação -->
    <div class="sb-nav">

        <!-- Dashboard -->
        <a href="<?php echo site_url('admin/dashboard') ?>"
           class="sb-item <?php echo ($second=='dashboard'||$second=='')?'active':'' ?>"
           data-title="Dashboard">
            <i class="fa fa-dashboard"></i>
            <span class="sb-txt">Dashboard</span>
        </a>

        <?php if ($access == 1): ?>

        <span class="sb-label">Jurídico</span>

        <a href="<?php echo site_url('admin/cases') ?>"
           class="sb-item <?php echo ($second=='cases'&&$third!='starred_cases'&&$third!='archived_cases')?'active':'' ?>"
           data-title="Processos">
            <i class="fa fa-folder-open"></i><span class="sb-txt">Processos</span>
        </a>
        <a href="<?php echo site_url('admin/cases/starred_cases') ?>"
           class="sb-item <?php echo $third=='starred_cases'?'active':'' ?>"
           data-title="Favoritos">
            <i class="fa fa-star"></i><span class="sb-txt">Favoritos</span>
        </a>
        <a href="<?php echo site_url('admin/cases/archived_cases') ?>"
           class="sb-item <?php echo $third=='archived_cases'?'active':'' ?>"
           data-title="Arquivados">
            <i class="fa fa-archive"></i><span class="sb-txt">Arquivados</span>
        </a>
        <a href="<?php echo site_url('admin/case_study') ?>"
           class="sb-item <?php echo $second=='case_study'?'active':'' ?>"
           data-title="Jurisprudência">
            <i class="fa fa-book"></i><span class="sb-txt">Jurisprudência</span>
        </a>
        <a href="<?php echo site_url('admin/diligencias') ?>"
           class="sb-item <?php echo $second=='diligencias'?'active':'' ?>"
           data-title="Diligências">
            <i class="fa fa-gavel"></i><span class="sb-txt">Diligências</span>
        </a>
        <a href="<?php echo site_url('admin/appointments') ?>"
           class="sb-item <?php echo $second=='appointments'?'active':'' ?>"
           data-title="Agenda">
            <i class="fa fa-calendar"></i>
            <span class="sb-txt">Agenda</span>
            <?php if(count((array)$appointment_alert)>0): ?><span class="sb-badge"><?php echo count((array)$appointment_alert) ?></span><?php endif; ?>
        </a>
        <a href="<?php echo site_url('admin/diario_oficial') ?>"
           class="sb-item <?php echo $second=='diario_oficial'?'active':'' ?>"
           data-title="Diário PJe">
            <i class="fa fa-newspaper-o"></i><span class="sb-txt">Diário Oficial PJe</span>
        </a>
        
        <a href="<?php echo site_url('admin/to_do_list') ?>"
           class="sb-item <?php echo $second=='to_do_list'?'active':'' ?>"
           data-title="Diário PJe">
            <i class="fa fa-check-square-o"></i><span class="sb-txt">Prazos e Publicações</span>
        </a>
        
        <a href="<?php echo site_url('admin/patrimonio') ?>"
          class="sb-item <?php echo $second=='patrimonio'?'active':'' ?>"
         data-title="Busca Patrimonial">
           <i class="fa fa-search"></i><span class="sb-txt">Busca Patrimonial</span>
          </a>

 <!-- Tarefas treeview -->
        <a href="#" class="sb-item <?php echo ($second=='tasks'||$second=='to_do_list')?'active open':'' ?> sb-tree"
           data-target="sub-tasks" data-title="Tarefas">
            <i class="fa fa-tasks"></i>
            <span class="sb-txt">Tarefas</span>
            <?php if($t_total>0): ?><span class="sb-badge"><?php echo $t_total ?></span><?php endif; ?>
            <i class="fa fa-angle-left"></i>
        </a>
        <ul class="sb-sub <?php echo ($second=='tasks'||$second=='to_do_list')?'open':'' ?>" id="sub-tasks">
            <li class="<?php echo ($second=='tasks'&&$third!='my_tasks')?'active':'' ?>"><a href="<?php echo site_url('admin/tasks') ?>"><i class="fa fa-list"></i> <?php echo lang('tasks') ?></a></li>
            <li class="<?php echo $third=='my_tasks'?'active':'' ?>"><a href="<?php echo site_url('admin/tasks/my_tasks') ?>"><i class="fa fa-inbox"></i> <?php echo lang('my_tasks') ?></a></li>
            
        </ul>
        
        <span class="sb-label">Gestão</span>


        <!-- Financeiro treeview -->
        <a href="#" class="sb-item <?php echo $second=='financeiro'?'active open':'' ?> sb-tree"
           data-target="sub-fin" data-title="Financeiro">
            <i class="fa fa-money"></i>
            <span class="sb-txt">Financeiro</span>
            <i class="fa fa-angle-left"></i>
        </a>
        <ul class="sb-sub <?php echo $second=='financeiro'?'open':'' ?>" id="sub-fin">
            <li class="<?php echo ($second=='financeiro'&&!$third)?'active':'' ?>"><a href="<?php echo site_url('admin/financeiro') ?>"><i class="fa fa-dashboard"></i> Visão Geral</a></li>
            <li class="<?php echo ($second=='financeiro'&&$third=='lancamentos'&&$fourth=='receber')?'active':'' ?>"><a href="<?php echo site_url('admin/financeiro/lancamentos/receber') ?>"><i class="fa fa-arrow-down"></i> A Receber</a></li>
            <li class="<?php echo ($second=='financeiro'&&$third=='lancamentos'&&$fourth=='pagar')?'active':'' ?>"><a href="<?php echo site_url('admin/financeiro/lancamentos/pagar') ?>"><i class="fa fa-arrow-up"></i> A Pagar</a></li>
            <li class="<?php echo ($second=='financeiro'&&$third=='recibos')?'active':'' ?>"><a href="<?php echo site_url('admin/financeiro/recibos') ?>"><i class="fa fa-file-text-o"></i> Recibos</a></li>
            <li class="<?php echo ($second=='financeiro'&&$third=='bpo')?'active':'' ?>"><a href="<?php echo site_url('admin/financeiro/bpo') ?>"><i class="fa fa-university"></i> BPO Financeiro</a></li>
            <li class="<?php echo ($second=='financeiro'&&$third=='relatorio')?'active':'' ?>"><a href="<?php echo site_url('admin/financeiro/relatorio') ?>"><i class="fa fa-bar-chart"></i> Relatórios</a></li>
        </ul>

        
        <a href="<?php echo site_url('admin/documents') ?>"
           class="sb-item <?php echo $second=='documents'?'active':'' ?>" data-title="Documentos">
            <i class="fa fa-file-o"></i><span class="sb-txt">Documentos</span>
        </a>
        <a href="<?php echo site_url('admin/reports') ?>"
           class="sb-item <?php echo $second=='reports'?'active':'' ?>" data-title="Relatórios">
            <i class="fa fa-line-chart"></i><span class="sb-txt">Relatórios</span>
        </a>
        <a href="<?php echo site_url('admin/message') ?>"
           class="sb-item <?php echo $second=='message'?'active':'' ?>" data-title="Mensagens">
            <i class="fa fa-envelope"></i>
            <span class="sb-txt">Mensagens</span>
            <?php if(count((array)$admin_messages)>0): ?><span class="sb-badge"><?php echo count((array)$admin_messages) ?></span><?php endif; ?>
        </a>

        <span class="sb-label">Pessoas</span>

        <a href="<?php echo site_url('admin/clients') ?>"
           class="sb-item <?php echo $second=='clients'?'active':'' ?>" data-title="Clientes">
            <i class="fa fa-users"></i><span class="sb-txt">Clientes</span>
        </a>
        <a href="<?php echo site_url('admin/employees') ?>"
           class="sb-item <?php echo $second=='employees'?'active':'' ?>" data-title="Colaboradores">
            <i class="fa fa-id-badge"></i><span class="sb-txt">Colaboradores</span>
        </a>
        <a href="<?php echo site_url('admin/contacts') ?>"
           class="sb-item <?php echo $second=='contacts'?'active':'' ?>" data-title="Contatos">
            <i class="fa fa-address-book-o"></i><span class="sb-txt">Contatos</span>
        </a>
        <a href="<?php echo site_url('admin/notice') ?>"
           class="sb-item <?php echo $second=='notice'?'active':'' ?>" data-title="Avisos">
            <i class="fa fa-bullhorn"></i><span class="sb-txt">Avisos</span>
        </a>
        <a href="<?php echo site_url('admin/attendance') ?>"
           class="sb-item <?php echo $second=='attendance'?'active':'' ?>" data-title="Presença">
            <i class="fa fa-clock-o"></i><span class="sb-txt">Presença</span>
        </a>

        <span class="sb-label">Configurações</span>

        <!-- Gestão de usuários -->
        <a href="#" class="sb-item <?php echo in_array($second,['user_role','departments','permissions','holidays','leave_types'])?'active open':'' ?> sb-tree"
           data-target="sub-users" data-title="Usuários">
            <i class="fa fa-shield"></i>
            <span class="sb-txt">Usuários & Permissões</span>
            <i class="fa fa-angle-left"></i>
        </a>
        <ul class="sb-sub <?php echo in_array($second,['user_role','departments','permissions','holidays','leave_types'])?'open':'' ?>" id="sub-users">
            <li class="<?php echo $second=='user_role'?'active':'' ?>"><a href="<?php echo site_url('admin/user_role') ?>"><i class="fa fa-angle-double-right"></i> <?php echo lang('user_role') ?></a></li>
            <li class="<?php echo $second=='departments'?'active':'' ?>"><a href="<?php echo site_url('admin/departments') ?>"><i class="fa fa-angle-double-right"></i> <?php echo lang('departments') ?></a></li>
            <li class="<?php echo $second=='permissions'?'active':'' ?>"><a href="<?php echo site_url('admin/permissions') ?>"><i class="fa fa-angle-double-right"></i> <?php echo lang('permissions') ?></a></li>
            <li class="<?php echo $second=='holidays'?'active':'' ?>"><a href="<?php echo site_url('admin/holidays') ?>"><i class="fa fa-angle-double-right"></i> <?php echo lang('holidays') ?></a></li>
            <li class="<?php echo $second=='leave_types'?'active':'' ?>"><a href="<?php echo site_url('admin/leave_types') ?>"><i class="fa fa-angle-double-right"></i> <?php echo lang('leave_types') ?></a></li>
        </ul>

        <!-- Masters -->
        <a href="#" class="sb-item <?php echo in_array($second,['case_category','court_category','act','court','case_stage','location','tax','payment_mode','custom_fields'])?'active open':'' ?> sb-tree"
           data-target="sub-masters" data-title="Cadastros">
            <i class="fa fa-folder"></i>
            <span class="sb-txt">Cadastros</span>
            <i class="fa fa-angle-left"></i>
        </a>
        <ul class="sb-sub <?php echo in_array($second,['case_category','court_category','act','court','case_stage','location','tax','payment_mode','custom_fields'])?'open':'' ?>" id="sub-masters">
            <li class="<?php echo $second=='location'?'active':'' ?>"><a href="<?php echo site_url('admin/location') ?>"><i class="fa fa-angle-double-right"></i> <?php echo lang('locations') ?></a></li>
            <li class="<?php echo $second=='tax'?'active':'' ?>"><a href="<?php echo site_url('admin/tax') ?>"><i class="fa fa-angle-double-right"></i> <?php echo lang('tax') ?></a></li>
            <li class="<?php echo $second=='case_category'?'active':'' ?>"><a href="<?php echo site_url('admin/case_category') ?>"><i class="fa fa-angle-double-right"></i> Categoria Processo</a></li>
            <li class="<?php echo $second=='court_category'?'active':'' ?>"><a href="<?php echo site_url('admin/court_category') ?>"><i class="fa fa-angle-double-right"></i> Categoria Tribunal</a></li>
            <li class="<?php echo $second=='act'?'active':'' ?>"><a href="<?php echo site_url('admin/act') ?>"><i class="fa fa-angle-double-right"></i> <?php echo lang('act') ?></a></li>
            <li class="<?php echo $second=='court'?'active':'' ?>"><a href="<?php echo site_url('admin/court') ?>"><i class="fa fa-angle-double-right"></i> <?php echo lang('court') ?></a></li>
            <li class="<?php echo $second=='case_stage'?'active':'' ?>"><a href="<?php echo site_url('admin/case_stage') ?>"><i class="fa fa-angle-double-right"></i> Fases</a></li>
            <li class="<?php echo $second=='payment_mode'?'active':'' ?>"><a href="<?php echo site_url('admin/payment_mode') ?>"><i class="fa fa-angle-double-right"></i> <?php echo lang('payment_mode') ?></a></li>
            <li class="<?php echo $second=='custom_fields'?'active':'' ?>"><a href="<?php echo site_url('admin/custom_fields') ?>"><i class="fa fa-angle-double-right"></i> Campos extras</a></li>
        </ul>

        <!-- Admin -->
        <a href="#" class="sb-item <?php echo in_array($second,['settings','notification','languages'])?'active open':'' ?> sb-tree"
           data-target="sub-admin" data-title="Sistema">
            <i class="fa fa-cog"></i>
            <span class="sb-txt">Sistema</span>
            <i class="fa fa-angle-left"></i>
        </a>
        <ul class="sb-sub <?php echo in_array($second,['settings','notification','languages'])?'open':'' ?>" id="sub-admin">
            <li class="<?php echo $second=='settings'?'active':'' ?>"><a href="<?php echo site_url('admin/settings') ?>"><i class="fa fa-angle-double-right"></i> Configurações Gerais</a></li>
            <li class="<?php echo $second=='notification'?'active':'' ?>"><a href="<?php echo site_url('admin/notification') ?>"><i class="fa fa-angle-double-right"></i> Notificações</a></li>
            <li class="<?php echo $third=='canned_messages'?'active':'' ?>"><a href="<?php echo site_url('admin/settings/canned_messages') ?>"><i class="fa fa-angle-double-right"></i> Respostas rápidas</a></li>
            <li class="<?php echo $second=='languages'?'active':'' ?>"><a href="<?php echo site_url('admin/languages') ?>"><i class="fa fa-angle-double-right"></i> Idiomas</a></li>
        </ul>

        <?php elseif ($access == 2): ?>

        <span class="sb-label">Menu</span>
        <a href="<?php echo site_url('admin/my_cases') ?>" class="sb-item <?php echo $second=='my_cases'?'active':'' ?>" data-title="Meus Processos">
            <i class="fa fa-file"></i><span class="sb-txt">Meus Processos</span>
        </a>
        <a href="<?php echo site_url('admin/message/send_message/'.$admin['id']) ?>" class="sb-item <?php echo $third=='send_message'?'active':'' ?>" data-title="Mensagens">
            <i class="fa fa-envelope"></i><span class="sb-txt">Mensagens</span>
            <?php if(count((array)$admin_messages)>0): ?><span class="sb-badge"><?php echo count((array)$admin_messages) ?></span><?php endif; ?>
        </a>

        <?php else: ?>

        <span class="sb-label">Menu</span>
        <?php foreach($actions as $a): if($a->action=='cases'): ?>
        <a href="<?php echo site_url('admin/cases') ?>" class="sb-item <?php echo $second=='cases'?'active':'' ?>" data-title="Processos"><i class="fa fa-folder-open"></i><span class="sb-txt">Processos</span></a>
        <?php break; endif; endforeach; ?>
        <?php foreach($actions as $a): if($a->action=='tasks'): ?>
        <a href="<?php echo site_url('admin/tasks') ?>" class="sb-item <?php echo $second=='tasks'?'active':'' ?>" data-title="Tarefas"><i class="fa fa-tasks"></i><span class="sb-txt">Tarefas</span></a>
        <?php break; endif; endforeach; ?>
        <?php foreach($actions as $a): if($a->action=='appointments'): ?>
        <a href="<?php echo site_url('admin/appointments') ?>" class="sb-item <?php echo $second=='appointments'?'active':'' ?>" data-title="Agenda"><i class="fa fa-calendar"></i><span class="sb-txt">Agenda</span></a>
        <?php break; endif; endforeach; ?>
        <?php foreach($actions as $a): if($a->action=='documents'): ?>
        <a href="<?php echo site_url('admin/documents') ?>" class="sb-item <?php echo $second=='documents'?'active':'' ?>" data-title="Documentos"><i class="fa fa-file-o"></i><span class="sb-txt">Documentos</span></a>
        <?php break; endif; endforeach; ?>
        <?php foreach($actions as $a): if($a->action=='message'): ?>
        <a href="<?php echo site_url('admin/message') ?>" class="sb-item <?php echo $second=='message'?'active':'' ?>" data-title="Mensagens"><i class="fa fa-envelope"></i><span class="sb-txt">Mensagens</span></a>
        <?php break; endif; endforeach; ?>
        <?php if($access==3): ?>
        <a href="<?php echo site_url('admin/diligencias') ?>" class="sb-item <?php echo $second=='diligencias'?'active':'' ?>" data-title="Diligências"><i class="fa fa-gavel"></i><span class="sb-txt">Diligências</span></a>
        <?php endif; ?>

        <?php endif; ?>

    </div><!-- /sb-nav -->
</aside>

<!-- ════ TOPBAR ══════════════════════════════════ -->
<div id="bp-topbar">
    <!-- Toggle sidebar -->
    <div class="tb-toggle" id="sb-toggle" title="Recolher/expandir menu">
        <i class="fa fa-bars"></i>
    </div>

    <!-- Título da página (preenchido por JS) -->
    <span id="tb-page-title"></span>

    <!-- Direita -->
    <div class="tb-right">

        <!-- Idioma -->
        <div class="dropdown">
            <a href="#" class="tb-icon-btn" data-toggle="dropdown" title="Idioma">
                <i class="fa fa-globe"></i>
            </a>
            <ul class="dropdown-menu dropdown-menu-right">
                <li class="header">Idioma</li>
                <li><ul class="menu">
                    <li><a href="<?php echo site_url('admin/languages/switch_language/english/'.$first.'/'.$second.'/'.$third.'/'.$fourth) ?>">
                        <img src="<?php echo base_url('assets/img/eng.png') ?>" style="width:18px;height:18px;border-radius:50%;margin-right:7px"> English
                    </a></li>
                    <?php foreach($langs as $lang): ?>
                    <li><a href="<?php echo site_url('admin/languages/switch_language/'.$lang->name.'/'.$first.'/'.$second.'/'.$third.'/'.$fourth) ?>">
                        <img src="<?php echo base_url('assets/uploads/images/'.$lang->flag) ?>" style="width:18px;height:18px;border-radius:50%;margin-right:7px"> <?php echo ucwords($lang->name) ?>
                    </a></li>
                    <?php endforeach; ?>
                </ul></li>
            </ul>
        </div>

        <?php if ($access != 2): ?>

        <!-- Processos -->
        <?php if(check_user_role(105)==1): ?>
        <div class="dropdown">
            <a href="#" class="tb-icon-btn" data-toggle="dropdown" title="Processos">
                <i class="fa fa-folder-open"></i>
                <?php if(!empty($case_alert)): ?><span class="tb-dot"></span><?php endif; ?>
            </a>
            <ul class="dropdown-menu dropdown-menu-right">
                <li class="header"><?php echo !empty($case_alert) ? count((array)$case_alert).' processo(s) com prazo' : 'Processos' ?></li>
                <li><ul class="menu">
                    <?php if(!empty($case_alert)): ?>
                    <?php foreach($case_alert as $new): ?>
                    <li><a href="<?php echo site_url('admin/cases/view_case/'.$new->id) ?>"><i class="fa fa-legal"></i> <?php echo $new->case_no ?> — <?php echo date_convert($new->next_date) ?></a></li>
                    <?php endforeach; ?>
                    <?php else: ?>
                    <li><a href="<?php echo site_url('admin/cases') ?>"><i class="fa fa-folder-open"></i> Ver todos os processos</a></li>
                    <?php endif; ?>
                </ul></li>
                <li class="footer"><a href="<?php echo site_url('admin/cases') ?>">Ver todos</a></li>
            </ul>
        </div>
        <?php endif; ?>

        <!-- Diário PJe -->
        <div class="dropdown">
            <a href="#" class="tb-icon-btn" data-toggle="dropdown" title="Diário Oficial PJe">
                <i class="fa fa-newspaper-o"></i>
            </a>
            <ul class="dropdown-menu dropdown-menu-right">
                <li class="header">Diário Oficial PJe</li>
                <li><ul class="menu">
                    <li><a href="<?php echo site_url('admin/diario_oficial') ?>"><i class="fa fa-newspaper-o"></i> Ver publicações</a></li>
                    <li><a href="<?php echo site_url('admin/diario_oficial/advogados') ?>"><i class="fa fa-users"></i> Advogados monitorados</a></li>
                </ul></li>
                <li class="footer"><a href="<?php echo site_url('admin/diario_oficial') ?>">Abrir módulo</a></li>
            </ul>
        </div>

        <!-- Agenda -->
        <?php if(check_user_role(106)==1): ?>
        <div class="dropdown">
            <a href="#" class="tb-icon-btn" data-toggle="dropdown" title="Agenda">
                <i class="fa fa-calendar"></i>
                <?php if(!empty($appointment_alert)): ?><span class="tb-dot"></span><?php endif; ?>
            </a>
            <ul class="dropdown-menu dropdown-menu-right">
                <li class="header"><?php echo !empty($appointment_alert) ? count((array)$appointment_alert).' agendamento(s) próximo(s)' : 'Agenda' ?></li>
                <li><ul class="menu">
                    <?php if(!empty($appointment_alert)): ?>
                    <?php foreach($appointment_alert as $new): ?>
                    <li><a href="<?php echo site_url('admin/appointments/view_appointment/'.$new->id) ?>"><i class="fa fa-calendar-check-o"></i> <?php echo $new->title ?></a></li>
                    <?php endforeach; ?>
                    <?php else: ?>
                    <li><a href="<?php echo site_url('admin/appointments') ?>"><i class="fa fa-calendar"></i> Ver agenda completa</a></li>
                    <?php endif; ?>
                </ul></li>
                <li class="footer"><a href="<?php echo site_url('admin/appointments') ?>">Ver agenda</a></li>
            </ul>
        </div>
        <?php endif; ?>

        <!-- Tarefas -->
        <?php if(check_user_role(107)==1): ?>
        <div class="dropdown">
            <a href="#" class="tb-icon-btn" data-toggle="dropdown" title="Tarefas">
                <i class="fa fa-tasks"></i>
                <?php if($t_total>0): ?><span class="tb-dot"></span><?php endif; ?>
            </a>
            <ul class="dropdown-menu dropdown-menu-right">
                <li class="header"><?php echo $t_total>0 ? $t_total.' tarefa(s) pendente(s)' : 'Tarefas' ?></li>
                <li><ul class="menu">
                    <?php if(!empty($to_do_alert)): ?>
                    <?php foreach($to_do_alert as $new): ?>
                    <li><a href="<?php echo site_url('admin/to_do_list/view_to_do/'.$new->id) ?>"><i class="fa fa-check-square-o"></i> <?php echo $new->title ?></a></li>
                    <?php endforeach; ?>
                    <?php else: ?>
                    <li><a href="<?php echo site_url('admin/tasks') ?>"><i class="fa fa-tasks"></i> Ver todas as tarefas</a></li>
                    <?php endif; ?>
                </ul></li>
                <li class="footer"><a href="<?php echo site_url('admin/tasks') ?>">Ver tarefas</a></li>
            </ul>
        </div>
        <?php endif; ?>

        <!-- Mensagens -->
        <a href="<?php echo site_url('admin/message') ?>" class="tb-icon-btn" title="Mensagens">
            <i class="fa fa-envelope"></i>
            <?php if(count((array)$admin_messages)>0): ?><span class="tb-dot"></span><?php endif; ?>
        </a>

        <?php else: ?>

        <!-- Mensagens cliente -->
        <a href="<?php echo site_url('admin/message/send_message/'.$admin['id']) ?>" class="tb-icon-btn" title="Mensagens">
            <i class="fa fa-envelope"></i>
            <?php if(count((array)$admin_messages)>0): ?><span class="tb-dot"></span><?php endif; ?>
        </a>

        <?php endif; ?>

        <!-- Usuário -->
        <div class="dropdown">
            <a href="#" class="tb-user-btn" data-toggle="dropdown">
                <div class="tb-avatar"><?php echo $iniciais ?></div>
                <span class="hidden-xs"><?php echo $admin['name'] ?></span>
                <i class="fa fa-caret-down"></i>
            </a>
            <ul class="dropdown-menu dropdown-menu-right" style="right:0;left:auto;min-width:200px">
                <li class="user-header bg-light-blue">
                    <?php if(!empty($admin['image'])): ?>
                    <img src="<?php echo base_url('assets/uploads/images/'.$admin['image']) ?>" class="img-circle">
                    <?php else: ?>
                    <img src="<?php echo base_url('assets/uploads/images/avatar5.png') ?>" class="img-circle">
                    <?php endif; ?>
                    <p><?php echo $admin['name'] ?></p>
                </li>
                <li><a href="<?php echo site_url('admin/account') ?>"><i class="fa fa-user-o" style="margin-right:7px"></i> Meu Perfil</a></li>
                <li role="separator" class="divider"></li>
                <li><a href="<?php echo site_url('admin/login/logout') ?>" style="color:#c0392b"><i class="fa fa-sign-out" style="margin-right:7px"></i> Sair</a></li>
            </ul>
        </div>

    </div><!-- /tb-right -->
</div><!-- /#bp-topbar -->

<!-- ════ CONTEÚDO ════════════════════════════════ -->
<div id="bp-content">

<?php
if ($this->session->flashdata('message')) $message = $this->session->flashdata('message');
if ($this->session->flashdata('error'))   $error   = $this->session->flashdata('error');
?>
<?php if (!empty($error) || !empty($message)): ?>
<div style="padding:12px 20px 0">
    <?php if (!empty($error)): ?>
    <div class="alert alert-danger alert-dismissible"><button class="close" data-dismiss="alert">&times;</button><i class="fa fa-ban"></i> <?php echo $error ?></div>
    <?php endif; ?>
    <?php if (!empty($message)): ?>
    <div class="alert alert-success alert-dismissible"><button class="close" data-dismiss="alert">&times;</button><i class="fa fa-check-circle"></i> <?php echo $message ?></div>
    <?php endif; ?>
</div>
<?php endif; ?>
