Skip to content

Commit 9b22aa9

Browse files
Update customer and transaction tables with event field
1 parent d03216b commit 9b22aa9

File tree

8 files changed

+28
-20
lines changed

8 files changed

+28
-20
lines changed

customers.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
<th>Customer</th>
5757
<th>Phone</th>
5858
<th>Address</th>
59-
<th>Email Address</th>
59+
<th>Facebook</th>
6060
<th>Birthdate</th>
6161
<th>Date</th>
6262
<th class="text-center">Option</th>
@@ -84,7 +84,7 @@
8484
<div style="margin-top: 5px;"><label class="form-label">Fullname (ex. Juan Luna) </label><input class="form-control" type="text" name="name" required="" pattern="^(?!\s).*$" value="<?=$_SESSION['c_fullname'] ?? '' ?>"></div>
8585
<div style="margin-top: 5px;"><label class="form-label">Address</label><input class="form-control" type="text" name="address" required="" pattern="^(?![\s.]).*$" value="<?=$_SESSION['c_address'] ?? '' ?>"></div>
8686
<div style="margin-top: 5px;"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" required="" pattern="[0-9]+" minlength="11" maxlength="11" value="<?=$_SESSION['c_phone'] ?? '' ?>"></div>
87-
<div style="margin-top: 5px;"><label class="form-label">Email</label><input class="form-control" type="email" name="email" required="" value="<?=$_SESSION['c_email'] ?? '' ?>"></div>
87+
<div style="margin-top: 5px;"><label class="form-label">Facebook</label><input class="form-control" type="text" name="facebook" required="" value="<?=$_SESSION['c_facebook'] ?? '' ?>"></div>
8888
<div style="margin-top: 5px;"><label class="form-label">Birthdate</label><input class="form-control" name="date" type="date" required="" value="<?=$_SESSION['c_birthdate'] ?? '' ?>"></div>
8989

9090
</div>
@@ -105,7 +105,7 @@
105105
<div style="margin-top: 5px;"><label class="form-label">Fullname (ex. Juan Luna)</label><input class="form-control" type="text" name="name" required="" pattern="^(?!\s).*$" value="<?=$_SESSION['c_fullname'] ?? '' ?>"></div>
106106
<div style="margin-top: 5px;"><label class="form-label">Address</label><input class="form-control" type="text" name="address" required="" pattern="^(?![\s.]).*$" value="<?=$_SESSION['c_address'] ?? '' ?>"></div>
107107
<div style="margin-top: 5px;"><label class="form-label">Phone</label><input class="form-control" type="text" name="phone" required="" pattern="[0-9]+" minlength="11" maxlength="11" value="<?=$_SESSION['c_phone'] ?? '' ?>"></div>
108-
<div style="margin-top: 5px;"><label class="form-label">Email</label><input class="form-control" type="email" name="email" required="" value="<?=$_SESSION['c_email'] ?? '' ?>"></div>
108+
<div style="margin-top: 5px;"><label class="form-label">Facebook</label><input class="form-control" type="text" name="facebook" required="" value="<?=$_SESSION['c_facebook'] ?? '' ?>"></div>
109109
<div style="margin-top: 5px;"><label class="form-label">Birthdate</label><input class="form-control" name="date" type="date" required="" value="<?=$_SESSION['c_birthdate'] ?? '' ?>"></div>
110110

111111
</div>

functions/customer-create.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,43 @@
77
$fullname = $_POST['name'];
88
$address = $_POST['address'];
99
$phone = $_POST['phone'];
10-
$email = $_POST['email'];
10+
$facebook = $_POST['facebook'];
1111
$birthdate = $_POST['date'];
1212

1313
if (date('Y') < date('Y', strtotime($birthdate))) {
1414
header('Location: ../customers.php?type=error&message=Invalid birthdate!');
1515
exit;
1616
}
1717

18-
$sql = "SELECT * FROM customers WHERE email = :email OR phone = :phone";
18+
$sql = "SELECT * FROM customers WHERE facebook = :facebook OR phone = :phone";
1919
$stmt = $db->prepare($sql);
20-
$stmt->bindParam(':email', $email);
20+
$stmt->bindParam(':facebook', $facebook);
2121
$stmt->bindParam(':phone', $phone);
2222
$stmt->execute();
2323

2424
if ($stmt->rowCount() > 0) {
2525
$_SESSION['c_fullname'] = $fullname;
2626
$_SESSION['c_address'] = $address;
2727
$_SESSION['c_phone'] = $phone;
28-
$_SESSION['c_email'] = $email;
28+
$_SESSION['c_facebook'] = $facebook;
2929
$_SESSION['c_birthdate'] = $birthdate;
30-
header('Location: ../customers.php?type=error&message=Email address or phone number is already exist');
30+
header('Location: ../customers.php?type=error&message=facebook address or phone number is already exist');
3131
exit;
3232
}
3333

34-
$sql = "INSERT INTO customers (fullname, address, phone, email, birthdate) VALUES (:fullname, :address, :phone, :email, :birthdate)";
34+
$sql = "INSERT INTO customers (fullname, address, phone, facebook, birthdate) VALUES (:fullname, :address, :phone, :facebook, :birthdate)";
3535
$stmt = $db->prepare($sql);
3636
$stmt->bindParam(':fullname', $fullname);
3737
$stmt->bindParam(':address', $address);
3838
$stmt->bindParam(':phone', $phone);
39-
$stmt->bindParam(':email', $email);
39+
$stmt->bindParam(':facebook', $facebook);
4040
$stmt->bindParam(':birthdate', $birthdate);
4141
$stmt->execute();
4242

4343
$_SESSION['c_fullname'] = '';
4444
$_SESSION['c_address'] = '';
4545
$_SESSION['c_phone'] = '';
46-
$_SESSION['c_email'] = '';
46+
$_SESSION['c_facebook'] = '';
4747
$_SESSION['c_birthdate'] = '';
4848

4949
generate_logs('Adding Customer', $fullname.'| New Customer was added');

functions/customer-update.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
$fullname = $_POST['name'];
77
$address = $_POST['address'];
88
$phone = $_POST['phone'];
9-
$email = $_POST['email'];
9+
$facebook = $_POST['facebook'];
1010
$birthdate = $_POST['date'];
1111

12-
$sql = "UPDATE customers SET fullname = :fullname, address = :address, phone = :phone, email = :email, birthdate = :birthdate WHERE id = :id";
12+
$sql = "UPDATE customers SET fullname = :fullname, address = :address, phone = :phone, facebook = :facebook, birthdate = :birthdate WHERE id = :id";
1313
$statement = $db->prepare($sql);
1414
$statement->bindParam(':id', $id);
1515
$statement->bindParam(':fullname', $fullname);
1616
$statement->bindParam(':address', $address);
1717
$statement->bindParam(':phone', $phone);
18-
$statement->bindParam(':email', $email);
18+
$statement->bindParam(':facebook', $facebook);
1919
$statement->bindParam(':birthdate', $birthdate);
2020
$statement->execute();
2121

functions/setup.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
fullname VARCHAR(255),
2828
address VARCHAR(255),
2929
phone VARCHAR(255),
30-
email VARCHAR(255),
30+
facebook VARCHAR(255),
3131
birthdate DATE,
3232
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
3333
)
@@ -50,6 +50,7 @@
5050
customer_id int,
5151
user_id int,
5252
status VARCHAR(255),
53+
event VARCHAR(255),
5354
created_at DATE DEFAULT CURRENT_TIMESTAMP,
5455
FOREIGN KEY (customer_id) REFERENCES customers(id) ON DELETE CASCADE,
5556
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE

functions/transaction-create.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
session_start();
44
try {
55
$customer_id = $_POST['id'];
6+
$event = $_POST['event'];
67
$user_id = $_SESSION['id'];
78

89
$sql = "SELECT * FROM transactions WHERE user_id = :user_id AND status = 'Pending'";
@@ -22,9 +23,10 @@
2223
$stmt->execute();
2324
$customer = $stmt->fetch(PDO::FETCH_ASSOC);
2425

25-
$sql = "INSERT INTO transactions (customer_id, user_id, status) VALUES (:customer_id, :user_id, 'Pending')";
26+
$sql = "INSERT INTO transactions (customer_id, user_id, event, status) VALUES (:customer_id, :user_id, :event, 'Pending')";
2627
$stmt = $db->prepare($sql);
2728
$stmt->bindParam(':customer_id', $customer_id);
29+
$stmt->bindParam(':event', $event);
2830
$stmt->bindParam(':user_id', $user_id);
2931
$stmt->execute();
3032

functions/view/datatable.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ function customer_list()
3737
<td><img class="rounded-circle me-2" width="30" height="30" src="assets/img/avatars/avatar1.png"><?php echo $row['fullname']; ?></td>
3838
<td><?php echo $row['phone'] ?></td>
3939
<td><?php echo $row['address'] ?></td>
40-
<td><?php echo $row['email'] ?></td>
40+
<td><?php echo $row['facebook'] ?></td>
4141
<td><?php echo $row['birthdate'] ?></td>
4242
<td><?php echo $row['created_at'] ?></td>
4343
<td class="text-center">
4444
<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>
45-
<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'] ?>" data-email="<?php echo $row['email'] ?>" data-birthdate="<?php echo $row['birthdate'] ?>" title="Here you can update the customer Information."><i class="far fa-edit text-warning" style="font-size: 20px;"></i></a>
45+
<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'] ?>" data-facebook="<?php echo $row['facebook'] ?>" data-birthdate="<?php echo $row['birthdate'] ?>" title="Here you can update the customer Information."><i class="far fa-edit text-warning" style="font-size: 20px;"></i></a>
4646
<!-- <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> -->
4747
</td>
4848
</tr>
@@ -173,7 +173,7 @@ function transaction_item_list($id)
173173
function get_rent_list()
174174
{
175175
global $db;
176-
$sql = "SELECT r.id, i.name, r.qty, r.price, r.returned, r.penalty, r.item_return, r.created_at, t.status, c.fullname, c.phone, c.address, c.id as customer_id, t.id as transact_id
176+
$sql = "SELECT r.id, i.name, r.qty, r.price, r.returned, r.penalty, r.item_return, r.created_at, t.status, c.fullname, c.phone, c.address, c.id as customer_id, t.id as transact_id, t.event
177177
FROM rentals r
178178
JOIN transactions t ON r.transact_id = t.id
179179
JOIN customers c ON t.customer_id = c.id
@@ -211,6 +211,7 @@ function get_rent_list()
211211
<td><?php echo $row['created_at'] ?></td>
212212
<td><?php echo $row['returned'] ?></td>
213213
<td>₱<?php echo $row['price'] ?></td>
214+
<td><?php echo $row['event'] ?></td>
214215
<td><?php echo $status ?> | <?php echo $daysOverdue ?> Days</td>
215216
<td class="text-center">
216217
<a data-bss-tooltip="" class="mx-1" href="profile.php?id=<?php echo $row['customer_id'] ?>" title="Here you can see the customer transactions."><i class="far fa-eye text-primary" style="font-size: 20px;"></i></a>

functions/view/get-data.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
include_once 'functions/connection.php';
33
function get_customer_data() {
44
global $db;
5-
$sql = 'SELECT t.id, c.fullname, c.phone, c.email, c.address
5+
$sql = 'SELECT t.id, c.fullname, c.phone, c.facebook, c.address
66
FROM customers c
77
JOIN transactions t ON c.id = t.customer_id
88
WHERE t.user_id = :user_id AND t.status = "pending"

rents.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
<th>Borrowed Date</th>
9090
<th>Returned Date</th>
9191
<th>Rent Price</th>
92+
<th>Event</th>
9293
<th>Status</th>
9394
<th class="text-center">Option</th>
9495
</tr>
@@ -117,6 +118,9 @@
117118
</optgroup>
118119
</select>
119120
</div>
121+
<div style="margin-top: 5px;"><label class="form-label">Event</label>
122+
<input class="form-control" type="text" name="event">
123+
</div>
120124
</div>
121125
<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>
122126
</form>

0 commit comments

Comments
 (0)