noalyss  Version-6.9.1.8
 All Data Structures Namespaces Files Functions Variables Pages
class_iposte.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of NOALYSS.
4  *
5  * NOALYSS is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * NOALYSS is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with NOALYSS; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
20 // Copyright Author Dany De Bontridder danydb@aevalys.eu
21 
22 /*!\file
23  * \brief Html Input
24  *
25  */
26 require_once NOALYSS_INCLUDE.'/lib/class_html_input.php';
27 require_once NOALYSS_INCLUDE.'/lib/class_itext.php';
28 require_once NOALYSS_INCLUDE.'/lib/class_ibutton.php';
29 require_once NOALYSS_INCLUDE.'/lib/class_ipopup.php';
30 require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
31 /**
32  *@brief show a button, for selecting a account and a input text for manually inserting an account
33  * the different value of table are
34  * - 0 no table, it means no TD tags
35  * - 1 the button and the text are separated by TD tags
36  * - 2 the button and the text are in the same column (TD)
37  * - 3 the button and the text are in the table (TD)
38  *\note we use the set_attribute for giving parameter to search_account
39  * attribute are
40  * - gDossier
41  * - jrn if set there is a filter on a ledger, in that case, contains the jrn_id (0 for no filter)
42  * - account field to update with the account_number,
43  * - label field to update control with account_label,
44  * - bracket if true return the account_number between bracket
45  * - noquery don't start a search with the content
46  * - no_overwrite do not overwrite the existant content
47  * - query value to seek
48  *@note needed javascript are
49  - echo js_include('prototype.js');
50  - echo js_include('scriptaculous.js');
51  - echo js_include('effects.js');
52  - echo js_include('controls.js');
53  - echo js_include('dragdrop.js');
54  - echo js_include('accounting_item.js');
55  *\see ajax_poste.php
56  *\code
57 // must be done BEFORE any FORM
58  echo js_include('prototype.js');
59  echo js_include('scriptaculous.js');
60  echo js_include('effects.js');
61  echo js_include('controls.js');
62  echo js_include('dragdrop.js');
63  echo js_include('accounting_item.js');
64 
65 
66 require_once NOALYSS_INCLUDE.'/lib/class_iposte.php';
67 
68 // In the FORM
69 $text=new IPoste();
70 $text->name('field');
71 $text->value=$p_res[$i]['pvalue'];
72 $text->set_attribute('gDossier',Dossier::id());
73 $text->set_attribute('jrn',0);
74 $text->set_attribute('account','field');
75 
76 
77 \endcode
78  */
79 class IPoste extends HtmlInput
80 {
81 
82  function __construct($p_name="",$p_value="",$p_id="")
83  {
84  $this->name=$p_name;
85  $this->readOnly=false;
86  $this->size=10;
87  $this->value=$p_value;
88  $this->selected="";
89  $this->table=0;
90  $this->disabled=false;
91  $this->javascript="";
92  $this->extra2="all";
93  $this->attribute=array();
94  $this->id=$p_id;
95 
96 
97  }
98 
99  static function ipopup($p_name)
100  {
101  $ip=new IPopup($p_name);
102  $ip->title='Plan comptable';
103  $ip->value='';
104  $ip->set_height('80%');
105  $ip->set_zindex(20);
106  return $ip->input();
107  }
108  /*!\brief create the javascript for adding the javascript properties
109  * onto the *button*
110  *\return a javascript surrounded by the tag <SCRIPT>
111  */
112  public function get_js_attr()
113  {
114  $attr="";
115  /* Add properties at the widget */
116  for ($i=0;$i< count($this->attribute);$i++)
117  {
118  list($name,$value)=$this->attribute[$i];
119  $tmp1=sprintf("$('%s_bt').%s='%s';",
120  $this->id,
121  $name,
122  $value);
123  $attr.=$tmp1;
124  }
125  $attr=create_script($attr);
126  return $attr;
127  }
128 
129  public function dsp_button()
130  {
131  $this->id=($this->id=="")?$this->name:$this->id;
132  $javascript='search_poste(this)';
133  $button=HtmlInput::button_image($javascript,$this->id."_bt", 'alt="'._('Recherche').'" class="image_search"',"image/magnifier13.png");
134  /* add the property */
135  $sc=$this->get_js_attr();
136  return $button.$sc;
137  }
138  /*!\brief show the html input of the widget*/
139  public function input($p_name=null,$p_value=null)
140  {
141  $this->name=($p_name==null)?$this->name:$p_name;
142  $this->value=($p_value==null)?$this->value:$p_value;
143  if ( $this->readOnly==true) return $this->display();
144  //--
145  if ( ! isset($this->ctrl) ) $this->ctrl='none';
146 
147  if ( ! isset($this->javascript)) $this->javascript="";
148  $this->id=($this->id=="")?$this->name:$this->id;
149 
150  /* create the text */
151  $itext=new IText($this->name,$this->value,$this->id);
152 
153  if ( isset ($this->css_size))
154  $itext->css_size=$this->css_size;
155  else
156  $itext->size=$this->size;
157 
158  $itext->javascript=$this->javascript;
159  /* create the button */
160  $ibutton=$this->dsp_button();
161  if ( $this->table==3)
162  {
163  $r='<table>'.tr(td($itext->input()).td($ibutton));
164  $r.='</table>';
165  return $r;
166  }
167  $r=$itext->input().$ibutton;
168  if ( $this->table==1) $r=td($r);
169 
170  return $r;
171 
172 
173  //--
174 
175  }
176  /*!\brief print in html the readonly value of the widget*/
177  public function display()
178  {
179  $r=sprintf('<TD><input type="hidden" name="%s" value="%s">
180  %s
181 
182  </TD>',
183  $this->name,
184  $this->value ,
185  $this->value
186  );
187 
188  return $r;
189 
190  }
191  /**
192  *add a double click to poste to see his history
193  *@note change $this->javascript
194  */
195  public function dbl_click_history()
196  {
197  $r=' ondblclick="get_history_account(\''.$this->name.'\',\''.dossier::id().'\')"';
198  $this->javascript=$r;
199  }
200  static public function test_me()
201  {
202  }
203 }
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
dbl_click_history()
add a double click to poste to see his history
input($p_name=null, $p_value=null)
show the html input of the widget
show a button, for selecting a account and a input text for manually inserting an account the differe...
$all disabled
$ret javascript
__construct($p_name="", $p_value="", $p_id="")
for($e=0;$e< count($array);$e++) $desc readOnly
$name size
display()
print in html the readonly value of the widget
$from_poste name
$description css_size
get_js_attr()
create the javascript for adding the javascript properties onto the button
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
static button_image($javascript, $id="xx", $p_class='class="button"', $p_image="")
button Html image
$select_type table
$me_code selected
create_script($p_string)
create the HTML for adding the script tags around of the script
static ipopup($p_name)