Skip to content
Open

a #29

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions admin/medicine/addMed.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<th scope="col"> ID</th>
<th scope="col">Medicine Name</th>
<th scope = "col">In Stock </th>
<th scope = "col">Recommended Dosage</th>
</tr>
</thead>
<tbody>';
Expand All @@ -64,6 +65,7 @@
<tr>
<td><?php echo $medicine["ID"] ?></td>
<td><?php echo $medicine["medName"] ?></td>
<td><?php echo $medicine["recommendedDosage"] ?></td>
<td><?php echo $medicine["inStock"] ?></td>
</tr>
<?php
Expand All @@ -90,23 +92,26 @@
<input type="text" class="form-control" name="medLot" placeholder="" required>
</div>
<div class="form-group">
<label>Medicine price</label>
<label>Price</label>
<input type="text" class="form-control" name="medPrice" placeholder="Price" required>
</div>
<div class="form-group">
<label> Medicine type</label>
<label> Type</label>
<select name="medType" id="" class="form-select" aria-label=".form-select-sm example">
<option selected>Select Medicine Type</option>
<option value="Liquid">Liquid</option>
<option value="Tablet">Tablet</option>
<option value="Capsule">Capsule</option>
<option value="Others">Others</option>
</select>
</div>
<div class="form-group">
<label> Medicine quantity</label>
<label> Quantity</label>
<input type="text" class="form-control" name="medQuantity" placeholder="Amount to add (at least 1)" required>
</div>
<div class="form-group">
<label> Recommended Dosage</label>
<input type="text" class="form-control" name="medDosage" placeholder="Amount to add (at least 1)" required>
</div>
<div class="form-group">
<label>Manufacture date</label>
<input type="date" class="form-control" name="medManuDate" style="color:gray;" value="" min="1997-01-01" max="<?php $date = date('Y-m-d');
Expand Down
6 changes: 3 additions & 3 deletions admin/medicine/medSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
$medName = trim($_POST['medName']) . "%";
$currentDate = date('Y-m-d');
// Prepare the statement
$sql = "SELECT med.ID, med.medName, SUM(ship.quantity) as inStock
$sql = "SELECT med.ID, med.medName,med.recommendedDosage, SUM(ship.quantity) as inStock
FROM medicines AS med
JOIN medshipment AS ship ON med.ID = ship.medID
WHERE medName LIKE ? AND expirationDate >= ?
GROUP BY med.ID, med.medName";
WHERE medName LIKE ? AND ship.expirationDate >= ?
GROUP BY med.ID, med.medName, med.recommendedDosage";

$stmt = $conn->prepare($sql);

Expand Down
7 changes: 3 additions & 4 deletions admin/medicine/outStockSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
$conn = $db->getConnection();

// Prepare the statement
$sql = "SELECT med.ID, med.medName, SUM(ship.quantity) as inStock
$sql = "SELECT med.ID, med.medName, recommendedDosage, SUM(ship.quantity) as inStock
FROM medicines AS med
JOIN medshipment AS ship ON med.ID = ship.medID
GROUP BY med.ID, med.medName
HAVING SUM(ship.quantity) = 0";
GROUP BY med.ID, med.medName, recommendedDosage
HAVING SUM(ship.quantity) < recommendedDosage";

$stmt = $conn->prepare($sql);

Expand All @@ -22,4 +22,3 @@
$results = $result->fetch_all(MYSQLI_ASSOC);
// Free result and close statement
$stmt->close();
?>
8 changes: 5 additions & 3 deletions admin/medicine/processAddMed.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
$expireDate = date_create_from_format("Y-m-d",$_POST['medExpireDate']);
$manuDate = date_create_from_format("Y-m-d",$_POST['medManuDate']);

$conn = $db->getConnection();

$medicineItem = array(
'medName'=>$name,
'price' => $price,
'medType' => $type
);
$result = $db->select('medicines','ID',$medicineItem);
if(!$result){
$medicineItem['recommendedDosage'] = $_POST['medDosage'];

$db->insert('medicines',$medicineItem);

$result = $db->select('medicines','ID',$medicineItem);
}

Expand All @@ -33,8 +34,9 @@
'manufactureDate' => date_format($manuDate,'Y-m-d'),
'medID' => $result['ID']
);

$result = $db->select('medshipment','*',array('Lot' => $lot));
echo var_dump($result)."<br>";

if($result){
$db->updateAmount('medshipment',array('quantity' => $quantity),array('Lot' => $lot));
}else{
Expand Down
6 changes: 3 additions & 3 deletions admin/medicine/requestMed.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,16 @@
<input type="text" class="form-control" name="medQuantity" placeholder="Amount to add (at least 1)" required>
</div>
<div class="form-group">
<label style=""> Medicine usage</label>
<label > Medicine usage</label>
<input type="text" class="form-control" name="medUsage" placeholder="Usage" required>
</div>
<div class="form-group">
<label style="">Manufacture date</label>
<label>Manufacture date</label>
<input type="date" class="form-control" name="medManuDate" style="color:gray;" value="" min="1997-01-01" max="<?php $date = date('Y-m-d');
echo $date; ?>" required>
</div>
<div class="form-group">
<label style="">Expiration date</label>
<label>Expiration date</label>
<input type="date" class="form-control" name="medExpireDate" style="color:gray;" value="" min="<?php $date = date('Y-m-d');
echo $date; ?>" max="2030-12-31" required>
</div>
Expand Down
35 changes: 35 additions & 0 deletions classes/Dbh.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,41 @@ public function getConnection()
{
return $this->conn;
}
public function query($sql, $bind) {
$stmt = $this->conn->prepare($sql);

// Execute the statement
if (!$stmt) {
echo "EMPTY QUERY<br>";
return null;
}

if ($bind) {
// Bind parameters to the statement
foreach ($bind as $type => $values) {
foreach ($values as $value) {
$stmt->bind_param($type, $value);
}
}
}

$stmt->execute();

// Get the results
$result = $stmt->get_result();

// Fetch all rows
if ($result) {
$results = $result->fetch_all(MYSQLI_ASSOC);
}

// Free result and close statement
$stmt->close();

return $results;
}


// dbName => component
public function select($table, $items = '*', $where = null, $allFlag = false)
{
Expand Down
4 changes: 4 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">

Expand Down Expand Up @@ -44,6 +47,7 @@
</nav>

<!-- dummycode -->
<?php echo var_dump($_SESSION)."<br>";?>
<a href="codeTester.php">code test</a>
<a href="admin/dashboard.php">dashboard Admin</a>
<a href="staff/staffHome.php">staff home</a>
Expand Down
4 changes: 4 additions & 0 deletions staff/logout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
session_start();
session_destroy();
header('location:../index.php');
3 changes: 2 additions & 1 deletion staff/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@
<a class="nav-link" href="staffHome.php"> <i class="fa fa-th-large"></i> &nbsp Home Page</a>
</li>
<li class="nav-item">
<a class="nav-link" href="../index.php"><i class="fa fa-share"></i> &nbsp Log out</a>
<a class="nav-link" href="logout.php"><i class="fa fa-share"></i> &nbsp Log out</a>
</li>
</ul>

</div>
</div>
</nav>