function displaydevices($category_id, $specification_id) { //select all the devices according to the category and the specification $daoprod = new ProductDAO(); $resprod = $daoprod->findByCategoryAndSpecification($category_id, $specification_id); //if the query has no product, we show a error message if (!$resprod) { echo '<span class="text-danger">*' . t('No result found') . '</span>'; } ?> <form action="?<?php echo 'idcategory=' . $category_id . '&idspecification=' . $specification_id; ?> " method="POST"> <table class="table table-bordered"> <tr> <th></th> <th></th> <th><?php echo t('Serial number'); ?> </th> <th><?php echo t('Purchase price'); ?> </th> <th><?php echo t('Discount'); ?> </th> <th><?php echo t('Brand'); ?> </th> <th><?php echo t('Model'); ?> </th> <th><?php echo t('Classification'); ?> </th> <th><?php echo t('Electricity cost'); ?> </th> <th><?php echo t('Consumption'); ?> </th> <th><?php echo t('Release year'); ?> </th> <th><?php echo t('Description'); ?> </th> </tr> <?php //display the devices foreach ($resprod as $product) { ?> <tr> <!-- create a radiobutton for each row and put the productid as the value it will be useful when the users wants to delete or modify a product --> <td><input type="radio" name="radioval" value="<?php echo $product->id; ?> "></td> <!-- image not implement yet --> <td><img height="150" width="150" src="data:image;base64,<?php echo $product->image; ?> "></td> <td><?php echo $product->serial_number; ?> </td> <td><?php echo $product->purchase_price; ?> </td> <td><?php echo $product->periodical_discount; ?> </td> <td><?php echo $product->brand; ?> </td> <td><?php echo $product->model; ?> </td> <td><?php echo $product->classification; ?> </td> <td><?php echo $product->cost; ?> </td> <td><?php echo $product->consumption; ?> </td> <td><?php echo $product->release_year; ?> </td> <td><?php echo $product->description; ?> </td> </tr> <?php } ?> </table> <br> <button class="btn btn-primary" type="submit" name="action" value="Modify"><?php echo t('Modify'); ?> </button> <button class="btn btn-primary" type="submit" name="action" value="Delete"><?php echo t('Delete'); ?> </button> </form> <?php }
function displaydevices($category_id, $specification_id) { $product_dao = new ProductDAO(); $products = $product_dao->findByCategoryAndSpecification($category_id, $specification_id); ?> <div class="table-responsive"> <table class="table table-hover table-bordered""> <thead> <tr> <th></th> <th><?php echo t('Serial number'); ?> </th> <th><?php echo t('Purchase price'); ?> </th> <th><?php echo t('Periodical discount'); ?> </th> <th><?php echo t('Brand'); ?> </th> <th><?php echo t('Model'); ?> </th> <th><?php echo t('Classification'); ?> </th> <th><?php echo t('Consumption'); ?> </th> <th><?php echo t('Description'); ?> </th> </tr> </thead> <?php //display the devices data in a table foreach ($products as $product) { ?> <tr <?php echo 'data-href="?action&category=' . $category_id . '&specification=' . $specification_id . '&product_id=' . $product->id . '"'; ?> > <td><img height="150" width="150" src="data:image;base64,<?php echo $product->image; ?> "></td> <?php foreach (['serial_number', 'purchase_price', 'periodical_discount', 'brand', 'model', 'classification', 'consumption', 'description'] as $property_name) { ?> <td><?php echo $product->{$property_name}; ?> </td> <?php } ?> </tr> <?php } ?> </table> </div> <?php }