fct='update_value'; $this->dblclick=''; $this->callback='null'; $this->javascript=''; // the pa_id to filter $this->plan=0; // or the container of the Plan Analytic which contains the pa_id $this->plan_ctl=""; } /*!\brief set the javascript callback function * by default it is update_value called BEFORE the querystring is send * If you use the plan ctl must be set to filter_anc *\param $p_name callback function name */ function set_callback($p_name) { $this->callback=$p_name; } /*!\brief set the javascript callback function * by default it is update_value called AFTER an item has been selected *\param $p_name callback function name */ function set_function($p_name) { $this->fct=$p_name; } /*!\brief set the extra javascript property for a double click on * INPUT field *\param $p_action action when a double click happens *\note the $p_action cannot contain a double quote */ function set_dblclick($p_action) { $this->dblclick=$p_action; } /*!\brief show the html input of the widget*/ public function input($p_name=null,$p_value=null) { if ( $p_name == null && $this->name == "") throw (new Exception('Le nom d une icard doit ĂȘtre donne')); $this->value=($p_value==null)?$this->value:$p_value; if ( $this->readOnly==true) return $this->display(); $this->id=($this->id=="")?$this->name:$this->id; $label=''; if ( $this->dblclick != '') { $e=sprintf(' ondblclick="%s" ', $this->dblclick); $this->dblclick=$e; } $input=sprintf('', $this->name, $this->name, $this->value, $this->size, $this->dblclick, $this->javascript ); $div=sprintf('
', $this->name); $query="op=autoanc&".dossier::get(); // add parameter to search into a plan (pa_id) or get the value from // a HtmlObject if ($this->plan <> 0) { $query.="&pa_id=".$this->plan; } elseif ( $this->plan_ctl <> '') { $this->set_attribute("plan_ctl", $this->plan_ctl); } $attr=$this->get_js_attr(); $javascript=sprintf('try { new Ajax.Autocompleter("%s","%s_choices","ajax_misc.php?%s",'. '{paramName:"anccard",minChars:1,indicator:null, '. 'callback:%s, '. ' afterUpdateElement:%s});} catch (e){alert(e.message);};', $this->name, $this->name, $query, $this->callback, $this->fct); $javascript=create_script($javascript.$this->dblclick); $r=$label.$input.$attr.$div.$javascript; if ( $this->table == 1 ) $r=td($r); return $r; } /*!\brief print in html the readonly value of the widget*/ public function display() { $r=sprintf(' ', $this->name, $this->value ); $r.=''.$this->value.''; return $r; } /** *@brief return a string containing the button for displaying * a search form. When clicking on the result, update the input text file * the common used attribute as * - jrn the ledger * - label the field to update * - name name of the input text * - price amount * - tvaid * - typecard (deb, cred, filter or list of value) * will be set * if ICard is in readOnly, the button disappears, so the return string is empty \code // search ipopup $search_card=new IPopup('ipop_card'); $search_card->title=_('Recherche de fiche'); $search_card->value=''; echo $search_card->input(); $a=new ICard('test'); $a->search(); \endcode *\see ajax_card.php *\note the ipopup id is hard coded : ipop_card *@return HTML string with the button */ function search() { if ( $this->readOnly==true) return ''; $button=new IButton($this->name.'_bt'); $a=""; foreach (array('typecard','jrn','label','price','tvaid') as $att) { if (isset($this->$att) ) $a.="this.".$att."='".$this->$att."';"; } if (isset($this->name)) $a.="this.inp='".$this->name."';"; $a.="this.popup='ipop_card';"; $button->javascript=$a.' search_card(this)'; return $button->input(); } static public function test_me() { } }