<?php

include "../auxiliar/parametros.inc";
include '../idiomas/config.inc';

$is_venda = isset($GLOBALS['is_venda']) && $GLOBALS['is_venda'];

if (($p_fvalle_prazo_pagamento == 1 || $p_fvalle_prazo_pagamento == 2) && $is_venda) {

    include_once "../bd/funcoes.inc";
    include_once "../bd/bd_os.inc";
    $tabelaDePrecos = lecookie('tabelaDePrecos');
    $codos = lecookie('codos');

    $forma = getFormaDePagamentoDaOS($codos);
    // var_dump($forma);

    // $tabelasDePreco = getTabelasDePreco($codusu);
    // foreach ($tabelasDePreco as $t) {

    //     if ($tabelaDePrecos == $t["codprodtabela"])
    //         $tabelaSelecionada = $t;
    // }
?>






    <!-- <div class="form-group"> -->
        <!-- <label for='descricao' id='descricao'>Prazo: &nbsp; </label> -->


        <button type="button" id="btnSelecionarPrazoFValle" class="btn btn-success" data-toggle="modal" data-target="#modal-seleciona-forma-de-pagamento-fvalle">
            <span id="spanPrazoSelecionadoFValle">
                <?php if (is_null($forma)) : ?>
                    <?php echo $fv_selecionar_prazo; ?>
                <?php else : ?>
                    <?php echo $forma['descricao']; ?>
                <?php endif; ?>
            </span>
            &nbsp;
            <i class="fa fa-pencil"></i>
        </button>


        <?php if ($p_fvalle_prazo_pagamento == 2):?>
            <input type="hidden" id="btnAbreModalConfirmacaoAlteraPrecoFValle" onclick="selectTabelaDePrecoFValle(true)"></input>
        <?php else: ?>
            <input type="hidden" id="btnAbreModalConfirmacaoAlteraPrecoFValle" data-toggle="modal" data-target="#modal-confirma-alteracao-preco-ao-selecionar-forma-pagamento"></input>
        <?php endif; ?>
    <!-- </div> -->


    <div class="modal fade" id="modal-confirma-alteracao-preco-ao-selecionar-forma-pagamento">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title"><?php echo $msg_atencao; ?> </h4>
                </div>
                <div class="modal-body">
                    <p>
                    <?php echo $fv_alterar_preço_dos_itens_ja_inclusos; ?>
                    </p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-danger pull-left" data-dismiss="modal" onclick="selectTabelaDePrecoFValle(false)"><?php echo $bt_nao ; ?></button>
                    <button type="button" class="btn btn-primary pull-right" onclick="selectTabelaDePrecoFValle(true)" data-dismiss="modal"><?php echo $bt_sim ; ?></button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
    </div>




    <div class="modal fade" id="modal-seleciona-forma-de-pagamento-fvalle">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title"><?php echo $fv_prazo_pagamento; ?> </h4>
                </div>
                <div class="modal-body">
                    <div id="buscaPrazoContainerFValle">
                        <?php include '../modais/busca_prazo_de_pagamento.php'; ?>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default pull-left" data-dismiss="modal"><?php echo $bt_sair; ?> </button>
                </div>
            </div>
            <!-- /.modal-content -->
        </div>
        <!-- /.modal-dialog -->
    </div>















<?php } ?>