Skip to content

Commit 5a140a4

Browse files
Version 3.0 - OverAll
1 parent 5e92553 commit 5a140a4

21 files changed

+223
-78
lines changed

Diff for: README.MD

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Here you can change the `xampp/htdocs/index.php` to redirect to the `CUSTMBRS` f
2020
}
2121
$uri .= $_SERVER['HTTP_HOST'];
2222
header('Location: '.$uri.'/CUSTMBRS/');
23-
exit;
23+
exit();
2424
?>
2525
```
2626

Diff for: customer.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,17 @@
125125
</div>
126126
<div class="modal-body">
127127
<form class="needs-validation" action="functions/customer-create.php" method="post" novalidate>
128-
<div class="mb-1"><label class="form-label">Fullname</label><input class="form-control" type="text" name="fullname" required="">
128+
<div class="mb-1"><label class="form-label">Fullname</label><input class="form-control" type="text" name="fullname" pattern="^(?![\s.]).*$" required="">
129129
<div class="invalid-feedback">
130130
Please enter your fullname.
131131
</div>
132132
</div>
133-
<div class="mb-1"><label class="form-label">Address</label><input class="form-control" type="text" name="address" required="">
133+
<div class="mb-1"><label class="form-label">Address</label><input class="form-control" type="text" name="address" pattern="^(?![\s.]).*$" required="">
134134
<div class="invalid-feedback">
135135
Please enter your address.
136136
</div>
137137
</div>
138-
<div class="mb-1"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" required="">
138+
<div class="mb-1"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" pattern="[0-9]+" minlength="11" maxlength="11" required="">
139139
<div class="invalid-feedback">
140140
Please enter your phone number.
141141
</div>
@@ -155,17 +155,17 @@
155155
<div class="modal-body">
156156
<form class="needs-validation" action="functions/customer-update.php" method="post" novalidate>
157157
<input type="hidden" name="id" id="id">
158-
<div class="mb-1"><label class="form-label">Fullname</label><input class="form-control" type="text" name="fullname" required="">
158+
<div class="mb-1"><label class="form-label">Fullname</label><input class="form-control" type="text" name="fullname" pattern="^(?![\s.]).*$" required="">
159159
<div class="invalid-feedback">
160160
Please enter your fullname.
161161
</div>
162162
</div>
163-
<div class="mb-1"><label class="form-label">Address</label><input class="form-control" type="text" name="address" required="">
163+
<div class="mb-1"><label class="form-label">Address</label><input class="form-control" type="text" name="address" pattern="^(?![\s.]).*$" required="">
164164
<div class="invalid-feedback">
165165
Please enter your address.
166166
</div>
167167
</div>
168-
<div class="mb-1"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" required="">
168+
<div class="mb-1"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" pattern="[0-9]+" minlength="11" maxlength="11" required="">
169169
<div class="invalid-feedback">
170170
Please enter your phone number.
171171
</div>

Diff for: functions/cottage-create.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
if ($stmt->rowCount() > 0) {
1616
header('Location: ../cottage.php?type=error&message=' . $name . ' is already exist');
17-
exit;
17+
exit();
1818
}
1919

2020
if ($picture['error'] === UPLOAD_ERR_OK) {
@@ -35,13 +35,13 @@
3535

3636
generate_logs('Adding cottage', $name . '| New cottage was added');
3737
header('Location: ../cottage.php?type=success&message=New cottage was added successfully');
38-
exit;
38+
exit();
3939
} else {
4040
header('Location: ../cottage.php?type=error&message=Error uploading the image');
41-
exit;
41+
exit();
4242
}
4343
} else {
4444
header('Location: ../cottage.php?type=error&message=Image upload failed');
45-
exit;
45+
exit();
4646
}
4747
?>

Diff for: functions/cottage-update.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
if ($stmt->rowCount() > 0) {
1717
header('Location: ../cottage.php?type=error&message=' . $name . ' is already exist');
18-
exit;
18+
exit();
1919
}
2020

2121
$upload_path = '';
@@ -27,7 +27,7 @@
2727

2828
if (!move_uploaded_file($picture['tmp_name'], $upload_path)) {
2929
header('Location: ../cottage.php?type=error&message=Error uploading the image');
30-
exit;
30+
exit();
3131
}
3232
}
3333

@@ -44,8 +44,8 @@
4444
if ($stmt->rowCount() > 0) {
4545
generate_logs('Adding cottage', $name . '| New cottage was added');
4646
header('Location: ../cottage.php?type=success&message=New cottage was added successfully');
47-
exit;
47+
exit();
4848
} else {
4949
header('Location: ../cottage.php?type=error&message=Failed to update the cottage');
50-
exit;
50+
exit();
5151
}

Diff for: functions/customer-create.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
$stmt->execute();
1212

1313
if ($stmt->rowCount() > 0) {
14-
header('Location: ../customer.php?type=error&message='.$fullname.' is already exist');
15-
exit;
14+
header('Location: ../customer.php?type=error&message='.$fullname.' or '.$phone.' is already exist');
15+
exit();
1616
}
1717

1818
$sql = "INSERT INTO customers (fullname, address, phone) VALUES (:fullname, :address, :phone)";

Diff for: functions/data/get-calendar.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
foreach ($results as $row) {
1616
$event = array(
17-
'title' => $row['cottage_name'].' | '.$row['fullname'],
17+
'title' => '#'.$row['cottage_name'].' | '.$row['fullname']. ' 📆Start - '.$row['start_datetime']. ' 📆End - '.$row['end_datetime'],
1818
'start' => $row['start_datetime'],
1919
'end' => $row['end_datetime']
2020
);

Diff for: functions/login.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@
1515
$_SESSION['username'] = $username;
1616
$_SESSION['type'] = $user['type'];
1717
$_SESSION['id'] = $user['id'];
18-
18+
if (isset($_POST['remember'])) {
19+
setcookie('username', $username, time() + (86400 * 30), "/");
20+
setcookie('password', $password, time() + (86400 * 30), "/");
21+
} else {
22+
setcookie('username', '', time() - 3600, "/");
23+
setcookie('password', '', time() - 3600, "/");
24+
}
1925
generate_logs('Login', $username.'| Logged in');
2026
header('location: ../index.php');
2127
} else {

Diff for: functions/mark-partiallypaid.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
include_once 'connection.php';
3+
4+
$id = $_POST['id'];
5+
$transaction = $_POST['transaction'];
6+
$amount = $_POST['amount'];
7+
$price = $_POST['price'];
8+
9+
$sql = "SELECT * FROM `rentals` WHERE id = :id";
10+
$statement = $db->prepare($sql);
11+
$statement->bindParam(':id', $id);
12+
$statement->execute();
13+
$rental = $statement->fetch();
14+
15+
$amount = $rental['amount'] + $amount;
16+
17+
$sql = "UPDATE `rentals` SET `amount` = :amount WHERE id = :id";
18+
$statement = $db->prepare($sql);
19+
$statement->bindParam(':id', $id);
20+
$statement->bindParam(':amount', $amount);
21+
$statement->execute();
22+
23+
$sql = "UPDATE `transactions` SET `payment_status` = 'PARTIALLY PAID' WHERE id = :id";
24+
$statement = $db->prepare($sql);
25+
$statement->bindParam(':id', $transaction);
26+
$statement->execute();
27+
28+
generate_logs('Mark Paid', 'Transaction ID:'.$id.'| Transaction has been marked as Partially Paid');
29+
header('Location: ../rentals.php?type=success&message=Transaction has been marked as Partially paid.');

Diff for: functions/setup.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,9 @@
6161
cottage_id INT,
6262
transact_id INT,
6363
type VARCHAR(255),
64-
start_datetime DATETIME,
65-
end_datetime DATETIME,
64+
start_datetime DATE,
65+
end_datetime DATE,
66+
amount DOUBLE,
6667
created_at DATE DEFAULT CURRENT_TIMESTAMP,
6768
FOREIGN KEY (cottage_id) REFERENCES cottages(id) ON DELETE CASCADE,
6869
FOREIGN KEY (transact_id) REFERENCES transactions(id) ON DELETE CASCADE

Diff for: functions/staff-create.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
$address = $_POST['address'];
77
$phone = $_POST['phone'];
88

9-
$sql = "SELECT * FROM users WHERE username = :username";
9+
$sql = "SELECT * FROM users WHERE username = :username OR phone = :phone";
1010
$stmt = $db->prepare($sql);
1111
$stmt->bindParam(':username', $username);
12+
$stmt->bindParam(':phone', $phone);
1213
$stmt->execute();
1314

1415
if ($stmt->rowCount() > 0) {
15-
header('Location: ../users.php?type=error&message='.$username.' is already exist');
16-
exit;
16+
header('Location: ../users.php?type=error&message='.$username.' or '.$phone.' is already exist');
17+
exit();
1718
}
1819

1920
$sql = "INSERT INTO users (`username`, `password`, `address`, `phone`, `type`) VALUES (:username, :password, :address, :phone, 'staff')";

Diff for: functions/tables/datatables.php

+44-20
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function user_logs(){
1313
foreach ($results as $row) {
1414
?>
1515
<tr>
16-
<td><?php echo $row['id']; ?></td>
16+
<td>#<?php echo $row['id']; ?></td>
1717
<td><?php echo $row['type'] ?></td>
1818
<td><?php echo $row['logs'] ?></td>
1919
<td><?php echo $row['created_at'] ?></td>
@@ -37,7 +37,7 @@ function customer_list(){
3737
<td><?php echo $row['address'] ?></td>
3838
<td><?php echo $row['created_at'] ?></td>
3939
<td class="text-center">
40-
<a data-bss-tooltip="" class="mx-1" href="profile.php?id=<?php echo $row['id']?>" title="Here you can see the customer transactions."><i class="far fa-eye text-primary" style="font-size: 20px;"></i></a>
40+
4141
<a data-bs-toggle="modal" data-bss-tooltip="" class="mx-1" href="#" data-bs-target="#update" data-id="<?php echo $row['id']?>" data-fullname="<?php echo $row['fullname']?>" data-address="<?php echo $row['address']?>" data-phone="<?php echo $row['phone']?>" title="Here you can update the customer Information."><i class="far fa-edit text-warning" style="font-size: 20px;"></i></a>
4242
<a data-bs-toggle="modal" data-bss-tooltip="" class="mx-1" href="#" data-bs-target="#remove" data-id="<?php echo $row['id']?>" title="Here you can remove the customer."><i class="far fa-trash-alt text-danger" style="font-size: 20px;"></i></a>
4343
</td>
@@ -124,23 +124,25 @@ function cottage_available_list($start, $end, $type){
124124
if (!$rental) {
125125
?>
126126
<div class="col-xl-4">
127-
<div class="card"><img class="card-img-top w-100 d-block fit-cover" style="height: 200px;" src="functions/<?php echo $cottage['picture']; ?>">
127+
<div class="card">
128+
<img class="card-img-top w-100 d-block fit-cover" style="height: 200px;" src="functions/<?php echo $cottage['picture']; ?>">
128129
<div class="card-body p-4">
129130
<p class="text-primary card-text mb-0">Cottage ID: <?php echo $cottage['id']; ?></p>
130131
<h4 class="card-title mb-4"><?php echo $cottage['type']; ?></h4>
131132
<p>Price Day: ₱<?php echo number_format($cottage['priceDay'], 2); ?></p>
132133
<p>Price Night: ₱<?php echo number_format($cottage['priceNight'], 2); ?></p>
133134
<div class="container mb-4">
134135
<div class="row">
135-
<div class="col">
136-
<form action="" method="post">
137-
<button class="btn btn-primary mx-1" href="#add" type="button" data-bs-target="#add" data-bs-toggle="modal"
138-
data-id="<?php echo $cottage['id']; ?>"
139-
data-type="<?php echo $cottage['type']; ?>"
140-
data-start="<?php echo $_GET['start']; ?>"
141-
data-end="<?php echo $_GET['end']; ?>"
142-
>Add Cottage</button>
143-
</form>
136+
<div class="col">
137+
<form action="" method="post">
138+
<button class="btn btn-primary mx-1" href="#add" type="button" data-bs-target="#add" data-bs-toggle="modal"
139+
data-id="<?php echo $cottage['id']; ?>"
140+
data-type="<?php echo $cottage['type']; ?>"
141+
data-start="<?php echo $_GET['start']; ?>"
142+
data-end="<?php echo $_GET['end']; ?>"
143+
>Add Cottage</button>
144+
</form>
145+
</div>
144146
</div>
145147
</div>
146148
</div>
@@ -179,11 +181,10 @@ function transaction_list(){
179181
foreach ($results as $row) {
180182
?>
181183
<tr>
182-
<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/icon.png">&nbsp;<?php echo $row['cottage_name']; ?></td>
184+
<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/icon.png">#<?php echo $row['cottage_name']; ?></td>
183185
<td><?php echo $row['start_datetime']; ?></td>
184186
<td><?php echo $row['end_datetime']; ?></td>
185187
<td><?php echo $row['type']; ?></td>
186-
<td><?php echo $row['created_at']; ?></td>
187188
<td class="text-center">
188189
<a class="mx-1" href="#" data-bs-target="#update" data-id="<?php echo $row['id']?>" data-type="<?php echo $row['type']?>" data-start="<?php echo $row['start_datetime']?>" data-end="<?php echo $row['end_datetime']?>" data-bs-toggle="modal"><i class="fas fa-user-edit fs-4 text-warning"></i></a>
189190
<a class="mx-1" href="#" data-bs-target="#remove" data-id="<?php echo $row['id']?>" data-bs-toggle="modal"><i class="fas fa-trash-alt fs-4 text-danger"></i></a>
@@ -262,7 +263,7 @@ function activity_logs(){
262263
foreach ($results as $row) {
263264
?>
264265
<tr>
265-
<td><?php echo $row['id']; ?></td>
266+
<td>#<?php echo $row['id']; ?></td>
266267
<td><?php echo $row['type'] ?></td>
267268
<td><?php echo $row['logs'] ?></td>
268269
<td><?php echo $row['created_at'] ?></td>
@@ -277,6 +278,8 @@ function sales_report(){
277278
r.type AS rental_type,
278279
c.name AS cottage_name,
279280
r.created_at AS created_at,
281+
r.start_datetime AS startdate,
282+
r.end_datetime AS enddate,
280283
t.payment_status AS payment_status,
281284
CASE
282285
WHEN r.type = 'day' THEN c.priceDay
@@ -285,17 +288,20 @@ function sales_report(){
285288
END AS cottage_price
286289
FROM rentals r
287290
JOIN cottages c ON r.cottage_id = c.id
288-
JOIN `transactions` t ON r.transact_id = t.id;";
291+
JOIN `transactions` t ON r.transact_id = t.id
292+
WHERE status = 'Proceed';";
289293
$stmt = $db->prepare($sql);
290294
$stmt->execute();
291295
$results = $stmt->fetchAll();
292296

293297
foreach ($results as $row) {
294298
?>
295299
<tr>
296-
<td class="sorting_1"><img class="rounded-circle me-2" width="30" height="30" src="assets/img/icon.png"><?php echo $row['cottage_name']?></td>
300+
<td class="sorting_1"><img class="rounded-circle me-2" width="30" height="30" src="assets/img/icon.png">#<?php echo $row['cottage_name']?></td>
297301
<td><?php echo $row['cottage_price']?></td>
298302
<td><?php echo $row['rental_type']?></td>
303+
<td><?php echo $row['startdate']?></td>
304+
<td><?php echo $row['enddate']?></td>
299305
<td><?php echo $row['payment_status']?></td>
300306
<td><?php echo $row['created_at']?></td>
301307
</tr>
@@ -309,9 +315,13 @@ function rentals_list(){
309315
$sql = "SELECT r.id AS rental_id,
310316
r.type AS rental_type,
311317
c.name AS cottage_name,
318+
r.start_datetime AS startdate,
319+
r.end_datetime AS enddate,
312320
r.created_at AS created_at,
321+
r.amount AS amount,
313322
t.payment_status AS payment_status,
314323
t.id AS transaction_id,
324+
u.fullname AS customer_name,
315325
CASE
316326
WHEN r.type = 'day' THEN c.priceDay
317327
WHEN r.type = 'night' THEN c.priceNight
@@ -320,21 +330,35 @@ function rentals_list(){
320330
FROM rentals r
321331
JOIN cottages c ON r.cottage_id = c.id
322332
JOIN `transactions` t ON r.transact_id = t.id
323-
WHERE t.payment_status = 'UNPAID';";
333+
JOIN `customers` u ON t.customer_id = u.id
334+
WHERE t.payment_status = 'UNPAID' OR t.payment_status = 'PARTIALLY PAID';";
324335
$stmt = $db->prepare($sql);
325336
$stmt->execute();
326337
$results = $stmt->fetchAll();
327338

328339
foreach ($results as $row) {
340+
$balance = $row['amount'] - $row['cottage_price'];
329341
?>
330342
<tr>
331-
<td class="sorting_1"><img class="rounded-circle me-2" width="30" height="30" src="assets/img/icon.png"><?php echo $row['cottage_name']?></td>
343+
<td class="sorting_1"><img class="rounded-circle me-2" width="30" height="30" src="assets/img/icon.png">#<?php echo $row['cottage_name']?></td>
344+
<td>#<?php echo $row['transaction_id']?></td>
345+
<td><?php echo $row['customer_name']?></td>
332346
<td><?php echo $row['cottage_price']?></td>
347+
<td><?php echo $balance?></td>
333348
<td><?php echo $row['rental_type']?></td>
349+
<td><?php echo $row['startdate']?></td>
350+
<td><?php echo $row['enddate']?></td>
334351
<td><?php echo $row['payment_status']?></td>
335352
<td><?php echo $row['created_at']?></td>
336353
<td class="text-center">
337-
<button class="btn btn-info mx-1" href="#" data-bs-target="#paid" data-id="<?php echo $row['transaction_id']?>" data-bs-toggle="modal">Mark Paid</button>
354+
<button class="btn btn-success mx-1" href="#" data-bs-target="#paid" data-id="<?php echo $row['transaction_id']?>" data-bs-toggle="modal">Mark Paid</button>
355+
<?php
356+
if ($balance < 0){
357+
?>
358+
<button class="btn btn-warning mx-1" href="#" data-bs-target="#partiallypaid" data-id="<?php echo $row['rental_id']?>" data-transaction="<?php echo $row['transaction_id']?>" data-price="<?php echo $row['cottage_price']?>" data-bs-toggle="modal">Mark Partially Paid</button>
359+
<?php
360+
}
361+
?>
338362
<button class="btn btn-danger mx-1" href="#" data-bs-target="#cancel" data-id="<?php echo $row['transaction_id']?>" data-bs-toggle="modal">Cancel</button>
339363
</td>
340364
</tr>

Diff for: functions/tables/todolist.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<a data-bss-tooltip="" class="mx-1" href="profile.php?id=<?php echo $row['id']?>" title="Here you can see the customer transactions."><i class="far fa-eye text-primary" style="font-size: 20px;"></i></a>

0 commit comments

Comments
 (0)