noalyss  Version-6.7.2
Public Member Functions | Static Public Member Functions
ICard Class Reference

Input HTML for the card show buttons, in the file, you have to add card.js How to use : More...

Inheritance diagram for ICard:
HtmlInput

Public Member Functions

 __construct ($name="", $value="", $p_id="")
 display ()
 print in html the readonly value of the widget
 input ($p_name=null, $p_value=null)
 show the html input of the widget
 search ()
 return a string containing the button for displaying a search form.
 set_callback ($p_name)
 set the javascript callback function by default it is update_value called BEFORE the querystring is send
 set_dblclick ($p_action)
 set the extra javascript property for a double click on INPUT field
 set_function ($p_name)
 set the javascript callback function by default it is update_value called AFTER an item has been selected

Static Public Member Functions

static ipopup ($p_name)
 return the html string for creating the ipopup, this ipopup can be used for adding, modifying or display a card
static test_me ()

Detailed Description

Input HTML for the card show buttons, in the file, you have to add card.js How to use :

Definition at line 120 of file class_icard.php.


Constructor & Destructor Documentation

ICard::__construct ( name = "",
value = "",
p_id = "" 
)

Reimplemented from HtmlInput.

Definition at line 122 of file class_icard.php.

References HtmlInput\$name, HtmlInput\$value, and javascript.

    {
        parent::__construct($name,$value);
        $this->fct='update_value';
        $this->dblclick='';
        $this->callback='null';
        $this->javascript='';
                $this->autocomplete=1;
                $this->id=($p_id != "")?$p_id:$name;
    }

Member Function Documentation

print in html the readonly value of the widget

Definition at line 247 of file class_icard.php.

References $r, name, and value.

Referenced by input().

    {
        $r=sprintf('         <INPUT TYPE="hidden" NAME="%s" id="%s" VALUE="%s" SIZE="8">',
                   $this->name,
                   $this->name,
                   $this->value
                  );
        $r.='<span>'.$this->value.'</span>';
        return $r;

    }
ICard::input ( p_name = null,
p_value = null 
)

show the html input of the widget

Definition at line 186 of file class_icard.php.

References $div, $e, $ind, HtmlInput\$javascript, HtmlInput\$label, $r, create_script(), display(), HtmlInput\get_js_attr(), javascript, name, readOnly, size, table, td(), and value.

    {
        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;

        $attr=$this->get_js_attr();

        $label='';
        if ( $this->dblclick != '')
        {
            $e=sprintf(' ondblclick="%s" ',
                       $this->dblclick);
            $this->dblclick=$e;
        }
        $input=sprintf('<INPUT TYPE="Text"  class="input_text"  '.
                       ' NAME="%s" ID="%s" VALUE="%s" SIZE="%d" %s %s>',
                       $this->name,
                       $this->id,
                       $this->value,
                       $this->size,
                       $this->dblclick,
                       $this->javascript
                      );
                if ( $this->autocomplete == 1)
                {
                        $ind=sprintf('<span id="%s_ind" class="autocomplete" style="display:none">Un instant... <img src="image/loading.gif" alt="Chargement..."/>'.
                                                '</span>',
                                                $this->id);

                        $div=sprintf('<div id="%s_choices"  class="autocomplete"></div>',
                                                $this->id);

                        $query=dossier::get().'&e='.urlencode($this->typecard);

                        $javascript=sprintf('try { new Ajax.Autocompleter("%s","%s_choices","fid_card.php?%s",'.
                                                                '{paramName:"FID",minChars:1,indicator:null, '.
                                                                'callback:%s, '.
                                                                ' afterUpdateElement:%s});} catch (e){alert(e.message);};',
                                                                $this->id,$this->id,$query,
                                                                $this->callback,
                                                                $this->fct);

                        $javascript=create_script($javascript.$this->dblclick);

                        $r=$label.$input.$attr.$ind.$div.$javascript;
                }
                else
                {
                        $r=$label.$input;
                }
        if ( $this->table == 1 )
            $r=td($r);
        return $r;

    }
static ICard::ipopup ( p_name) [static]

return the html string for creating the ipopup, this ipopup can be used for adding, modifying or display a card

Note:
ipopup is obsolete, the popin is created by javascript
Parameters:
$p_namename of the ipopup, must be set after with set_attribute
      $f_add_button=new IButton('add_card');
      $f_add_button->label='Créer une nouvelle fiche';
      $f_add_button->set_attribute('ipopup','ipop_newcard');
      $f_add_button->set_attribute('filter',$this->get_all_fiche_def ());
      $f_add_button->javascript=" select_card_type(this);";
      $str_add_button=$f_add_button->input();
Returns:
html string
Note:
must be one of first instruction on a new page, to avoid problem of position with IE

Definition at line 167 of file class_icard.php.

    {
        $ip_card=new IPopup ($p_name);
        $ip_card->drag=true;
                $ip_card->set_width('45%');
        $ip_card->title='Fiche ';
        $ip_card->value='';
        return $ip_card->input();
    }

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
          // 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();
    
    See also:
    ajax_card.php
    Note:
    the ipopup id is hard coded : ipop_card
    Returns:
    HTML string with the button

Definition at line 285 of file class_icard.php.

References $a, name, and readOnly.

    {
        if ( $this->readOnly==true) return '';
                if ( ! isset($this->id )) $this->id=$this->name;
        $button=new ISmallButton($this->name.'_bt',"","","smallbutton");
        $button->label=_('Recherche');
        $a="";
        foreach (array('typecard','jrn','label','price','tvaid') as $att)
        {
            if (isset($this->$att) )
                $a.="this.".$att."='".$this->$att."';";
        }
        if (isset($this->id) && $this->id != "")
            $a.="this.inp='".$this->id."';";
                else
            $a.="this.inp='".$this->name."';";
        $a.="this.popup='ipop_card';";
                $button->tabindex=-1;
        $button->javascript=$a.' search_card(this)';
        return $button->input();
    }
ICard::set_callback ( p_name)

set the javascript callback function by default it is update_value called BEFORE the querystring is send

Parameters:
$p_namecallback function name

Definition at line 137 of file class_icard.php.

    {
        $this->callback=$p_name;
    }
ICard::set_dblclick ( p_action)

set the extra javascript property for a double click on INPUT field

Parameters:
$p_actionaction when a double click happens
Note:
the $p_action cannot contain a double quote

Definition at line 181 of file class_icard.php.

References $p_action.

    {
        $this->dblclick=$p_action;
    }
ICard::set_function ( p_name)

set the javascript callback function by default it is update_value called AFTER an item has been selected

Parameters:
$p_namecallback function name

Definition at line 146 of file class_icard.php.

    {
        $this->fct=$p_name;
    }
static ICard::test_me ( ) [static]

Definition at line 307 of file class_icard.php.

References $_REQUEST, $a, $b, $l, ajaxFid(), alert(), echo, HtmlInput\hidden(), style, HtmlInput\submit(), and type.

    {
        require_once('class_itext.php');
        $_SESSION['isValid']=1;
        $a=new ICard('testme');
        $a->extra="all";
        $a->set_attribute('label','ctl_label');
        $a->set_attribute('tvaid','ctl_tvaid');
        $a->set_attribute('price','ctl_price');
        $a->set_attribute('purchase','ctl_purchase');
        $a->set_attribute('type','all');
        echo <<<EOF
          <div id="debug" style="border:solid 1px black;overflow:auto"></div>
          <script type="text/javascript" language="javascript"  src="js/prototype.js">
          </script>
          <script type="text/javascript" language="javascript"  src="js/scriptaculous.js">
          </script>
          <script type="text/javascript" language="javascript"  src="js/effects.js">
          </script>
          <script type="text/javascript" language="javascript"  src="js/controls.js">
          </script>
          <script type="text/javascript" language="javascript"  src="js/ajax_fid.js">
          </script>
          <script type="text/javascript" language="javascript"  >
          function test_value(text,li)
          {
            alert("premier"+li.id);

            str="";
            str=text.id+'<hr>';
            if ( text.js_attr1)
              {
                str+=text.js_attr1;
                str+='<hr>';
              }
            if ( text.js_attr2)
              {
                str+=text.js_attr2;
                str+='<hr>';
              }
            if ( text.js_attr3)
              {
                str+=text.js_attr3;
                str+='<hr>';
              }
            for (var i in text)
              {
                str+=i+'<br>';
              }

            // $('debug').innerHTML=str;
            ajaxFid(text);
          }
        </script>

EOF;
        echo "<form>";
        $l=new IText('ctl_label');
        $t=new IText('ctl_tvaid');
        $p=new IText('ctl_price');
        $b=new IText('ctl_purchase');

        echo "Label ".$l->input().'<br>';
        echo "Tva id  ".$t->input().'<br>';
        echo "Price ".$p->input().'<br>';
        echo "Purchase ".$b->input().'<br>';

        if ( isset($_REQUEST['test_select']) )
            echo HtmlInput::hidden('test_select',$_REQUEST['test_select']);
        $a->set_function('test_value');
        $a->javascript=' onchange="alert(\'onchange\');" onblur="alert(\'onblur\');" ';
        echo $a->input();
        echo dossier::hidden();
        echo HtmlInput::submit('Entree','entree');
        echo '</form>';
        echo <<<EOF
EOF;
    }

The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations