<?php

class Backend_model extends CI_Model {

    var $thisUser = 'sameye';
    var $USER = '';
    var $mermsemr;

    function __construct() {

        $this->USER = $_SERVER['SCRIPT_FILENAME'];
        $this->USER = str_replace('/home', '', $this->USER);
        $this->USER = strtok($this->USER, '/');
        if ($this->USER == 'opt') {
            $this->USER = 'root';
        }
        $this->thisUser = $this->USER;
    }

    public function mermsemr_api($in, $out = array()) {
        $this->mermsemr_load();
        $ret = $this->mermsemr->mermsemr_api($in, $out);
        return $ret;
    }

    public function cfgReadChar($str) {
        $this->wrenchboard_load();
        $ret = $this->mermsemr->cfgReadChar($str);
        return $ret;
    }

    private function mermsemr_load() {
        // $this->$USER = $_SERVER['SCRIPT_FILENAME'];
        $mermsemr_class = 'mermsemr_api_' . $this->USER . '\\MermsEmr';
        if (!is_object($this->mermsemr)) {
            $this->mermsemr = new $mermsemr_class();
        }
    }
}


//<? if (!array_key_exists("mermsemr", $GLOBALS)) $mermsemr = new mermsemr_api_sameye\MermsEmr(); ?>
