X-Git-Url: https://git.llucax.com/mecon/samurai.git/blobdiff_plain/3c702b40a1806798e475c48abb456e5a9c2dac72..c74aaa35877c730b8eeee3800836bddcc7eb8b8f:/lib/SAMURAI/Permiso.php?ds=sidebyside diff --git a/lib/SAMURAI/Permiso.php b/lib/SAMURAI/Permiso.php index c2049c9..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 @@ -310,6 +314,7 @@ class SAMURAI_Permiso { $consulta.= $sql['obtener_datos_permiso3']; $tmp[] = $id_sistema; } + $consulta.= $sql['obtener_datos_permiso5']; $dbh = $db->prepare($consulta); $res = $db->execute($dbh, $tmp); while ($re = $res->fetchrow(DB_FETCHMODE_ASSOC)) { @@ -388,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 +?>