noalyss Version-9
iposte.class.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 */
26require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
27/**
28 *@brief show a button, for selecting a account and a input text for manually inserting an account
29 * the different value of table are
30 * - 0 no table, it means no TD tags
31 * - 1 the button and the text are separated by TD tags
32 * - 2 the button and the text are in the same column (TD)
33 * - 3 the button and the text are in the table (TD)
34 *\note we use the set_attribute for giving parameter to search_account
35 * attribute are
36 * - gDossier
37 * - jrn if set there is a filter on a ledger, in that case, contains the jrn_id (0 for no filter)
38 * - account field to update with the account_number,
39 * - label field to update control with account_label,
40 * - bracket if true return the account_number between bracket
41 * - noquery don't start a search with the content
42 * - no_overwrite do not overwrite the existant content
43 * - query value to seek
44 *@note needed javascript are
45 - echo js_include('prototype.js');
46 - echo js_include('scriptaculous.js');
47 - echo js_include('effects.js');
48 - echo js_include('controls.js');
49 - echo js_include('dragdrop.js');
50 - echo js_include('accounting_item.js');
51 *\see ajax_poste.php
52 *\code
53// must be done BEFORE any FORM
54 echo js_include('prototype.js');
55 echo js_include('scriptaculous.js');
56 echo js_include('effects.js');
57 echo js_include('controls.js');
58 echo js_include('dragdrop.js');
59 echo js_include('accounting_item.js');
60
61
62
63// In the FORM
64$text=new IPoste();
65$text->name('field');
66$text->value=$p_res[$i]['pvalue'];
67$text->set_attribute('gDossier',Dossier::id());
68$text->set_attribute('jrn',0);
69$text->set_attribute('account','field');
70
71
72\endcode
73 */
74class IPoste extends HtmlInput
75{
76 var $nb_row; // number of row, default 1
77 var $jrn; //!< concerned ledger
78 function __construct($p_name="",$p_value="",$p_id="")
79 {
80 $this->name=$p_name;
81 $this->readOnly=false;
82 $this->size=15;
83 $this->value=$p_value;
84 $this->selected="";
85 $this->table=0;
86 $this->disabled=false;
87 $this->javascript="";
88 $this->extra2="all";
89 $this->extra="";
90 $this->attribute=array();
91 $this->id=$p_id;
92 $this->nb_row=1;
93
94 }
95
96 static function ipopup($p_name)
97 {
98 $ip=new IPopup($p_name);
99 $ip->title='Plan comptable';
100 $ip->value='';
101 $ip->set_height('80%');
102 $ip->set_zindex(20);
103 return $ip->input();
104 }
105 /*!\brief create the javascript for adding the javascript properties
106 * onto the *button*
107 *\return a javascript surrounded by the tag <SCRIPT>
108 */
109 public function get_js_attr()
110 {
111 $attr="";
112 /* Add properties at the widget */
113 for ($i=0;$i< count($this->attribute);$i++)
114 {
115 list($name,$value)=$this->attribute[$i];
116 $tmp1=sprintf("$('%s_bt').%s='%s';",
117 $this->id,
118 $name,
119 $value);
120 $attr.=$tmp1;
121 }
123 return $attr;
124 }
125
126 public function dsp_button()
127 {
128 $this->id=($this->id=="")?$this->name:$this->id;
129 $javascript='search_accounting(this)';
130 $button=Icon_Action::icon_magnifier($this->id."_bt", $javascript);
131 /* add the property */
132 $sc=$this->get_js_attr();
133 return $button.$sc;
134 }
135 /*!\brief show the html input of the widget*/
136 public function input($p_name=null,$p_value=null)
137 {
138 $this->name=($p_name==null)?$this->name:$p_name;
139 $this->value=($p_value==null)?$this->value:$p_value;
140 if ( $this->readOnly==true) return $this->display();
141 //--
142 if ( ! isset($this->ctrl) ) $this->ctrl='none';
143
144 if ( ! isset($this->javascript)) $this->javascript="";
145 $this->id=($this->id=="")?$this->name:$this->id;
146
147 /* create the text */
148 if ( $this->nb_row ==1 ) {
149 $itext=new IText($this->name,$this->value,$this->id);
150 }else {
151 $itext=new ITextarea($this->name, $this->value, $this->id);
152 $itext->style=$this->extra;
153 }
154
155 if ( isset ($this->css_size))
156 $itext->css_size=$this->css_size;
157 else
158 $itext->size=$this->size;
159
160 $itext->javascript=$this->javascript;
161 /* create the button */
162 $ibutton=$this->dsp_button();
163 if ( $this->table==3)
164 {
165 $r='<table>'.tr(td($itext->input()).td($ibutton));
166 $r.='</table>';
167 return $r;
168 }
169 $r=$itext->input().$ibutton;
170 if ( $this->table==1) $r=td($r);
171
172 return $r;
173
174
175 //--
176
177 }
178 /*!\brief print in html the readonly value of the widget*/
179 public function display()
180 {
181 $r=sprintf('<TD><input type="hidden" name="%s" value="%s">
182 %s
183
184 </TD>',
185 $this->name,
186 $this->value ,
187 $this->value
188 );
189
190 return $r;
191
192 }
193 /**
194 *add a double click to poste to see his history
195 *@note change $this->javascript
196 */
197 public function dbl_click_history()
198 {
199 $r=' ondblclick="get_history_account(\''.$this->id.'\',\''.dossier::id().'\')"';
200 $this->javascript=$r;
201 }
202 static public function test_me()
203 {
204 }
205}
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
$select selected
$ret javascript
$name size
$description css_size
$from_poste name
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
create a popup in html above the current layer the html inside the popup cannot contain any floating ...
show a button, for selecting a account and a input text for manually inserting an account the differe...
__construct($p_name="", $p_value="", $p_id="")
get_js_attr()
create the javascript for adding the javascript properties onto the button
dbl_click_history()
add a double click to poste to see his history
$jrn
concerned ledger
static ipopup($p_name)
input($p_name=null, $p_value=null)
show the html input of the widget
display()
print in html the readonly value of the widget
Html Input.
Definition: itext.class.php:30
Manage the TEXTAREA html element.
static icon_magnifier($id, $p_javascript, $p_style="")
Display a icon with a magnify glass.
$all table
$icard readOnly
$account nb_row
create_script($p_string)
create the HTML for adding the script tags around of the script
$all disabled
$poste extra
$sc
Definition: upgrade.inc.php:42