-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustomers.php
More file actions
91 lines (83 loc) · 4.43 KB
/
Copy pathcustomers.php
File metadata and controls
91 lines (83 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
require_once 'includes/config.php';
require_once 'includes/functions.php';
require_login();
$page_title = 'Customers';
require_once 'includes/header.php';
require_once 'includes/topbar.php';
require_once 'includes/sidebar.php';
// Get all customers
try {
$pdo = new PDO(
"mysql:host=" . DB_HOST . ";dbname=" . DB_NAME,
DB_USER,
DB_PASS
);
$stmt = $pdo->query("SELECT * FROM customers ORDER BY company_name");
$customers = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$error = "Could not retrieve customers";
}
?>
<div class="page-wrapper">
<div class="page-content">
<div class="container-fluid">
<div class="row">
<div class="col-sm-12">
<div class="page-title-box d-md-flex justify-content-md-between align-items-center">
<h4 class="page-title">Customers</h4>
<div class="">
<ol class="breadcrumb mb-0">
<li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a>
</li><!--end nav-item-->
<li class="breadcrumb-item active">Customers</li>
</ol>
</div>
</div><!--end page-title-box-->
<div class="d-flex float-end mb-4">
<a href="customer_add.php" class="btn btn-primary">Add Customer</a>
</div>
<div class="clearfix"></div>
<?php if (isset($error)): ?>
<div class="alert alert-danger"><?php echo $error; ?></div>
<?php else: ?>
<div class="card">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Company Name</th>
<th>Contact</th>
<th>Email</th>
<th>Phone</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($customers as $customer): ?>
<tr>
<td><?php echo htmlspecialchars($customer['company_name']); ?></td>
<td><?php echo htmlspecialchars($customer['contact_name']); ?></td>
<td><?php echo htmlspecialchars($customer['email']); ?></td>
<td><?php echo htmlspecialchars($customer['phone']); ?></td>
<td>
<a href="customer_view.php?id=<?php echo $customer['id']; ?>"
class="btn btn-sm btn-outline-primary">View</a>
<a href="customer_edit.php?id=<?php echo $customer['id']; ?>"
class="btn btn-sm btn-outline-secondary">Edit</a>
<a href="invoice_create.php?customer_id=<?php echo $customer['id']; ?>"
class="btn btn-sm btn-outline-success">New Invoice</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
<?php require_once 'includes/footer.php'; ?>