X-Git-Url: https://git.llucax.com/mecon/samurai.git/blobdiff_plain/de4cfadb31bf782b45184a44ba02bb73f8cc2f77..c74aaa35877c730b8eeee3800836bddcc7eb8b8f:/lib/SAMURAI/Permiso.php?ds=sidebyside diff --git a/lib/SAMURAI/Permiso.php b/lib/SAMURAI/Permiso.php index ba385a0..1d45cbd 100644 --- a/lib/SAMURAI/Permiso.php +++ b/lib/SAMURAI/Permiso.php @@ -232,7 +232,11 @@ class SAMURAI_Permiso { 'desc_permiso' => $this->getDescripcion(), 'responsable' => $this->getResponsable(), ); - return $this->_db->autoExecute('permiso', $datos, DB_AUTOQUERY_INSERT); + $res = $this->_db->autoExecute('samurai.permiso', $datos, DB_AUTOQUERY_INSERT); + if (PEAR::isError($res)) { + return $res; + } + $this->setId($idPermiso); } // -X2C @@ -283,7 +287,7 @@ class SAMURAI_Permiso { 'desc_permiso' => $this->getDescripcion(), 'responsable' => $this->getResponsable(), ); - return $this->_db->autoExecute('permiso', $datos, DB_AUTOQUERY_UPDATE, 'id_permiso ='.$this->getId()); + return $this->_db->autoExecute('samurai.permiso', $datos, DB_AUTOQUERY_UPDATE, 'id_permiso ='.$this->getId()); } // -X2C @@ -389,6 +393,41 @@ class SAMURAI_Permiso { } // -X2C + /** + * Metodo que devuelve los datos necesarios para listar permisos. + * + * @param SAMURAI_DB &$db Base de Datos + * @param int $id_sistema Identificador de un sistema en particular. + * + * @return mixed + * @access public + * @static + */ + function getPermisosPager(&$db, $id_sistema = null) { + + //@TODO REEMPLAZA A getPermisos + + if ($id_sistema) { + $sql = ' + SELECT p.id_permiso, p.desc_permiso, p.responsable + FROM samurai.permiso AS p, samurai.perm_sist AS ps + WHERE ps.id_sistema = '. $id_sistema .' + AND ps.id_permiso = p.id_permiso + ORDER BY p.desc_permiso + '; + } + else { + $sql = ' + SELECT p.id_permiso, p.desc_permiso, NOT count(ps.id_sistema) AS cuenta + FROM samurai.permiso AS p + LEFT JOIN samurai.perm_sist AS ps + ON (p.id_permiso = ps.id_permiso) + GROUP BY p.id_permiso, p.desc_permiso + ORDER BY p.desc_permiso + '; + } + return $db->query ($sql); + } } // -X2C Class :SAMURAI_Permiso -?> \ No newline at end of file +?>