~marcelo-escobal/geined/Alianza

« back to all changes in this revision

Viewing changes to funcxul.php

  • Committer: Cualquier Desarrollador
  • Date: 2010-01-29 21:15:22 UTC
  • Revision ID: desarrollo@marte-20100129211522-u97qh9o90mhdap04
Importación inicial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
include('log.inc');
 
3
function inicio()
 
4
{
 
5
    /** Manda los encabezados correctos para una aplicación XUL
 
6
     */
 
7
    header('Content-type: application/vnd.mozilla.xul+xml');
 
8
    echo '<?xml version="1.0"?>
 
9
    <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>';
 
10
}
 
11
function estilo()
 
12
{
 
13
    echo '<html:link type="text/css" href="alianza.css" rel="stylesheet" />';
 
14
}
 
15
function encabezado($titulo)
 
16
{
 
17
    inicio();
 
18
    echo '<window
 
19
        id="findfile-window" 
 
20
        title="'.$titulo.'Find Files"
 
21
        orient="vertical"
 
22
        xmlns:html="http://www.w3.org/1999/xhtml"
 
23
        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">';
 
24
    echo "<html:h1>$titulo</html:h1>";
 
25
}
 
26
function encabezadoMenu($texto)
 
27
{
 
28
    echo "<html:h2>$texto</html:h2>";
 
29
}
 
30
function imagenMenu($imagen,$enlace,$texto)
 
31
{
 
32
    echo '<html:td>
 
33
            <html:a href="'.$enlace.'">
 
34
                <html:img src="../images/'.$imagen.'" width="64" height="64" align="top" border="0" />
 
35
            </html:a>'.$texto.
 
36
        '</html:td>';
 
37
}
 
38
function encabezadoImagen($titulo,$imagen)
 
39
{
 
40
    inicio();
 
41
    encabezado($titulo);
 
42
    echo '<html:h2>
 
43
            <html:img src="../images/'.$imagen.'" border="0" />'.$titulo.
 
44
        '</html:h2>';
 
45
}
 
46
function encabezadoFecha($titulo)
 
47
{
 
48
    inicio();
 
49
    encabezado($titulo);
 
50
    echo '<html:style type="text/css">@import url(../js/calendar-win2k-1.css);</html:style>';
 
51
    echo '<script type="text/javascript" src="../js/calendar.js"></script>';
 
52
    echo '<script type="text/javascript" src="../js/lang/calendar-es.js"></script>';
 
53
    echo '<script type="text/javascript" src="../js/calendar-setup.js"></script>';
 
54
}    
 
55
function nota($texto)
 
56
{
 
57
    echo '<html:table>
 
58
            <html:tr>
 
59
                <html:td>
 
60
                    <html:span class="nota">'.$texto.'</html:span>
 
61
                </html:td>
 
62
            </html:tr>
 
63
        </html:table>';
 
64
}    
 
65
function pie($texto,$enlace){
 
66
    echo '<html:table>
 
67
        <html:tr>
 
68
        <html:td>
 
69
        <html:a href="'.$enlace.'">'.$texto .'</html:a>
 
70
        </html:td>
 
71
        </html:tr>
 
72
        </html:table>';
 
73
}
 
74
function botones()
 
75
{
 
76
    echo '<html:input type="submit" value="Aceptar" />';
 
77
}
 
78
function moneda($numero)
 
79
{
 
80
    $moneda = number_format($numero, 2);
 
81
    $moneda = '$' . $moneda;
 
82
    return $moneda;
 
83
}
 
84
function mysqlAFecha($fecha)
 
85
 
86
    ereg( "([0-9]{2,4})-([0-9]{1,2})-([0-9]{1,2})", $fecha, $mifecha); 
 
87
    $lafecha=$mifecha[3]."/".$mifecha[2]."/".$mifecha[1]; 
 
88
    return $lafecha; 
 
89
 
90
function fechaAMysql($fecha)
 
91
 
92
    ereg( "([0-9]{1,2})/([0-9]{1,2})/([0-9]{2,4})", $fecha, $mifecha); 
 
93
    $lafecha=$mifecha[3]."-".$mifecha[2]."-".$mifecha[1]; 
 
94
    return $lafecha; 
 
95
 
96
function duplicado($pagina)
 
97
{
 
98
    encabezado('Error');
 
99
    nota('Ya existe un dato igual al que usted intenta agregar.
 
100
    Verifique el dato e inténtelo nuevamente');
 
101
    boton('Volver',$pagina);
 
102
}
 
103
function confirmarBorrar($id,$pagina)
 
104
{
 
105
    encabezado('Confirmar eliminación de registro');
 
106
    nota('¿Esta seguro que desea eliminar este registro?');
 
107
    echo '<html:form action="'.$pagina.'?accion=eliminar" method="post">';
 
108
    echo '<html:input type="hidden" name="id" value="'. $id.'">';
 
109
    echo '<html:input type="submit" value="Confirmar">';
 
110
    echo '</html:form>';
 
111
    boton('Volver',$pagina);
 
112
}
 
113
function borrar($bdd,$id,$pagina)
 
114
{
 
115
    $sql = 'DELETE from ' . $bdd . ' WHERE id = "' . $id . '"';
 
116
    $result = mysql_query($sql) or die('Error: ' . mysql_error());
 
117
    redirigir($pagina);
 
118
}
 
119
function celda($texto)
 
120
{
 
121
    echo '<treecell label="'.$texto.'" />';
 
122
}
 
123
function lineaMoneda($texto)
 
124
{
 
125
    echo '<html:td align="right">'.moneda($texto).'</html:td>';
 
126
}
 
127
function lineaNumero($texto)
 
128
{
 
129
    echo '<html:td align="right">'.number_format($texto,2,'.','').'</html:td>';
 
130
}
 
131
function noAutorizado()
 
132
{
 
133
    inicio();
 
134
    encabezado('Acceso no autorizado');
 
135
    nota('Usted no se encuentra autorizado para ver esta página');
 
136
    boton('Volver','alianza.py');
 
137
    fin();
 
138
}
 
139
function scriptFecha()
 
140
{
 
141
    echo '<script type="text/javascript">
 
142
    Calendar.setup({
 
143
    inputField     :    "f_date_b",           //*
 
144
    ifFormat       :    "%d/%m/%Y",
 
145
    showsTime      :    false,
 
146
    button         :    "f_trigger_b",        //*
 
147
    step           :    1
 
148
    });
 
149
    </script>';
 
150
}
 
151
function scriptNoenter()
 
152
{
 
153
    echo '<script type="text/javascript">
 
154
    function stopRKey(evt) {
 
155
  var evt = (evt) ? evt : ((event) ? event : null);
 
156
  var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null);
 
157
  if ((evt.keyCode == 13) && (node.type=="text"))  {return false;}
 
158
    }
 
159
    document.onkeypress = stopRKey;
 
160
    </script>';
 
161
}
 
162
function inputFecha($texto,$campo,$valor)
 
163
{
 
164
    echo '<html:tr>
 
165
            <html:td>'.$texto.'</html:td>
 
166
            <html:td>
 
167
                <html:input type="text" name="'.$campo.'" id="f_date_b" value="'.mysql_a_fecha($valor).'"/>
 
168
                <html:button type="reset" id="f_trigger_b">...</html:button>
 
169
            </html:td>
 
170
        </html:tr>';
 
171
}
 
172
function inputTexto($texto,$campo,$valor)
 
173
{
 
174
    echo '<html:tr>
 
175
            <html:td>'.$texto.'</html:td>
 
176
            <html:td>
 
177
                <html:input type="text" name="'.$campo.'" value="'.$valor.'" />
 
178
            </html:td>
 
179
        </html:tr>';
 
180
}
 
181
function inputNumero($texto,$campo,$valor)
 
182
{
 
183
    echo '<html:tr>
 
184
            <html:td>'.$texto.'</html:td>
 
185
            <html:td>
 
186
                <html:input type="text" name="'.$campo.'" value="'.number_format($valor,2,'.','').'" />
 
187
            </html:td>
 
188
        </html:tr>';
 
189
}
 
190
function inputMemo($texto,$campo,$valor)
 
191
{
 
192
    echo '<html:tr>
 
193
            <html:td>'.$texto.'</html:td>
 
194
            <html:td>
 
195
                <html:textarea name="'.$campo.'" rows="10" cols="50">'.$valor.'</html:textarea>
 
196
            </html:td>
 
197
        </html:tr>';
 
198
}
 
199
function formulario($accion)
 
200
{
 
201
    echo '<html:form action="'.$accion.'" method="POST">';
 
202
}
 
203
function finTabla(){
 
204
    echo '</treechildren></tree>';
 
205
}
 
206
function inputCombo($texto,$campo,$resultado,$valor)
 
207
{
 
208
    echo '<html:tr><html:td>'.$texto.'</html:td>';
 
209
    echo '<html:td><html:select name="'.$campo.'">';
 
210
    for($i=0; $i < mysql_num_rows($resultado); $i++){
 
211
        $fil = mysql_fetch_row($resultado);
 
212
        echo '<html:option value="' . $fil[0] .'"';
 
213
        if($fil[0]==$valor){
 
214
            echo 'selected="selected"';
 
215
        }
 
216
        echo '>'.$fil[1].'</html:option>';
 
217
    }
 
218
    echo '</html:select></html:td></html:tr>';
 
219
}
 
220
function boton($texto,$accion){
 
221
    echo '<button label="'.$texto.'" onclick="window.location='."'".$accion."'".';"
 
222
            />';
 
223
}
 
224
function mboton($texto,$accion)
 
225
{
 
226
    echo '<html:button class="menubutton" onClick=parent.location="'.$accion.'">'.$texto.'</html:button>';
 
227
}
 
228
function tboton($texto,$accion)
 
229
{
 
230
    echo '<html:td>
 
231
            <html:button class="cssbutton" onClick=parent.location="'.$accion.'">'.$texto.'</html:button>
 
232
        </html:td>';
 
233
}
 
234
function fin()
 
235
{
 
236
    echo '</window>';
 
237
}
 
238
function imagen($imagen)
 
239
{
 
240
    echo '<html:img src="../images/'.$imagen.'" width="64" height="64" border="0" />';
 
241
}
 
242
function imagenEnlace($imagen,$enlace){
 
243
    echo '<html:a href="'.$enlace.'">
 
244
            <html:img src="../images/'.$imagen.'" border="0" />
 
245
        </html:a>';
 
246
}
 
247
function encabezadoTabla($arr){
 
248
    echo '<tree flex="1">
 
249
            <treecols>';
 
250
    foreach($arr as $a){
 
251
        echo '<treecol id="'.$a.'" label="'.$a.'" flex="1"/>';
 
252
    }
 
253
    echo '</treecols><treechildren>';
 
254
}
 
255
function campoOculto($variable,$dato)
 
256
{
 
257
    echo '<html:input type="hidden" name="'.$variable.'" value="'.$dato.'" />';
 
258
}
 
259
function finFormulario()
 
260
{
 
261
    echo '</html:form>';
 
262
}
 
263
function inputCheck($texto,$variable,$valor)
 
264
{
 
265
    echo '<html:tr><html:td>';
 
266
    echo $texto;
 
267
    if($valor=="1"){
 
268
        $adicional= "checked";
 
269
    }
 
270
    echo '</html:td>
 
271
    <html:td>
 
272
        <html:input type="checkbox" name="'.$variable.'" value="1"'.$adicional.' />
 
273
    </html:td></html:tr>';
 
274
    
 
275
}
 
276
function autorizacion($niv)
 
277
{
 
278
    /* 20: cualquiera
 
279
    * 10: docente
 
280
    * 5: recepcion
 
281
    * 4: Adriana
 
282
    * 3: Hassan / Leo
 
283
    * 2: Mariana
 
284
    * 1: Marcelo */
 
285
    @session_start();
 
286
    if ($_SESSION['auth']!='yes') {
 
287
        redirigir("no_autorizado.html");
 
288
    }
 
289
    $sql = 'SELECT * FROM usuarios WHERE usuario="' . $_SESSION['logname'] . '"';
 
290
    $res = mysql_query($sql);
 
291
    if ($res==0){
 
292
        header("location: no_autorizado.html");
 
293
    }
 
294
    $fil = mysql_fetch_row($res);
 
295
    $nivel = $fil[4];
 
296
    if($nivel>$niv){
 
297
        header("location: no_autorizado.html");
 
298
    }
 
299
}
 
300
function session_started()
 
301
{
 
302
  if(isset($_SESSION)){ return true; }else{ return false; }
 
303
}
 
304
function redirigir($url)
 
305
{
 
306
echo '<script type="text/javascript">
 
307
<!--
 
308
window.location = "' .$url.'"
 
309
//-->
 
310
</script>';
 
311
}
 
312
?>