Ayuda con Update
Publicado por MIGUEL (20 intervenciones) el 12/06/2020 04:11:51
Hola, tengo un formulario en el cual requiero actualizar un registro de fecha. La condición es que la fecha debe ser igual al día actual o inferior y no estar vacío el campo. Realmente creo no estoy manejando bien el error de mysql, ya que al presionar el botón finalizar solo me se refresca pero no guarda.
Agradezco ayuda, esto hace parte de mi proyecto de estudios.
Tabla del formulario principal
Script Para Enviar los datos de Finalización
Ejecución de la Consulta y Actualización
Agradezco ayuda, esto hace parte de mi proyecto de estudios.
Tabla del formulario principal
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
<div class="card-content table-responsive">
<form class="form-horizontal" method="post" id="detalle_solicitud" role="form">
<div id="e_table">
<table class="table table-striped">
<thead>
<th style="background-color:#700202; color: white">N° Solicitud</th>
<th style="background-color:#700202; color: white">Paciente</th>
<th style="background-color:#700202; color: white">Proveedor</th>
<th style="background-color:#700202; color: white">Fecha Creación</th>
<th style="background-color:#700202; color: white; width: 60px;">Fecha Prestación</th>
<th style="background-color:#700202; color: white; width: 60px;"></th>
<th style="background-color:#700202; color: white; width: 60px;"></th>
</thead>
<?php while($row = mysqli_fetch_array($consulta)) { ?>
<tr>
<td style="width: auto;"><?php echo $row["or_id"]; ?></td>
<td style="width: auto;"><?php echo $row["cl"]; ?> - <?php echo $row["cl_name"]; ?></td>
<td style="width: auto;"><?php echo $row["prov_name"]; ?></td>
<td style="width: auto;"><?php echo $row["or_finit"]; ?></td>
<td style="width: auto;"><input type="date" id="<?php echo $row["or_id"]; ?>" name="start_at" value="" class="form-control" placeholder="inicio"></td>
<td style="width:60px; alignment-adjust: central; alignment-baseline: central">
<input type="button" name="view" id="<?php echo $row["or_id"]; ?>" class="btn btn-info btn-xs view_data" value="ver" data-toggle="tooltip" title="Detalle de Solicitud"/>
</td>
<td style="width:60px; alignment-adjust: central; alignment-baseline: central">
<input type="submit" name="fin_solicitud" id="<?php echo $row["or_id"]; ?>" class="btn btn-info btn-xs" value="Finalizar" data-toggle="tooltip" title="Finalizar Solicitud"/>
</td>
</tr>
<?php }?>
</table>
</div>
</form>
</div>
Script Para Enviar los datos de Finalización
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
$(document).ready(function(){
$fecha_actual = strtotime(date("d-m-Y H:i:00",time()));
$('#detalle_solicitud').on("submit", function(event){
event.preventDefault();
if($('#start_at').val() == "") {
alert("Fecha de Prestación del Servicio es Requerida");
if($('#start_at').val() > $fecha_actual){
alert("La Fecha de Prestación es Mayor a la Fecha Actual");
} else{
$.ajax({
url:"Controlador/finalizar.php",
method:"POST",
data:$('#detalle_solicitud').serialize(),
beforeSend:function(){
$('#fin_solicitud').val("FINALIZAR");
},
success:function(data){
$('#detalle_solicitud')[0].reset();
$('#e_table').html(data);
}
});
}
}
});
});
Ejecución de la Consulta y Actualización
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
<?php
$connect = mysqli_connect("localhost", "root", "", "audasyst");
if(!empty($_POST)){
$output = '';
$id = mysqli_real_escape_string($connect, $_POST["id"]);
$start_at = mysqli_real_escape_string($connect, $_POST["start_at"]);
$query = "UPDATE orden SET or_fend = $start_at WHERE or_id = $id";
$resultado = mysqli_query($connect, $query) ;
if($query==TRUE){
$select_query = "SELECT or_id, cl, pr_id, serv, cd, or_obs, or_finit, or_fend, or_status, or_create, prov_name, cl_name, se_name, ci_name FROM orden INNER JOIN cliente ON orden.cl=cliente.cl_id INNER JOIN provider ON orden.pr_id=provider.prov_id INNER JOIN service ON orden.serv=service.se_id INNER JOIN city ON orden.cd=city.ci_id WHERE or_status ='Pendiente' ORDER BY or_finit ASC";
$consultaorden = mysqli_query($connect, $select_query);
$output.='
<table class="table table-striped">
<thead>
<th style="background-color:#700202; color: white">N° Solicitud</th>
<th style="background-color:#700202; color: white">Paciente</th>
<th style="background-color:#700202; color: white">Proveedor</th>
<th style="background-color:#700202; color: white">Fecha Creación</th>
<th style="background-color:#700202; color: white; width: 60px;">Fecha Prestación</th>
<th style="background-color:#700202; color: white; width: 60px;"></th>
<th style="background-color:#700202; color: white; width: 60px;"></th>
</thead>';
while($row = mysqli_fetch_array($consultaorden)){
$output .= '<tr>
<td style="width: auto;">'.$row["or_id"].'</td>
<td style="width: auto;">'.$row["cl"].' - '.$row["cl_name"].' </td>
<td style="width: auto;">'.$row["prov_name"].' </td>
<td style="width: auto;">'.$row["or_finit"].' </td>
<td style="width: auto;"><input type="date" id="<?php echo $row["or_id"]; ?>" name="start_at" value="" class="form-control" placeholder="inicio"></td>
<td style="width:60px; alignment-adjust: central; alignment-baseline: central">
<input type="button" name="view" id="<?php echo $row["or_id"]; ?>" class="btn btn-info btn-xs view_data" value="ver" data-toggle="tooltip" title="Detalle de Solicitud"/>
</td>
<td style="width:60px; alignment-adjust: central; alignment-baseline: central">
<input type="submit" name="fin_solicitud" id="<?php echo $row["or_id"]; ?>" class="btn btn-info btn-xs" value="Finalizar" data-toggle="tooltip" title="Finalizar Solicitud"/>
</td>
</tr>';
}
$output.= '</table>';
}
echo $output;
} else{
echo 'Error al Actualizar la información de la solicitud';
printf("Errormessage: %s\n", mysqli_error($connect));
}
?>
Valora esta pregunta
0