Pass parameter to Modal window

Asked

Viewed 25 times

0

I’m having a little trouble executing some of my codes and I’d like your help .

Goal of my PHP : Generate a table*( Already being generated )* that has two buttons from it one of EDIT (This is already working normal , because I can only pass the table data to input) and another of VISUALISE ( However this view I need to pass 4 information from this initial table , to be performed a query in another database ) , so I am only able to pass this variable if it is an input that in this button in question does not help me , I need this 4 information to come as if they were variable , so I can make a query and leave the results .

Follow my code BELOW :

 <script>
                                function visualizar(e) {
                                    var linha = $(e).closest("tr");
                                    var filial = linha.find("td:eq(0)").text().trim(); // texto da primeira coluna
                                    var codigo = linha.find("td:eq(1)").text().trim(); // texto da segunda coluna
                                    var boleto = linha.find("td:eq(4)").text().trim(); // texto da terceira coluna
                                    var parcela = linha.find("td:eq(5)").text().trim(); // texto da quarta coluna

                                    $("#filialVisualizar").val(filial);
                                    $("#codigoVisualizar").val(codigo);
                                    $("#boletoVisualizar").val(boleto);
                                    $("#parcelaVisualizar").val(parcela);
                                }
<?php include("conexao/conexao_banco_lobo.php")?>
                    <?php 
 $data_inicial = $_POST['data_inicial'];
 $data_inicial = explode('-', $data_inicial);     // transforma em array
 $data_inicial = implode('', $data_inicial);     // transforma em string novamente


  $query = " SELECT  * FROM TESTE"; $params = array(); $options = array('Scrollable' => SQLSRV_CURSOR_KEYSET); $stmt = sqlsrv_query($conn, $query, $params, $options); ?>

                    <br />
                    <section id="unseen">
                        <div class="table-responsive">
                            <table class="table table-bordered table-striped table-condensed">
                                <tr>
                                    <th>
                                        <center><b>Filial</b></center>
                                    </th>
                                    <th>
                                        <center><b>Código</b></center>
                                    </th>
                                    <th>
                                        <center><b>Nome</b></center>
                                    </th>
                                    <th>
                                        <center><b>CNPJ</b></center>
                                    </th>
                                    <th>
                                        <center><b>Boleto</b></center>
                                    </th>
                                    <th>
                                        <center><b>Parcela</b></center>
                                    </th>
                                    <th>
                                        <center><b>Vencimento</b></center>
                                    </th>
                                    <th>
                                        <center><b>Atraso</b></center>
                                    </th>
                                    <th>
                                        <center><b>Valor</b></center>
                                    </th>
                                    <th>
                                        <center><b>Telefone</b></center>
                                    </th>
                                    <th>
                                        <center><b>Contato</b></center>
                                    </th>
                                    <th>
                                        <center><b>E-mail</b></center>
                                    </th>
                                    <th>
                                        <center><b>Representante</b></center>
                                    </th>
                                    <th></th>
                                    <th></th>
                                </tr>
                                <?php while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) { 
 ?>

                                <tr>
                                    <td>
                                        <center>
                                            <?php $filial = $row['E1_FILIAL'];
                                             if($filial == '010101'){
                                             echo 'BA' ;}
                                             if($filial == '010102'){
                                             echo 'SP' ;}
                                             if($filial == '010103'){
                                             echo 'RJ' ;}
                                             if($filial == '010104'){
                                             echo 'MG' ;}
                                             if($filial == '010105'){
                                             echo 'VDC' ;}
                                             if($filial == '010106'){
                                             echo 'PR' ;}
                                             if($filial == '010107'){
                                             echo 'PE' ;}
                                             if($filial == '010108'){
                                             echo 'RS' ;}
                                             
                                            ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['A1_COD']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['A1_NOME']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['A1_CGC']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['E1_NUM']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['E1_PARCELA']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['DATA']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['ATRASO']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['VALOR']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['TELEFONE']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['A1_CONTATO']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['A1_EMAIL']; ?>
                                        </center>
                                    </td>
                                    <td>
                                        <center>
                                            <?php echo $row['A3_NOME']; ?>
                                        </center>
                                    </td>

                                    <td>
                                        <center><i class="fa fa-edit" title="Editar" data-toggle="modal" data-target="#modalClient" class="btnEditar" onclick="editar(this)"></i></center>
                                    </td>

                                                                            <center><i class="fa fa-eye" title="Visualizar" data-toggle="modal" data-target="#modalVisualizar" class="btnEditar" onclick="visualizar(this)"></i></center>
                                                                            
        <div class="modal fade" id="modalVisualizar" tabindex="-1" role="dialog" aria-labelledby="modalVisualizar" aria-hidden="true">
                                <div class="modal-dialog" role="document">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <h4 class="modal-title"><center>Visualizar - Cobrança</center></h4>
                                        </div>
                                        <div class="modal-body">
                                            <?php       
sql = ("SELECT * FROM FIN_TELCOBR WHERE REC_FILIAL ='$filialVisualizar' AND REC_CODIGO = '$codigoCliente' AND REC_BOLETO ='$boletoCliente' AND REC_PARCELA = '$parcelaCliente'");
                                             $params = array(); $options = array('Scrollable' => SQLSRV_CURSOR_KEYSET); $stmt_sql = sqlsrv_query($conn, $sql, $params, $options); ?>
                                            <table class="table table-bordered table-striped table-condensed">
                                                <tr>
                                                    <th>
                                                        <center><b>Filial</b></center>
                                                    </th>
                                                    <th>
                                                        <center><b>Código</b></center>
                                                    </th>
                                                    <th>
                                                        <center><b>Boleto</b></center>
                                                    </th>
                                                    <th>
                                                        <center><b>Parcela</b></center>
                                                    </th>
                                                    <th>
                                                        <center><b>Observação</b></center>
                                                    </th>
                                                    <th>
                                                        <center><b>Dt Ligação</b></center>
                                                    </th>
                                                    <th>
                                                        <center><b>Negociação</b></center>
                                                    </th>
                                                </tr>
   <?php while ($row_sql = sqlsrv_fetch_array($stmt_sql, SQLSRV_FETCH_ASSOC)) { 
 ?>

                                                <tr>
                                                    <td>
                                                        <?php echo $row_sql['REC_FILIAL']; ?>
                                                    </td>
                                                    <td>
                                                        <?php echo $row_sql['REC_CODIGO']; ?>
                                                    </td>
                                                    <td>
                                                        <?php echo $row_sql['REC_BOLETO']; ?>
                                                    </td>
                                                    <td>
                                                        <?php echo $row_sql['REC_PARCELA']; ?>
                                                    </td>
                                                    <td>
                                                        <?php echo $row_sql['TEL_OBS']; ?>
                                                    </td>
                                                    <td>
                                                        <?php echo $row_sql['TEL_LIGACAO']; ?>
                                                    </td>
                                                    <td>
                                                        <?php echo $row_sql['TEL_NEGOCIACAO']; ?>
                                                    </td>
                                                </tr>

                                                <?php
        }
    ?>
                                            </table>
                                        </div>
                                    </div>
                                </div>
                            </div>                                                           

                                </tr>

                                <?php
        }
    ?>
                            </table>

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.