Add: début ajout autocompletion ajax sur la liste des sociétés
This commit is contained in:
parent
0ee5e91095
commit
10af1d81fa
@ -46,6 +46,12 @@ $fichinterid = isset($_GET["id"])?$_GET["id"]:'';
|
|||||||
// Sécurité d'accès client et commerciaux
|
// Sécurité d'accès client et commerciaux
|
||||||
$socid = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
|
$socid = restrictedArea($user, 'ficheinter', $fichinterid, 'fichinter');
|
||||||
|
|
||||||
|
//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['socid_id'])
|
||||||
|
{
|
||||||
|
$_POST['socid'] = $_POST['socid_id'];
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Traitements des actions
|
* Traitements des actions
|
||||||
@ -166,8 +172,17 @@ if ($_GET["action"] == 'create')
|
|||||||
$syear = date("Y", time());
|
$syear = date("Y", time());
|
||||||
print '<table class="border" width="100%">';
|
print '<table class="border" width="100%">';
|
||||||
|
|
||||||
print '<input type="hidden" name="socid" value='.$_GET["socid"].'>';
|
if ($_GET["socid"])
|
||||||
print "<tr><td>".$langs->trans("Company")."</td><td>".$societe->getNomUrl(1)."</td></tr>";
|
{
|
||||||
|
print '<input type="hidden" name="socid" value='.$_GET["socid"].'>';
|
||||||
|
print "<tr><td>".$langs->trans("Company")."</td><td>".$societe->getNomUrl(1)."</td></tr>";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "<tr><td>".$langs->trans("Company")."</td><td>";
|
||||||
|
$html->select_societes('','socid','');
|
||||||
|
print "</td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
print "<tr><td>".$langs->trans("Date")."</td><td>";
|
print "<tr><td>".$langs->trans("Date")."</td><td>";
|
||||||
$html->select_date(time(),"p",'','','','fichinter');
|
$html->select_date(time(),"p",'','','','fichinter');
|
||||||
@ -187,7 +202,7 @@ if ($_GET["action"] == 'create')
|
|||||||
|
|
||||||
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
|
print '<tr><td valign="top">'.$langs->trans("Project").'</td><td>';
|
||||||
|
|
||||||
$numprojet = $societe->has_projects();
|
if ($_GET["socid"]) $numprojet = $societe->has_projects();
|
||||||
|
|
||||||
if (!$numprojet)
|
if (!$numprojet)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -633,16 +633,54 @@ class Form
|
|||||||
* \param filter Criteres optionnels de filtre
|
* \param filter Criteres optionnels de filtre
|
||||||
*/
|
*/
|
||||||
function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0)
|
function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0)
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
// On recherche les societes
|
// On recherche les societes
|
||||||
$sql = "SELECT s.rowid, s.nom FROM";
|
$sql = "SELECT s.rowid, s.nom FROM";
|
||||||
$sql.= " ".MAIN_DB_PREFIX ."societe as s";
|
$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";
|
$sql.= " ORDER BY nom ASC";
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
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 '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
||||||
|
print '<td class="nobordernopadding">';
|
||||||
|
print '<div>';
|
||||||
|
if ($obj->rowid == 0)
|
||||||
|
{
|
||||||
|
print '<input type="text" size="30" id="'.$htmlname.'" name="'.$htmlname.'" value=""/>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<input type="text" size="30" id="'.$htmlname.'" name="'.$htmlname.'" value="'.$obj->nom.'"/>';
|
||||||
|
}
|
||||||
|
print ajax_autocompleter($socid,$htmlname,'/societe/ajaxcompanies.php','');
|
||||||
|
print '</td>';
|
||||||
|
print '<td class="nobordernopadding" align="left" width="16">';
|
||||||
|
print ajax_indicator($htmlname,'working');
|
||||||
|
print '</td></tr>';
|
||||||
|
print '</table>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
print '<select class="flat" name="'.$htmlname.'">';
|
print '<select class="flat" name="'.$htmlname.'">';
|
||||||
if ($showempty) print '<option value="-1"> </option>';
|
if ($showempty) print '<option value="-1"> </option>';
|
||||||
$num = $this->db->num_rows($resql);
|
$num = $this->db->num_rows($resql);
|
||||||
@ -664,8 +702,10 @@ class Form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
print '</select>';
|
print '</select>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
dolibarr_print_error($this->db);
|
dolibarr_print_error($this->db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,6 +46,13 @@ $mesg = '';
|
|||||||
|
|
||||||
if (! $user->rights->produit->lire) accessforbidden();
|
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
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -33,16 +33,19 @@ top_htmlhead("", "", 1, 1);
|
|||||||
print '<body id="mainbody">';
|
print '<body id="mainbody">';
|
||||||
|
|
||||||
// Generation liste des sociétés
|
// 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 = "SELECT rowid, nom";
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe";
|
$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;";
|
$sql.= " ORDER BY nom ASC;";
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
$resql=$db->query($sql);
|
||||||
|
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -52,7 +55,7 @@ if(isset($_POST['newcompany']) && !empty($_POST['newcompany']))
|
|||||||
{
|
{
|
||||||
print '<li>';
|
print '<li>';
|
||||||
print $company->nom;
|
print $company->nom;
|
||||||
print '<span id="socid" class="informal" style="display:none">'.$company->rowid.'-idcache</span>';
|
print '<span id="object" class="informal" style="display:none">'.$company->rowid.'-idcache</span>';
|
||||||
print '</li>';
|
print '</li>';
|
||||||
}
|
}
|
||||||
print '</ul>';
|
print '</ul>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user