Skip to content
Snippets Groups Projects
Commit d0626e34 authored by Bitha17's avatar Bitha17
Browse files

ticket purchase logic

parent 0a482aa0
Branches
Tags
No related merge requests found
......@@ -6,7 +6,8 @@ require_once(__DIR__ . '/../Models/Pembelian.php');
class PembelianController {
private $pembelianModel;
public function __construct() {
$this->pembelianModel = new PembelianModel();
}
......@@ -31,7 +32,7 @@ class PembelianController {
return $this->pembelianModel->getAllPembelian();
}
public function paginateHistory($page=1,$pagesize=10,$pembelian) {
public function paginateHistory($pembelian,$page=1,$pagesize=10) {
$maxpage = ceil(count($pembelian)/$pagesize);
if ($page > $maxpage) {
$page = $maxpage;
......@@ -41,5 +42,33 @@ class PembelianController {
return $selectedHistory;
}
// Returns true if purchase succeeds
public function purchaseTicket($ticketId,$userId) {
// $purchases = $this->getAllPembelian();
// foreach ($purchases as $purchase) :
// echo $purchase['pembelian_id'] . ': ' . $purchase['user_id'] . ', ' . $purchase['ticket_id'] . ', ' . $purchase['pembelian_created_time']."\n";
// endforeach;
$createdTime = date("Y-m-d H:i:s");
$this->createPembelian($ticketId,$userId,$createdTime);
// $purchases = $this->getAllPembelian();
// foreach ($purchases as $purchase) :
// echo $purchase['pembelian_id'] . ': ' . $purchase['user_id'] . ', ' . $purchase['ticket_id'] . ', ' . $purchase['pembelian_created_time']."\n";
// endforeach;
}
public function handleRequest() {
if (isset($_GET['action'])) {
if ($_GET['action'] === 'purchaseTicket') {
$ticketId = $_POST['ticketId'];
$userId = $_POST['userId'];
$this->purchaseTicket($ticketId,$userId);
} else {
// Handle other actions here, if needed
}
}
}
}
?>
......@@ -26,5 +26,11 @@ class TicketController {
public function deleteTicket($ticketId) {
return $this->ticketModel->deleteTicket($ticketId);
}
public function previewTicket($ticketId) {
$ticket = $this->getTicket($ticketId);
include(__DIR__ . '/../Views/pembelian/pembelian.php');
}
}
?>
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment