phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r4391 - phpcompta/trunk/include


From: phpcompta-dev
Subject: [Phpcompta-dev] r4391 - phpcompta/trunk/include
Date: Fri, 18 Nov 2011 13:48:30 +0100 (CET)

Author: danydb
Date: 2011-11-18 13:48:29 +0100 (Fri, 18 Nov 2011)
New Revision: 4391

Added:
   phpcompta/trunk/include/class_ianccard.php
Modified:
   phpcompta/trunk/include/class_anc_print.php
Log:
#462 : autocompletion pour les activit?\195?\169s

Modified: phpcompta/trunk/include/class_anc_print.php
===================================================================
--- phpcompta/trunk/include/class_anc_print.php 2011-11-18 10:55:55 UTC (rev 
4390)
+++ phpcompta/trunk/include/class_anc_print.php 2011-11-18 12:48:29 UTC (rev 
4391)
@@ -37,7 +37,7 @@
 require_once('constant.php');
 require_once('class_dossier.php');
 require_once ('class_anc_plan.php');
-
+require_once 'class_ianccard.php';
 class Anc_Print
 {
     var $db;                                           /*!< $db database 
connection */
@@ -104,8 +104,9 @@
         $to->value=$this->to;
         $to->size=10;
 
-        $from_poste=new IText('from_poste','from_poste');
+        $from_poste=new IAncCard('from_poste','from_poste');
         $from_poste->size=10;
+        $from_poste->plan_ctl='pa_id';
         $from_poste->value=$this->from_poste;
 
         $to_poste=new IText('to_poste','to_poste');

Added: phpcompta/trunk/include/class_ianccard.php
===================================================================
--- phpcompta/trunk/include/class_ianccard.php                          (rev 0)
+++ phpcompta/trunk/include/class_ianccard.php  2011-11-18 12:48:29 UTC (rev 
4391)
@@ -0,0 +1,200 @@
+<?php
+/*
+ *   This file is part of PhpCompta.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+/* $Revision: 4273 $ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/*!\file
+ * \brief Input HTML for the card show buttons
+ *
+ */
+
+/*!
+ * \brief 
+*/
+require_once('class_html_input.php');
+require_once('function_javascript.php');
+
+class IAncCard extends HtmlInput
+{
+    function __construct($name="",$value="")
+    {
+        parent::__construct($name,$value);
+        $this->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
+     *
+     *\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();
+
+
+        $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->name,
+                       $this->value,
+                       $this->size,
+                       $this->dblclick,
+                       $this->javascript
+                      );
+
+
+        $div=sprintf('<div id="%s_choices"  class="autocomplete"></div>',
+                     $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 <> '')
+        {
+            $query.="&pa_ctl=".$this->plan_ctl;
+        }
+
+        $javascript=sprintf('try { new 
Ajax.Autocompleter("%s","%s_choices","ajax_misc.php?%s",'.
+                            '{paramName:"anccard",minChars:2,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('         
+                    <INPUT TYPE="hidden" NAME="%s" VALUE="%s" SIZE="8">',
+                   $this->name,
+                   $this->value
+                  );
+        $r.='<span>'.$this->value.'</span>';
+        return $r;
+
+    }
+    /**
+     address@hidden 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
+     address@hidden 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()
+    {
+      
+    }
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]