Skip to content

Commit 1002217

Browse files
authored
Merge pull request #52 from kasunmendis7/develop
added payment details ui
2 parents 92ba943 + 4d65cf7 commit 1002217

26 files changed

+2057
-83
lines changed

controllers/AdminController.php

+57-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use app\core\Request;
88
use app\models\Admin;
99
use app\models\Customer;
10+
use app\models\Promotion;
1011
use app\models\Technician;
1112

1213
class AdminController extends Controller
@@ -74,7 +75,62 @@ public function adminLogin()
7475
public function promotions()
7576
{
7677
$this->setLayout('auth');
77-
return $this->render('/admin/admin-promotions');
78+
$promotions = Promotion::getAllPromotions();
79+
return $this->render('/admin/admin-promotions', [
80+
'promotions' => $promotions
81+
]);
82+
}
83+
84+
public function insert_promotion()
85+
{
86+
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
87+
$desc = $_POST['promdesc'];
88+
$price = $_POST['price'];
89+
$create = $_POST['strdate'];
90+
$update = $_POST['enddate'];
91+
92+
$success = Promotion::insert_promotion($desc, $create, $price, $update);
93+
94+
if ($success) {
95+
header('Location:/admin-promotions');
96+
}
97+
98+
99+
}
100+
}
101+
102+
public function update_promotion()
103+
{
104+
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
105+
106+
print_r($_POST);
107+
$desc = $_POST['promdesc'];
108+
$price = $_POST['price'];
109+
$update = $_POST['enddate'];
110+
$id = $_POST['promid'];
111+
$success = Promotion::updatePromotion($id, $desc, $price, $update);
112+
113+
if ($success) {
114+
header('Location:/admin-promotions');
115+
}
116+
117+
118+
}
119+
}
120+
121+
public function delete_promotion()
122+
{
123+
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
124+
125+
$id = $_POST['promid'];
126+
$success = Promotion::deletePromotion($id);
127+
128+
if ($success) {
129+
header('Location:/admin-promotions');
130+
}
131+
132+
133+
}
78134
}
79135

80136

controllers/CustomerController.php

+6
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,10 @@ public function customerTransactions()
195195
$this->setLayout('auth');
196196
return $this->render('/customer/customer-transactions');
197197
}
198+
199+
public function customerPaymentDetails()
200+
{
201+
$this->setLayout('auth');
202+
return $this->render('/customer/customer-payment-details');
203+
}
198204
}

controllers/ServiceCentreController.php

+6
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,10 @@ public function viewServiceCenterProfile($id)
141141
]);
142142
}
143143

144+
public function serviceCenterPaymentDetails()
145+
{
146+
$this->setLayout('auth');
147+
return $this->render('service-centre/service-center-payment-details');
148+
}
149+
144150
}

controllers/TechnicianController.php

+5
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ public function technicianTransactions()
159159
return $this->render('/technician/technician-transactions');
160160
}
161161

162+
public function technicianPaymentDetails()
163+
{
164+
$this->setLayout('auth');
165+
return $this->render('/technician/technician-payment-details');
166+
}
162167

163168
}
164169

models/Promotion.php

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
3+
namespace app\models;
4+
5+
use app\core\Application;
6+
use app\core\DbModel;
7+
8+
9+
class Promotion extends DbModel
10+
{
11+
12+
public function tableName(): string
13+
{
14+
return 'promotion';
15+
}
16+
17+
public function primaryKey(): string
18+
{
19+
return 'promotion_id';
20+
}
21+
22+
public function rules(): array
23+
{
24+
return [
25+
'admin_id' => [self::RULE_REQUIRED],
26+
'descriptioin' => [self::RULE_REQUIRED],
27+
'price' => [self::RULE_REQUIRED],
28+
'created_at' => [self::RULE_REQUIRED],
29+
'updated_at' => [self::RULE_REQUIRED],
30+
31+
];
32+
}
33+
34+
35+
public function updateRules(): array
36+
{
37+
return [
38+
39+
];
40+
}
41+
42+
public function attributes(): array
43+
{
44+
return [
45+
'admin_id',
46+
'description',
47+
'price',
48+
'media',
49+
'created_at',
50+
'updated_at'
51+
];
52+
}
53+
54+
55+
public static function getAllPromotions()
56+
{
57+
$sql = "SELECT * FROM promotion";
58+
$stmt = (new Promotion)->prepare($sql);
59+
$stmt->execute();
60+
$promotion = $stmt->fetchAll(\PDO::FETCH_ASSOC);
61+
return $promotion;
62+
63+
}
64+
65+
public static function insert_promotion($desc, $create, $price, $update, $admin_id = 1)
66+
{
67+
$sql = "INSERT INTO promotion
68+
(description, created_at, price, updated_at,admin_id)
69+
VALUES (:desc, :created, :price, :updated,:admin)";
70+
71+
$stmt = (new Promotion)->prepare($sql);
72+
$stmt->bindParam(':desc', $desc);
73+
$stmt->bindParam(':created', $create);
74+
$stmt->bindParam(':price', $price);
75+
$stmt->bindParam(':updated', $update);
76+
$stmt->bindParam(':admin', $admin_id);
77+
78+
return $stmt->execute();
79+
}
80+
81+
public static function updatePromotion($id, $desc, $price, $update)
82+
{
83+
$sql = "UPDATE promotion
84+
SET description = :desc,
85+
price = :price,
86+
updated_at = :updated
87+
WHERE promotion_id = :id";
88+
89+
$stmt = (new Promotion)->prepare($sql);
90+
$stmt->bindParam(':id', $id);
91+
$stmt->bindParam(':desc', $desc);
92+
$stmt->bindParam(':price', $price);
93+
$stmt->bindParam(':updated', $update);
94+
95+
return $stmt->execute();
96+
}
97+
98+
public static function deletePromotion($id)
99+
{
100+
$sql = "DELETE FROM promotion WHERE promotion_id = :id";
101+
102+
$stmt = (new Promotion)->prepare($sql);
103+
$stmt->bindParam(':id', $id);
104+
105+
return $stmt->execute();
106+
}
107+
}

public/css/admin/reports.css

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/* General Reset */
2+
body {
3+
margin: 0;
4+
font-family: Arial, sans-serif;
5+
background-color: #f5f5f5;
6+
}
7+
8+
/* Centering Container */
9+
.promotion-container {
10+
display: flex;
11+
justify-content: center;
12+
align-items: center;
13+
height: 100vh; /* Full viewport height */
14+
background-color: #f5f5f5; /* Light background */
15+
}
16+
17+
/* Promotion Form Styling */
18+
.promotion-form {
19+
background-color: #ffffff; /* White background */
20+
padding: 30px;
21+
border-radius: 8px;
22+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Subtle shadow */
23+
width: 400px;
24+
}
25+
26+
.promotion-form h2 {
27+
text-align: center;
28+
margin-bottom: 20px;
29+
color: #010336; /* Deep blue */
30+
}
31+
32+
/* Form Group Styling */
33+
.form-group {
34+
margin-bottom: 15px;
35+
}
36+
37+
.form-group label {
38+
display: block;
39+
font-weight: bold;
40+
margin-bottom: 5px;
41+
color: #333333; /* Darker text */
42+
}
43+
44+
.form-group input,
45+
.form-group select {
46+
width: 100%;
47+
padding: 10px;
48+
border: 1px solid #cccccc;
49+
border-radius: 5px;
50+
box-sizing: border-box;
51+
font-size: 16px;
52+
}
53+
54+
.form-group input:focus,
55+
.form-group select:focus {
56+
border-color: #010336; /* Highlighted border */
57+
outline: none;
58+
box-shadow: 0 0 5px rgba(1, 3, 54, 0.2);
59+
}
60+
61+
/* Button Styling */
62+
button {
63+
width: 100%;
64+
padding: 12px;
65+
background-color: #010336; /* Deep blue */
66+
color: #ffffff; /* White text */
67+
border: none;
68+
border-radius: 5px;
69+
font-size: 16px;
70+
cursor: pointer;
71+
font-weight: bold;
72+
}
73+
74+
button:hover {
75+
background-color: #002080; /* Slightly lighter blue */
76+
transition: background-color 0.3s;
77+
}

0 commit comments

Comments
 (0)