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         $javascript='search_poste(this)';
00133         $button=HtmlInput::button_image($javascript,$this->name."_bt", 'alt="'._('Recherche').'" class="image_search"',"image/magnifier13.png");
00134         /*  add the property */
00135         $sc=$this->get_js_attr();
00136         return $button.$sc;
00137     }
00138     /*!\brief show the html  input of the widget*/
00139     public function input($p_name=null,$p_value=null)
00140     {
00141         $this->name=($p_name==null)?$this->name:$p_name;
00142         $this->value=($p_value==null)?$this->value:$p_value;
00143         if ( $this->readOnly==true) return $this->display();
00144         //--
00145         if ( ! isset($this->ctrl) ) $this->ctrl='none';
00146 
00147         if ( ! isset($this->javascript)) $this->javascript="";
00148                 $this->id=($this->id=="")?$this->name:$this->id;
00149 
00150         /* create the text  */
00151         $itext=new IText($this->name,$this->value,$this->id);
00152 
00153         if ( isset ($this->css_size))
00154              $itext->css_size=$this->css_size;
00155         else
00156              $itext->size=$this->size;
00157 
00158                  $itext->javascript=$this->javascript;
00159         /* create the button */
00160         $ibutton=$this->dsp_button();
00161         if ( $this->table==3)
00162         {
00163             $r='<table>'.tr(td($itext->input()).td($ibutton));
00164             $r.='</table>';
00165             return $r;
00166         }
00167         $r=$itext->input().$ibutton;
00168         if ( $this->table==1) $r=td($r);
00169 
00170         return $r;
00171 
00172 
00173         //--
00174 
00175     }
00176     /*!\brief print in html the readonly value of the widget*/
00177     public function display()
00178     {
00179         $r=sprintf('<TD><input type="hidden" name="%s" value="%s">
00180                    %s
00181 
00182                    </TD>',
00183                    $this->name,
00184                    $this->value ,
00185                    $this->value
00186                   );
00187 
00188         return $r;
00189 
00190     }
00191         /**
00192          *add a double click to poste to see his history
00193          *@note change $this->javascript
00194          */
00195         public function dbl_click_history()
00196         {
00197                 $r=' ondblclick="get_history_account(\''.$this->name.'\',\''.dossier::id().'\')"';
00198                 $this->javascript=$r;
00199         }
00200     static public function test_me()
00201     {
00202     }
00203 }
 All Data Structures Namespaces Files Functions Variables Enumerations