Skip to content

Commit 95f62ca

Browse files
Version 1.6 Bootstrap form Validation added
1 parent 905c182 commit 95f62ca

23 files changed

+548
-71
lines changed

assets/js/main.js

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
(function () {
2+
'use strict'
3+
4+
// Fetch all the forms we want to apply custom Bootstrap validation styles to
5+
var forms = document.querySelectorAll('.needs-validation')
6+
7+
// Loop over them and prevent submission
8+
Array.prototype.slice.call(forms)
9+
.forEach(function (form) {
10+
form.addEventListener('submit', function (event) {
11+
if (!form.checkValidity()) {
12+
event.preventDefault()
13+
event.stopPropagation()
14+
}
15+
16+
form.classList.add('was-validated')
17+
}, false)
18+
})
19+
})();
20+
121
$(document).ready(function() {
222
const currentPath = window.location.pathname;
323
const urlParams = new URLSearchParams(window.location.search);
@@ -10,21 +30,21 @@ new DataTable('table.table-display',{
1030

1131
{
1232
extend: 'excel',
13-
title: 'UMLTFIPGB - Utilizing Machine Learning Technique to Forecast the Influence of Population Growth on the Budget of Barangay Begong',
33+
title: 'CUSTMBRS - Cottage Usage Scheduling with Transaction Monitoring for a Beach Resort System',
1434
className: 'btn btn-primary',
1535
text: '<i class="fa fa-file-excel"></i> EXCEL'
1636
},
1737
{
1838
extend: 'pdf',
19-
title: 'UMLTFIPGB - Utilizing Machine Learning Technique to Forecast the Influence of Population Growth on the Budget of Barangay Begong',
39+
title: 'CUSTMBRS - Cottage Usage Scheduling with Transaction Monitoring for a Beach Resort System',
2040
className: 'btn btn-primary',
2141
text: '<i class="fa fa-file-pdf"></i> PDF'
2242
},
2343
{
2444
extend: 'print',
2545
className: 'btn btn-primary',
2646
text: '<i class="fa fa-print"></i> Print',
27-
title: 'UMLTFIPGB - Utilizing Machine Learning Technique to Forecast the Influence of Population Growth on the Budget of Barangay Begong',
47+
title: 'CUSTMBRS - Cottage Usage Scheduling with Transaction Monitoring for a Beach Resort System',
2848
autoPrint: true,
2949
exportOptions: {
3050
columns: ':visible',
@@ -39,20 +59,6 @@ new DataTable('table.table-display',{
3959
}
4060
]
4161
});
42-
43-
// VANTA.WAVES({
44-
// el: "#bg-animation",
45-
// mouseControls: false,
46-
// touchControls: true,
47-
// gyroControls: false,
48-
// minHeight: 200.00,
49-
// minWidth: 200.00,
50-
// scale: 1.00,
51-
// scaleMobile: 1.00,
52-
// color: 0xb7b7c0,
53-
// waveSpeed: 1.00,
54-
// zoom: 0.60
55-
// })
5662

5763
if (type == 'success') {
5864
Swal.fire(

assets/js/tinymce.min.js

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

calendar.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
include_once 'functions/menu/offcanva-menu.php'
2+
include_once 'functions/menu/offcanva-menu.php';
3+
include_once 'functions/authentication.php';
34
?>
45
<!DOCTYPE html>
56
<html data-bs-theme="light" lang="en">

cottage.php

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
include_once 'functions/menu/offcanva-menu.php'
2+
include_once 'functions/menu/offcanva-menu.php';
3+
include_once 'functions/authentication.php';
34
?>
45
<!DOCTYPE html>
56
<html data-bs-theme="light" lang="en">
@@ -111,34 +112,50 @@
111112
<h4 class="modal-title">Add Cottage</h4><button class="btn-close" type="button" aria-label="Close" data-bs-dismiss="modal"></button>
112113
</div>
113114
<div class="modal-body">
114-
<form novalidate="" method="post">
115-
<div class="mb-1"><label class="form-label">Name</label><input class="form-control" type="text" name="name" required="" placeholder="Cottage Name"></div>
116-
<div class="mb-1"><label class="form-label">Price Day</label><input class="form-control" type="number" name="day" required="" value="0"></div>
117-
<div class="mb-1"><label class="form-label">Price Night</label><input class="form-control" type="number" name="night" required="" value="0"></div>
118-
<div class="mb-1"><label class="form-label">Picture</label><input class="form-control" type="file" name="picture" required="" accept="image/*"></div>
119-
</form>
115+
<form class="needs-validation" method="post" novalidate>
116+
<div class="mb-1"><label class="form-label">Name</label><input class="form-control" type="text" name="name" required="" placeholder="Cottage Name">
117+
<div class="invalid-feedback">
118+
Please enter your cottage name.
119+
</div>
120+
</div>
121+
<div class="mb-1"><label class="form-label">Picture</label><input class="form-control" type="file" name="picture" required="" accept="image/*">
122+
<div class="invalid-feedback">
123+
Please add cottage picture.
124+
</div>
125+
</div>
126+
120127
</div>
121-
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">Close</button><button class="btn btn-primary" type="button">Save</button></div>
128+
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">Close</button><button class="btn btn-primary" type="submit">Save</button></div>
129+
</form>
122130
</div>
123131
</div>
124132
</div>
125133
<div class="modal fade" role="dialog" tabindex="-1" id="update">
126134
<div class="modal-dialog" role="document">
127135
<div class="modal-content">
128136
<div class="modal-header">
129-
<h4 class="modal-title">Add Customer</h4><button class="btn-close" type="button" aria-label="Close" data-bs-dismiss="modal"></button>
137+
<h4 class="modal-title">Update Cottage</h4><button class="btn-close" type="button" aria-label="Close" data-bs-dismiss="modal"></button>
130138
</div>
131139
<div class="modal-body">
132-
<form novalidate="" method="post">
133-
<div class="mb-1"><label class="form-label">Fullname</label><input class="form-control" type="text" name="fullname" required=""></div>
134-
<div class="mb-1"><label class="form-label">Address</label><input class="form-control" type="text" name="address" required=""></div>
135-
<div class="mb-1"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" required=""></div>
136-
</form>
140+
<form class="needs-validation" method="post" novalidate>
141+
<div class="mb-1"><label class="form-label">Name</label><input class="form-control" type="text" name="name" required="" placeholder="Cottage Name">
142+
<div class="invalid-feedback">
143+
Please enter your cottage name.
144+
</div>
145+
</div>
146+
<div class="mb-1"><label class="form-label">Picture</label><input class="form-control" type="file" name="picture" required="" accept="image/*">
147+
<div class="invalid-feedback">
148+
Please add cottage picture.
149+
</div>
150+
</div>
151+
137152
</div>
138-
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">Close</button><button class="btn btn-primary" type="button">Save</button></div>
153+
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">Close</button><button class="btn btn-primary" type="submit">Save</button></div>
154+
</form>
139155
</div>
140156
</div>
141157
</div>
158+
142159
<div class="modal fade" role="dialog" tabindex="-1" id="remove">
143160
<div class="modal-dialog" role="document">
144161
<div class="modal-content">

customer.php

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
2-
include_once 'functions/menu/offcanva-menu.php'
2+
include_once 'functions/menu/offcanva-menu.php';
3+
include_once 'functions/authentication.php';
34
?>
45
<!DOCTYPE html>
56
<html data-bs-theme="light" lang="en">
@@ -130,30 +131,54 @@
130131
<h4 class="modal-title">Add Customer</h4><button class="btn-close" type="button" aria-label="Close" data-bs-dismiss="modal"></button>
131132
</div>
132133
<div class="modal-body">
133-
<form novalidate="" method="post">
134-
<div class="mb-1"><label class="form-label">Fullname</label><input class="form-control" type="text" name="fullname" required=""></div>
135-
<div class="mb-1"><label class="form-label">Address</label><input class="form-control" type="text" name="address" required=""></div>
136-
<div class="mb-1"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" required=""></div>
137-
</form>
134+
<form class="needs-validation" method="post" novalidate>
135+
<div class="mb-1"><label class="form-label">Fullname</label><input class="form-control" type="text" name="fullname" required="">
136+
<div class="invalid-feedback">
137+
Please enter your fullname.
138+
</div>
139+
</div>
140+
<div class="mb-1"><label class="form-label">Address</label><input class="form-control" type="text" name="address" required="">
141+
<div class="invalid-feedback">
142+
Please enter your address.
143+
</div>
144+
</div>
145+
<div class="mb-1"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" required="">
146+
<div class="invalid-feedback">
147+
Please enter your phone number.
148+
</div>
149+
</div>
138150
</div>
139-
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">Close</button><button class="btn btn-primary" type="button">Save</button></div>
151+
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">Close</button><button class="btn btn-primary" type="submit">Save</button></div>
152+
</form>
140153
</div>
141154
</div>
142155
</div>
143156
<div class="modal fade" role="dialog" tabindex="-1" id="update">
144157
<div class="modal-dialog" role="document">
145158
<div class="modal-content">
146159
<div class="modal-header">
147-
<h4 class="modal-title">Add Customer</h4><button class="btn-close" type="button" aria-label="Close" data-bs-dismiss="modal"></button>
160+
<h4 class="modal-title">Update Customer</h4><button class="btn-close" type="button" aria-label="Close" data-bs-dismiss="modal"></button>
148161
</div>
149162
<div class="modal-body">
150-
<form novalidate="" method="post">
151-
<div class="mb-1"><label class="form-label">Fullname</label><input class="form-control" type="text" name="fullname" required=""></div>
152-
<div class="mb-1"><label class="form-label">Address</label><input class="form-control" type="text" name="address" required=""></div>
153-
<div class="mb-1"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" required=""></div>
154-
</form>
163+
<form class="needs-validation" method="post" novalidate>
164+
<div class="mb-1"><label class="form-label">Fullname</label><input class="form-control" type="text" name="fullname" required="">
165+
<div class="invalid-feedback">
166+
Please enter your fullname.
167+
</div>
168+
</div>
169+
<div class="mb-1"><label class="form-label">Address</label><input class="form-control" type="text" name="address" required="">
170+
<div class="invalid-feedback">
171+
Please enter your address.
172+
</div>
173+
</div>
174+
<div class="mb-1"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" required="">
175+
<div class="invalid-feedback">
176+
Please enter your phone number.
177+
</div>
178+
</div>
155179
</div>
156-
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">Close</button><button class="btn btn-primary" type="button">Save</button></div>
180+
<div class="modal-footer"><button class="btn btn-light" type="button" data-bs-dismiss="modal">Close</button><button class="btn btn-primary" type="submit">Save</button></div>
181+
</form>
157182
</div>
158183
</div>
159184
</div>

functions/authentication.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
session_start();
3+
if (!isset($_SESSION['username'])) {
4+
header('Location: ./login.php');
5+
}
6+
?>

functions/connection.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
include_once 'setup.php';
3+
$db = new PDO('mysql:host=localhost;dbname=' . $database, 'root', '');
4+
5+
if (!$db) {
6+
die("Connection failed: " . $db->connect_error);
7+
}
8+
9+
function generate_logs($type, $logs)
10+
{
11+
session_start();
12+
global $db;
13+
$sql = "INSERT INTO logs (logs, type) VALUES (:logs, :type)";
14+
$stmt = $db->prepare($sql);
15+
$stmt->bindParam(':logs', $logs);
16+
$stmt->bindParam(':type', $type);
17+
$stmt->execute();
18+
}

functions/customer-create.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
include_once 'connection.php';
3+
4+
$fullname = $_POST['name'];
5+
$address = $_POST['address'];
6+
$phone = $_POST['phone'];
7+
$email = $_POST['email'];
8+
$birthdate = $_POST['date'];
9+
10+
$sql = "SELECT * FROM customers WHERE fullname = :fullname OR phone = :phone";
11+
$stmt = $db->prepare($sql);
12+
$stmt->bindParam(':fullname', $fullname);
13+
$stmt->bindParam(':phone', $phone);
14+
$stmt->execute();
15+
16+
if ($stmt->rowCount() > 0) {
17+
header('Location: ../customers.php?type=error&message='.$fullname.' is already exist or phone number is already exist');
18+
exit;
19+
}
20+
21+
$sql = "INSERT INTO customers (fullname, address, phone, email, birthdate) VALUES (:fullname, :address, :phone, :email, :birthdate)";
22+
$stmt = $db->prepare($sql);
23+
$stmt->bindParam(':fullname', $fullname);
24+
$stmt->bindParam(':address', $address);
25+
$stmt->bindParam(':phone', $phone);
26+
$stmt->bindParam(':email', $email);
27+
$stmt->bindParam(':birthdate', $birthdate);
28+
$stmt->execute();
29+
30+
generate_logs('Adding Customer', $fullname.'| New Customer was added');
31+
header('Location: ../customers.php?type=success&message=New customer was added successfully');
32+
?>

functions/customer-remove.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
include_once 'connection.php';
3+
4+
try {
5+
$id = $_POST['data_id'];
6+
$sql = "SELECT * FROM customers WHERE id = :id";
7+
$statement = $db->prepare($sql);
8+
$statement->bindParam(':id', $id);
9+
$statement->execute();
10+
$result = $statement->fetch(PDO::FETCH_ASSOC);
11+
12+
$sql = "DELETE FROM customers WHERE id = :id";
13+
$statement = $db->prepare($sql);
14+
$statement->bindParam(':id', $id);
15+
$statement->execute();
16+
generate_logs('Removing Customer', $result['fullname'].' was removed');
17+
header('Location: ../customers.php?type=success&message='.$result['fullname'].' was removed successfully!');
18+
} catch (\Throwable $th) {
19+
generate_logs('Removing Staff', $th);
20+
header('Location: ../customers.php?type=error&message=Something went wrong, please try again');
21+
}

functions/customer-update.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
include_once 'connection.php';
3+
4+
try {
5+
$id = $_POST['data_id'];
6+
$fullname = $_POST['name'];
7+
$address = $_POST['address'];
8+
$phone = $_POST['phone'];
9+
$email = $_POST['email'];
10+
$birthdate = $_POST['date'];
11+
12+
$sql = "UPDATE customers SET fullname = :fullname, address = :address, phone = :phone, email = :email, birthdate = :birthdate WHERE id = :id";
13+
$statement = $db->prepare($sql);
14+
$statement->bindParam(':id', $id);
15+
$statement->bindParam(':fullname', $fullname);
16+
$statement->bindParam(':address', $address);
17+
$statement->bindParam(':phone', $phone);
18+
$statement->bindParam(':email', $email);
19+
$statement->bindParam(':birthdate', $birthdate);
20+
$statement->execute();
21+
22+
generate_logs('Customer Update', $fullname.'| Info was updated');
23+
header('Location: ../customers.php?type=success&message=Customer Info was updated successfully!');
24+
exit();
25+
26+
} catch (\Throwable $th) {
27+
generate_logs('Customer Update', $fullname.'| Error: '.$th->getMessage());
28+
}
29+
30+
?>

0 commit comments

Comments
 (0)