Fix: search company with jQuery - ok

This commit is contained in:
Regis Houssin
2010-10-10 18:04:28 +00:00
parent 4d4c4a8bed
commit a58ae14d8f
10 changed files with 3 additions and 105 deletions

View File

@@ -40,13 +40,6 @@ $langs->load("members");
$langs->load("users"); $langs->load("users");
$langs->load("mails"); $langs->load("mails");
// If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id']))
{
$_GET['socid'] = $_GET['socid_id'];
$_POST['socid'] = $_POST['socid_id'];
$_REQUEST['socid'] = $_REQUEST['socid_id'];
}
// Security check // Security check
if (! $user->rights->adherent->cotisation->lire) accessforbidden(); if (! $user->rights->adherent->cotisation->lire) accessforbidden();

View File

@@ -42,14 +42,6 @@ $langs->load("bills");
$langs->load("members"); $langs->load("members");
$langs->load("users"); $langs->load("users");
// If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id']))
{
$_GET['socid'] = $_GET['socid_id'];
$_POST['socid'] = $_POST['socid_id'];
$_REQUEST['socid'] = $_REQUEST['socid_id'];
}
// Security check // Security check
if (! $user->rights->adherent->lire) accessforbidden(); if (! $user->rights->adherent->lire) accessforbidden();

View File

@@ -29,13 +29,6 @@
require("../main.inc.php"); require("../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
// If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id']))
{
$_GET['socid'] = $_GET['socid_id'];
$_POST['socid'] = $_POST['socid_id'];
$_REQUEST['socid'] = $_REQUEST['socid_id'];
}
// Security check // Security check
if (!$user->rights->categorie->lire) if (!$user->rights->categorie->lire)

View File

@@ -31,13 +31,6 @@ require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php");
$langs->load("categories"); $langs->load("categories");
// If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id']))
{
$_GET['socid'] = $_GET['socid_id'];
$_POST['socid'] = $_POST['socid_id'];
$_REQUEST['socid'] = $_REQUEST['socid_id'];
}
// Security check // Security check
$socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid']; $socid=isset($_GET['socid'])?$_GET['socid']:$_POST['socid'];

View File

@@ -35,13 +35,6 @@ if ($conf->projet->enabled)
$langs->load("trips"); $langs->load("trips");
// If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id']))
{
$_GET['socid'] = $_GET['socid_id'];
$_POST['socid'] = $_POST['socid_id'];
$_REQUEST['socid'] = $_REQUEST['socid_id'];
}
// Security check // Security check
$id=isset($_GET["id"])?$_GET["id"]:$_POST["id"]; $id=isset($_GET["id"])?$_GET["id"]:$_POST["id"];

View File

@@ -40,14 +40,6 @@ $langs->load("users");
$errors = array(); $errors = array();
$socid=$_GET["socid"]?$_GET["socid"]:$_POST["socid"]; $socid=$_GET["socid"]?$_GET["socid"]:$_POST["socid"];
// If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id']))
{
$socid = $_GET['socid'] = $_GET['socid_id'];
$socid = $_POST['socid'] = $_POST['socid_id'];
$socid = $_REQUEST['socid'] = $_REQUEST['socid_id'];
}
// Security check // Security check
$contactid = isset($_GET["id"])?$_GET["id"]:''; $contactid = isset($_GET["id"])?$_GET["id"]:'';
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;

View File

@@ -37,13 +37,6 @@ require_once(DOL_DOCUMENT_ROOT.'/lib/fourn.lib.php');
require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php'); require_once(DOL_DOCUMENT_ROOT.'/product/class/product.class.php');
if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT.'/projet/class/project.class.php');
// If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id']))
{
$_GET['socid'] = $_GET['socid_id'];
$_POST['socid'] = $_POST['socid_id'];
$_REQUEST['socid'] = $_REQUEST['socid_id'];
}
$langs->load('bills'); $langs->load('bills');
$langs->load('suppliers'); $langs->load('suppliers');

View File

@@ -86,7 +86,6 @@ function ajax_autocompleter($selected='',$htmlname,$valname,$url)
$script.= '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />'; $script.= '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />';
//$script.= '<div id="'.$htmlname.'" class="ui-widget"></div>';
$script.= '<script type="text/javascript">'; $script.= '<script type="text/javascript">';
$script.= 'jQuery(document).ready(function() { $script.= 'jQuery(document).ready(function() {
jQuery("input#search_'.$htmlname.'").autocomplete({ jQuery("input#search_'.$htmlname.'").autocomplete({
@@ -104,48 +103,6 @@ function ajax_autocompleter($selected='',$htmlname,$valname,$url)
} }
}); });
});'; });';
/*
$script.= 'new Ajax.Autocompleter(\''.$htmlname.'\',\'result'.$htmlname.'\',\''.$url.'\',{
method: \'post\',
paramName: \'socid\',
minChars: \'1\',
indicator: \'indicator'.$htmlname.'\',
afterUpdateElement: ac_return
});'; // paramName must be 'socid', as it is the name of POST parameter to send value in htmlname field.
// and it is name of parameter read by ajaxcompanies.php
// Note: The ac_return will fill value inside field htmlname (param of Autocompleter constructor)
// and will also fill value inside field htmlname_id (using function ac_return)*/
$script.= '</script>';
return $script;
}
/**
* \brief Get value of field, do Ajax process and return result. Use jQuery.
* \param selected Preselected value
* \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
*/
function ajax_autocompleter2($selected='', $htmlname, $url, $option='')
{
$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" />';
$script.= '<script type="text/javascript">';
$script.= 'jQuery(function() {
jQuery("input#'.$htmlname.'free").autocomplete({
source: "'.$url.($option?'?'.$option:'').'",
delay: 300,
minLength: 1,
select: function(event, ui) {
/* jQuery("#'.$htmlname.'free") is automatically affected with ui.item.key */
/* jQuery("#'.$htmlname.'free").val(ui.item.fulltext); */
jQuery("#'.$htmlname.'").val(ui.item.key);
/* alert(ui.item.key); */
}
});
});';
$script.= '</script>'; $script.= '</script>';
return $script; return $script;

View File

@@ -37,14 +37,6 @@ $langs->load('companies');
$projectid = (isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:'')); $projectid = (isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:''));
$projectref = (isset($_GET["ref"])?$_GET["ref"]:''); $projectref = (isset($_GET["ref"])?$_GET["ref"]:'');
// If socid provided by ajax company selector
if (! empty($_REQUEST['socid_id']))
{
$_GET['socid'] = $_GET['socid_id'];
$_POST['socid'] = $_POST['socid_id'];
$_REQUEST['socid'] = $_REQUEST['socid_id'];
}
if ($projectid == '' && $projectref == '' && ($_GET['action'] != "create" && $_POST['action'] != "add" && $_POST["action"] != "update" && !$_POST["cancel"])) accessforbidden(); if ($projectid == '' && $projectref == '' && ($_GET['action'] != "create" && $_POST['action'] != "add" && $_POST["action"] != "update" && !$_POST["cancel"])) accessforbidden();
$mine = $_REQUEST['mode']=='mine' ? 1 : 0; $mine = $_REQUEST['mode']=='mine' ? 1 : 0;

View File

@@ -52,14 +52,14 @@ dol_syslog(join(',',$_GET));
// Generation liste des societes // Generation liste des societes
if (! empty($_POST['newcompany']) || ! empty($_GET['socid']) || ! empty($_POST['id_fourn'])) if (! empty($_GET['newcompany']) || ! empty($_GET['socid']) || ! empty($_GET['id_fourn']))
{ {
$return_arr = array(); $return_arr = array();
// Define filter on text typed // Define filter on text typed
$socid = $_POST['newcompany']?$_POST['newcompany']:''; $socid = $_GET['newcompany']?$_GET['newcompany']:'';
if (! $socid) $socid = $_GET['socid']?$_GET['socid']:''; if (! $socid) $socid = $_GET['socid']?$_GET['socid']:'';
if (! $socid) $socid = $_POST['id_fourn']?$_POST['id_fourn']:''; if (! $socid) $socid = $_GET['id_fourn']?$_GET['id_fourn']:'';
$sql = "SELECT rowid, nom"; $sql = "SELECT rowid, nom";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";