| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- class VoucherHelper
- {
- public $db;
- /**
- * Class constructor.
- */
- public function __construct()
- {
- global $db;
- $this->db = $db;
- }
- function showInputField($fk_product)
- {
- $inputFieldString = '';
- $sql = "SELECT pr.rowid, pr.label FROM llx_product as pr
- INNER JOIN llx_product_extrafields as pre ON pre.fk_object = pr.rowid
- WHERE pre.is_in_bundle IS null
- AND pre.hotelsales is null
- ORDER BY pr.label";
- $result = $this->db->query($sql);
- $inputFieldString .= '<select class="flat minwidth100" id="fk_product" name="fk_product" data-select2-id="fk_product" tabindex="-1" aria-hidden="true">';
- $inputFieldString .= '<option value="-1" data-select2-id="4"> </option>';
- if ($this->db->num_rows($result) > 0) {
- while ($row = $this->db->fetch_object($result)) {
- $selected = $row->rowid == $fk_product ? 'selected' : '';
- $inputFieldString .= '<option value="' . $row->rowid . '" ' . $selected . '>' . $row->label . '</option>';
- }
- }
- $inputFieldString .= '</select>';
- return $inputFieldString;
- }
- function JSGeneratorForSelectInput($id){
- print '<script>$("#' . $id . '").select2({
- dir: "ltr",
- width: "resolve",
- minimumInputLength: 0,
- language: select2arrayoflanguage,
- matcher: function(params, data) {
- if ($.trim(params.term) === "") {
- return data;
- }
- keywords = (params.term).split(" ");
- for (var i = 0; i < keywords.length; i++) {
- if (((data.text).toUpperCase()).indexOf((keywords[i]).toUpperCase()) == -1) {
- return null;
- }
- }
- return data;
- },
- theme: "default",
- containerCssClass: ":all:",
- selectionCssClass: ":all:",
- templateResult: function(data, container) {
- if (data.element) {
- $(container).addClass($(data.element).attr("class"));
- }
- if (data.id == -1 && $(data.element).attr("data-html") == undefined) {
- return " ";
- }
- if ($(data.element).attr("data-html") != undefined) return htmlEntityDecodeJs($(data.element).attr("data-html")); // If property html set, we decode html entities and use this
- return data.text;
- },
- templateSelection: function(selection) {
- if (selection.id == -1) return "<span class="placeholder">" + selection.text + "</span>";
- return selection.text;
- },
- escapeMarkup: function(markup) {
- return markup;
- },
- dropdownCssClass: "ui-dialog"
- });</script>';
- }
- }
- ?>
|