Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
- <html>
- <head>
- <title>Housekeeping Room Assignment</title>
- <!-- CSS for formatting control -->
- <?php
- include('dt.css');
- ?>
- <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
- <meta http-equiv="Pragma" content="no-cache" />
- <meta http-equiv="Expires" content="0" />
- </head>
- <body>
- <font size = +2>.: Housekeeping Stats :.</font>
- <!-- menu -->
- <!-- End menu -->
- <hr>
- <?php
- include('header.php');
- ?>
- Select a date to show stats for that specific date:<br><br>
- <form method="post">
- <label>Date To Show:</label>
- <?php
- $DaysToSubtract = 0;
- // Check if form is submitted successfully
- if(isset($_POST["TheDate"]))
- {
- //echo 'I have a date!';
- $now = time(); // or your date as well
- $your_date = strtotime($_POST["TheDate"]);
- $datediff = $now - $your_date ;
- //echo round($datediff / (60 * 60 * 24));
- $DaysToSubtract = round($datediff / (60 * 60 * 24)) - 1 ;
- //echo $DaysToSubtract;
- ?>
- <input type="date" id="TheDate" name="TheDate" value="<?php echo date($_POST["TheDate"]); ?>" />
- <?php
- }
- else
- {
- //Default to today!
- ?>
- <input type="date" id="TheDate" name="TheDate" value="<?php echo date('Y-m-d'); ?>" />
- <?php
- }
- ?>
- <input type="submit">
- </form>
- <?php
- //Get the HKs with boards today
- $strSQLA = 'SELECT DISTINCT RoomNumber FROM Boards WHERE TheDate = CURRENT_DATE() - ' . $DaysToSubtract . ' Order By RoomNumber';
- //echo $strSQLA ."<br>";
- $resultA = @mysqli_query ($dbc,$strSQLA);
- while ($rowA = mysqli_fetch_array ($resultA, MYSQLI_ASSOC))
- {
- $arrStarts = array();
- $arrStops = array();
- $arrCompletes = array();
- $arrEmployees = array();
- $RoomTotals = 0;
- echo '<h2>Room ' . $rowA['RoomNumber'] . "</h2>";
- //For each room, get the punches
- $strSQLC= 'SELECT * FROM Punches WHERE date(Timestamp) = CURRENT_DATE() - ' . $DaysToSubtract . ' AND RoomNumber = ' . $rowA['RoomNumber'] . ' Order By EmpID asc, TimeStamp asc';
- //echo $strSQLC . '<br>';
- $resultC = @mysqli_query ($dbc,$strSQLC);
- while ($rowC = mysqli_fetch_array ($resultC, MYSQLI_ASSOC))
- {
- //Display the results
- //echo $rowB['RoomNumber'] . ' - ' . $rowC['TimeStamp'] . ' - ' . $rowC['Status'] . '<br>';
- //if a StartResume, add to the start array
- //if a Pause or Clean_***, add to the finish array
- //Ignore all others
- switch ($rowC['Status'])
- {
- case 'StartResume':
- array_push($arrEmployees,$rowC['EmpID']);
- array_push($arrStarts,$rowC['TimeStamp']);
- break;
- case 'Pause':
- case 'Clean_Vac':
- case 'Clean_Occ':
- //array_push($arrEmployees,$rowC['EmpID']);
- array_push($arrStops,$rowC['TimeStamp']);
- array_push($arrCompletes,$rowC['Status']);
- break;
- }
- //array_push($arrRooms,$strTemp);
- //arrStarts = array();
- //arrStops = array();
- //arrCompletes = array();
- }//End of punches
- echo '<table border = 1><tr><th>Employee</th><th>Entered</th><th>Exited</th><th>Time In<br>Room</th><th>Status</th></tr>';
- //Display what is in the arrays
- for ($y = 0; $y < count((array) $arrStarts);$y++)
- {
- //Same name, do the calculation
- $TempStart = new DateTime($arrStarts[$y]);//start time
- $TempStop = new DateTime($arrStops[$y]);//start time
- $interval = $TempStop->diff($TempStart);
- //Get the employee name
- $strSQLName = "SELECT EmpName From Employee WHERE EmpID = " . $arrEmployees[$y];
- //echo $strSQLName . '<br>';
- $resultName = @mysqli_query ($dbc,$strSQLName);
- while ($rowName = mysqli_fetch_array ($resultName, MYSQLI_ASSOC))
- {
- $strOutput = $rowName['EmpName'];
- }
- echo '<tr><td>' . $strOutput . '</td><td>' . $arrStarts[$y] . '</td><td>' . $arrStops[$y] . '</td><td align="center">' . $interval->format('%i') . '</td><td>' . $arrCompletes[$y] . '</td></tr>';
- //echo '- ' . $arrStarts[$y] . ' - ' . $arrStops[$y] . ' - ' . $interval->format('%i') . '<br>';
- //$arrTotals = array();
- try
- {
- array_push($arrTotals,$interval->format('%i'));
- } catch (Exception $e)
- {
- echo 'Morgan caught an error!';
- }
- $RoomTotals += $interval->format('%i');
- }
- echo '<tr><td></td><td></td><td align="right"><b>Total</b></td><td align="center"><b>' . $RoomTotals . '</b></td></tr>';
- echo '</table>';
- //echo $row['EmpID'] . '<br>';
- echo '<hr>';
- }//End of employee
- ?>
- <!-- footer -->
- <?php
- include('footer.php');
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement