<?php
defined('BASEPATH') OR exit('No direct script access allowed');

if (!function_exists('show_alert')) {
    function show_alert()
    {
        $CI =& get_instance();

        // Error
        if ($CI->session->flashdata('error')) {
            echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">'
                 . $CI->session->flashdata('error') .
                 '<button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                 </button>
                 </div>';
        }

        // Success
        if ($CI->session->flashdata('success')) {
            echo '<div class="alert alert-success alert-dismissible fade show" role="alert">'
                 . $CI->session->flashdata('success') .
                 '<button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                 </button>
                 </div>';
        }

        // Info
        if ($CI->session->flashdata('info')) {
            echo '<div class="alert alert-info alert-dismissible fade show" role="alert">'
                 . $CI->session->flashdata('info') .
                 '<button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                 </button>
                 </div>';
        }

        // Warning
        if ($CI->session->flashdata('warning')) {
            echo '<div class="alert alert-warning alert-dismissible fade show" role="alert">'
                 . $CI->session->flashdata('warning') .
                 '<button type="button" class="close" data-dismiss="alert" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                 </button>
                 </div>';
        }
    }
}
