function testgetPay($expectedresult, $rate, $hours) { echo "<h1>Running Get Pay with Parameters:</h1>"; echo "rate = " . $rate . "<br />"; echo "hours = " . $hours . "<br />"; $result = getPay($rate, $hours); echo "Expected Value is " . $expectedresult . ". Return value is " . $result . "<br />"; if ($result == $expectedresult) { echo '<p style="color:#008000"><b>Passed.</b></p>'; } else { echo '<p style="color:#800000"><b>Failed.</b></p>'; } }
$booking = getBookings($babysitterid); if ($booking === 0) { echo "<p>There are no bookings for this babysitter</p>"; exit; } //Create select query $bookings_query = "SELECT b.starttime, b.endtime, b.confirmed, b.id, p.firstName, p.lastName, s.rate FROM bookings b INNER JOIN babysitters s ON b.idBabysitter = s.id INNER JOIN parents p ON b.idParent = p.id WHERE s.id = '{$babysitterid}'"; echo '<br />' . '<table>' . '<tr>' . '<th>Parent</th>' . '<th>Date/Time</th>' . '<th>Hours</th>' . '<th>Pay</th>' . '<th>Status</th>' . '</tr>'; if ($stmt = $mysqli->prepare($bookings_query)) { $stmt->execute(); $stmt->store_result(); $stmt->bind_result($starttime, $endtime, $confirmed, $id, $firstName, $lastName, $rate); while ($stmt->fetch()) { $ustarttime = strtotime(str_replace('-', '/', $starttime)); $uendtime = strtotime(str_replace('-', '/', $endtime)); echo '<tr>' . '<td>' . $firstName . " " . $lastName . '</td>' . '<td>' . $starttime . '</td>' . '<td>' . getLength($ustarttime, $uendtime) . '</td>' . '<td>$' . number_format(getPay($rate, getLength($ustarttime, $uendtime)), 2) . '</td>' . '<td>'; if (is_null($confirmed)) { echo "<a href='confirmbooking.php?bsid={$babysitterid}&confirmed=1&id={$id}'>confirm</a><br />"; echo "<a href='confirmbooking.php?bsid={$babysitterid}&confirmed=0&id={$id}'>reject</a>"; } else { echo $confirmed === 0 ? "rejected" : "confirmed"; } echo '</td></tr>'; } $stmt->free_result(); $stmt->close(); } echo '</table>'; $mysqli->close(); ?>