- Joined
- Apr 26, 2017
- Posts
- 337
- Reaction
- 28
- Points
- 210
- Age
- 25
looking for equipment borrowing system via php source code with printing report sana salamat
<?php
// Database connection
$host = "localhost";
$username = "root";
$password = "";
$dbname = "equipment_db";
$conn = mysqli_connect($host, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Borrow equipment
if(isset($_POST['borrow'])){
$equipment_id = $_POST['equipment_id'];
$user_id = $_POST['user_id'];
$borrow_date = date('Y-m-d');
// Insert borrowed equipment into the database
$sql = "INSERT INTO borrowings (equipment_id, user_id, borrow_date) VALUES ('$equipment_id', '$user_id', '$borrow_date')";
if (mysqli_query($conn, $sql)) {
echo "Equipment borrowed successfully.";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
// Return equipment
if(isset($_POST['return'])){
$borrow_id = $_POST['borrow_id'];
$return_date = date('Y-m-d');
// Update return date in the database
$sql = "UPDATE borrowings SET return_date = '$return_date' WHERE borrow_id = '$borrow_id'";
if (mysqli_query($conn, $sql)) {
echo "Equipment returned successfully.";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
}
// Print report
if(isset($_POST['print_report'])){
$start_date = $_POST['start_date'];
$end_date = $_POST['end_date'];
// Query to fetch borrowings between the selected dates
$sql = "SELECT b.borrow_id, e.equipment_name, u.user_name, b.borrow_date, b.return_date
FROM borrowings b
INNER JOIN equipments e ON b.equipment_id = e.equipment_id
INNER JOIN users u ON b.user_id = u.user_id
WHERE b.borrow_date BETWEEN '$start_date' AND '$end_date'";
$result = mysqli_query($conn, $sql);
// Generate the report
$report = "";
if(mysqli_num_rows($result) > 0){
$report .= "<table>
<tr>
<th>Borrow ID</th>
<th>Equipment Name</th>
<th>User Name</th>
<th>Borrow Date</th>
<th>Return Date</th>
</tr>";
while($row = mysqli_fetch_assoc($result)){
$borrow_id = $row['borrow_id'];
$equipment_name = $row['equipment_name'];
$user_name = $row['user_name'];
$borrow_date = $row['borrow_date'];
$return_date = $row['return_date'];
$report .= "<tr>
<td>$borrow_id</td>
<td>$equipment_name</td>
<td>$user_name</td>
<td>$borrow_date</td>
<td>$return_date</td>
</tr>";
}
$report .= "</table>";
// Print the report
echo $report;
} else {
echo "No borrowings found between the selected dates.";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Equipment Borrowing System</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
</style>
</head>
<body>
<h1>Equipment Borrowing System</h1>
<h2>Borrow Equipment</h2>
<form method="POST" action="">
<label for="equipment_id">Equipment ID:</label>
<input type="text" name="equipment_id" required>
<br><br>
<label for="user_id">User ID:</label>
<input type="text" name="user_id" required>
<br><br>
<button type="submit" name="borrow">Borrow</button>
</form>
<h2>Return Equipment</h2>
<form method="POST" action="">
<label for="borrow_id">Borrow ID:</label>
<input type="text" name="borrow_id" required>
<br><br>
<button type="submit" name="return">Return</button>
</form>
<h2>Generate Report</h2>
<form method="POST" action="">
<label for="start_date">Start Date:</label>
<input type="date" name="start_date" required>
<br><br>
<label for="end_date">End Date:</label>
<input type="date" name="end_date" required>
<br><br>
<button type="submit" name="print_report">Print Report</button>
</form>
</body>
</html>
equipments
with columns equipment_id
(INT), equipment_name
(VARCHAR).users
with columns user_id
(INT), user_name
(VARCHAR).borrowings
with columns borrow_id
(INT), equipment_id
(INT), user_id
(INT), borrow_date
(DATE), return_date
(DATE).$host
, $username
, $password
, $dbname
) to match your own MySQL database settings.I can help you with that. Developing an equipment borrowing system with PHP source code and printing reports can be quite complex, but I'll try to provide you with an overview of the steps involved. Here's a high-level outline of what you would need to do:
1. Database: Design and create a database to store information about the equipment and borrowing records. Define tables for equipment details, user information, and borrowing history.
2. User Interface: Create the necessary web pages using PHP, HTML, and CSS to allow users to interact with the system. This may include pages for equipment checkout, return, searching, and generating reports.
3. Equipment Management: Implement functionality to manage equipment, such as adding new equipment, updating information, and tracking availability.
4. Borrowing System: Develop a system for users to borrow equipment. This involves validating user information, checking equipment availability, updating the database with borrowing records, and generating receipts.
5. Reporting: Implement a reporting system that allows you to generate and print reports based on specific criteria, such as borrowed equipment, overdue items, or borrowing history.
6. Printing: Use PHP libraries like TCPDF or FPDF to generate PDF reports that can be easily printed or saved.
Remember, this is just a general overview, and actual implementation details may vary depending on your specific requirements. Developing a complete equipment borrowing system can be time-consuming, so make sure to plan, test, and iterate along the way. Good luck with your project!
salamat meron po ako nyan Asset Management System
pa try posalamat meron po ako nyan Asset Management System
binebenta PM mepa try po