helper.class.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. class VoucherHelper
  3. {
  4. public $db;
  5. /**
  6. * Class constructor.
  7. */
  8. public function __construct()
  9. {
  10. global $db;
  11. $this->db = $db;
  12. }
  13. function showInputField($fk_product)
  14. {
  15. $inputFieldString = '';
  16. $sql = "SELECT pr.rowid, pr.label FROM llx_product as pr
  17. INNER JOIN llx_product_extrafields as pre ON pre.fk_object = pr.rowid
  18. WHERE pre.is_in_bundle IS null
  19. AND pre.hotelsales is null
  20. ORDER BY pr.label";
  21. $result = $this->db->query($sql);
  22. $inputFieldString .= '<select class="flat minwidth100" id="fk_product" name="fk_product" data-select2-id="fk_product" tabindex="-1" aria-hidden="true">';
  23. $inputFieldString .= '<option value="-1" data-select2-id="4">&nbsp;</option>';
  24. if ($this->db->num_rows($result) > 0) {
  25. while ($row = $this->db->fetch_object($result)) {
  26. $selected = $row->rowid == $fk_product ? 'selected' : '';
  27. $inputFieldString .= '<option value="' . $row->rowid . '" ' . $selected . '>' . $row->label . '</option>';
  28. }
  29. }
  30. $inputFieldString .= '</select>';
  31. return $inputFieldString;
  32. }
  33. }
  34. ?>