$current_category = null; while ($row = $result->fetch_assoc()) { if ($row["category_name"] != $current_category and $row["category_name"] != null) { $current_category = $row["category_name"]; echo '<tbody class="print_tbody" id="print_tbody"> <tr id="category"><td colspan="5" class="table_heading"><h4 class="none">' . $row["category_name"] . '</h4></td></tr> <tr id="category_columns"> <th>Item</th> <th>Unit</th> <th>Quantity Present</th> <th>Quantity Required</th> <th>Notes</th> </tr>'; } echo '<tr id="column_data" class="row">'; $sales_factor = VariablesTable::get_expected_sales() / VariablesTable::get_base_sales(); $quantity = is_numeric($row["quantity"]) ? BaseQuantityTable::get_estimated_quantity($sales_factor, $row["item_name"]) - $row["quantity"] : "-"; if ($quantity != "-") { $quantity = eval("return " . str_replace('x', $quantity, $row["factor"]) . ";"); if ($row["rounding_option"] == "up") { $quantity = ceil($quantity / $row["rounding_factor"]) * $row["rounding_factor"]; } else { if ($row["rounding_option"] == "down") { $quantity = floor($quantity / $row["rounding_factor"]) * $row["rounding_factor"]; } } } echo ' <td>' . $row["item_name"] . '</td> <td>' . $row["unit"] . '</td> <td>' . $row["quantity"] . '</td> <td class="quantity_required">' . ($quantity == '-0' ? abs($quantity) : $quantity) . '</td>
<div class="divider"></div> <div class="toolbar_div"> <label class="switch float_left" id="toolbar_toggle"> <input class="switch-input" type="checkbox" onclick=checkRequired() /> <span class="switch-label" data-on="Required" data-off="All"></span> <span class="switch-handle"></span> </label> </div> <div class="divider"></div> <?php if ($_SESSION["userrole"] == "admin") { ?> <div class="toolbar_div"> <form action="print_preview.php" method="post"> <span >Expected Sales ($):</span> <input class="print_expected" type="number" name="expected_sales" value="<?php echo VariablesTable::get_expected_sales(); ?> " onchange="this.form.submit()"> </form> </div> <div class="divider"></div> <?php } ?> <div class="toolbar_div"> <a id="print_share" class="option" onclick=sendPrint()>Share</a> </div> <div class="divider"></div> <div class="toolbar_div"> <a id="print_pdf" class="option" onclick=printPdf()>PDF</a> </div>