diff --git a/app/views/profile/index.php b/app/views/profile/index.php index 342f298f2f7ff0acd98f548a4d215f53a63af5db..b5d97511f6fa35e35bb8e1c633502b7f082da370 100644 --- a/app/views/profile/index.php +++ b/app/views/profile/index.php @@ -26,6 +26,7 @@ echo "<script>console.log('$id, $fullName, $email, $phone')</script>"; <!-- include js --> <script src="../../../public/js/profile.js"></script> <script src="../../../public/js/register.js"></script> + <script>window.onload = function() {showExp();};</script> <title>NutriCraft</title> </head> <body> @@ -43,6 +44,7 @@ echo "<script>console.log('$id, $fullName, $email, $phone')</script>"; <div class="boxKiri"> <div class="photoContainer"> <img src=<?php echo $photo?> alt="photoProfile" class="photoProfile" id="photoProfile"> + <div id="exp"></div> <div class="editPhotoButton"> <label for="file" class="fileLabel">Choose a Photo</label> <input type="file" name="file" id="file" class="file" accept="image/*" onchange="updatePhoto()"> diff --git a/public/js/profile.js b/public/js/profile.js index 06b526052f2ca4823925d3718101ae9d0dcd619b..82502e4fb41ed3430f3d25fc0a5bc18516e49d72 100644 --- a/public/js/profile.js +++ b/public/js/profile.js @@ -77,4 +77,30 @@ function showConfirmationdelete() { console.log('cancel'); hideConfirmation(); }); +} + +function showExp(){ + const show = "exp"; + + xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + if (this.readyState === 4){ + let response = this.response; + // const jsonObject = JSON.parse(response); + console.log(response); + + const parentElement = document.getElementById("exp"); + let html = ""; + + html += ` + <div"> + <h1>EXP : ${response}</h1> + </div> + `; + + parentElement.innerHTML = html; + } + }; + xhttp.open('GET', `../../server/controller/auth/Profile.php?show=${show}`, true); + xhttp.send(); } \ No newline at end of file diff --git a/server/controller/auth/Profile.php b/server/controller/auth/Profile.php index d7703e5eff30b6a76cc1c08f20b0e8f9e48275a2..a2e9891b08a132de0866e4db223b5643d7a9704d 100644 --- a/server/controller/auth/Profile.php +++ b/server/controller/auth/Profile.php @@ -111,6 +111,46 @@ if(isset($_POST['submit'])){ echo "<script>window.location.href='/?profile'</script>"; } +if(isset($_GET['show'])){ + $serviceUrl = $_ENV['SOAP_URL_USER_LEVEL']."?APIkey=".$_ENV["SOAP_KEY"]; + + $soapRequest = ' + <Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"> + <Body> + <getExpUser xmlns="http://Services.nutricraft.org/"> + <arg0 xmlns="">1</arg0> + </getExpUser> + </Body> + </Envelope>'; + + $options = [ + CURLOPT_URL => $serviceUrl, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $soapRequest, + CURLOPT_HTTPHEADER => [ + 'Content-Type: text/xml; charset=utf-8', + 'Content-Length: ' . strlen($soapRequest), + ], + ]; + + $curl = curl_init(); + curl_setopt_array($curl, $options); + + $response = curl_exec($curl); + + curl_close($curl); + + if (curl_errno($curl)) { + echo 'cURL Error: ' . curl_error($curl); + } else { + $xml = new SimpleXMLElement($response); + $returnValue = (string)$xml->xpath('//return')[0]; + echo $returnValue; + } +} + + // if(isset($_POST['submit'])){ // if(isset($_POST['fullName'])){ // $fullName = $_POST['fullName'];