Skip to content
Snippets Groups Projects
Commit b7f89592 authored by Henri Queneau's avatar Henri Queneau
Browse files

FIX #3386 add autocomplete file, autocomplete is ok on list model(module)

parent 08e4c0e0
No related branches found
No related tags found
No related merge requests found
...@@ -63,8 +63,8 @@ $arrayPDO = array(); ...@@ -63,8 +63,8 @@ $arrayPDO = array();
if(isset($_REQUEST['what']) && !empty($_REQUEST['what'])) if(isset($_REQUEST['what']) && !empty($_REQUEST['what']))
{ {
$what = $func->protect_string_db($_REQUEST['what']); $what = $func->protect_string_db($_REQUEST['what']);
$where = " lower(object_id) like lower(?) and "; $where = " (lower(object_id) like lower(?) or lower(description) like lower(?)) and ";
$arrayPDO = array_merge($arrayPDO, array($what."%")); $arrayPDO = array_merge($arrayPDO, array("%".$what."%", "%".$what."%"));
} }
if($_SESSION['user']['UserId'] != 'superadmin') { if($_SESSION['user']['UserId'] != 'superadmin') {
...@@ -92,6 +92,8 @@ $select[ENT_LISTMODELS] = array(); ...@@ -92,6 +92,8 @@ $select[ENT_LISTMODELS] = array();
array_push($select[ENT_LISTMODELS], "object_type || '|' || object_id as list_id", 'object_type', 'object_id', 'title', 'description'); array_push($select[ENT_LISTMODELS], "object_type || '|' || object_id as list_id", 'object_type', 'object_id', 'title', 'description');
$where .= ' 1=1 group by object_type, object_id, title, description'; $where .= ' 1=1 group by object_type, object_id, title, description';
// var_dump($select);
// var_dump($where);
$tab = $request->PDOselect($select, $where, $arrayPDO, $orderstr, $_SESSION['config']['databasetype']); $tab = $request->PDOselect($select, $where, $arrayPDO, $orderstr, $_SESSION['config']['databasetype']);
for ($i=0;$i<count($tab);$i++) for ($i=0;$i<count($tab);$i++)
...@@ -176,7 +178,10 @@ $label_add = _ADD_LISTMODEL; ...@@ -176,7 +178,10 @@ $label_add = _ADD_LISTMODEL;
$_SESSION['m_admin']['init'] = true; $_SESSION['m_admin']['init'] = true;
$title = _LISTMODELS." : ".$i." "._LISTMODEL; $title = _LISTMODELS." : ".$i." "._LISTMODEL;
$autoCompletionArray = false;//array(); //$autoCompletionArray = false;//array();
$autoCompletionArray = array();
$autoCompletionArray["list_script_url"] = $_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=listmodels_list_by_label';
$autoCompletionArray["number_to_begin"] = 1;
$list->admin_list($tab, $i, $title, 'list_id','admin_listmodels','entities', 'list_id', true, $page_name_up, $page_name_val, $page_name_ban, $page_name_del, $page_name_add, $label_add, false, false, _ALL_LISTMODELS, _LISTMODEL, "share-alt-square", true, true, false, true, "", true, $autoCompletionArray, false, true); $list->admin_list($tab, $i, $title, 'list_id','admin_listmodels','entities', 'list_id', true, $page_name_up, $page_name_val, $page_name_ban, $page_name_del, $page_name_add, $label_add, false, false, _ALL_LISTMODELS, _LISTMODEL, "share-alt-square", true, true, false, true, "", true, $autoCompletionArray, false, true);
?> ?>
<?php
/**
* File : entities_list_by_label.php
*
* List of entities for autocompletion
*
* @package Maarch Framework 3.0
* @version 3
* @since 10/2005
* @license GPL
* @author Cédric Ndoumba <dev@maarch.org>
*/
require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php");
require_once('modules'.DIRECTORY_SEPARATOR.'entities'.DIRECTORY_SEPARATOR.'class'.DIRECTORY_SEPARATOR.'class_manage_entities.php');
require_once("modules/entities/entities_tables.php");
$ent = new entity();
$db = new Database();
$select = "select distinct(description) from ".ENT_LISTMODELS;
$where = " where (lower(description) like lower(?) ";
$where .= " or lower(object_id) like lower(?)) ";
if($_SESSION['user']['UserId'] != 'superadmin')
{
$my_tab_entities_id = $ent->get_all_entities_id_user($_SESSION['user']['entities']);
if (count($my_tab_entities_id)>0)
{
$where.= ' and object_id in ('.join(',', $my_tab_entities_id).')';
}
}
$sql = $select.$where." order by description";
//var_dump($sql);
$stmt = $db->query($sql,array("%".$_REQUEST['what']."%","%".$_REQUEST['what']."%"));
$listModels = array();
while($line = $stmt->fetchObject())
{
array_push($listModels, $line->description);
}
echo "<ul>\n";
$authViewList = 0;
foreach($listModels as $description)
{
if($authViewList >= 10)
{
$flagAuthView = true;
}
// if(stripos($entity, $_REQUEST['what']) === 0)
// {
echo "<li>".$description."</li>\n";
if(isset($flagAuthView) && $flagAuthView)
{
echo "<li>...</li>\n";
break;
}
$authViewList++;
// }
}
echo "</ul>";
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment