noalyss Version-9
select_dialog.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * PhpCompta is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
21
22/**
23 * @file
24 * @brief
25 */
27{
28 /**
29 * Default constructor
30 * @param type $p_id javascript DOMid
31 * @param type $value Label to display
32 * @example select-box-test.php
33 */
35 {
36 parent::__construct($p_id, $value);
37 $this->set_filter("y");
38 }
39 function input()
40 {
41 $id=$this->get_id();
42
43 // display the button
44 printf('<input type="button" class="smallbutton " id="%s_bt" value="%s" onclick="document.getElementById(\'select_dialog%s\').style.display=\'block\'">',
45 $this->id, $this->value,$this->id);
46 printf('<div class="inner_box" id="select_dialog%s" style="display:none;position:fixed;top:10rem">',$id);
47 echo HtmlInput::title_box(_("Sélection"),"select_dialog".$id, "hide");
48
49 $list_id=sprintf('%s_list',$this->id);
50
51 printf('<input type="hidden" id="%s" name="%s" value="%s">', $this->id,
52 $this->id, $this->default_value);
53 printf('<div class=" " id="select_box%s" style="%s">',
54 $this->id, $this->style_box);
55
56 // Show the filter if there is one,
57
58 echo HtmlInput::filter_list($list_id);
59
60 // Print the list of possible options
61 printf('<ul class="tab_row" id="%s">',$list_id);
62 for ($i=0; $i<count($this->item); $i++)
63 {
64 if ($this->item[$i]['type']=="url")
65 {
66 printf('<li><a href="%s">%s</a></li>', $this->item[$i]['url'],
67 $this->item[$i]['label']);
68 }
69 else // For javascript
70 if ($this->item[$i]['type']=="javascript")
71 {
72 printf('<li><a href="javascript:void(0)" onclick="%s">%s</a></li>',
73 $this->item[$i]['javascript'], $this->item[$i]['label']);
74 }
75 else if ($this->item[$i]['type']=="value")
76 {
77 printf('<li><a href="javascript:void(0)" onclick="%s">%s</a></li>',
78 $this->item[$i]['javascript'], $this->item[$i]['label']);
79 }
80 else if ($this->item[$i]['type']=="input") {
81 $ok=new IButton("ok");
82 $ok->value=$this->item[$i]['label'];
83 $ok->javascript=$this->item[$i]['input']->javascript;
84 printf('<li> %s %s</li>',
85 $this->item[$i]['input']->input(),
86 $ok->input()
87 );
88 }
89 }
90
91 echo "</ul>";
92 echo "</div>";
93 echo '</div>';
94
95 // javascript : onclick on button
96 echo "<script>";
97 echo $javascript;
98 echo "</script>";
99 }
100
101}
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static filter_list($p_list_id)
Display a field for searching an element in a list, the searchable text must be in an element with th...
Html Input.
Display a kind of select.
set_filter($p_filter)
__construct($p_id, $value)