| 1 | <? |
|---|
| 2 | // ************************************************************************************************************************************************* |
|---|
| 3 | // Aplicación WEB: ogAdmWebCon |
|---|
| 4 | // Autor: José Manuel Alonso (E.T.S.I.I.) Universidad de Sevilla |
|---|
| 5 | // Fecha Creación: Año 2009-2010 |
|---|
| 6 | // Fecha Última modificación: Agosto-2010 |
|---|
| 7 | // Nombre del fichero: gestor_dministradores_centros.php |
|---|
| 8 | // Descripción : |
|---|
| 9 | // Gestiona la asignación de administradores a las Unidades organizativas |
|---|
| 10 | // ************************************************************************************************************************************************* |
|---|
| 11 | include_once("../includes/ctrlacc.php"); |
|---|
| 12 | include_once("../clases/AdoPhp.php"); |
|---|
| 13 | include_once("../includes/CreaComando.php"); |
|---|
| 14 | include_once("../includes/opciones.php"); |
|---|
| 15 | //________________________________________________________________________________________________________ |
|---|
| 16 | $opcion=0; // Inicializa parametros |
|---|
| 17 | $idcentro=0; |
|---|
| 18 | $idusuario=0; |
|---|
| 19 | |
|---|
| 20 | if (isset($_POST["opcion"])) $opcion=$_POST["opcion"]; // Recoge parametros |
|---|
| 21 | if (isset($_POST["idcentro"])) $idcentro=$_POST["idcentro"]; |
|---|
| 22 | if (isset($_POST["idusuario"])) $idusuario=$_POST["idusuario"]; |
|---|
| 23 | |
|---|
| 24 | $cmd=CreaComando($cadenaconexion); // Crea objeto comando |
|---|
| 25 | $resul=false; |
|---|
| 26 | if ($cmd){ |
|---|
| 27 | $resul=Gestiona(); |
|---|
| 28 | $cmd->Conexion->Cerrar(); |
|---|
| 29 | } |
|---|
| 30 | $literal=""; |
|---|
| 31 | switch($opcion){ |
|---|
| 32 | case $op_alta : |
|---|
| 33 | $literal="resultado_insertar_administradores_centros"; |
|---|
| 34 | break; |
|---|
| 35 | case $op_eliminacion : |
|---|
| 36 | $literal="resultado_eliminar_administradores_centros"; |
|---|
| 37 | break; |
|---|
| 38 | default: |
|---|
| 39 | break; |
|---|
| 40 | } |
|---|
| 41 | if ($resul){ |
|---|
| 42 | if ($opcion==$op_alta ) |
|---|
| 43 | echo $literal."(1,'".$cmd->DescripUltimoError()." ',".$idusuario.");".chr(13); |
|---|
| 44 | else |
|---|
| 45 | echo $literal."(1,'".$cmd->DescripUltimoError()." ',".$idusuario.");".chr(13); |
|---|
| 46 | } |
|---|
| 47 | else{ |
|---|
| 48 | echo $literal."(0,'".$cmd->DescripUltimoError()."',".$idusuario.")"; |
|---|
| 49 | } |
|---|
| 50 | // ************************************************************************************************************************************************* |
|---|
| 51 | function Gestiona(){ |
|---|
| 52 | global $cmd; |
|---|
| 53 | global $opcion; |
|---|
| 54 | global $idusuario; |
|---|
| 55 | global $idcentro; |
|---|
| 56 | global $urlimgth; |
|---|
| 57 | global $op_alta; |
|---|
| 58 | global $op_eliminacion; |
|---|
| 59 | |
|---|
| 60 | $cmd->CreaParametro("@idusuario",$idusuario,1); |
|---|
| 61 | $cmd->CreaParametro("@idcentro",$idcentro,1); |
|---|
| 62 | |
|---|
| 63 | switch($opcion){ |
|---|
| 64 | case $op_alta : |
|---|
| 65 | $cmd->texto="INSERT INTO administradores_centros(idusuario,idcentro) VALUES (@idusuario,@idcentro)"; |
|---|
| 66 | $resul=$cmd->Ejecutar(); |
|---|
| 67 | break; |
|---|
| 68 | case $op_eliminacion : |
|---|
| 69 | $cmd->texto='DELETE FROM administradores_centros WHERE idusuario='.$idusuario.' AND idcentro='.$idcentro; |
|---|
| 70 | $resul=$cmd->Ejecutar(); |
|---|
| 71 | break; |
|---|
| 72 | default: |
|---|
| 73 | break; |
|---|
| 74 | } |
|---|
| 75 | return($resul); |
|---|
| 76 | } |
|---|
| 77 | ?> |
|---|