From f459542edc1522c17edd347e2104c3ff936f70a0 Mon Sep 17 00:00:00 2001 From: "CHIEFSOFT\\ameye" Date: Wed, 19 Jul 2023 07:25:49 -0400 Subject: [PATCH] Dash Recent --- www-api/app/Config/Routes.php | 2 + www-api/app/Controllers/BaseController.php | 1 + www-api/app/Controllers/WrenchDashRecent.php | 132 +++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 www-api/app/Controllers/WrenchDashRecent.php diff --git a/www-api/app/Config/Routes.php b/www-api/app/Config/Routes.php index cb5a40de..a54135f5 100644 --- a/www-api/app/Config/Routes.php +++ b/www-api/app/Config/Routes.php @@ -188,6 +188,8 @@ $routes->post('/en/wrench/api/v1/confirmcredit', 'WrenchTransactions::a $routes->post('/en/wrench/api/v1/mynotifications', 'WrenchNotifications::apigate'); +$routes->post('/en/wrench/api/v1/dashrecent', 'WrenchDashRecent::apigate'); + $routes->post('/en/wrench/api/v1/getmedia', 'WrenchMedia::apigate'); diff --git a/www-api/app/Controllers/BaseController.php b/www-api/app/Controllers/BaseController.php index 7faf6744..5644762f 100644 --- a/www-api/app/Controllers/BaseController.php +++ b/www-api/app/Controllers/BaseController.php @@ -197,6 +197,7 @@ abstract class BaseController extends Controller 'confirmcredit' => ['POST'], 'setaccsettings' => ['POST'], 'getaccsettings' => ['POST'], + 'dashrecent' => ['POST'], ]; return $endpoints; } diff --git a/www-api/app/Controllers/WrenchDashRecent.php b/www-api/app/Controllers/WrenchDashRecent.php new file mode 100644 index 00000000..0dedb4c2 --- /dev/null +++ b/www-api/app/Controllers/WrenchDashRecent.php @@ -0,0 +1,132 @@ + OPTIONS DIE*****" ); + die(); + } + + //$request = service('request'); + // what is the endpoint + $uri = urldecode(current_url(true)); + $findme = '?'; + $pos = strpos($uri, $findme); + if ($pos > 5) { + $uri = substr($uri, 0, $pos); + } + log_message('critical', "API-GATE URI -> ".$uri ); + $pieces = explode('/', $uri); + $psc = count($pieces); + + $endpoint = $psc > 0 ? $pieces[$psc - 1] : ''; + log_message('critical', "Enpoint-> ".$endpoint ); + + $endpoints = $this->endPointList(); + $out = array(); + $res1 = []; + if (array_key_exists($endpoint, $endpoints)) { + } else { + http_response_code(404); + // tell the user product does not exist + return json_encode([ + 'message' => 'Endpoint not found.', + 'URI' => $uri, + ]); + } + + // echo "EXYTACT INPUT DATA HERE"; + $raw_json = file_get_contents('php://input'); + $raw_array = json_decode($raw_json, true); + log_message('critical', "WrenchDashRecent-Gate 003"); + $local_out =[]; + if ($_SERVER["REQUEST_METHOD"] == "POST") { // if upload lets modify all the data + if (isset($_FILES) && is_array($_FILES) && count($_FILES)>0) { + $raw_array = array_merge($_POST,$_FILES); + } + } + log_message('critical', "WrenchDashRecent-Gate 004"); + if ($_SERVER['REQUEST_METHOD'] == 'GET') { + log_message('critical', "Enpoint LOC2 HERE -> ".$endpoint ); + $get_param = $_GET['reqData'] ?? null; + $raw_array = ($get_param!=null) ? json_decode($get_param, true):[]; + } + //$in = $raw_array; + log_message('critical', "WrenchDashRecent-CALL RAW DATA".serialize($raw_array) ); + //-- move to another module start + + log_message('critical', "WrenchTransactions-Gate 005 ->".$endpoint); + + $in = $this->rawDataToInData($raw_array); + $in["loc"] = $_SERVER["REMOTE_ADDR"]; + log_message('critical', "WrenchDashRecent-CALL PREPARE DATA".serialize($in) ); + + switch ($endpoint){ + + case 'dashrecent': + log_message('critical', "WrenchDashRecent-Gate 006 ->".$endpoint); + $call_backend = fasle; + $this->dashRecent($in,$out); + $in["action"] = WRENCHBOARD_USER_STARTCREDIT; + break; + + case 'confirmcredit': + // Confrim + break; + } + + + + if ( $call_backend == true && $in["action"] !='' ){ + log_message('critical', "WrenchDashRecent-Gate 007 ->".$endpoint); + // $wrenchboard = new \App\Models\BackendModel(); + $ret = $this->callBackEndData($in,$out); // $wrenchboard->wrenchboard_api($in, $out); + //$out['internal_return'] = $ret; + } + else + { + $out = $local_out; + } + + return json_encode( ( new \App\Models\ResultFormatter() )->processOutJson($in, $out)); + return $this->response->setJson($response); + } + + private function dashRecent($in,$out){ + + $in["action"] = WRENCHBOARD_FAMILY_SGGESTWAITING; + $ret = $this->callBackEndData($in,$out); + + + } + private function callBackEndData($in,$out){ + log_message('critical', "WrenchDashRecent-Gate 007 ->"); + $wrenchboard = new \App\Models\BackendModel(); + $ret = $wrenchboard->wrenchboard_api($in, $out); + $out['internal_return'] = $ret; + return $ret; + } + private function rawDataToInData($in){ + + + return $in; + } + +} \ No newline at end of file