no esta funcionando el proceso con UPDATE
Publicado por zendi (1058 intervenciones) el 21/01/2019 21:02:49
Que tal a todos, he desarrollado este codigo para un condominio, especificamente es para cancelar la deuda total por cedula. El formulario trae los datos pero cuando presiono el boton Procesar pago no efectua el pago o la cancelacion de la deuda.
Aqui les muestro el codigo completo el problema esta exactamente donde esta el codigo en negrita. si alguien puede ayudarme. Hay algo que no esta bien en ese lugar.
Aqui les muestro el codigo completo el problema esta exactamente donde esta el codigo en negrita. si alguien puede ayudarme. Hay algo que no esta bien en ese lugar.
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
<?php
$connect = pg_connect("host=localhost port=5432 dbname=administra user=postgres password=Wrap*/1808");
error_reporting(E_ALL ^ E_WARNING ^ E_NOTICE);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Cancelación de la Deuda por Cedula</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script language="JavaScript" src="../Clases/css/calendario.js"></script>
<script language="JavaScript" src="../Clases/css/overlib_mini.js"></script>
<!-- Este script permite Máscara de entrada de la fecha (en
./) -->
<SCRIPT type="text/javascript">
var patron = new Array(2,2,4)
var patron2 = new Array(1,3,3,3,3)
function mascara(d,sep,pat,nums){
if(d.valant != d.value){
val = d.value
largo = val.length
val = val.split(sep)
val2 = ''
for(r=0;r<val.length;r++){
val2 += val[r]
}
if(nums){
for(z=0;z<val2.length;z++){
if(isNaN(val2.charAt(z))){
letra = new RegExp(val2.charAt(z),"g")
val2 = val2.replace(letra,"")
}
}
}
val = ''
val3 = new Array()
for(s=0; s<pat.length; s++){
val3[s] = val2.substring(0,pat[s])
val2 = val2.substr(pat[s])
}
for(q=0;q<val3.length; q++){
if(q ==0){
val = val3[q]
}
else{
if(val3[q] != ""){
val += sep + val3[q]
}
}
}
d.value = val
d.valant = val
}
}
}
function myFunction()
{
var r=confirm("En realidad desea Pagar la Deuda?");
if (r==true){
x="You pressed OK!";
return true;
}
else
{
x="You pressed Cancel!";
return false;
}
}
</SCRIPT>
</head>
<style type="text/css">
.sr {
background-color: #FFFFCF;
color: #000000;
font-family: Arial;
font-size: 12px;
}
input.color1 {background-color: #00CC99; font-weight: bold; font-size: 12px; color: white;}
</style>
<body>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<form name="form1" action="cancelaporcedula.php" method="post"><fieldset style="width:auto"><LEGEND>Deuda</LEGEND>
<table><th>Coloque su cédula sin puntos <"."> o <"guiones">, solo escríbala y luego Presione el botón Buscar
</table>
<TABLE align="center" class="div1">
<TR>
<td class="sr"><?php echo "Cedula:" ?></td>
<td class="sr"><input type="text" name = "cedula" size="8" maxlength="8" /></td>
</TR>
<tr>
<td><input TYPE="submit" class="color1" NAME="buscar" VALUE="Buscar"></td>
<td><INPUT TYPE="BUTTON" class="color1" VALUE="Salir" ONCLICK="window.location.href='menu1.php'"></td>
<!-- <td><input type='submit' class='color1' name="action" value='Procesar pago' align='right'></td>
--> </tr>
</TABLE>
<!--</form>
-->
</fieldset><br />
<?php
if ($_POST['cedula'] && $_POST['buscar']):
/*//imprime el nombre y apellido*/
$nombre = "SELECT apellidos,nombres FROM propietarios WHERE propietarios.cedula = '{$_POST['cedula']}'";
$nombre1 = @pg_query($connect,$nombre);
while ($nombre =@pg_fetch_array($nombre1)):
$apellidos = strtoupper($nombre['apellidos']);
$nombres = strtoupper($nombre['nombres']);
echo"<table border='1' bordercolor='#00CC99' bgcolor='#99CC00' align='center'>
<tr class='sr'>
<td width ='50' align='center'>Apellidos
<td width ='50' align='center'>Nombres
</tr>";
echo "<tr>
<td width ='100'>$apellidos</td>
<td width ='100'>$nombres</td>
</tr>
</table><br>";
endwhile;
echo"<table border='1' bordercolor='#00CC99' bgcolor='#99CC00' align='center'>
<tr class='sr'>
<th>Apartamento
<th>Cédula
<th>Deuda
<th>Nro de Voucher";
$resultado1 = "SELECT cedula, nroapto, SUM(monto) as deuda FROM deuda WHERE deuda.cedula = '{$_POST['cedula']}' GROUP BY cedula,nroapto";
$resultado = @pg_query($connect,$resultado1);
echo"<table border='1' bordercolor='#00CC99' bgcolor='#99CC00' align='center'>
</tr></table> ";
while ($seleccionado =@pg_fetch_array($resultado)):
$nroapto = $seleccionado['nroapto'];
$cedula = $seleccionado['cedula'];
$monto = $seleccionado['deuda'];
echo"<tr>
<td><input type='text' value='$nroapto' name='nroapto' readonly='true'></td>
<td width='50'><input type='text' value='$cedula' name='cedula' readonly='true'></td>
<td width='50'><input type='text' value='$monto' size='8' readonly='true' name='deuda'></td>
<td width='50'><input type='text' value='$voucher' size='30' name='voucher' align='right'></td>
</tr>";
echo"</table><br>";
echo"<input type='submit' class='color1' name='action' value='Procesar pago' align='right'>";
endwhile;
echo "hola";
if ($_POST['voucher'] && $_POST['action']):
////Proceso que descuenta o cancela la deuda del condominio
$hoy = date("Y-m-d");
$condominio = 'Condominio';
$valor = $_POST['deuda'];
$voucher1 = $_POST['voucher'];
$hora = time();
$cero = 0.00;
if (isset($hoy) and isset($condominio) and isset($valor) and isset($voucher) and isset($hora)):
$connect3 = pg_connect("host=localhost port=5432 dbname=administra user=postgres password=Wrap*/1808");
$cancelado= "INSERT INTO ingresos(voucher,fecha,descripcion,monto,hora) VALUES ('$voucher1','$hoy',UPPER('$condominio'),$valor,$hora)";
$cancelar = @pg_query($connect,$cancelado);
$actualiza ="UPDATE deuda set monto=$cero WHERE deuda.cedula = '{$_POST['cedula']}'";
$cambiar = @pg_query($connect,$actualiza);
echo("<script type='text/javascript'>window.location='cancelaporcedula.php'; </script>");
header("location:cancelaporcedula.php");
endif;
endif;
// endwhile;
endif;
?>
</form>
</body>
</html>
Valora esta pregunta


0