-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.php
More file actions
executable file
·318 lines (297 loc) · 11.8 KB
/
home.php
File metadata and controls
executable file
·318 lines (297 loc) · 11.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<?php include "includes/head_login.php"; ?>
<?php
$if_login = new usuario();// instancio la clase usuario
$if_login->if_login();
?>
<script type="text/javascript">
$(function() {
$( "#accordion" ).tabs(
{
}
);
});
$(document).ready(function() {
$('.info').hover(
function(){
$(this).css("opacity",0.7);
$(this).css("border-color","yellow");
},function(){
$(this).css("opacity",100);
$(this).css("border-color","grey");
});
$('.fecha').hover(
function(){
$('.fecha').css("opacity",0.7);
},function(){
$('.fecha').css("opacity",100);
});
});
window.contador = 0;
function historial_entrada_ajax(start){
window.contador = window.contador+start;
$.ajax(
{
url:'ajax/historial_entradas.php',
type:'post',
async:true,
data:'start='+window.contador,
success:respuesta,
errror:respuesta
}
);
}
window.contador2=0;
function historial_salida_ajax(start){
window.contador2 = window.contador2+start;
$.ajax(
{
url:'ajax/historial_salidas.php',
type:'post',
async:true,
data:'start='+window.contador2,
success:respuestaSal,
errror:respuestaSal
}
);
}
function respuesta(data){
$("#respuesta").html(data);
}
function respuestaSal(data){
$("#respuesta_salidas").html(data);
}
function add_money(){
guita = $("#plata_nueva").val();
$.ajax(
{
url:'ajax/add_money.php',
type:'post',
async:true,
data:'cantidad='+guita,
success:respuestaAdd,
errror:respuestaAdd
}
);
}
function respuestaAdd(data){
alert(data);
location.href='home.php';
}
function remove_money(){
guita = $("#saco_plata").val();
razon = $("#razon").val();
$.ajax(
{
url:'ajax/remove_money.php',
type:'post',
async:true,
data:'cantidad='+guita+'&razon='+razon,
success:respuestaAdd,
errror:respuestaAdd
}
);
}
//VARIABLE GLOBAL
var textoAnterior = '';
//ESTA FUNCIÓN DEFINE LAS REGLAS DEL JUEGO
function cumpleReglas(simpleTexto)
{
//la pasamos por una poderosa expresión regular
var expresion = new RegExp("^(|([0-9]{1,9}(\\.([0-9]{1,9})?)?))$");
//si pasa la prueba, es válida
if(expresion.test(simpleTexto))
return true;
return false;
}//end function checaReglas
//ESTA FUNCIÓN REVISA QUE TODO LO QUE SE ESCRIBA ESTÉ EN ORDEN
function revisaCadena(textItem)
{
//si comienza con un punto, le agregamos un cero
if(textItem.value.substring(0,1) == '.')
textItem.value = '0' + textItem.value;
//si no cumples las reglas, no te dejo escribir
if(!cumpleReglas(textItem.value))
textItem.value = textoAnterior;
else //todo en orden
textoAnterior = textItem.value;
}//end function revisaCadena
</script>
<div id="content">
<section id="slid_pe">
<div id="accordion">
<ul>
<li><a href="#tab1">Fondo actual</a></h3></li>
<li><a href="#tab2">Ingresar plata</a></li>
<li><a href="#tab3">Retirar plata</a></li>
<li><a href="#tab4">Historial de ingresos</a></li>
<li><a href="#tab5">Historial de egresos</a></li>
<li><a href="#tab6">Estadísticas</a></li>
</ul>
<div id="tab1">
<h1> Bienvenido <?php echo $_SESSION['ses_usuario']; ?></h1>
<?php
$dinero = new modelos();
$res = $dinero->averiguar_dinero();
if($res == null or $res == 0 or empty($res)):
echo "No posees plata en tu cuenta, ve a la pestaña <b>ingresar plata</b> para agregar tus fondos";
else:
echo "Actualmente tienes $".$res." en tu capital ";
endif;
?>
</div>
<div id="tab2">
<h2>Centro de ingresos</h2>
<form method="post" name="add_plata" action="" >
<table summary="" >
<tr>
<td>
Ingresa el monto que quieres agregar a tu banco:
</td>
</tr>
<tr>
<td>
<input class="input" type="text" id="plata_nueva" onKeyUp="revisaCadena(this)" class="form-login" >
</td>
<td>
<div id="ejemplo" align="justify">
Los decimales son expresados con puntos, ejemplo 2 pesos con cincuenta sería 2.50
</div>
</td>
</tr>
<tr>
<td>
Causa del ingreso:
<br>
<input type="text" name="causa_ingreso" class="input">
</td>
<td>
Sueldo, prestado por pepe, etc
</td>
</tr>
<tr>
<td>
<input type="button" onclick="add_money();" value="Guardar">
</td>
</tr>
</table>
</form>
<?php
$procesar = new modelos();
$res = $procesar->averiguar_dinero();
if($res == null or $res == 0 or empty($res)):
else:
echo "Hasta ahora cuentas en tu banco con $".$procesar->capital_actual." pesos";
endif;
?>
</div><!-- fin tab 2 -->
<div id="tab3">
<h2>Retiro de dinero</h2>
<form method="post" name="quit_plata" action="procesar_rem.php" >
<table summary="" >
<tr>
<td>
Ingrese el monto que retirarás de tú banco:
</td>
</tr>
<tr>
<td>
<input class="input" type="text" id="saco_plata" onKeyUp="revisaCadena(this)" class="form-login">
</td>
<td>
<div id="ejemplo" align="justify">
Los decimales son expresados con puntos, ejemplo 2 pesos con cincuenta sería 2.50
</div>
</td>
</tr>
<tr>
<td>
Motivo del gasto:
<input class="input" type="text" id="razon" class="form-login">
</td>
<td>
<div id="ejemplo" align="justify">
<br>
Retiro $15 para devolverle a pepito lo que me prestó </div>
</td>
</tr>
<tr>
<td>
<input type="button" value="Guardar" onclick=" remove_money();">
</td>
</tr>
</table>
</form>
<?php
$res = $dinero->averiguar_dinero();
if($res == null or $res == 0 or empty($res)):
//echo "Todavía no has ingresado dinero a tu cuenta";
else:
echo "Hasta ahora cuentas en tu banco con $".$procesar->capital_actual." pesos";
endif;
?>
</div><!-- fin tab3 -->
<div id="tab4">
<div id="respuesta">
<?php
$res = $procesar->traer_hist_ent();
if(is_array($res)):
foreach($res as $key =>$row){
//echo "<tr><td class='ingreso' >
echo "<div class='info'>";
echo "Ingresaste $".$row['ingreso']."";
$viejo = $row['fecha'];
$exp = explode(" ",$viejo);
$fechaOld = $exp[0];
$explo = explode("-",$fechaOld);
$hora = $exp[1];
echo "<br>el ".$explo[2]."/".$explo[1]."/".$explo[0]." a las ".$hora;
echo "<br>Causa: ".$row['causa'];
echo "</div>";
}
echo "<a href='javascript:void(0)' onclick='historial_entrada_ajax(5);' id='siguiente'>Siguiente</a>";
else:
echo $res;
endif;
?>
</div><!-- fin respuesta -->
<br>
</div>
<div id="tab5">
<div id="respuesta_salidas">
<?php
$res = $procesar->traer_hist_sal();
if(is_array($res)):
foreach($res as $key =>$row){
//echo "<tr><td class='ingreso' >
echo "<div class='info'>";
echo "Sacaste $".$row['salio']."";
$viejo = $row['fecha'];
$exp = explode(" ",$viejo);
$fechaOld = $exp[0];
$explo = explode("-",$fechaOld);
$hora = $exp[1];
echo "<br>el ".$explo[2]."/".$explo[1]."/".$explo[0]." a las ".$hora;
echo "<br>Causa: ";
if($row['causa'] == null ){
echo "Sin causa";
}else{
echo $row['causa'];
}
echo "</div>";
}
echo "<a href='javascript:void(0)' onclick='historial_salida_ajax(5);' id='siguiente'>Siguiente</a>";
else:
echo $res;
endif;
?>
</div><!-- fin respuesta -->
</div><!-- fin tab 5 -->
<div id="tab6">
<div id="chart_div"></div>
</div>
</div>
</section>
<section id="info_general">
<br><br>
</section>
</div> <!-- fin content -->