I have a problem and that is that when I click on the modal I want to load the id of said provider, it is necessary because it is a warning to deactivate or activate said provider, I leave the code
This is the code with which I show a table with the suppliers and assign the buttons to perform both the action of editing a provider and to eliminate it however with the latter I have problems since it is with this which has a modal, I need to weigh the data of the row in which I am clicking so that once inside the modal I effectively deactivate said provider and not another one in the database.
function listado_proveedores(){
$conexion = new connex();
$seleccion = "SELECT Proveedor.*,Estado.Descripcion_Estado FROM Proveedor inner join Estado on Proveedor.ID_Estado=Estado.ID_Estado order by Proveedor.ID_Estado DESC";
$consulta = $conexion->query($seleccion);
//Función while para capturar uno a uno las filas resultantes de la consulta
$lista = "";
while($fila = $conexion->row($consulta))
{
//concateno a la variable creada los resultados de la fila
$id = $fila['ID_Estado'];
$lista .= '<tr>
<td>'.$fila['Rut'].'</td>
<td>'.$fila['Razon_Social'].'</td>
<td>'.$fila['Comuna'].'</td>
<td>'.$fila['Descripcion_Estado'].'</td>
<td><button type="button" class="btn btn-warning" onclick="editar('.$fila['ID_Proveedor'].')">Modificar</button></td>';
if ($id ==2){
$lista .='<td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal_hab">Habilitar</button></td>
</tr>';
}
if ($id ==1){
$lista .='<td><button type="button" class="btn btn-primary" data-toggle="modal" data-target="#modal_des">Deshabilitar</button></td>
</tr>';
}
}
echo $lista;
$conexion->cerrar();
}? >
This is the modal code (there are 2, one to enable and one to disable) as well as the table where I show the information
<script type="text/javascript" src="../../js/menus/jQuery.js"></script>
<link rel="stylesheet" type="text/css" href="../../js/menus/cssDatatable.min.css"/>
<script type="text/javascript" src="../../js/menus/jQueryDatatable.js"></script>
<script type="text/javascript" src="/js/compra/proveedor.js"></script>
<?php
include '../../db/compras/select_tabla_prov.php';
?>
<div id="page-inner" align="center">
<div align="center" class="row">
<h1>Proveedores</h1>
<hr>
</div>
<div class="row" align="left">
<td><button class="btn btn-success" onclick="ingresar_proveedor();">Nuevo</button></td>
<td><button class="btn btn-danger" onclick="volver();">Volver</button></td>
<br/>
<br/>
<table id="tablita2" class="table table-striped table-hover">
<thead style="background-color: #ccffcc;">
<tr>
<th>RUT</th>
<th>Razon Social Proveedor</th>
<th>Comuna</th>
<th>Estado</th>
<th>Modificacion</th>
<th>Desabilitar/Habilitar</th>
</tr>
</thead>
<tbody>
<?php
listado_proveedores();
?>
</tbody>
</table>
</div>
</div>
!------MODAL DONDE HABILITAMOS PROVEEDOR----!
<div class="modal fade" id="modal_hab" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">Habilitación Proveedor</h4>
</div>
<div class="modal-body">
¿Realmente desea habilitar dicho proveedor?
</div>
<div align="center">
<button type="button" class="btn btn-primary" onclick="cerrar_modal()">SI</button>
<button type="button" class="btn btn-warning" data-dismiss="modal">NO</button>
</div>
</div>
</div>
</div>
!------MODAL DONDE DESHABILITAMOS PROVEEDOR----!
<div class="modal fade" id="modal_des" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">Deshabilitacion Proveedor</h4>
</div>
<div class="modal-body">
¿Realmente desea deshabilitar dicho proveedor?
</div>
<div align="center">
<button type="button" class="btn btn-primary" onclick="cerrar_modal()">SI</button>
<button type="button" class="btn btn-warning" data-dismiss="modal">NO</button>
</div>
</div>
</div>
</div>
Basically I need that when I press the disable button I load the corresponding modal and know that I'm clicking and I mean that row and not another.
These are the functions I occupy
$(document).ready(function() {
$('#tablita2').DataTable();
});
function ingresar_proveedor(){
$("#page-wrapper").load("vista/modulos/ingreso/ingreso_proveedor.php")
}
function MostrarModal(){
$('#modal_contacto').modal('show')//mostramos el modal
$('body').addClass('modal-open');
}
function volver(){
$("#page-wrapper").load("vista/menus/inicio.php")
}
function editar(id){
$("#page-wrapper").load('vista/modulos/modificacion/modificacion_proveedor.php?valor='+id);
}