X-Git-Url: https://git.llucax.com/mecon/ai.git/blobdiff_plain/493cf2effdb418f10f2ae77cec0786c5cef0bbcc..da51d7f6085a1f40e5869aacbbcfabc2efc881e1:/lib/AI/Servicio.php?ds=sidebyside diff --git a/lib/AI/Servicio.php b/lib/AI/Servicio.php index 9fb5e8c..d6277cf 100644 --- a/lib/AI/Servicio.php +++ b/lib/AI/Servicio.php @@ -190,7 +190,10 @@ class AI_Servicio extends AI_DBTreeObject { $id = intval($this->$id_field); if ($orden === AI_SERVICIO_ORDEN_LONG_HIJOS) { $query = " - SELECT A.*, SUM(CEIL(LENGTH(B.nombre) / 22)) as RENGLONES + SELECT + A.*, + count(1) as COUNT, + SUM(CEIL(LENGTH(B.nombre) / 22)) as RENGLONES FROM {$this->conf['base']}.{$this->conf['tabla']} AS A, {$this->conf['base']}.{$this->conf['tabla']} AS B WHERE A.$id_field = B.$id_padre @@ -198,7 +201,9 @@ class AI_Servicio extends AI_DBTreeObject { if ($soloHabilitados) { $query .= " AND A.{$this->conf['habilitado']} = 1"; } - $query .= " GROUP BY A.$id_field ORDER BY RENGLONES DESC"; + $query .= " + GROUP BY A.$id_field + ORDER BY RENGLONES DESC, COUNT DESC"; } elseif ($orden === AI_SERVICIO_ORDEN_LONG_NOMBRE) { $query = " SELECT *