noalyss  Version-6.9.1.8
 All Data Structures Namespaces Files Functions Variables Pages
class_html_input.php
Go to the documentation of this file.
1 <?php
2 /*
3  * This file is part of NOALYSS.
4  *
5  * NOALYSS is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * NOALYSS is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with NOALYSS; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
20 
21 // Copyright Author Dany De Bontridder danydb@aevalys.eu
22 
23 /*! \file
24  * \brief This class is used to create all the HTML INPUT TYPE
25  */
26 
27 /*!
28  * \brief class widget This class is used to create all the HTML INPUT TYPE
29  * and some specials which works with javascript like
30  * js_search.
31  *
32  * special value
33  * js_search and js_search_only :you need to add a span widget the name
34  * of the js_* widget + '_label' , the member extra contains cred,deb to
35  * filter the search of cred of deb of a jrn or contains a string with
36  * a list of frd_id.
37  * Possible type
38  * $type
39  * - TEXT
40  * - HIDDEN
41  * - BUTTON in this->js you have the javascript code
42  * - SELECT the options are passed via this->value, this array is
43  * build thanks the make_array function, each array (of the
44  * array) aka row must contains a field value and a field label
45  * - PASSWORD
46  * - CHECKBOX
47  * - RADIO
48  * - TEXTAREA
49  * - RICHTEXT
50  * - FILE
51  * - SPAN
52  */
53 class HtmlInput
54 {
55 
56  var $type; /*!< $type type of the widget */
57  var $name; /*!< $name field NAME of the INPUT */
58  var $value; /*!< $value what the INPUT contains */
59  var $readOnly; /*!< $readonly true : we cannot change value */
60  var $size; /*!< $size size of the input */
61  var $selected; /*!< $selected for SELECT RADIO and CHECKBOX the selected value */
62  var $table; /*!< $table =1 add the table tag */
63  var $label; /*!< $label the question before the input */
64  var $disabled; /*!< $disabled poss. value == true or nothing, to disable INPUT*/
65  var $extra; /*!< $extra different usage, it depends of the $type */
66  var $extra2; /*!< $extra2 different usage,
67  it depends of the $type */
68  var $javascript; /*!< $javascript is the javascript to add to the widget */
69  var $ctrl; /*!<$ctrl is the control to update (see js_search_card_control) */
70 
71  var $tabindex;
72  function __construct($p_name="",$p_value="",$p_id="")
73  {
74  $this->name=$p_name;
75  $this->readOnly=false;
76  $this->size=20;
77  $this->width=50;
78  $this->heigh=20;
79  $this->value=$p_value;
80  $this->selected="";
81  $this->table=0;
82  $this->disabled=false;
83  $this->javascript="";
84  $this->extra="";
85  $this->extra2="all";
86  $this->attribute=array();
87  $this->id=$p_id;
88 
89  }
90  function setReadOnly($p_read)
91  {
92  $this->readOnly=$p_read;
93  }
94  /*!\brief set the extra javascript property for the INPUT field
95  *\param $p_name name of the parameter
96  *\param $p_value default value of this parameter
97  */
98  public function set_attribute($p_name,$p_value)
99  {
100  $this->attribute[]=array($p_name,$p_value);
101  $this->$p_name=$p_value;
102  }
103  /**
104  *@brief you can add attribute to this in javascript
105  * this function is a wrapper and create a script (in js) to modify
106  * "this" (in javascript) with the value of obj->attribute from PHP
107  *@return return string with the javascript code
108  */
109  public function get_js_attr()
110  {
111  require_once NOALYSS_INCLUDE.'/lib/function_javascript.php';
112  $attr="";
113  if ( count($this->attribute) == 0) return "";
114 
115  /* Add properties at the widget */
116  for ($i=0;$i< count($this->attribute);$i++)
117  {
118  list($name,$value)=$this->attribute[$i];
119  $tmp1=sprintf("$('%s').%s='%s';",
120  $this->name,
121  $name,
122  $value);
123  $attr.=$tmp1;
124  }
125  $attr=create_script($attr);
126  return $attr;
127  }
128  /**
129  * Make a JSON object, this method create a javascript object
130  * with the attribute set, it returns a javascript string with the object
131  * @param $p_name : name of the object, can be null. If the name is not null, return
132  * $p_name={} otherwise only the object {}
133  * @return javascript string with the object
134  * @note: there is not check on the key->value, so you could need to escape
135  * special char as quote, single-quote...
136  * @deprecated
137  * @code
138  $a=new IButton()
139  $a->set_attribute('prop','1');
140  $a->set_attribute('prop','2');
141  $a->set_attribute('prop','3');
142  $string = $a->make_object('property');
143  echo $string => property={'prop':'1','prop2':'2','prop3':'3'};
144  $string = $a->make_object(null);
145  echo $string => {'prop':'1','prop2':'2','prop3':'3'};
146  @endcode
147  */
148  public function make_object_deprecated($p_name=null)
149  {
150  $name=($p_name != null)?$p_name.'=':'';
151  if ( count($this->attribute) == 0) return $name."{}";
152  $ret=$name."{";
153  $and='';
154 
155  for ($i=0;$i< count($this->attribute);$i++)
156  {
157  list($name,$value)=$this->attribute[$i];
158  $tmp1=sprintf($and."'%s':'%s'",
159  $name,
160  $value);
161  $ret.=$tmp1;
162  $and=',';
163  }
164 
165  $ret.='}';
166  return $ret;
167  }
168  //#####################################################################
169  /* Debug
170  */
171  function debug()
172  {
173  echo "Type ".$this->type."<br>";
174  echo "name ".$this->name."<br>";
175  echo "value". $this->value."<br>";
176  $readonly=($this->readonly==false)?"false":"true";
177  echo "read only".$readonly."<br>";
178  }
179  static function submit ($p_name,$p_value,$p_javascript="",$p_class="smallbutton")
180  {
181 
182  return '<INPUT TYPE="SUBMIT" class="'.$p_class.'" NAME="'.$p_name.'" ID="'.$p_name.'_submit_id" VALUE="'.$p_value.'" '.$p_javascript.'>';
183  }
184  static function button ($p_name,$p_value,$p_javascript="",$p_class="smallbutton")
185  {
186 
187  return '<INPUT TYPE="button" class="'.$p_class.'" NAME="'.$p_name.'" ID="'.$p_name.'" VALUE="'.$p_value.'" '.$p_javascript.'>';
188  }
189 
190  static function reset ($p_value)
191  {
192  return '<INPUT TYPE="RESET" class="smallbutton" VALUE="'.$p_value.'">';
193  }
194  static function hidden($p_name,$p_value,$p_id="")
195  {
196  if ($p_id=="") $p_id=$p_name;
197  return '<INPUT TYPE="hidden" id="'.$p_id.'" NAME="'.$p_name.'" VALUE="'.$p_value.'">';
198  }
199 
200  static function extension()
201  {
202  return self::hidden('plugin_code',$_REQUEST['plugin_code']);
203  }
204 
205  /*!\brief create a button with a ref
206  *\param $p_label the text
207  *\param $p_value the location of the window,
208  *\param $p_name the id of the span
209  *\param $p_javascript javascript for this button
210  *\return string with htmlcode
211  */
212  static function button_anchor($p_label,$p_value,$p_name="",$p_javascript="",$p_class="button")
213  {
214  $r=sprintf('<span id="%s" > <A class="'.$p_class.'" style="display:inline;" href="%s" %s >%s</A></span>',
215  $p_name,
216  $p_value,
217  $p_javascript,
218  $p_label);
219  return $r;
220  }
221  static function infobulle($p_comment)
222  {
223  $r='<A HREF="#" tabindex="-1" style="display:inline;color:black;background-color:yellow;padding-left:4px;width:2em;padding-right:4px;text-decoration:none;" onmouseover="showBulle(\''.$p_comment.'\')" onclick="showBulle(\''.$p_comment.'\')" onmouseout="hideBulle(0)">?</A>';
224  return $r;
225  }
226  static function warnbulle($p_comment)
227  {
228  $r='<A HREF="#" tabindex="-1" style="display:inline;color:red;background-color:white;padding-left:4px;padding-right:4px;text-decoration:none;" onmouseover="showBulle(\''.$p_comment.'\')" onclick="showBulle(\''.$p_comment.'\')" onmouseout="hideBulle(0)">&Delta;</A>';
229  return $r;
230  }
231  /**
232  * return a string containing the html code for calling the modifyOperation
233  */
234  static function detail_op($p_jr_id,$p_mesg)
235  {
236  return sprintf('<A class="detail" style="text-decoration:underline;display:inline" HREF="javascript:modifyOperation(%d,%d)">%s</A>',
237  $p_jr_id,dossier::id(),$p_mesg);
238  }
239  /**
240  * @brief return an anchor to view the detail of an action
241  * @param $ag_id
242  * @param $p_mesg
243  * @param $p_modify let you modify an operation
244  *
245  */
246  static function detail_action($ag_id,$p_mesg,$p_modify=1)
247  {
248  return sprintf('<A class="detail" style="text-decoration:underline;display:inline" HREF="javascript:view_action(%d,%d,%d)">%s</A>',
249  $ag_id,dossier::id(),$p_modify,$p_mesg);
250  }
251  /**
252  * return a string containing the html code for calling the modifyModeleDocument
253  */
254  static function detail_modele_document($p_id,$p_mesg)
255  {
256  return sprintf('<A class="detail" style="text-decoration:underline" HREF="javascript:modifyModeleDocument(%d,%d)">%s</A>',
257  $p_id,dossier::id(),$p_mesg);
258  }
259 
260  /**
261  * return a string containing the html code for calling the removeStock
262  */
263  static function remove_stock($p_id,$p_mesg)
264  {
265  return sprintf('<A class="detail" style="text-decoration:underline" HREF="javascript:removeStock(%d,%d)">%s</A>',
266  $p_id,dossier::id(),$p_mesg);
267  }
268 
269  /**
270  * display a div with the history of the card
271  */
272  static function history_card($f_id,$p_mesg,$p_style="")
273  {
274  $view_history= sprintf('<A class="detail" style="text-decoration:underline;%s" HREF="javascript:view_history_card(\'%s\',\'%s\')" >%s</A>',
275  $p_style,$f_id, dossier::id(), $p_mesg);
276  return $view_history;
277  }
278  /**
279  * display a div with the history of the card
280  */
282  {
283  static $e=0;
284  $e++;
285  $js= sprintf('onclick="view_history_card(\'%s\',\'%s\')"',
286  $f_id, dossier::id());
288  return $view_history;
289  }
290 
291  /**
292  * display a div with the history of the account
293  */
294  static function history_account($p_account,$p_mesg,$p_style="")
295  {
296  $view_history= sprintf('<A class="detail" style="text-decoration:underline;%s" HREF="javascript:view_history_account(\'%s\',\'%s\')" >%s</A>',
297  $p_style,$p_account, dossier::id(), $p_mesg);
298  return $view_history;
299  }
300 
301  /**
302  * return the html code to create an hidden div and a button
303  * to show this DIV. This contains all the available ledgers
304  * for the user in READ or RW
305  *@param $selected is an array of checkbox
306  *@param $div div suffix
307  *@note the choosen ledger are stored in the array r_jrn (_GET)
308  */
309  static function select_ledger($p_type,$p_selected,$div='')
310  {
311  global $g_user;
312  $r = '';
313  /* security : filter ledger on user */
314  $p_array = $g_user->get_ledger($p_type, 3);
315 
316  ob_start();
317 
318 
319  /* create a hidden div for the ledger */
320  echo '<div id="div_jrn'.$div.'" >';
321  echo HtmlInput::title_box(_("Journaux"), $div."jrn_search");
322  echo '<div style="padding:5px">';
323  echo '<form method="GET" id="'.$div.'search_frm" onsubmit="return hide_ledger_choice(\''.$div.'search_frm\')">';
324  echo HtmlInput::hidden('nb_jrn', count($p_array));
325  echo _('Filtre ').HtmlInput::filter_table($div.'tb_jrn', '0,1,2', 2);
326  echo '<table class="result" id="'.$div.'tb_jrn">';
327  echo '<tr>';
328  echo th(_('Nom'));
329  echo th(_('Description'));
330  echo th(_('Type'));
331  echo '</tr>';
332  echo '<tr>';
333  echo '<td>';
334  echo HtmlInput::button('sel_'.$div,_('Inverser la sélection'),' onclick = "toggle_checkbox(\''."{$div}search_frm".'\')"');
335  echo '</td>';
336  echo '</tr>';
337  for ($e=0;$e<count($p_array);$e++)
338  {
339  $row=$p_array[$e];
340  $r=new ICheckBox($div.'r_jrn'.$e,$row['jrn_def_id']);
341  $idx=$row['jrn_def_id'];
342  if ( $p_selected != null && in_array($row['jrn_def_id'],$p_selected))
343  {
344  $r->selected=true;
345  }
346  $class=($e%2==0)?' class="even" ':' class="odd" ';
347  echo '<tr '.$class.'>';
348  echo '<td style="white-space: nowrap">'.$r->input().$row['jrn_def_name'].'</td>';
349  echo '<td >'.$row['jrn_def_description'].'</td>';
350  echo '<td >'.$row['jrn_def_type'].'</td>';
351  echo '</tr>';
352 
353  }
354  echo '</table>';
355  echo HtmlInput::hidden('div',$div);
356  echo HtmlInput::submit('save',_('Valider'));
357  echo HtmlInput::button_close($div."jrn_search");
358  echo '</form>';
359  echo '</div>';
360  echo '</div>';
361 
362  $ret=ob_get_contents();
363  ob_end_clean();
364  return $ret;
365  }
366  /**
367  *create a hidden plus button to select the cat of ledger
368  *@note the selected value is stored in the array p_cat
369  */
370  static function select_cat($array_cat)
371  {
372  ob_start();
373  $ledger=new ISmallButton('l');
374  $ledger->label=_("Catégorie");
375  $ledger->javascript=" show_cat_choice()";
376  echo $ledger->input();
377 
378  /* create a hidden div for the ledger */
379  echo '<div id="div_cat">';
380  echo '<h2 class="info">'._('Choix des categories').'</h2>';
381  $selected=(isset($_GET['r_cat']))?$_GET['r_cat']:null;
382 
383  echo '<ul>';
384  for ($e=0;$e<count($array_cat);$e++)
385  {
386  $row=$array_cat[$e];
387  $re=new ICheckBox('r_cat['.$e.']',$row['cat']);
388 
389  if ( $selected != null && isset($selected[$e]))
390  {
391  $re->selected=true;
392  }
393  echo '<li style="list-style-type: none;">'.$re->input().$row['name'].'('.$row['cat'].')</li>';
394 
395  }
396  echo '</ul>';
397  $hide=new IButton('l2');
398  $hide->label=_("Valider");
399  $hide->javascript=" hide_cat_choice() ";
400  echo $hide->input();
401 
402  echo '</div>';
403  $r=ob_get_contents();
404  ob_end_clean();
405  return $r;
406  }
407  static function display_periode($p_id)
408  {
409  $r=sprintf('<a href="javascript:void(0)" onclick="display_periode(%d,%d)">Modifier</a>',
410  dossier::id(),
411  $p_id);
412  return $r;
413  }
414  /**
415  *close button for the HTML popup
416  *@see add_div modify_operation
417  *@param $div_name is the name of the div to remove
418  */
419  static function button_close($div_name)
420  {
421  $a=new IButton('Fermer');
422  $a->label=_("Fermer");
423  $a->javascript="removeDiv('".$div_name."')";
424  $html=$a->input();
425 
426  return $html;
427 
428  }
429  /**
430  * @brief Hide the HTML popup
431  * @param type $div_name
432  * @return type
433  */
434  static function button_hide($div_name)
435  {
436  $a=new IButton('Fermer');
437  $a->label=_("Fermer");
438  $a->javascript="$('".$div_name."').hide()";
439  $html=$a->input();
440 
441  return $html;
442 
443  }
444  /**
445  * Return a html string with an anchor which close the inside popup. (top-right corner)
446  *@param name of the DIV to close
447  */
448  static function anchor_close($div,$p_js="")
449  {
450  $r='';
451  $r.='<div class="bxbutton">';
452  $r.= '<A id="close_div" class="input_text" onclick="removeDiv(\''.$div.'\');'.$p_js.'">&#10761;</A>';
453  $r.='</div>';
454  return $r;
455  }
456  /**
457  * button Html
458  *@param $action action action to perform (message) without onclick
459  *@param $javascript javascript to execute
460  */
461  static function button_action($action,$javascript,$id="xx",$p_class="button")
462  {
463  if ($id=="xx"){
464  $id=HtmlInput::generate_id("xx");
465  }
466  $r="";
467  $r.='<input type="button" id="'.$id.'" class="'.$p_class.'" onclick="'.$javascript.'" value="'.h($action).'">';
468  return $r;
469 
470  }
471  /**
472  * Image to click ,
473  * @param string $p_image filename of the image under image/
474  * @param string $p_js javascript when the image is clicked
475  * @param string $p_message Message
476  */
477  static function image_click($p_image,$p_js,$p_message)
478  {
479  $ret=sprintf('<a class="nav" style="display:inline" href="#" title="%s"><img src="image/%s" onclick="%s"></a>',
480  $p_message,$p_image,$p_js);
481  return $ret;
482 
483  }
484  /**
485  * button Html image
486  *@param $javascript javascript to execute
487  * @param $id id of the button
488  * @param $class class of the button
489  * @param $p_image image
490  */
491  static function button_image($javascript,$id="xx",$p_class='class="button"',$p_image="")
492  {
493  if ($id=="xx"){
494  $id=HtmlInput::generate_id("xx");
495  }
496  $r="";
497  $r.='<image id="'.$id.'" '.$p_class.' onclick="'.$javascript.'" src="'.$p_image.'" />';
498  return $r;
499 
500  }
501  /**
502  * Return a html string with an anchor to hide a div, put it in the right corner
503  *@param $action action action to perform (message)
504  *@param $javascript javascript
505  *@note not protected against html
506  *@see Acc_Ledger::display_search_form
507  */
508  static function anchor_hide($action,$javascript)
509  {
510  $r='';
511  $r.='<div style="position:absolute;margin:2px;right:2px">';
512  $r.= '<span id="close_div" class="input_text" onclick="'.$javascript.'">'.$action.'</span>';
513  $r.='</div>';
514  return $r;
515  }
516 
517  /**
518  * Javascript to print the current window
519  */
520  static function print_window()
521  {
522  $r='';
523  $r.=HtmlInput::button('print','Imprimer','onclick="window.print();"');
524  return $r;
525  }
526  /**
527  *show the detail of a card
528  */
529  static function card_detail($p_qcode,$pname='',$p_style="",$p_nohistory=false)
530  {
531  //if ($pname=='')$pname=$p_qcode;
532  $r="";
533  $histo=($p_nohistory==true)?' ,nohistory:1':"";
534  $r.=sprintf('<a href="javascript:void(0)" %s onclick="fill_ipopcard({qcode:\'%s\' %s})">%s [%s]</a>',
535  $p_style,$p_qcode,$histo,$pname,$p_qcode);
536  return $r;
537  }
538  /**
539  *transform request data to hidden
540  *@param $array is an of indices
541  *@param $request name of the superglobal $_POST $_GET $_REQUEST(default)
542  *@return html string with the hidden data
543  */
544  static function array_to_hidden($array,$global_array )
545  {
546 
547  $r="";
548 
549  if ( count($global_array )==0) return '';
550  foreach ($array as $a)
551  {
552  if (isset($global_array [$a]))
553  if (is_array($global_array[$a]) == false ) {
554  $r.=HtmlInput::hidden($a,$global_array [$a]);
555  } else {
556  if (count($global_array[$a]) > 0)
557  {
558  foreach ($global_array[$a] as $value)
559  {
560  $r.=HtmlInput::hidden($a."[]",$value);
561  }
562  }
563  }
564  }
565 
566  return $r;
567  }
568  /**
569  * @brief transform a json to hidden
570  * @param json $p_json
571  */
572  static function json_to_hidden($p_json)
573  {
574  $aJson=json_decode($p_json);
575  foreach($aJson as $key=>$value)
576  {
578  }
579  }
580  /**
581  *transform $_GET data to hidden
582  *@param $array is an of indices
583  *@see HtmlInput::request_to_hidden
584  *@return html string with the hidden data
585  */
586  static function get_to_hidden($array)
587  {
588  $r=self::array_to_hidden($array,$_GET );
589  return $r;
590  }
591 
592  /**
593  *transform $_POST data to hidden
594  *@param $array is an of indices
595  *@see HtmlInput::request_to_hidden
596  *@return html string with the hidden data
597  */
598  static function post_to_hidden($array)
599  {
600  $r=self::array_to_hidden($array,$_POST );
601  return $r;
602  }
603 
604  /**
605  *transform $_REQUEST data to hidden
606  *@param $array is an of indices
607  *@see HtmlInput::request_to_hidden
608  *@return html string with the hidden data
609  */
610  static function request_to_hidden($array)
611  {
612  $r=self::array_to_hidden($array,$_REQUEST );
613  return $r;
614  }
615 
616  /**
617  *transform request data to string
618  *@param $array is an of indices
619  *@param $request name of the superglobal $_POST $_GET $_REQUEST(default)
620  *@return html string with the string data
621  */
622  static function array_to_string($array,$global_array,$start="?" )
623  {
624 
625  $r=$start;
626 
627  if ( count($global_array )==0) return '';
628  $and="";
629  foreach ($array as $a)
630  {
631  if (isset($global_array [$a]))
632  {
633  if (is_array($global_array[$a]) == false ) {
634  $r.=$and."$a=".$global_array [$a];
635  } else {
636  for ($i=0;$i<count($global_array[$a]);$i++) {
637  $r.=$and."$a"."[]=".$global_array[$a][$i];
638  $and="&amp;";
639  }
640  }
641  }
642  $and="&amp;";
643  }
644 
645  return $r;
646  }
647  /**
648  *transform $_GET data to string
649  *@param $array is an of indices
650  *@see HtmlInput::request_to_string
651  *@return html string with the string data
652  */
653  static function get_to_string($array,$start="?")
654  {
655  $r=self::array_to_string($array,$_GET ,$start);
656  return $r;
657  }
658 
659  /**
660  *transform $_POST data to string
661  *@param $array is an of indices
662  *@see HtmlInput::request_to_string
663  *@return html string with the string data
664  */
665  static function post_to_string($array)
666  {
667  $r=self::array_to_string($array,$_POST );
668  return $r;
669  }
670 
671  /**
672  *transform $_REQUEST data to string
673  *@param $array is an of indices
674  *@see HtmlInput::request_to_string
675  *@return html string with the string data
676  */
677  static function request_to_string($array,$start="?")
678  {
679  $r=self::array_to_string($array,$_REQUEST,$start );
680  return $r;
681  }
682 
683  /**
684  * generate an unique id for a widget,
685  *@param $p_prefix prefix
686  *@see HtmlInput::IDate
687  *@return string with a unique id
688  */
689  static function generate_id($p_prefix)
690  {
691  $r=sprintf('%s_%d',$p_prefix,mt_rand(0,999999));
692  return $r;
693  }
694  /**
695  * return default if the value if the value doesn't exist in the array
696  *@param $ind the index to check
697  *@param $default the value to return
698  *@param $array the array
699  */
700  static function default_value($ind,$default,$array)
701  {
702  if ( ! isset($array[$ind]))
703  {
704  return $default;
705  }
706  return $array[$ind];
707  }
708  /**
709  * return default if the value if the value doesn't exist in $_GET
710  * @param $ind name of the variable
711  * @param type $default
712  * @return type
713  */
714  static function default_value_get($ind, $default)
715  {
716  if (!isset($_GET[$ind]))
717  {
718  return $default;
719  }
720  return $_GET[$ind];
721  }
722  /**
723  * return default if the value if the value doesn't exist in $_POST
724  * @param $ind name of the variable
725  * @param type $default
726  * @return type
727  */
728  static function default_value_post($ind, $default)
729  {
730  if (!isset($_POST[$ind]))
731  {
732  return $default;
733  }
734  return $_POST[$ind];
735  }
736  /**
737  * return default if the value if the value doesn't exist in $_REQUEST
738  * @param $ind name of the variable
739  * @param type $default
740  * @return type
741  */
742  static function default_value_request($ind, $default)
743  {
744  if (!isset($_REQUEST[$ind]))
745  {
746  return $default;
747  }
748  return $_REQUEST[$ind];
749  }
750  /**
751  * Title for boxes, you can customize the symbol thanks symbol with
752  * the mode "custom"
753  * @param type $name Title
754  * @param type $div element id, except for mode none or custom
755  * @param type $mod hide , close , zoom , custom or none, with
756  * custom , the $name contains all the code
757  * @param type $p_js contains the javascript with "custom" contains button + code
758  * @return type
759  */
760  static function title_box($name,$div,$mod="close",$p_js="")
761  {
762  if ($mod=='close') {$r=HtmlInput::anchor_close($div,$p_js); }else
763  if ($mod=='hide') {$r=HtmlInput::anchor_hide("&#10761;","$('$div').hide();$p_js");} else
764  if ($mod=='zoom') {$r='<span id="span_'.$div.'" style="float:right;margin-right:5px;padding-top:3px">'.HtmlInput::anchor("&#11036;","",$p_js,' name="small'.$div.'" id="close_div" class="input_text" ').'</span>'; } else
765  if ( $mod == 'custom') {$r='<span id="span_'.$div.'" style="float:right;margin-right:5px">'.$p_js."</span>";} else
766  if ( $mod == 'none') {$r="" ; }
767  else
768  die (__FILE__.":".__LINE__._('Paramètre invaide'));
769  $r.=h2($name,' class="title" ');
770  return $r;
771  }
772  /**
773  * @brief let you create only a link and set an id on it.
774  * After create a javascript for getting the event
775  * onclick = function() {...}
776  * @param type $p_text Text to display
777  * @param type $p_id id of the link
778  * @param type $type title of the link
779  * @code
780  * echo HtmlInput::anchor_empty('go','go_id');
781  * <script>$("go_id").onclick=function (e) { ...}</script>
782  * @endcode
783  */
784  static function anchor_empty($p_text,$p_id,$p_title="")
785  {
786  $p_url="javascript:void(0)";
787  $str=sprintf('<a id="%s" href="javascript:void(0)" class="line" title="%s">%s</a>',
788  $p_id,$p_title,$p_text);
789  return $str;
790  }
791  /**
792  *Return a simple anchor with a url or a javascript
793  * if $p_js is not null then p_url will be javascript:void(0)
794  * we don't add the event onclick. You must give p_url OR p_js
795  * default CSS class=line
796  * @param string $p_text text of the anchor
797  * @param string $p_url url
798  * @param string $p_js javascript
799  * @param string $p_style is the visuable effect (class, style...)
800  */
801  static function anchor($p_text,$p_url="",$p_js="",$p_style=' class="line" ')
802  {
803  if ($p_js != "")
804  {
805  $p_url="javascript:void(0)";
806  }
807 
808 
809  $str=sprintf('<a %s href="%s" %s>%s</a>',
810  $p_style,$p_url,$p_js,$p_text);
811  return $str;
812  }
813  /**
814  *Create an ISelect object containing the available repository for reading
815  * or writing
816  * @remark $g_user global.
817  *
818  * @param $p_cn db object
819  * @param $p_name name of the select
820  * @param $p_mode is 'R' for reading, 'W' for writinh
821  * @return ISelect
822  * @throws Exception if p_mode is wrong
823  */
824  static function select_stock( $p_cn, $p_name,$p_mode)
825  {
826  global $g_user;
827  if ( ! in_array($p_mode,array('R','W') ) )
828  {
829  throw new Exception (__FILE__.":".__LINE__." $p_mode invalide");
830  }
831  $profile=$g_user->get_profile();
832  $sel=new ISelect($p_name);
833 
834  if ($p_mode == 'W')
835  {
836  $sel->value=$p_cn->make_array("
837  select r_id,r_name
838  from stock_repository join profile_sec_repository using (r_id)
839  where
840  ur_right='W' and p_id=".sql_string($profile).
841  " order by 2" );
842  return $sel;
843  }
844  if ($p_mode == 'R')
845  {
846  $sel->value=$p_cn->make_array("
847  select r_id,r_name
848  from stock_repository join profile_sec_repository using (r_id)
849  where
850  p_id=".sql_string($profile).
851  " order by 2" );
852  return $sel;
853  }
854  }
855  static function filter_table_form($p_table_id,$p_col,$start_row,$p_name,$p_old_value)
856  {
857  $r= "
858  <span>
859  <input id=\"lk_".$p_table_id."\" name=\"$p_name\" value=\"$p_old_value\"autocomplete=\"off\" class=\"input_text\" name=\"filter\" onkeyup=\"filter_table(this, '$p_table_id','$p_col',$start_row )\" type=\"text\">
860  <input type=\"button\" class=\"smallbutton\" onclick=\"$('lk_".$p_table_id."').value='';filter_table($('lk_".$p_table_id."'), '$p_table_id','$p_col',$start_row );\" value=\"X\">
861  </span>
862  ";
863  $r.=' <span class="notice" id="info_'.$p_table_id.'"></span>';
864  return $r;
865  }
866  static function filter_table($p_table_id,$p_col,$start_row)
867  {
868  $r= "
869  <span>
870  <input id=\"lk_".$p_table_id."\" autocomplete=\"off\" class=\"input_text\" name=\"filter\" onkeyup=\"filter_table(this, '$p_table_id','$p_col',$start_row )\" type=\"text\">
871  <input type=\"button\" class=\"smallbutton\" onclick=\"$('lk_".$p_table_id."').value='';filter_table($('lk_".$p_table_id."'), '$p_table_id','$p_col',$start_row );\" value=\"X\">
872  </span>
873  ";
874  $r.=' <span class="notice" id="info_'.$p_table_id.'"></span>';
875  return $r;
876  }
877 
878  static function show_reconcile($p_div, $let,$span="")
879  {
880  $r = '<A style="color:red;text-decoration:underline" href="javascript:void(0)" onclick="show_reconcile(\'' . $p_div . '\',\'' . $let . '\')">' . $let.$span . '</A>';
881  return $r;
882  }
883  /**
884  * Zoom the calendar
885  * @param type $obj objet json for the javascript
886  * @see calendar_zoom in scripts.js
887  */
888  static function calendar_zoom($obj)
889  {
890  $button=new ISmallButton("calendar", _("Calendrier"));
891  $button->javascript="calendar_zoom($obj)";
892  return $button->input();
893  }
894  /**
895  *
896  * @param type $p_array indice
897  * - div div name
898  * - type ALL, VEN, ACH or ODS
899  * - all_type 1 yes 0 no
900  *
901  */
902  static function button_choice_ledger($p_array)
903  {
904  extract ($p_array, EXTR_SKIP);
905  $bledger_param = json_encode(array(
906  'dossier' => $_REQUEST['gDossier'],
907  'type' => $type,
908  'all_type' => $all_type,
909  'div' => $div,
910  'class'=>'inner_box'
911  ));
912 
913  $bledger_param = str_replace('"', "'", $bledger_param);
914  $bledger = new ISmallButton('l');
915  $bledger->label = _("choix des journaux");
916  $bledger->javascript = " show_ledger_choice($bledger_param)";
917  $f_ledger = $bledger->input();
918  $hid_jrn = "";
919  if (isset($_REQUEST[$div . 'nb_jrn']))
920  {
921  for ($i = 0; $i < $_REQUEST[$div . 'nb_jrn']; $i++)
922  {
923  if (isset($_REQUEST[$div . "r_jrn"][$i]))
924  $hid_jrn.=HtmlInput::hidden($div . 'r_jrn[' . $i . ']', $_REQUEST[$div . "r_jrn"][$i]);
925  }
926  $hid_jrn.=HtmlInput::hidden($div . 'nb_jrn', $_REQUEST[$div . 'nb_jrn']);
927  } else
928  {
929  $hid_jrn = HtmlInput::hidden($div . 'nb_jrn', 0);
930  }
931  echo $f_ledger;
932  echo '<span id="ledger_id' . $div . '">';
933  echo $hid_jrn;
934  echo '</span>';
935  }
936  /**
937  * @brief Returns HTML code for displaying a icon with a link to a receipt document from
938  * the ledger
939  * @param $p_jr_id jrn.jr_id
940  * @param $p_name name in the link , if the name is empty then we show the icon
941  * @return nothing or HTML Code for a link to the document
942  */
943  static function show_receipt_document($p_jr_id,$p_name="")
944  {
945  global $cn;
946  $image=$p_name;
947 
948  // Check the jr_id has a receipt document
949  $array=$cn->get_array('select jr_def_id,jr_pj_name,jr_grpt_id from jrn where jr_id=$1',array($p_jr_id));
950  if (count($array)==0) return "";
951  if ($array[0]['jr_pj_name'] == "") return "";
952  $str_dossier=Dossier::get();
953 
954  // Name is empty then use an image
955  if ( $p_name == "") {
956  $image='<IMG style="width:24px;height:24px;border:0px" SRC="image/documents.png" title="' . h($array[0]['jr_pj_name']) . '" >';
957  }
958 
959  // Build the url
960  $href=http_build_query(array('gDossier'=>Dossier::id(),'jr_id'=>$p_jr_id,'act'=>'RAW:receipt'));
961 
962  $r=sprintf('<A class="mtitle line" HREF="export.php?%s">%s</A>', $href, $image);
963  return $r;
964 
965  }
966  /**
967  *
968  * @param type $p_operation_jr_id action_gestion_operation.ago_id
969  */
970  static function button_action_remove_operation($p_operation)
971  {
972  $rmOperation=sprintf("javascript:confirm_box(null,'"._('Voulez-vous effacer cette relation ')."',function () {remove_operation('%s','%s');});",
973  dossier::id(),
974  $p_operation);
975  $js= '<a class="tinybutton" id="acop'.$p_operation.'" href="javascript:void(0)" onclick="'.$rmOperation.'">'.SMALLX.'</a>';
976  return $js;
977  }
978  static function button_action_add_concerned_card($p_agid)
979  {
980  $dossier=Dossier::id();
981  $javascript= <<<EOF
982  obj={dossier:$dossier,ag_id:$p_agid};action_add_concerned_card(obj);
983 EOF;
984  $js=HtmlInput::button_action(_('Ajout autres'), $javascript,'xx','smallbutton');
985  return $js;
986  }
987  static function button_action_add()
988  {
989  $dossier=Dossier::id();
990  $js=HtmlInput::button_action(_('Nouvel événement'),'action_add('.$dossier.')','xx','smallbutton');
991  return $js;
992  }
993 }
$_GET['qcode']
function window
Definition: smoke.js:7
function confirm_box(p_obj, p_message, p_callback_true)
Confirm a form thanks a modal dialog Box, it returns true if we agree otherwise false.
Definition: scripts.js:2885
$_POST['ac']
Definition: do.php:279
$str
Definition: fiche.inc.php:97
$opd_description style
static json_to_hidden($p_json)
transform a json to hidden
static default_value_post($ind, $default)
return default if the value if the value doesn't exist in $_POST
static filter_table_form($p_table_id, $p_col, $start_row, $p_name, $p_old_value)
function view_history_card(p_value, dossier)
Change the view of card history.
Definition: acc_ledger.js:723
static anchor($p_text, $p_url="", $p_js="", $p_style='class="line" ')
Return a simple anchor with a url or a javascript if $p_js is not null then p_url will be javascript:...
sql_string($p_string)
Fix the problem with the quote char for the database.
Definition: ac_common.php:457
function show_cat_choice()
show the cat of ledger choice
Definition: scripts.js:950
static infobulle($p_comment)
__construct($p_name="", $p_value="", $p_id="")
static anchor_close($div, $p_js="")
Return a html string with an anchor which close the inside popup.
margin left
h2($p_string, $p_class="", $raw="")
Definition: ac_common.php:68
th($p_string, $p_extra='', $raw='')
Definition: ac_common.php:58
$p_mesg
Definition: opening.inc.php:35
$all disabled
get_js_attr()
you can add attribute to this in javascript this function is a wrapper and create a script (in js) to...
static history_card_button($f_id, $p_mesg)
display a div with the history of the card
make_object_deprecated($p_name=null)
Make a JSON object, this method create a javascript object with the attribute set, it returns a javascript string with the object.
for($i=0;$i< count($a);$i++)
function show_ledger_choice(json_obj)
show the ledger choice
Definition: scripts.js:845
$p_url
function modifyModeleDocument(p_value, dossier)
static history_account($p_account, $p_mesg, $p_style="")
display a div with the history of the account
$ret javascript
set_attribute($p_name, $p_value)
set the extra javascript property for the INPUT field
static display_periode($p_id)
static request_to_hidden($array)
transform $_REQUEST data to hidden
$histo
Definition: fiche.inc.php:61
static title_box($name, $div, $mod="close", $p_js="")
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static button($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
function modifyOperation(p_value, dossier)
Show the details of an operation.
Definition: acc_ledger.js:845
if(!defined('ALLOWED'))
if($show_row!=0) margin right
for($e=0;$e< count($array);$e++) $desc readOnly
function hideBulle(p_ctl)
Definition: infobulle.js:50
static anchor_hide($action, $javascript)
Return a html string with an anchor to hide a div, put it in the right corner.
static array_to_string($array, $global_array, $start="?")
transform request data to string
function removeDiv(elt)
remove a object created with add_div
Definition: scripts.js:714
function showBulle(p_ctl)
Definition: infobulle.js:30
$div
function view_action(ag_id, dossier, modify)
Definition: scripts.js:2019
$name size
static post_to_hidden($array)
transform $_POST data to hidden
$desc heigh
static select_stock($p_cn, $p_name, $p_mode)
Create an ISelect object containing the available repository for reading or writing.
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Calendar prototype hide
Hides the calendar.
Definition: calendar.js:1349
static filter_table($p_table_id, $p_col, $start_row)
$poste extra
static post_to_string($array)
transform $_POST data to string
global $g_user
Find the default module or the first one.
Definition: action.inc.php:24
$from_poste name
static button_anchor($p_label, $p_value, $p_name="", $p_javascript="", $p_class="button")
create a button with a ref
setReadOnly($p_read)
static array_to_hidden($array, $global_array)
transform request data to hidden
if(!$inner) display
$_REQUEST['ac']
if(!isset($_REQUEST['p_jrn'])) else $Ledger id
if($zoom==1) height
Definition: calendar.php:14
if($q[$e]['j_qcode']!= '') else $view_history
function hide_cat_choice()
hide the cat of ledger choice
Definition: scripts.js:957
static reset($p_value)
static get_to_string($array, $start="?")
transform $_GET data to string
static calendar_zoom($obj)
Zoom the calendar.
if(defined("RECOVER")) position
Definition: index.php:324
$input_from type
Definition: balance.inc.php:70
static anchor_empty($p_text, $p_id, $p_title="")
let you create only a link and set an id on it.
static default_value_get($ind, $default)
return default if the value if the value doesn't exist in $_GET
function remove_operation(p_dossier, p_id)
remove the concerned operation of an action
Definition: gestion.js:90
static request_to_string($array, $start="?")
transform $_REQUEST data to string
for($i=0;$i<=6;$i++) $ind
Definition: calendar.php:29
class widget This class is used to create all the HTML INPUT TYPE and some specials which works with ...
background color
Definition: index.php:328
static select_ledger($p_type, $p_selected, $div='')
return the html code to create an hidden div and a button to show this DIV.
function removeStock(s_id, p_dossier)
remove an attached document of an action
Definition: gestion.js:248
static default_value($ind, $default, $array)
return default if the value if the value doesn't exist in the array
static generate_id($p_prefix)
generate an unique id for a widget,
static extension()
$select_type table
function fill_ipopcard(obj)
show the ipopup window and display the details of a card, to work some attribute must be set ...
Definition: card.js:435
static hidden($p_name, $p_value, $p_id="")
static get_to_hidden($array)
transform $_GET data to hidden
$me_code selected
static default_value_request($ind, $default)
return default if the value if the value doesn't exist in $_REQUEST
create_script($p_string)
create the HTML for adding the script tags around of the script
$desc width
if(count($last_operation)>0) text decoration
Definition: dashboard.php:57
static show_reconcile($p_div, $let, $span="")
$obj