How to keep the presentation of modal data

0

I developed a screen that shows the benefits granted to the citizen, a social assistance system, follow the view:

<!--onblur ="validaNomeCidadaoGeral('dcbe_usu_codigo','dcbe_usu_nome','dcbealert_usu_nome')" -->
<div class="conteudo" >
    <legend>Itens benefício eventual</legend>
    <p class="msgAviso" id="beneficios-msg" <?=(count($this->dadosBenItens)>0 ? "style='display: none;'" : "style='display: show;'")?>>
    </p>
    <div class="msgAviso" id="dcbealert_exc_bei" style="display: none;"></div>
        <table class="table table-bordered" id="beneficios_inseridos" 
        <?=(count($this->dadosBenItens)>0 ? "style='display: show;'" : "style='display: none;'")?>>
        <thead>
            <tr>
            <th>Benefício</th>
            <th>Tipo de benefício</th>
            <th>Quantidade</th>
            <th>Valor</th>
            <th>Benefício concedido</th>
            <th>Data Prevista</th>
            <th>Data Entrega</th>
            <th>Finaliza Entrega</th>
            </tr>
        </thead>   
    <tbody>
        <?php 
        if (count($this->dadosBenItens)>0) {
        // die('sdsadas')
        foreach($this->dadosBenItens as $ite) { ?>
            <tr id='beneficio_inserido<?=$ite->asbdi_codigo?>'>

                <td class="center">
                    <?=$ite->beneficio?>
                </td>
                <td class="center">
                    Tipo de benefício
                </td>
                <td class="center">
                    <?=$ite->asbdi_qtd?>
                </td>
                <td class="center">
                    <?=$ite->asbdi_valor?>
                </td>
                <td class="center">
                    <?=($ite->asbdi_concedido == 1 ? 'Sim' : 'Não')?>
                </td>

                <td class="center">
                    <?=($ite->asbdi_data_entrega)?>
                </td>
                <td class="center">
                    <p id = "" style="display: none"><?=($ite->asbdi_entrega)?></p>
                </td>
                <td>
                    <div>
                        <button onclick="gerarDataEntrega(<?=$ite->asbdi_codigo?>)">Finliza Entrega</button>
                    </div>
                </td> 
            </tr>

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

Result:

Solong,Iclickonthebuttontoloadthenecessaryfunctions,savethedateofdeliveryofthebenefitandgood.AfterthesuccessofajaxIwouldliketohidethebuttonandpresentthedate.

functiongerarDataEntrega(id){$.ajax({url:baseUrl+"/atendimentocras/beneficios-cidadao/data-entrega/",
        type: "POST",
        data: {id: id },
        success: function(resultado){

        }
    });
}

Plus the problem is that everything is in a foreach making it difficult to present the delivery date if the citizen has more than one benefit. And another how can I keep this presentation fixed? .

    
asked by anonymous 12.09.2018 / 20:29

2 answers

0

You can add id to the button, and in AJAX success you manipulate it with jQuery.

<div>
   <button id="id-botao-<?=$ite->asbdi_codigo?>"
           onclick="gerarDataEntrega(<?=$ite->asbdi_codigo?>)">
      Finliza Entrega
   </button>
</div>

success: function(resultado){
     $('#id-botao-'+id).hide();
     // faz o que precisa com a sua variável 'resultado' 
     ...
}

Is this what you want to do?

    
12.09.2018 / 21:17
0

I made some changes to the code, validating if the citizen already has benefits. If he already has the generate date button, it does not appear. How was it?

<!--onblur ="validaNomeCidadaoGeral('dcbe_usu_codigo','dcbe_usu_nome','dcbealert_usu_nome')" -->
<div class="conteudo" >
    <legend>Itens benefício eventual</legend>
    <p class="msgAviso" id="beneficios-msg" <?=(count($this->dadosBenItens)>0 ? "style='display: none;'" : "style='display: show;'")?>>
    </p>
    <div class="msgAviso" id="dcbealert_exc_bei" style="display: none;"></div>
        <table class="table table-bordered" id="beneficios_inseridos" 
        <?=(count($this->dadosBenItens)>0 ? "style='display: show;'" : "style='display: none;'")?>>
        <thead>
            <tr>
                <th>Benefício</th>
                <th>Tipo de benefício</th>
                <th>Quantidade</th>
                <th>Valor</th>
                <th>Benefício concedido</th>
                <th>Data Prevista</th>
                <th>Data Entrega</th>
                <th>Finaliza Entrega</th>
            </tr>
        </thead>   
    <tbody>
        <?php 
        if (count($this->dadosBenItens)>0) {
        // die('sdsadas')
        foreach($this->dadosBenItens as $ite) { ?>

                    <tr id='beneficio_inserido<?=$ite->asbdi_codigo?>'>

                        <td class="center">
                            <?=$ite->beneficio?>
                        </td>
                        <td class="center">
                            Tipo de benefício
                        </td>
                        <td class="center">
                            <?=$ite->asbdi_qtd?>
                        </td>
                        <td class="center">
                            <?=$ite->asbdi_valor?>
                        </td>
                        <td class="center">
                            <?=($ite->asbdi_concedido == 1 ? 'Sim' : 'Não')?>
                        </td>

                        <td class="center">
                            <?=($ite->asbdi_data_entrega)?>
                        </td>
                        <td class="center">
                            <p id="" style=""><?=($ite->asbdi_entrega)?></p>
                        </td>
                        <td>
            <?php if ($ite->asbdi_entrega == null): ?>
                            <div>
                                <button id="id-botao-<?=$ite->asbdi_codigo?>"
                                       onclick="gerarDataEntrega(<?=$ite->asbdi_codigo?>)">
                                  Finaliza Entrega
                                </button>
                            </div>
            <?php endif ?>
                        </td> 

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

I made a small change in ajax:

function gerarDataEntrega (id){
    $.ajax({
        url: baseUrl + "/atendimentocras/beneficios-cidadao/data-entrega/",
        type: "POST",
        data: {id: id },
        success: function(resultado){
            alert("Data de entrega efetuada com sucesso.");
            location.reload()
        }
    });
}

This was the way I found to solve this problem, of course the ideas of the topic helped me and much in the conclusion.

    
13.09.2018 / 13:58