Make code easier to understand
This commit is contained in:
parent
119f6d79dc
commit
783a66b4fc
@ -822,7 +822,7 @@ class Form
|
|||||||
/**
|
/**
|
||||||
* \brief Return list of products for customer in Ajax if Ajax activated or go to select_produits_do
|
* \brief Return list of products for customer in Ajax if Ajax activated or go to select_produits_do
|
||||||
* \param selected Preselected products
|
* \param selected Preselected products
|
||||||
* \param htmlname Name of HTML select
|
* \param htmlname Name of HTML seletc field (must be unique in page)
|
||||||
* \param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
|
* \param filtertype Filter on product type (''=nofilter, 0=product, 1=service)
|
||||||
* \param limit Limit sur le nombre de lignes retournees
|
* \param limit Limit sur le nombre de lignes retournees
|
||||||
* \param price_level Level of price to show
|
* \param price_level Level of price to show
|
||||||
@ -837,11 +837,11 @@ class Form
|
|||||||
{
|
{
|
||||||
if ($conf->global->MAIN_USE_JQUERY)
|
if ($conf->global->MAIN_USE_JQUERY)
|
||||||
{
|
{
|
||||||
print ajax_autocompleter2('','keysearch',DOL_URL_ROOT.'/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished,'');
|
print ajax_autocompleter2('',$htmlname,DOL_URL_ROOT.'/product/ajaxproducts.php','&price_level='.$price_level.'&type='.$filtertype.'&mode=1&status='.$status.'&finished='.$finished,'');
|
||||||
|
|
||||||
print '<div class="ui-widget">';
|
print '<div class="ui-widget">';
|
||||||
print '<label for="birds">'.$langs->trans("RefOrLabel").':</label>';
|
print '<label for="'.$htmlname.'">'.$langs->trans("RefOrLabel").':</label>';
|
||||||
print '<input id="birds" />';
|
print '<input id="'.$htmlname.'" />';
|
||||||
print '</div>';
|
print '</div>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -937,33 +937,35 @@ class Form
|
|||||||
$sql.= $db->order("p.ref");
|
$sql.= $db->order("p.ref");
|
||||||
$sql.= $db->plimit($limit);
|
$sql.= $db->plimit($limit);
|
||||||
|
|
||||||
|
|
||||||
|
// Build output string
|
||||||
|
$outselect='';
|
||||||
|
$outjson='';
|
||||||
|
|
||||||
dol_syslog("Form::select_produits_do search product sql=".$sql, LOG_DEBUG);
|
dol_syslog("Form::select_produits_do search product sql=".$sql, LOG_DEBUG);
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
if (! $result) dol_print_error($this->db);
|
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
|
|
||||||
|
$outselect.='<select class="flat" name="'.$htmlname.'"';
|
||||||
|
if ($conf->use_javascript_ajax && $num && $conf->global->PRODUIT_USE_SEARCH_TO_SELECT) $outselect.=' onchange="publish_selvalue(this);"';
|
||||||
|
$outselect.='>';
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
if (! $num)
|
if (! $num)
|
||||||
{
|
{
|
||||||
print '<select class="flat" name="'.$htmlname.'">';
|
$outselect.='<option value="0">-- '.$langs->trans("NoProductMatching").' --</option>';
|
||||||
print '<option value="0">-- '.$langs->trans("NoProductMatching").' --</option>';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<select class="flat" name="'.$htmlname.'"';
|
$outselect.='<option value="0" selected="true">-- '.$langs->trans("MatchingProducts").' --</option>';
|
||||||
if ($conf->global->PRODUIT_USE_SEARCH_TO_SELECT) print ' onchange="publish_selvalue(this);"';
|
|
||||||
print '>';
|
|
||||||
print '<option value="0" selected="true">-- '.$langs->trans("MatchingProducts").' --</option>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<select class="flat" name="'.$htmlname.'">';
|
$outselect.='<option value="0" selected="true"> </option>';
|
||||||
print '<option value="0" selected="true"> </option>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -1054,13 +1056,15 @@ class Form
|
|||||||
}
|
}
|
||||||
|
|
||||||
$opt.= "</option>\n";
|
$opt.= "</option>\n";
|
||||||
print $opt;
|
$outselect.=$opt;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
print '</select>';
|
$outselect.='</select>';
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|
||||||
|
print $outselect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -1129,6 +1133,10 @@ class Form
|
|||||||
}
|
}
|
||||||
$sql.= " ORDER BY pf.ref_fourn DESC";
|
$sql.= " ORDER BY pf.ref_fourn DESC";
|
||||||
|
|
||||||
|
// Build output string
|
||||||
|
$outselect='';
|
||||||
|
$outjson='';
|
||||||
|
|
||||||
dol_syslog("Form::select_produits_fournisseurs_do sql=".$sql,LOG_DEBUG);
|
dol_syslog("Form::select_produits_fournisseurs_do sql=".$sql,LOG_DEBUG);
|
||||||
$result=$this->db->query($sql);
|
$result=$this->db->query($sql);
|
||||||
if ($result)
|
if ($result)
|
||||||
@ -1136,24 +1144,25 @@ class Form
|
|||||||
|
|
||||||
$num = $this->db->num_rows($result);
|
$num = $this->db->num_rows($result);
|
||||||
|
|
||||||
|
$outselect.='<select class="flat" name="'.$htmlname.'"';
|
||||||
|
if ($conf->use_javascript_ajax && $num) $outselect.=' onchange="publish_selvalue(this);"';
|
||||||
|
$outselect.='>';
|
||||||
|
|
||||||
if ($conf->use_javascript_ajax)
|
if ($conf->use_javascript_ajax)
|
||||||
{
|
{
|
||||||
if (! $num)
|
if (! $num)
|
||||||
{
|
{
|
||||||
print '<select class="flat" name="'.$htmlname.'">';
|
$outselect.='<option value="0">-- '.$langs->trans("NoProductMatching").' --</option>';
|
||||||
print '<option value="0">-- '.$langs->trans("NoProductMatching").' --</option>';
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<select class="flat" name="'.$htmlname.'" onchange="publish_selvalue(this);">';
|
$outselect.='<option value="0" selected="true">-- '.$langs->trans("MatchingProducts").' --</option>';
|
||||||
print '<option value="0" selected="true">-- '.$langs->trans("MatchingProducts").' --</option>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<select class="flat" name="'.$htmlname.'">';
|
if (! $selected) $outselect.='<option value="0" selected="true"> </option>';
|
||||||
if (! $selected) print '<option value="0" selected="true"> </option>';
|
else $outselect.='<option value="0"> </option>';
|
||||||
else print '<option value="0"> </option>';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
@ -1196,12 +1205,15 @@ class Form
|
|||||||
}
|
}
|
||||||
$opt .= "</option>\n";
|
$opt .= "</option>\n";
|
||||||
|
|
||||||
print $opt;
|
$outselect.=$opt;
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
print '</select>';
|
$outselect.='</select>';
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
|
|
||||||
|
print $outselect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -147,9 +147,11 @@ function ajax_autocompleter($selected='',$htmlname,$url,$indicator='working')
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Get value of field, do Ajax process and return result
|
* \brief Get value of field, do Ajax process and return result. Use jQuery.
|
||||||
* \param htmlname nom et id du champ
|
* \param selected Preselected value
|
||||||
* \param url chemin du fichier de reponse : /chemin/fichier.php
|
* \param htmlname Name of html field
|
||||||
|
* \param url Path of source file to get values: /path/ajaxpage.php
|
||||||
|
* \param option Not used
|
||||||
* \return string script complet
|
* \return string script complet
|
||||||
*/
|
*/
|
||||||
function ajax_autocompleter2($selected='', $htmlname, $url, $option='')
|
function ajax_autocompleter2($selected='', $htmlname, $url, $option='')
|
||||||
@ -157,15 +159,20 @@ function ajax_autocompleter2($selected='', $htmlname, $url, $option='')
|
|||||||
$script = '<input type="hidden" name="'.$htmlname.'_id" id="'.$htmlname.'_id" value="'.$selected.'" />';
|
$script = '<input type="hidden" name="'.$htmlname.'_id" id="'.$htmlname.'_id" value="'.$selected.'" />';
|
||||||
|
|
||||||
$script.= '<script type="text/javascript">';
|
$script.= '<script type="text/javascript">';
|
||||||
$script.= '$(function() {
|
$script.= 'jQuery(function() {
|
||||||
$("#birds").autocomplete({
|
jQuery("input#'.$htmlname.'").autocomplete({
|
||||||
source: "'.$url.'",
|
source: "'.$url.($option?'?'.$option:'').'",
|
||||||
minLength: 2,
|
delay: 300,
|
||||||
extraParams: {
|
minLength: 1,
|
||||||
'.$htmlname.': function() { return $("#birds").val(); }
|
select: function(event, ui) {
|
||||||
|
alert(\'ee\');
|
||||||
|
jQuery("#state_id").val(ui.item.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});';
|
});';
|
||||||
|
// source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"],
|
||||||
|
|
||||||
|
|
||||||
$script.= '</script>';
|
$script.= '</script>';
|
||||||
|
|
||||||
return $script;
|
return $script;
|
||||||
|
|||||||
@ -24,19 +24,16 @@
|
|||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
|
||||||
//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
|
||||||
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
|
||||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
|
||||||
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
|
|
||||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
|
|
||||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||||
if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||||
if (! defined("NOLOGIN")) define("NOLOGIN",'1');
|
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||||
|
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
|
||||||
|
if (empty($_GET['keysearch']) && ! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||||
|
|
||||||
require('../main.inc.php');
|
require('../main.inc.php');
|
||||||
|
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php');
|
||||||
|
|
||||||
$langs->load("products");
|
$langs->load("products");
|
||||||
$langs->load("main");
|
$langs->load("main");
|
||||||
@ -46,6 +43,12 @@ $langs->load("main");
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Ajout directives pour resoudre bug IE
|
||||||
|
//header('Cache-Control: Public, must-revalidate');
|
||||||
|
//header('Pragma: public');
|
||||||
|
|
||||||
|
//print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||||
|
|
||||||
//top_htmlhead("", "", 1); // Disabled. An ajax return must not include html header.
|
//top_htmlhead("", "", 1); // Disabled. An ajax return must not include html header.
|
||||||
|
|
||||||
//print '<body class="nocellnopadd">'."\n";
|
//print '<body class="nocellnopadd">'."\n";
|
||||||
|
|||||||
@ -25,13 +25,12 @@
|
|||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
|
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
|
||||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||||
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||||
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
|
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
|
||||||
if (! defined("NOLOGIN")) define("NOLOGIN",'1');
|
|
||||||
|
|
||||||
require('../main.inc.php');
|
require('../main.inc.php');
|
||||||
|
|
||||||
@ -40,6 +39,12 @@ require('../main.inc.php');
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Ajout directives pour resoudre bug IE
|
||||||
|
header('Cache-Control: Public, must-revalidate');
|
||||||
|
header('Pragma: public');
|
||||||
|
|
||||||
|
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||||
|
|
||||||
//top_htmlhead("", "", 1, 1); // Disabled. An ajax return must not include html header.
|
//top_htmlhead("", "", 1, 1); // Disabled. An ajax return must not include html header.
|
||||||
|
|
||||||
//print '<body id="mainbody">';
|
//print '<body id="mainbody">';
|
||||||
|
|||||||
@ -23,11 +23,12 @@
|
|||||||
* \version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal
|
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL',1); // Disables token renewal
|
||||||
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||||
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||||
|
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
|
||||||
|
|
||||||
require('../main.inc.php');
|
require('../main.inc.php');
|
||||||
|
|
||||||
@ -36,6 +37,12 @@ require('../main.inc.php');
|
|||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Ajout directives pour resoudre bug IE
|
||||||
|
header('Cache-Control: Public, must-revalidate');
|
||||||
|
header('Pragma: public');
|
||||||
|
|
||||||
|
print '<!-- Ajax page called with url '.$_SERVER["PHP_SELF"].'?'.$_SERVER["QUERY_STRING"].' -->'."\n";
|
||||||
|
|
||||||
//top_htmlhead("", "", 1, 1); // Disabled. An ajax return must not include html header.
|
//top_htmlhead("", "", 1, 1); // Disabled. An ajax return must not include html header.
|
||||||
|
|
||||||
//print '<body id="mainbody">';
|
//print '<body id="mainbody">';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user