Commit d4a9126b authored by Chenu Denis's avatar Chenu Denis

[fix] 2.5X and 2.7X basic compatibility

parent 6fff2ea1
......@@ -2,6 +2,7 @@
border:0 none;
box-shadow: 0 0 0 rgba(0, 0, 0, 0.2) inset;
}
.ui-autocomplete{z-index:2}
.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; }
.ui-menu .ui-menu { margin-top: -3px; position: absolute; }
.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; }
......
function autoCpVille(qId,options){
var answerLibels=$("#question"+qId+" input[name*='X"+qId+options.answerLibel+"']");
console.log(answerLibels.length);
if(answerLibels.length>=1)
{
$(answerLibels).addClass('libelle');
$(answerLibels).keypress(function(e) {
var code = e.keyCode || e.which;
if (code == 9) {
......@@ -15,15 +15,25 @@ function autoCpVille(qId,options){
$(answerLibels).each(function(){
// Find final part
var thisid=$(this).attr("id");
console.log(thisid);
var n=thisid.indexOf('X'+qId+options.answerLibel);
var endLibel=$(this).attr("id").substring($(this).attr("id").indexOf(baseLibel)+baseLibelLength);
// Set the options for each lines
var optionLines=[];
var optionShow=[];
if(options.answerCp){optionLines.push("#question"+qId+" li[id$='X"+qId+options.answerCp+endLibel+"']");optionShow.push(options.showCp);}
if(options.answerInsee){optionLines.push("#question"+qId+" li[id$='X"+qId+options.answerInsee+endLibel+"']");optionShow.push(options.showInsee);}
if(options.answerNom){optionLines.push("#question"+qId+" li[id$='X"+qId+options.answerNom+endLibel+"']");optionShow.push(0);}
if(options.answerCp){
optionLines.push("#question"+qId+" .answer-item[id$='X"+qId+options.answerCp+endLibel+"']");
optionShow.push(options.showCp);
}
if(options.answerInsee){
optionLines.push("#question"+qId+" .answer-item[id$='X"+qId+options.answerInsee+endLibel+"']");
optionShow.push(options.showInsee);
}
if(options.answerNom){
optionLines.push("#question"+qId+" .answer-item[id$='X"+qId+options.answerNom+endLibel+"']");
optionShow.push(0);
}
$.each(optionLines, function( index, value ) {
if(!optionShow[index])
{
......@@ -32,8 +42,10 @@ function autoCpVille(qId,options){
}
$(value).find("input[type=text]").prop("readonly",true).addClass("readonly");
});
var parent=$(this).parent();
$(this).autocomplete({
minLength: 1,
appendTo: parent,
position: { my : "left top", at: "left bottom", collision: "flipfit" },
source: function(request, response) {
$.ajax({
......@@ -47,6 +59,12 @@ function autoCpVille(qId,options){
}
});
},
search: function (event, ui) {
$(this).addClass('autocomplete-search');
},
open: function (event, ui) {
$(this).removeClass('autocomplete-search');
},
change: function (event, ui) {
if(!ui.item){
$(this).val("");
......
......@@ -8,7 +8,7 @@
* @copyright 2015 Observatoire Régional de la Santé (ORS) - Nord-Pas-de-Calais <http://www.orsnpdc.org/>
* @copyright 2016 Formations logiciels libres - 2i2l = 42 <http://2i2l.fr/>
* @license GPL v3
* @version 2.0.1
* @version 2.1.1
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -152,7 +152,6 @@ class cpVille extends \ls\pluginmanager\PluginBase {
return;
}
$tableName=$this->tableName('insee_cp');
// 2.06 150729
$this->api->createTable($this, 'insee_cp', array(
'insee'=>'string(5)',
'nom'=>'text',
......@@ -284,6 +283,18 @@ class cpVille extends \ls\pluginmanager\PluginBase {
$sParametre=strtr($sParametre,array(
"/"=>" SUR ",
));
/* get the collation according to db */
switch (App()->getDb()->charset) {
case 'utf8':
$collate = " COLLATE utf8_general_ci";
break;
case 'utf8mb4':
$collate = " COLLATE utf8mb4_general_ci";
break;
default:
$collate = "";
break;
}
$iLimit=(int)$this->get('limitliste');
$iLimit=($iLimit>0) ? $iLimit : 10;
$sOrderBy=$this->get('orderby');
......@@ -317,7 +328,7 @@ class cpVille extends \ls\pluginmanager\PluginBase {
->select('*')
->from(self::tableName('insee_cp'))
->where(
Yii::app()->db->quoteColumnName('nomsimple')." COLLATE utf8_general_ci LIKE :nomsimple OR ".Yii::app()->db->quoteColumnName('nomsimple')." COLLATE utf8_general_ci LIKE :nomsimplespace OR ".Yii::app()->db->quoteColumnName('cp')." LIKE :cp",
Yii::app()->db->quoteColumnName('nomsimple')." {$collate} LIKE :nomsimple OR ".Yii::app()->db->quoteColumnName('nomsimple')." {$collate} LIKE :nomsimplespace OR ".Yii::app()->db->quoteColumnName('cp')." LIKE :cp",
array(':nomsimple'=>"{$sParametre}%",':nomsimplespace'=>"% {$sParametre}%",':cp'=>"{$sParametre}%"))
->order($sOrderBy)
->limit($iLimit)
......@@ -340,7 +351,7 @@ class cpVille extends \ls\pluginmanager\PluginBase {
{
if(ctype_digit($sParametre))
{
$oTowns->andWhere("{$dbCpColumn} LIKE :cpstart{$count} OR {$dbColumn} COLLATE utf8_general_ci LIKE :start{$count} OR {$dbColumn} COLLATE utf8_general_ci LIKE :space{$count}");
$oTowns->andWhere("{$dbCpColumn} LIKE :cpstart{$count} OR {$dbColumn} {$collate} LIKE :start{$count} OR {$dbColumn} {$collate} LIKE :space{$count}");
$aParams[":cpstart{$count}"]="{$sParametre}%";
$aParams[":start{$count}"]="{$sParametre}%";
$aParams[":space{$count}"]="% {$sParametre}%";
......@@ -348,7 +359,7 @@ class cpVille extends \ls\pluginmanager\PluginBase {
else
{
$sParametre = addcslashes(self::replaceSomeString($sParametre), '%_');
$oTowns->andWhere("{$dbColumn} COLLATE utf8_general_ci LIKE :start{$count} OR {$dbColumn} COLLATE utf8_general_ci LIKE :space{$count}");
$oTowns->andWhere("{$dbColumn} {$collate} LIKE :start{$count} OR {$dbColumn} {$collate} LIKE :space{$count}");
$aParams[":start{$count}"]="{$sParametre}%";
$aParams[":space{$count}"]="% {$sParametre}%";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment