@extends('usuarios.clientes.master.layoutcliente')
@section('conteudo')
<style type="text/css">
    .flex
        {
         min-width: 100%;
        }
</style>
<script src="{{asset('js/jquery.dataTables.min.js') }}"></script>
{{-- SELECT STYLE --}}
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css">


  <div class="container-fluid">
        <div class="page-header" width="100%">
            <div class="row align-items-end">
                <div class="col-lg-8">
                    <div class="page-header-title">
                        
                        <i class="ik ik-alert-triangle bg-red"></i>
                        <div class="d-inline">
                            <h4>Pedidos de destruição</h4>
                          <br/>
                        </div>
                    </div>
                </div>
                <div class="col-lg-4">
                    <nav class="breadcrumb-container" aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item">
                                <a href="../index.html"><i class="ik ik-home"></i></a>
                            </li>
                            <li class="breadcrumb-item"><a href="#">Forms</a></li>
                            <li class="breadcrumb-item active" aria-current="page">destruição</li>
                        </ol>
                    </nav>
                </div>
                </div>

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <form name="cadrdestrution"  method="post" enctype="multipart/form-data">
                                @csrf
                            {{-- <div class="card-header">
                                <h3>Input Group</h3>
                            </div> --}}
                            <div class="card-body">
                                <div class="mb-20">
                          
                                    <div class="row">
                                        <label class="col-sm-4 col-lg-2 col-form-label">Categoria</label>
                                        <div class="col-sm-8 col-lg-10">
                                            <div class="input-group">
                                                <span class="input-group-prepend" >
                                                    {{-- <label class="input-group-text"></label> --}}
                                                </span>
                                                <input type="text" class="form-control" name="tipodocumentosolicitacao" placeholder="pasta, caixa, documento específico">
                                            </div>
                                        </div>
                                    </div>
                                     <div class="row">
                                            <label class="col-sm-4 col-lg-2 col-form-label">Tipo Solicitação</label>
                                            <div class="col-sm-8 col-lg-10">
                                                <div class="input-group">
                                                       
                                                                    <div class="form-group">
                                                                        <select class="form-control select2" name="naturezasolicitacao">
                                                                            <option value="virtual">digital</option>
                                                                            <option value="fisica">fisica</option>
                                                                        </select>
                                                                    </div>
                                                          
                                                </div>
                                                  
                                            </div>
                                        </div>
                                        
                                         <div class="row">
                                            <label class="col-sm-4 col-lg-2 col-form-label">Agência/Departamento</label>
                                            <div class="col-sm-6">
                                                <div class="input-group input-group-warning">
                                                    <span class="input-group-prepend"><label class="input-group-text"><i class="ik ik-home"></i></label></span>
                                                    <input type="text" class="form-control" name="agencia" placeholder="Kilamba">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <label class="col-sm-4 col-lg-2 col-form-label">Urgencia</label>
                                            <div class="col-sm-8 col-lg-10">
                                                <div class="input-group">
                                                       
                                                                    <div class="form-group">
                                                                        <select class="form-control select2" name="urgencia">
                                                                            <option value="Não_Urgente">Normal</option>
                                                                            <option value="necessario">Necessario</option>
                                                                            <option value="urgente">urgente</option>>
                                                                        </select>
                                                                    </div>
                                                          
                                                </div>
                                                  
                                            </div>
                                        </div>
                                        
                                        <div class="row">
                                            <label class="col-sm-4 col-lg-2 col-form-label">Comprovativo digital</label>
                                            <div class="col-sm-8 col-lg-10">
                                                <div class="input-group">
                                                           <input type="file" name="comprovativo" class="form-control" />
                                                </div>
                                                  
                                            </div>
                                        </div>
                                           
                                        <div class="row">
                                            <label class="col-sm-4 col-lg-2 col-form-label">Descrição</label>
                                            <div class="col-sm-8 col-lg-10">
                                                <div class="input-group">
                                                    {{-- <span class="input-group-prepend" id="basic-addon2">
                                                         <label class="input-group-text"></label> 
                                                    </span> --}}
                                                    <textarea  class="form-control" placeholder="detalhes adicionais sobre a solicitação" name="nota"></textarea>
                                                </div>
                                            </div>
                                        </div>
                                </div>
                                <div class="row">
                                    <label class="col-sm-4 col-lg-2 col-form-label">senha</label>
                                    <div class="col-sm-6">
                                        <div class="input-group input-group-danger">
                                            <span class="input-group-prepend"><label class="input-group-text"><i class="ik ik-lock"></i></label></span>
                                            <input type="password" class="form-control" name="senha">
                                        </div>
                                    </div>
                            
                            </div>
                            <div class="row">
                                {{-- <label class="col-sm-4 col-lg-2 col-form-label"></label> --}}
                                <div class="col-sm-6">
                                    <br><p></p>
                                    <button type="submit" class="btn btn-outline-dark w-50">Solicitar destruição</button>
                                </div>
                            </div>
                        </div>
                        </form>
                    </div>
                </div>

    </div>


<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script>

<!-- (Optional) Latest compiled and minified JavaScript translation files -->
<script src="//cdn.jsdelivr.net/npm/promise-polyfill@8/dist/polyfill.js"></script>
<script src="//cdn.jsdelivr.net/npm/sweetalert2@10"></script>


<script type="text/javascript">
       var para=null;
    $(function () {
        $('form[name="cadrdestrution"]').submit(function (data) {
            data.preventDefault();
                
                var form=document.forms.namedItem("cadrdestrution");
                var oData=new FormData(form);
                
                var oReq=new XMLHttpRequest();
                oReq.open("POST","{{route('us.admin.cliente.GestSolicitacao.do.pedido.destruicao')}}",true)
                oReq.respondeType='josn';
                oReq.onload=function(e){
                    if(oReq.readyState===4)
                    {
                        if(oReq.status===200)
                        {
                            
                            para="para";
                            msgs=oReq.responseText;
                            
                            const vector=$.parseJSON(msgs);
                            
                            let verificador=vector[0].verificador;
                            
                            if(verificador==false)
                            {
                                console.log("erro")
                                 let mensagem=vector[0].mensagem;
                                  Swal.fire({
                                        icon: 'error',
                                        title: 'Alerta',
                                        showClass: {
                                            popup: 'animate__animated animate__fadeInDown'
                                        },
                                        hideClass: {
                                            popup: 'animate__animated animate__fadeOutUp'
                                        },
                                        text: ''+mensagem,
                                        })
                                
                                return;
                            }
                            
                              const Toast = Swal.mixin({
                                    toast: true,
                                    position: 'top-end',
                                    showConfirmButton: false,
                                    timer: 2200,
                                    timerProgressBar: true,
        
                                    });

                                Toast.fire({
                                icon: 'success',
                                title: 'solicitação feita com sucesso',
                                    });
                            window.location.href="{{route('us.admin.cliente.GestSolicitacao.open_solicitacao.destruicao')}}";
                            // window.location.assign("")
                            //window.href="";

                        }
                    }
                };
                
                oReq.onerror=function(e)
                {
                  console.log("erro o solicitar destruição")  
                };
                oReq.send(oData)
    
        });
    });
    
    </script>
@endsection