public function logoutAction() { $username = $_POST['username']; $return_array = array(); $data; if (!empty($username)) { $customer = new Object\Customer\Listing(); $customer->setCondition("username = ?", array($username)); foreach ($customer as $value) { session_start(); session_destroy(); $data = array("username" => $value->username); $return_array['status'] = 'success'; $return_array['message'] = 'Logout success'; $return_array['data'] = $data; } } else { $return_array['status'] = 'failed'; $return_array['message'] = 'This user has been logout'; $return_array['data'] = ''; } $json_customer = $this->_helper->json($return_array); Website_P1GlobalFunction::sendResponse($json_customer); $this->sendResponse($json_customer); }
public function userorderAction() { //die("test"); $content = $_POST['data']; $requestedData = json_decode($content); if ($this->checkExists($requestedData)) { if ($this->authenicateUserAPIKey($requestedData->auth)) { if (empty($requestedData->NRIC_PP) || !isset($requestedData->NRIC_PP) && $this->checkExists($requestedData->NRIC_PP)) { $json = array('code' => "REG004-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided."); echo json_encode($json); exit; } else { if (empty($requestedData->Username) || !isset($requestedData->Username) && $this->checkExists($requestedData->Username)) { $json = array('code' => "REG004-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided."); echo json_encode($json); exit; } else { if (empty($requestedData->EcomRefNoStatus) || !isset($requestedData->EcomRefNoStatus) && $this->checkExists($requestedData->EcomRefNoStatus)) { $json = array('code' => "REG004-202", 'ErrorMsg' => "Missing fields. Please check all fields are provided."); echo json_encode($json); exit; } } } $username = $requestedData->Username; $NRIC_PP = $requestedData->NRIC_PP; $Customer = new Object\Customer\Listing(); $Customer->setCondition("username = ? AND NRIC_PP = ?", array($username, $NRIC_PP)); $Customer = $Customer->load(); if ($this->checkExists($Customer)) { foreach ($Customer as $val) { $customerID = $val->o_id; $Order = new Object\Orders\Listing(); $Order->setCondition("Customer__id = ?", $customerID); $Order = $Order->load(); if ($this->checkExists($Order)) { foreach ($Order as $ord) { if ($ord->EcomRefNo && $ord->EcomRefNoStatus) { $data[] = array('EcomRefNo' => $ord->EcomRefNo, 'EcomRefNoStatus' => $ord->EcomRefNoStatus); } } if ($this->checkExists($data)) { $json = array('status' => "Success", 'EcomOrders' => $data); echo json_encode($json); exit; } else { $json = array('code' => "REG004-100", 'ErrorMsg' => "No Customer order found"); echo json_encode($json); exit; } } else { $json = array('code' => "REG004-100", 'ErrorMsg' => "No Customer order found"); echo json_encode($json); exit; } } } else { $json = array('code' => "REG004-202", 'ErrorMsg' => "No matching user(username with nric/passport number) found in system."); echo json_encode($json); exit; } } else { $json = array('code' => "REG004-201", 'ErrorMsg' => "Invalid authentication"); echo json_encode($json); exit; } } else { $json = array('code' => "REG004-204", 'status' => "failure", 'ErrorMsg' => "Json format is incorrect."); echo json_encode($json); exit; } }