<?php
session_start();
include "classes/db.class.php";
include "classes/fc.class.php";
include "config.php";


if (!isset($_SESSION['uid'])) {
    header("Location: login.php");
    exit;
}
$tabela = "servicos";
$coluna = "ABERTURA DESC";
$primaria = 'idservicos';
if (isset($_SESSION['tabela'])) {
    unset($_SESSION['tabela']);
}
if (isset($_SESSION['coluna'])) {
    unset($_SESSION['coluna']);
}
if (isset($_SESSION['primaria'])) {
    unset($_SESSION['primaria']);
}
if (isset($_SESSION['CODIGO'])) {
    unset($_SESSION['CODIGO']);
}

$_SESSION['primaria'] = $primaria;
$_SESSION['tabela'] = $tabela;
$_SESSION['coluna'] = $coluna;

$uid = $_SESSION['uid'];
$nome = $_SESSION['un'];
$email = $_SESSION['ue'];
$idsql = $_SESSION['uids'];

$pag = $_SERVER['REQUEST_URI'];
$pag = explode("/", $pag);
$page = $pag[2];

$lixo=FC::limpaos($idsql);





?>
<!DOCTYPE html>

<html lang="pt-br">

<head>

    <?php include "includes/header.php"; ?>

</head>

<body>

    <!-- navbar -->
    <?php include "includes/navbar.php"; ?>


    <div id="corpo" class="container card shadow-lg  my-2 py-1">

        <div class="row align-items-center justify-content-center my-2">

            <div class="col-7 col-md-7 text-start">
                <h4 class="text-dark"><i class='fas fa-tools me-2'></i>Ordens Serviços</h4>


            </div>
            <div class="col-5 col-md-5  text-end">

                <a href="#" class="btn btn-success text-light float-end" data-bs-toggle="modal"
                    data-bs-target="#mReg"><i class='fas fa-plus-circle'></i></a>


            </div>



        </div>

    </div>

    <div class="container card shadow-lg  mb-3 py-1">

        <div class="row mb-3">

            <div class="col-12 col-md-12 col-sm-12 col-lg-12 col-xl-12 mb-3">

                <table id="tbservicos" class="table table-striped mb-3   table-hover">

                    <thead class="border-0 border-1 border-bottom border-secondary">
                        <tr>
                            <th class="col-2 text-center">Data</th>
                            <th class='text-start'>Cliente</th>
                            <th class="col-2 text-center">Valor</th>
                            <th class="col-1 text-center">Status</th>
                            <th class="col-3 text-end"></th>

                        </tr>
                    </thead>
                    <tbody>


                    </tbody>
                </table>

            </div>

        </div>

    </div>



    <!-- footer -->
    <?php include "includes/footer.php";


    ?>



    <!-- Modal -->
    <div class="modal fade" id="mReg" tabindex="-1" aria-labelledby="mRegLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="mRegLabel">Nova O.S:</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">

                    <form id="fcad" class="was-validated" method='POST'>



                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='CODIGO' name='CODIGO' value="" class='form-control' required>
                        </div>

                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='ABERTURA' name='ABERTURA' value="<?php echo date('Y-m-d h:i:s'); ?>" class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' value="<?php echo date('Y-m-d h:i:s'); ?>" id='PREVISTA' name='PREVISTA' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='RAZAO' class='form-label'>RAZAO/CLIENTE:</label>
                            <input type='text' id='RAZAO' name='RAZAO' class='form-control text-uppercase' readonly required>
                            <button type="button" class="btn btn-success btn-sm w-100 text-center text-ligth" id="btncliente" onclick="buscaclientes(0);"><i class='fas fa-search me-2'></i>Buscar Cliente</button>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='MODELO' class='form-label'>MODELO:</label>
                            <input type='text' id='MODELO' name='MODELO' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='SERIE' class='form-label'>SERIE:</label>
                            <input type='text' id='SERIE' name='SERIE' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='MECANICO' name='MECANICO' value="<?php echo $idsql; ?>" class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='CLIENTE' class='form-label'>CLIENTE:</label>
                            <input type='hidden' id='CLIENTE' name='CLIENTE' value="" class='form-control'>

                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='SOLICITADO' class='form-label'>SOLICITADO:</label>
                            <input type='text' id='SOLICITADO' name='SOLICITADO' class='form-control text-uppercase'>
                        </div>

                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='PAGAMENTO' class='form-label'>PAGAMENTO:</label>
                            <input type='number' value="0.00" id='PAGAMENTO' name='PAGAMENTO' class='form-control'>
                        </div>
                        <div class="row">
                            <div class='col-md-12 col-sm-6 mb-1'>

                                <input type='hidden' value="<?php echo date('Y-m-d h:i:s'); ?>" id='ENTRACLIENTE' name='ENTRACLIENTE' class='form-control'>
                            </div>
                            <div class='col-md-12 col-sm-6 mb-1'>

                                <input type='hidden' value="<?php echo date('Y-m-d h:i:s'); ?>" id='SAIDACLIENTE' name='SAIDACLIENTE' class='form-control'>
                            </div>
                        </div>
                        <div class='col-md-12 col-sm-6 mb-1'>

                            <input type='hidden' id='PRONTA' value="<?php echo date('Y-m-d h:i:s'); ?>" name='PRONTA' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-6 mb-1'>

                            <input type='hidden' id='ENTREGUE' name='ENTREGUE' class='form-control' value="<?php echo date('Y-m-d h:i:s'); ?>">
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='FECHAMENTO' name='FECHAMENTO' class='form-control' value="<?php echo date('Y-m-d h:i:s'); ?>">
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='POS' class='form-label'>POS:</label>
                            <input type='text' id='POS' value="A" name='POS' class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='CANCELA' name='CANCELA' class='form-control' value="<?php echo date('Y-m-d h:i:s'); ?>">
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='TOTALPROD' name='TOTALPROD' value="0" class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='TOTALSERVICO' name='TOTALSERVICO' class='form-control' value="0" required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='TOTAL' value="0" name='TOTAL' class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='OBS' class='form-label'>OBS:</label>
                            <input type='text' id='OBS' name='OBS' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='DEFRECLAM1' class='form-label'>DEF.RECLAM:</label>
                            <textarea name="DEFRECLAM1" id="DEFRECLAM1" class="form-control" cols="5"></textarea>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='CARACTENT1' class='form-label'>CARACTENT1:</label>
                            <input type='text' id='CARACTENT1' name='CARACTENT1' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' value="" id='DEFEITENC1' name='DEFEITENC1' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-6 mb-1'>

                            <input type='hidden' value="" id='SEQUENCIA' name='SEQUENCIA' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-6 mb-1'>

                            <input type='hidden' id='ANO' name='ANO' value="<?php echo date('Y'); ?>" class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='IMPRESSO' value="0" name='IMPRESSO' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='VENDEDOR' name='VENDEDOR' value="<?php echo $idsql; ?>" class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='RECEBIDO' class='form-label'>RECEBIDO:</label>
                            <input type='text' id='RECEBIDO' name='RECEBIDO' class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='STATUS' name='STATUS' value="A" class='form-control' required>
                        </div>
                        <button type='submit' id='btnSalvar' class='btn btn-success text-light w-100'>Salvar<i class='fas fa-location-arrow ms-2'></i></button>
                    </form>


                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-warning  w-100" data-bs-dismiss="modal">Cancelar</button>

                </div>
            </div>
        </div>
    </div>

    <!-- Modal -->
    <div class="modal fade" id="mDados" tabindex="-1" aria-labelledby="mDadosLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="mDadosLabel">Ordem Serviço:</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">

                    <form id="fdados" class="was-validated" method='POST'>



                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='CODIGO2' name='CODIGO' value="" class='form-control' required>
                        </div>

                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='ABERTURA2' name='ABERTURA' value="<?php echo date('Y-m-d h:i:s'); ?>" class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' value="<?php echo date('Y-m-d h:i:s'); ?>" id='PREVISTA1' name='PREVISTA' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='RAZAO' class='form-label'>RAZAO/CLIENTE:</label>
                            <input type='text' id='RAZAO2' name='RAZAO' class='form-control text-uppercase' readonly required>
                            <button type="button" class="btn btn-success btn-sm w-100 text-center text-ligth" id="btncliente" onclick="buscaclientes(1);"><i class='fas fa-search me-2'></i>Buscar Cliente</button>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='MODELO' class='form-label'>MODELO:</label>
                            <input type='text' id='MODELO2' name='MODELO' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='SERIE' class='form-label'>SERIE:</label>
                            <input type='text' id='SERIE2' name='SERIE' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='MECANICO2' name='MECANICO' value="<?php echo $idsql; ?>" class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='CLIENTE' class='form-label'>CLIENTE:</label>
                            <input type='hidden' id='CLIENTE2' name='CLIENTE' value="" class='form-control'>

                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='SOLICITADO' class='form-label'>SOLICITADO:</label>
                            <input type='text' id='SOLICITADO2' name='SOLICITADO' class='form-control text-uppercase'>
                        </div>

                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='PAGAMENTO' class='form-label'>PAGAMENTO:</label>
                            <input type='number' value="0.00" id='PAGAMENTO2' name='PAGAMENTO' class='form-control'>
                        </div>
                        <div class="row">
                            <div class='col-md-12 col-sm-6 mb-1'>

                                <input type='hidden' value="<?php echo date('Y-m-d h:i:s'); ?>" id='ENTRACLIENTE2' name='ENTRACLIENTE' class='form-control'>
                            </div>
                            <div class='col-md-12 col-sm-6 mb-1'>

                                <input type='hidden' value="<?php echo date('Y-m-d h:i:s'); ?>" id='SAIDACLIENTE2' name='SAIDACLIENTE' class='form-control'>
                            </div>
                        </div>
                        <div class='col-md-12 col-sm-6 mb-1'>

                            <input type='hidden' id='PRONTA2' value="<?php echo date('Y-m-d h:i:s'); ?>" name='PRONTA' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-6 mb-1'>

                            <input type='hidden' id='ENTREGUE2' name='ENTREGUE' class='form-control' value="<?php echo date('Y-m-d h:i:s'); ?>">
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='FECHAMENTO2' name='FECHAMENTO' class='form-control' value="<?php echo date('Y-m-d h:i:s'); ?>">
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='POS' class='form-label'>POS:</label>
                            <input type='text' id='POS2' value="A" name='POS' class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='CANCELA2' name='CANCELA' class='form-control' value="<?php echo date('Y-m-d h:i:s'); ?>">
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='TOTALPROD2' name='TOTALPROD' value="" class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='TOTALSERVICO2' name='TOTALSERVICO' class='form-control' value="0" required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='TOTAL2' value="" name='TOTAL' class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='OBS' class='form-label'>OBS:</label>
                            <input type='text' id='OBS2' name='OBS' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='DEFRECLAM1' class='form-label'>DEF.RECLAM:</label>
                            <textarea name="DEFRECLAM1" id="DEFRECLAM12" class="form-control" cols="5"></textarea>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='CARACTENT1' class='form-label'>CARACTENT1:</label>
                            <input type='text' id='CARACTENT12' name='CARACTENT1' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' value="" id='DEFEITENC12' name='DEFEITENC1' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-6 mb-1'>

                            <input type='hidden' value="" id='SEQUENCIA2' name='SEQUENCIA' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-6 mb-1'>

                            <input type='hidden' id='ANO2' name='ANO' value="<?php echo date('Y'); ?>" class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='IMPRESSO2' value="0" name='IMPRESSO' class='form-control'>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='VENDEDOR2' name='VENDEDOR' value="<?php echo $idsql; ?>" class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>
                            <label for='RECEBIDO' class='form-label'>RECEBIDO:</label>
                            <input type='text' id='RECEBIDO2' name='RECEBIDO' class='form-control' required>
                        </div>
                        <div class='col-md-12 col-sm-12 mb-1'>

                            <input type='hidden' id='STATUS2' name='STATUS' class='form-control' required>
                        </div>
                        <button type='submit' id='btnSalvar2' class='btn btn-success text-light w-100'>Salvar<i class='fas fa-location-arrow ms-2'></i></button>
                    </form>


                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-warning  w-100" data-bs-dismiss="modal">Cancelar</button>

                </div>
            </div>
        </div>
    </div>

    <!-- Modal -->
    <div class="modal fade" id="mClientes" tabindex="-1" aria-labelledby="mClientesLabel" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered modal-lg">
            <div class="modal-content">
                <div class="modal-header bg-primary text-light">
                    <h5 class="modal-title" id="mClientesLabel">Busca Cliente:</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                </div>
                <div class="modal-body">

                    <div class="row">

                        <div class="col-12 col-md-12 col-sm-12 col-lg-12 col-xl-12 mb-3">

                            <table id="tbclientes" class="table table-striped mb-3   table-hover">

                                <thead class="border-0 border-1 border-bottom border-secondary">
                                    <tr>

                                        <th class='col-9 text-start'>Cliente</th>

                                        <th class="col-3 text-end"></th>

                                    </tr>
                                </thead>
                                <tbody>


                                </tbody>
                            </table>

                        </div>


                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-warning  w-100" data-bs-dismiss="modal">Cancelar</button>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <?php include "includes/libs.php"; ?>


    <script>
        var valor=0;
        $(function() {
            // Initialize tooltips
            pulse('Carregando...');

        });
        $(document).ready(function() {
            removeloader();

            $('#btnradio3').prop('checked', true);
            $('#btnradio2').prop('checked', false);
            $('#btnradio4').prop('checked', false);
            $('#btnradio1').prop('checked', false);

            var lista = $('#tbservicos tbody');
            lista.empty();
            var lista2 = $('#tbclientes tbody');
            lista2.empty();



            $.get('./rest/buscaos.php', function(resposta) {

                if (resposta != 'erro') {

                    lista.html(resposta);
                    $('#tbservicos').dataTable({
                        dom: 'Bfrtip',
                        buttons: [
                            'copy',
                            'excel',
                            'pdf',
                            'print'
                        ],
                        language: {
                            url: './langPT.json'
                        }

                    });

                } else {
                    mensagem('Erro ao carregar Registros!', 'erro');
                }


            });

            $.get('./rest/searchclientes.php', function(rs) {

                if (rs != 'erro') {

                    lista2.html(rs);
                    $('#tbclientes').dataTable({
                        dom: 'Bfrtip',
                        buttons: [
                            'copy',
                            'excel',
                            'pdf',
                            'print'
                        ],
                        language: {
                            url: './langPT.json'
                        }

                    });


                } else {
                    mensagem('Erro ao carregar clientes!', 'erro');
                }
            });



            $('#fcad').submit(function(e) {
                e.preventDefault(); // Prevent the default form submission

                $('#btnSalvar').prop('disabled', true); // Disable the button to prevent multiple submissions
                $('#CODIGO').val('<?php echo strval(FC::codigoservico());  ?>');
                $('#SEQUENCIA').val('<?php echo (FC::sequencia());  ?>');
                //$('#CODIGO').prop('readonly', true); // Disable the button to prevent multiple submissions

                //alert($('#CODIGO').val());
                //alert($('#SEQUENCIA').val());


                loaders('Criando Ordem de Serviço...');

                var formData = $(this).serialize(); // Serialize the form data



                $.ajax({
                    type: 'POST',
                    url: 'rest/cados.php',
                    data: formData,
                    success: function(response) {

                        //alert(response);
                        removeloader();
                        $('#btnSalvar').prop('disabled', false);

                        if (response == 'ok') {

                            mensagem('Ordem de Serviço cadastrada com sucesso! Adicione Items a OS...', 'sucesso');
                            $('#mReg').modal('hide');
                            setTimeout(() => {
                                $(location).attr('href', 'itens.php');
                            }, 2000);
                        } else {

                            mensagem('Erro ao cadastrar OS!' + response, 'erro');

                            //mensagem('Erro ao cadastrar cliente!', 'erro');
                        }

                        //console.log(response);
                    },
                    error: function(xhr, status, error) {
                        alert(error);

                        removeloader();
                        $('#btnSalvar').prop('disabled', false);
                        mensagem('Ocorreu um erro ao cadastrar OS !', 'erro');
                    }
                });
            });


            
            $('#fdados').submit(function(e) {
                e.preventDefault(); // Prevent the default form submission

                $('#btnSalvar2').prop('disabled',
                true); // Disable the button to prevent multiple submissions

                loaders('Atualizando Ordem de Serviço...');

                var formData = $(this).serialize(); // Serialize the form data

                $.ajax({
                    type: 'POST',
                    url: 'rest/editos.php',
                    data: formData,
                    success: function(response) {

                       // alert(response);
                        removeloader();
                        $('#btnSalvar2').prop('disabled', false);

                        if (response == 'ok') {

                            mensagem('OS atualizada com sucesso!', 'sucesso');
                            $('#mDados').modal('hide');
                            setTimeout(() => {
                                 $(location).attr('href', 'itens.php');
                            }, 2000);
                        } else {
                            mensagem('Erro ao atualizar Ordem de Serviço!', 'erro');
                        }

                        //console.log(response);
                    },
                    error: function(xhr, status, error) {
                        alert(error);

                        removeloader();
                        $('#btnCadastro2').prop('disabled', false);
                        mensagem('Ocorreu um erro ao atualizar a OS !', 'erro');
                    }
                });
            });


        });

        function removeloader() {



            Notiflix.Loading.remove(1923);
            // $('#corpo').fadeIn(500);
            //
        }


        function dados(id) {

            // alert(id);

            if (id != '' || id != null) {

                //$('#idcliente').val(id);

                $.post('rest/bsservico.php', {
                    id: id
                }, function(e) {

                    
                    var ds = JSON.parse(e);
                    $.each(ds[0], function(key, value) {
                     
                        $('#' + key + '2').val(value);


                    });

                    $('#mDados').modal('show'); 
                    $('#btnCadastro2').prop('disabled', false);
                    $('#mDadosLabel').html('Alterar Cadastro:' );

                });

            }

        }

        function buscaclientes(modo) {

            valor=modo;
            $('#mClientes').modal('show');

        }


        function adiciona(id, nome) {
            //alert(id);
            if (id != '' && nome != '') {

                
                if(valor==0){
                    $('#CLIENTE').val(id);
                    $('#RAZAO').val(nome);
                }else{
                    $('#CLIENTE2').val(id);
                    $('#RAZAO2').val(nome);
                }
                $('#mClientes').modal('hide');
                

            }
        }

        function excluiros(cod) {

            var codigo = cod;


            Notiflix.Confirm.show(
                'ATENCAO',
                'Deseja excluir a OS:' + codigo,
                'SIM',
                'CANCELAR',
                function okCb() {

                    // Call an AJAX endpoint to delete the item, passing id and type=1
                    $.post('./rest/excluios.php', {
                        codigo: codigo
                    }, function(res) {
                        if (res == 'ok') {
                            mensagem('Ordem de Serviço excluída com sucesso!', 'sucesso');
                            setTimeout(() => {
                                window.location.reload();
                            }, 2000);
                        } else {
                            mensagem('Erro ao excluir OS!', 'erro');
                        }
                    });


                },
                function cancelCb() {
                    //alert('If you say so...');
                }, {},
            );


        }
    </script>


</body>

</html>