<?php

class MDT_Controller extends CI_Controller {

    var $template = array(
        'table_open' => "<table class='table table-striped table-hover table-bordered table-condensed'>",
        'thead_open' => '<thead class=\'bg-indigo\'>',
        'thead_close' => '</thead>',
        'heading_row_start' => '<tr>',
        'heading_row_end' => '</tr>',
        'heading_cell_start' => '<th>',
        'heading_cell_end' => '</th>',
        'tbody_open' => '<tbody>',
        'tbody_close' => '</tbody>',
        'row_start' => '<tr>',
        'row_end' => '</tr>',
        'cell_start' => '<td>',
        'cell_end' => '</td>',
        'row_alt_start' => '<tr>',
        'row_alt_end' => '</tr>',
        'cell_alt_start' => '<td>',
        'cell_alt_end' => '</td>',
        'table_close' => '</table>'
    );
    var $template_nohead = array(
        'table_open' => "<table class='table table-striped table-hover table-bordered table-condensed'>",
        'thead_open' => '<thead>',
        'thead_close' => '</thead>',
        'heading_row_start' => '<tr>',
        'heading_row_end' => '</tr>',
        'heading_cell_start' => '<th>',
        'heading_cell_end' => '</th>',
        'tbody_open' => '<tbody>',
        'tbody_close' => '</tbody>',
        'row_start' => '<tr>',
        'row_end' => '</tr>',
        'cell_start' => '<td>',
        'cell_end' => '</td>',
        'row_alt_start' => '<tr>',
        'row_alt_end' => '</tr>',
        'cell_alt_start' => '<td>',
        'cell_alt_end' => '</td>',
        'table_close' => '</table>'
    );
    public $data = array();

    function __construct() {
        parent::__construct();
        
       
        
    }

    protected function smart_htmlspecialchars($str) {
        if (substr($str, 0, 1) == '<')
            return $str;
        return htmlspecialchars($str);
    }

    protected function sql_escape_func($inp) {
        if (is_array($inp)) {
            return array_map(__METHOD__, $inp);
        }


        if (!empty($inp) && is_string($inp)) {
            return str_replace(array('\\', "\0", "\n", "\r", "'", '"', "\x1a"), array('\\\\', '\\0', '\\n', '\\r', "\\'", '\\"', '\\Z'), $inp);
        }

        return $inp;
    }

    protected function medtrans_api($in, $out) {
        global $mobideliv;
        $ret = -1;
        $in['pid'] = 115;
        /* if (!array_key_exists('mobideliv', $GLOBALS)) {
            $USER = $_SERVER['SCRIPT_FILENAME'];
            $USER = str_replace('/home', '', $USER);
            $USER = strtok($USER, '/');
            if ($USER == 'opt') {
                $USER = 'root';
            }
            // Load API class
            $mobideliv_class = 'mobideliv_api_' . $USER . '\\MobiDeliv';
            // $mobideliv_class = 'mobideliv_api\\MobiDeliv';
            $mobideliv = new $mobideliv_class();
        }*/
        $ret = $mobideliv->mobideliv_api($in, $out);
        return $ret;
    }
    
    function formatedMesage($msgType,$theMessage)
    {
        return  "<div class=\"text-left\"><div class=\"alert alert-danger no-border\">".$theMessage."</div></div>";
    }

    protected function renderAdminPage($page_name, $data) {
        $this->load->view('admin/view_admin_header',$data);
        $this->load->view('admin/'.$page_name,$data);
        $this->load->view('admin/view_admin_footer',$data);
    }
    

}
