noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
class_iposte.php
Go to the documentation of this file.
00001 <?php
00002 /*
00003  *   This file is part of NOALYSS.
00004  *
00005  *   NOALYSS is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   NOALYSS is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with NOALYSS; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief Html Input
00024  *
00025  */
00026 require_once('class_html_input.php');
00027 require_once('class_itext.php');
00028 require_once('class_ibutton.php');
00029 require_once('class_ipopup.php');
00030 require_once('function_javascript.php');
00031 /**
00032  *@brief show a button, for selecting a account and a input text for manually inserting an account
00033  * the different value of table are
00034  * - 0 no table, it means no TD tags
00035  * - 1 the button and the text are separated by TD tags
00036  * - 2 the button and the text are in the same column (TD)
00037  * - 3 the button and the text are in the table (TD)
00038  *\note we use the set_attribute for giving parameter to search_account
00039  * attribute are
00040  *  - gDossier
00041  *  - jrn  if set there is a filter on a ledger, in  that case, contains the jrn_id (0 for no filter)
00042  *  - account field to update with the account_number,
00043  *  - label  field to update  control with account_label,
00044  *  - bracket if true return the account_number between bracket
00045  *  - noquery don't start a search with the content
00046  *  - no_overwrite do not overwrite the existant content
00047  *  - query value to seek
00048  *@note needed javascript are
00049  - echo js_include('prototype.js');
00050  - echo js_include('scriptaculous.js');
00051  - echo js_include('effects.js');
00052  - echo js_include('controls.js');
00053  - echo js_include('dragdrop.js');
00054  - echo js_include('accounting_item.js');
00055  *\see ajax_poste.php
00056  *\code
00057 // must be done BEFORE any FORM
00058  echo js_include('prototype.js');
00059  echo js_include('scriptaculous.js');
00060  echo js_include('effects.js');
00061  echo js_include('controls.js');
00062  echo js_include('dragdrop.js');
00063  echo js_include('accounting_item.js');
00064 
00065 
00066 require_once('class_iposte.php');
00067 
00068 // In the FORM
00069 $text=new IPoste();
00070 $text->name('field');
00071 $text->value=$p_res[$i]['pvalue'];
00072 $text->set_attribute('gDossier',Dossier::id());
00073 $text->set_attribute('jrn',0);
00074 $text->set_attribute('account','field');
00075 
00076 
00077 \endcode
00078  */
00079 class IPoste extends HtmlInput
00080 {
00081 
00082     function __construct($p_name="",$p_value="",$p_id="")
00083     {
00084         $this->name=$p_name;
00085         $this->readOnly=false;
00086         $this->size=10;
00087         $this->value=$p_value;
00088         $this->selected="";
00089         $this->table=0;
00090         $this->disabled=false;
00091         $this->javascript="";
00092         $this->extra2="all";
00093         $this->attribute=array();
00094         $this->id=$p_id;
00095        
00096 
00097     }
00098 
00099     static function ipopup($p_name)
00100     {
00101         $ip=new IPopup($p_name);
00102         $ip->title='Plan comptable';
00103         $ip->value='';
00104         $ip->set_height('80%');
00105         $ip->set_zindex(20);
00106         return $ip->input();
00107     }
00108     /*!\brief create the javascript for adding the javascript properties
00109      * onto the *button*
00110      *\return a javascript surrounded by the tag <SCRIPT>
00111      */
00112     public function get_js_attr()
00113     {
00114         $attr="";
00115         /* Add properties at the widget */
00116         for ($i=0;$i< count($this->attribute);$i++)
00117         {
00118             list($name,$value)=$this->attribute[$i];
00119             $tmp1=sprintf("$('%s_bt').%s='%s';",
00120                           $this->id,
00121                           $name,
00122                           $value);
00123             $attr.=$tmp1;
00124         }
00125         $attr=create_script($attr);
00126         return $attr;
00127     }
00128 
00129     public function dsp_button()
00130     {
00131                 $this->id=($this->id=="")?$this->name:$this->id;
00132         $ib=new ISmallButton($this->id.'_bt');
00133         $ib->label=_('Recherche');
00134        //  $ib->extra='style="background:url(image/search.png) no-repeat;background-position:0;padding-left:36px;"';
00135         $ib->javascript='search_poste(this)';
00136 
00137         /*  add the property */
00138         $sc=$this->get_js_attr();
00139         return $ib->input().$sc;
00140     }
00141     /*!\brief show the html  input of the widget*/
00142     public function input($p_name=null,$p_value=null)
00143     {
00144         $this->name=($p_name==null)?$this->name:$p_name;
00145         $this->value=($p_value==null)?$this->value:$p_value;
00146         if ( $this->readOnly==true) return $this->display();
00147         //--
00148         if ( ! isset($this->ctrl) ) $this->ctrl='none';
00149 
00150         if ( ! isset($this->javascript)) $this->javascript="";
00151                 $this->id=($this->id=="")?$this->name:$this->id;
00152 
00153         /* create the text  */
00154         $itext=new IText($this->name,$this->value,$this->id);
00155 
00156         if ( isset ($this->css_size))
00157              $itext->css_size=$this->css_size;
00158         else
00159              $itext->size=$this->size;
00160 
00161                  $itext->javascript=$this->javascript;
00162         /* create the button */
00163         $ibutton=$this->dsp_button();
00164         if ( $this->table==3)
00165         {
00166             $r='<table>'.tr(td($itext->input()).td($ibutton));
00167             $r.='</table>';
00168             return $r;
00169         }
00170         $r=$itext->input().$ibutton;
00171         if ( $this->table==1) $r=td($r);
00172 
00173         return $r;
00174 
00175 
00176         //--
00177 
00178     }
00179     /*!\brief print in html the readonly value of the widget*/
00180     public function display()
00181     {
00182         $r=sprintf('<TD><input type="hidden" name="%s" value="%s">
00183                    %s
00184 
00185                    </TD>',
00186                    $this->name,
00187                    $this->value ,
00188                    $this->value
00189                   );
00190 
00191         return $r;
00192 
00193     }
00194         /**
00195          *add a double click to poste to see his history
00196          *@note change $this->javascript
00197          */
00198         public function dbl_click_history()
00199         {
00200                 $r=' ondblclick="get_history_account(\''.$this->name.'\',\''.dossier::id().'\')"';
00201                 $this->javascript=$r;
00202         }
00203     static public function test_me()
00204     {
00205     }
00206 }
 All Data Structures Namespaces Files Functions Variables Enumerations