From 3dcf91bd7e512f7d88720b65a9de9aed2b63ce30 Mon Sep 17 00:00:00 2001 From: Olusesan Ameye Date: Sun, 3 Mar 2019 22:39:12 +0000 Subject: [PATCH] Backend Model added --- .../application/config/backend_defines.php | 28 ++++++++++ providerwww/application/config/constants.php | 4 ++ .../application/core/MER_Controller.php | 51 +++++-------------- .../application/models/Backend_model.php | 42 +++++++++++++++ 4 files changed, 87 insertions(+), 38 deletions(-) create mode 100644 providerwww/application/config/backend_defines.php create mode 100644 providerwww/application/models/Backend_model.php diff --git a/providerwww/application/config/backend_defines.php b/providerwww/application/config/backend_defines.php new file mode 100644 index 0000000..25e3008 --- /dev/null +++ b/providerwww/application/config/backend_defines.php @@ -0,0 +1,28 @@ +load->library(array('session', 'lib_login')); } - public function wrenchboard_api($in, $out) { + public function mermsemr_api($in, $out) { $this->load->model('backend_model'); // $out = array(); - return $this->backend_model->wrenchboard_api($in, $out); + return $this->backend_model->mermsemr_api($in, $out); } protected function smart_htmlspecialchars($str) { @@ -64,6 +64,16 @@ class MER_Controller extends CI_Controller { protected function loginUser($in, $out) { + + $data['action'] = MERMS_PROVIDERS_LOGIN; + $data['mlog'] = $mlog; + $data['member_id'] = $_SESSION['member_id']; + $this->load->model('backend_model'); + $out = array(); + $res = $this->backend_model->mermsemr_api($data, $out); + + + $_SESSION['session_id'] = "SASAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK"; $_SESSION['username'] = "ameye"; @@ -111,7 +121,7 @@ class MER_Controller extends CI_Controller { $data['member_id'] = $_SESSION['member_id']; $this->load->model('backend_model'); $out = array(); - $res = $this->backend_model->wrenchboard_api($data, $out); + $res = $this->backend_model->mermsemr_api($data, $out); $this->load->model('userlog_model'); $xy["member_id"] = $_SESSION['member_id']; @@ -230,42 +240,7 @@ class MER_Controller extends CI_Controller { return $query->result(); } - protected function getClientJobStats($client_id) { - $out = array(); - $out['total_jobs_completed'] = $out['total_jobs_active'] = $data['total_jobs_uncompleted'] = 0; - $out['total_pending_offers'] = 0; - $mysql = " SELECT count(*) AS total_jobs_completed FROM members_jobs_contract WHERE client_id =$client_id AND status = 5"; - $q = $this->db->query($mysql); - if ($q->num_rows() > 0) { - $out['total_jobs_completed'] = $q->row()->total_jobs_completed; - } - - - $mysql = " SELECT count(*) AS total_jobs_active FROM members_jobs_contract WHERE client_id =$client_id AND status IN (1,2)"; - $q = $this->db->query($mysql); - if ($q->num_rows() > 0) { - $out['total_jobs_active'] = $q->row()->total_jobs_active; - } - - - $mysql = " SELECT count(*) AS total_jobs_uncompleted FROM members_jobs_contract WHERE client_id =$client_id AND status NOT IN (1,2,5)"; - $q = $this->db->query($mysql); - if ($q->num_rows() > 0) { - $out['total_jobs_uncompleted'] = $q->row()->total_jobs_uncompleted; - } - - $mysql = " SELECT count(*) AS total_pending_offers FROM members_jobs_offer WHERE client_id =$client_id AND status=1"; - $q = $this->db->query($mysql); - if ($q->num_rows() > 0) { - $out['total_pending_offers'] = $q->row()->total_pending_offers; - } - - - - - return $out; //['escrow_c_offer'] + $out['escrow_balance']; - } protected function renderProviderSecurePage($page_name, $data) { diff --git a/providerwww/application/models/Backend_model.php b/providerwww/application/models/Backend_model.php new file mode 100644 index 0000000..2612381 --- /dev/null +++ b/providerwww/application/models/Backend_model.php @@ -0,0 +1,42 @@ +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(); + } + } +} + + +//