|
|
@@ -191,7 +191,11 @@ jQuery(document).ready(function(){
|
|
|
var score = this.getScoreFunction(search);
|
|
|
return function(item) {
|
|
|
//console.log('score:item:', item, ', score:', score(item));
|
|
|
- return score(item);// score(item) * (1 + Math.min(item.watchers / 100, 1));
|
|
|
+ if (search && search == item.id) {
|
|
|
+ return 1;
|
|
|
+ } else {
|
|
|
+ return score(item);// score(item) * (1 + Math.min(item.watchers / 100, 1));
|
|
|
+ }
|
|
|
};
|
|
|
},
|
|
|
load: function(query, callback) {
|
|
|
@@ -490,15 +494,29 @@ jQuery(document).ready(function(){
|
|
|
$sqlSelectLabel = "concat(z.`TYPE`, ' ', z.`DESC` , ' (', (select zp.`DESC` from `CRM_LISTA_ZASOBOW` as zp where zp.`ID`=z.`PARENT_ID` limit 1), ')')";
|
|
|
}
|
|
|
}
|
|
|
- $sql = "select z.`ID`
|
|
|
- , {$sqlSelectLabel} as `LABEL`
|
|
|
- from `CRM_LISTA_ZASOBOW` as z
|
|
|
- where z.`A_STATUS` in('NORMAL', 'WAITING')
|
|
|
- and (z.`DESC` like '%{$query}%' or z.`ID` like '%{$query}%')
|
|
|
- {$sqlWhere}
|
|
|
- -- group by z.`DESC`
|
|
|
- limit {$sqlLimit}
|
|
|
- ";
|
|
|
+ if (is_numeric($query)) {
|
|
|
+ $sql = "select z.`ID`
|
|
|
+ , {$sqlSelectLabel} as `LABEL`
|
|
|
+ , IF (z.`ID`='{$query}', 1000,
|
|
|
+ IF (z.`ID` like '{$query}%', 900, 100)
|
|
|
+ ) as _bestFit
|
|
|
+ from `CRM_LISTA_ZASOBOW` as z
|
|
|
+ where z.`A_STATUS` in('NORMAL', 'WAITING')
|
|
|
+ and (z.`ID` like '%{$query}%' or z.`DESC` like '%{$query}%')
|
|
|
+ {$sqlWhere}
|
|
|
+ order by _bestFit DESC
|
|
|
+ limit {$sqlLimit}
|
|
|
+ ";
|
|
|
+ } else {
|
|
|
+ $sql = "select z.`ID`
|
|
|
+ , {$sqlSelectLabel} as `LABEL`
|
|
|
+ from `CRM_LISTA_ZASOBOW` as z
|
|
|
+ where z.`A_STATUS` in('NORMAL', 'WAITING')
|
|
|
+ and (z.`ID` like '%{$query}%' or z.`DESC` like '%{$query}%')
|
|
|
+ {$sqlWhere}
|
|
|
+ limit {$sqlLimit}
|
|
|
+ ";
|
|
|
+ }
|
|
|
if(V::get('DBG_TS', 0, $_GET) > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">sql (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'</pre>';}
|
|
|
$res = $db->query($sql);
|
|
|
while ($r = $db->fetch($res)) {
|
|
|
@@ -514,15 +532,29 @@ jQuery(document).ready(function(){
|
|
|
$sqlLimit = 20;
|
|
|
$sqlSelectLabel = "concat(z.`TYPE`, ' ', z.`DESC`)";
|
|
|
$sqlWhereAdd = "";
|
|
|
- $sql = "select z.`ID`
|
|
|
- , {$sqlSelectLabel} as `LABEL`
|
|
|
- from `CRM_PROCES` as z
|
|
|
- where z.`A_STATUS` in('NORMAL', 'WAITING')
|
|
|
- and (z.`DESC` like '%{$query}%' or z.`ID` like '%{$query}%')
|
|
|
- {$sqlWhereAdd}
|
|
|
- -- group by z.`DESC`
|
|
|
- limit {$sqlLimit}
|
|
|
- ";
|
|
|
+ if (is_numeric($query)) {
|
|
|
+ $sql = "select z.`ID`
|
|
|
+ , {$sqlSelectLabel} as `LABEL`
|
|
|
+ , IF (z.`ID`='{$query}', 1000,
|
|
|
+ IF (z.`ID` like '{$query}%', 900, 100)
|
|
|
+ ) as _bestFit
|
|
|
+ from `CRM_PROCES` as z
|
|
|
+ where z.`A_STATUS` in('NORMAL', 'WAITING')
|
|
|
+ and (z.`DESC` like '%{$query}%' or z.`ID` like '%{$query}%')
|
|
|
+ {$sqlWhereAdd}
|
|
|
+ order by _bestFit DESC
|
|
|
+ limit {$sqlLimit}
|
|
|
+ ";
|
|
|
+ } else {
|
|
|
+ $sql = "select z.`ID`
|
|
|
+ , {$sqlSelectLabel} as `LABEL`
|
|
|
+ from `CRM_PROCES` as z
|
|
|
+ where z.`A_STATUS` in('NORMAL', 'WAITING')
|
|
|
+ and (z.`DESC` like '%{$query}%' or z.`ID` like '%{$query}%')
|
|
|
+ {$sqlWhereAdd}
|
|
|
+ limit {$sqlLimit}
|
|
|
+ ";
|
|
|
+ }
|
|
|
if(V::get('DBG_TS', 0, $_GET) > 2){echo'<pre style="max-height:200px;overflow:auto;border:1px solid red;text-align:left;">sql (' . __CLASS__ . '::' . __FUNCTION__ . ':' . __LINE__ . '): ';print_r($sql);echo'</pre>';}
|
|
|
$res = $db->query($sql);
|
|
|
while ($r = $db->fetch($res)) {
|