| ".$langs->trans("Date")." | ";
$html->select_date(time(),"p",'','','','fichinter');
@@ -187,7 +202,7 @@ if ($_GET["action"] == 'create')
print ' |
| '.$langs->trans("Project").' | ';
- $numprojet = $societe->has_projects();
+ if ($_GET["socid"]) $numprojet = $societe->has_projects();
if (!$numprojet)
{
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 74c9c66553f..09c5c16b8e8 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -633,16 +633,54 @@ class Form
* \param filter Criteres optionnels de filtre
*/
function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0)
- {
+ {
+ global $conf;
// On recherche les societes
$sql = "SELECT s.rowid, s.nom FROM";
$sql.= " ".MAIN_DB_PREFIX ."societe as s";
- if ($filter) $sql.= " WHERE $filter";
+ if ($filter) $sql.= " WHERE ".$filter;
+ if ($selected && $conf->use_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
+ {
+ if ($filter)
+ {
+ $sql.= " AND";
+ }
+ else
+ {
+ $sql.= " WHERE";
+ }
+ $sql.= " rowid = ".$selected;
+ }
$sql.= " ORDER BY nom ASC";
$resql=$this->db->query($sql);
if ($resql)
{
+ if ($conf->use_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT)
+ {
+ if ($selected) $obj = $this->db->fetch_object($resql);
+ $socid = $obj->rowid?$obj->rowid:'';
+
+ print '';
+ }
+ else
+ {
print '';
+ }
}
- else {
+ else
+ {
dolibarr_print_error($this->db);
}
}
diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php
index 7abbf0c5071..2456293eb65 100644
--- a/htdocs/product/fournisseurs.php
+++ b/htdocs/product/fournisseurs.php
@@ -46,6 +46,13 @@ $mesg = '';
if (! $user->rights->produit->lire) accessforbidden();
+//Récupère le résultat de la recherche Ajax
+//Todo: voir pour le supprimer par la suite
+if ($conf->use_ajax && $conf->global->COMPANY_USE_SEARCH_TO_SELECT && $_POST['id_fourn_id'])
+{
+ $_POST['id_fourn'] = $_POST['id_fourn_id'];
+}
+
/*
* Actions
*/
diff --git a/htdocs/societe/ajaxcompanies.php b/htdocs/societe/ajaxcompanies.php
index a0a2ec58ba3..2f248760c04 100644
--- a/htdocs/societe/ajaxcompanies.php
+++ b/htdocs/societe/ajaxcompanies.php
@@ -33,16 +33,19 @@ top_htmlhead("", "", 1, 1);
print '';
// Generation liste des sociétés
-if(isset($_POST['newcompany']) && !empty($_POST['newcompany']))
+if(isset($_POST['newcompany']) && !empty($_POST['newcompany']) || isset($_POST['socid']) && !empty($_POST['socid'])
+ || isset($_POST['id_fourn']) && !empty($_POST['id_fourn']))
{
- global $langs;
- $langs->load("dict");
+ $socid = $_POST['newcompany']?$_POST['newcompany']:'';
+ $socid = $_POST['socid']?$_POST['socid']:'';
+ $socid = $_POST['id_fourn']?$_POST['id_fourn']:'';
+
$sql = "SELECT rowid, nom";
$sql.= " FROM ".MAIN_DB_PREFIX."societe";
- $sql.= " WHERE nom LIKE '%" . utf8_decode($_POST['newcompany']) . "%'";
+ $sql.= " WHERE nom LIKE '%" . utf8_decode($socid) . "%'";
$sql.= " ORDER BY nom ASC;";
-
+
$resql=$db->query($sql);
if ($resql)
@@ -52,7 +55,7 @@ if(isset($_POST['newcompany']) && !empty($_POST['newcompany']))
{
print '';
print $company->nom;
- print ''.$company->rowid.'-idcache';
+ print ''.$company->rowid.'-idcache';
print '';
}
print '';
|