* Copyright (C) 2007-2012 Regis Houssin * * This program 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. * * This program 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 this program. If not, see . * or see http://www.gnu.org/ */ /** * \file htdocs/core/lib/ajax.lib.php * \brief Page called by Ajax request for produts */ /** * Get value of an HTML field, do Ajax process and show result * * @param string $selected Preselecte value * @param string $htmlname HTML name of input field * @param string $url Url for request: /chemin/fichier.php * @param string $option More parameters on URL request * @param int $minLength Minimum number of chars to trigger that Ajax search * @param int $autoselect Automatic selection if just one value * @return string Script */ function ajax_autocompleter($selected,$htmlname,$url,$option='',$minLength=2,$autoselect=0) { if (empty($minLength)) $minLength=1; $script = ''; $script.= ''; return $script; } /** * Get value of field, do Ajax process and return result * * @param string $htmlname Name of field * @param string $fields other fields to autocomplete * @param string $url Chemin du fichier de reponse : /chemin/fichier.php * @param string $option More parameters on URL request * @param int $minLength Minimum number of chars to trigger that Ajax search * @param int $autoselect Automatic selection if just one value * @return string Script */ function ajax_multiautocompleter($htmlname,$fields,$url,$option='',$minLength=2,$autoselect=0) { $script = ''."\n"; $script.= ''; return $script; } /** * Show an ajax dialog * * @param string $title Title of dialog box * @param string $message Message of dialog box * @param int $w Width of dialog box * @param int $h height of dialog box * @return void */ function ajax_dialog($title,$message,$w=350,$h=150) { global $langs; $msg.= '
'; $msg.= $message; $msg.= '
'."\n"; $msg.= ''; $msg.= "\n"; return $msg; } /** * Convert a select html field into an ajax combobox * * @param string $htmlname Name of html field * @return string Return html string to convert a select field into a combo */ function ajax_combobox($htmlname) { $msg.= ''; $msg.= "\n"; return $msg; } /** * On/off button for constant * * @param string $code Name of constant * @param array $input Input element * @param int $entity Entity to set * @return void */ function ajax_constantonoff($code,$input=array(),$entity=false) { global $conf, $langs; $entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity); $out= ''; $out.= ''.img_picto($langs->trans("Disabled"),'switch_off').''; $out.= ''.img_picto($langs->trans("Enabled"),'switch_on').''; return $out; } ?>