diff --git a/src/controllers/SoapPremiumController.php b/src/controllers/SoapPremiumController.php index 3d8112f8d3bcf5fbe276cc22d3963232237a2f3c..9b8d6b3f8594f11945a7beab86661949b64e1cb0 100644 --- a/src/controllers/SoapPremiumController.php +++ b/src/controllers/SoapPremiumController.php @@ -8,12 +8,10 @@ use app\models\SoapPremiumModel; use Exception; class SoapPremiumController extends BaseController { - public $model; - // public $soap_client; + private $model; public function __construct() { $this->model = SoapPremiumModel::getInstance(); - // $this->soap_client = $this->model->getSoapClient(); } public function checkStatus($params){ @@ -25,9 +23,8 @@ class SoapPremiumController extends BaseController { $uri = Request::getURL(); if($uri == '/premium-status'){ - $params = ["userId" => 1]; + $params = ["userId" => $_SESSION['user_id']]; $result = $this->checkStatus($params); - // response::send_json_response($result->userStatus); $data['userStatus'] = $result->userStatus; parent::render($data, 'premium-status', "layouts/base"); @@ -39,6 +36,18 @@ class SoapPremiumController extends BaseController { protected function post($urlParams) { - + if(isset($_POST['email'])){ + $params = ["userId" => $_SESSION['user_id'], "email" => $_POST['email']]; + $result = $this->model->registerPremium($params); + if($result->status == "success"){ + header("Location: /premium-status"); + } + else{ + throw new Exception("Invalid Email"); + } + } + else{ + throw new Exception("Invalid URL"); + } } } \ No newline at end of file diff --git a/src/models/SoapPremiumModel.php b/src/models/SoapPremiumModel.php index d3e4153ebe71562b006aedb3f9c2d031fcbff767..c47abc4b8bf01224031ee60b5c2e0c82e1ce893d 100644 --- a/src/models/SoapPremiumModel.php +++ b/src/models/SoapPremiumModel.php @@ -30,20 +30,24 @@ } return self::$instance; } - // public function getSoapClient() - // { - // return $this->soapclient; - // } + public function registerPremium($params) + { + return $this->soapclient->registerPremium($params); + } public function checkStatus($params) { return $this->soapclient->checkStatus($params); } - // public function getFunctions() - // { - // return $this->soapclient->__getFunctions(); - // } - // public function getTypes() - // { - // return $this->soapclient->__getTypes(); - // } + public function cancelRegister($params){ + return $this->soapclient->cancelRegister($params); + } + public function approvePremium($params){ + return $this->soapclient->approvePremium($params); + } + public function getAllPremium($params){ + return $this->soapclient->getAllPremium($params); + } + public function getAllPending($params){ + return $this->soapclient->getAllPending($params); + } } \ No newline at end of file diff --git a/views/premium-status.php b/views/premium-status.php index a0ecfb504245da5910fb52bfcfd34c5e862d08db..6c2cf8f63051278d199e3f3cd0c0a0cafad70793 100644 --- a/views/premium-status.php +++ b/views/premium-status.php @@ -1,8 +1,20 @@ -<div class='details'> +<div class='premium-status'> <h2 id="goBack"><a class='back-button' href="/films"><?php echo "< Films" ?></a></h2> <h1>Premium Status<h1> - <?php echo $data["userStatus"]?> - -</div> - + <br> + <p>Current: <?php $result = $data["userStatus"]; echo $result;?></p> + <br> + <?php + if($result == "REJECTED" || $result == "UNREGISTERED") { ?> + <form method="post" action="/premium-status"> + <label for="email">Email:</label> + <input type="email" id="email" name="email" required> + <button type="submit">Register for Premium</button> + </form> + <?php } elseif($result == "PENDING") { ?> + <div class="pending"> + <p>Your request is pending. Please wait for the admin to approve your request.</p> + <p>Click <a href="/premium-status">here</a> to refresh the page.</p> + </div> + <?php } ?> </div> \ No newline at end of file