@extends('usuarios.funcionarios.master.layout2')

@section('conteudo')

<nav class="d-none">

    {{ $base = \App\Models\BaseGestdoc::where('id',$idBase)->first()}}

    @if($base)

    @else

        {{-- Caso o armazém não seja encontrado no sistema, então o usuário será redireccionado a um nível anterior --}}
        <script>
            window.location.replace("{{ route('us.armazem.conf.arm.bases') }}");
        </script>
        @php
            exit();
        @endphp
    @endif

    {{ $armazem= \App\Models\ArmazemModel::where('id',$id)->first()}}



    @if($armazem)


        {{ $corredores= \App\Models\Corredor::where('armazem_id',$id)->get() }}
        {{ $corredoresCount= \App\Models\Corredor::where('armazem_id',$id)->count() }}
        {{ $modulos= \App\Models\Corredor::where('armazem_id',$id)->count() }}
        {{ $fileiras= \App\Models\Corredor::where('armazem_id',$id)->count() }}
        {{ $prateleiras= \App\Models\Corredor::where('armazem_id',$id)->count() }}
        {{ $caixas= \App\Models\Corredor::where('armazem_id',$id)->count() }}
        {{ $indexes= \App\Models\Corredor::where('armazem_id',$id)->count() }}
        {{ $base= $armazem->getBase }}
        {{ $configCorredores= \App\Models\ConfiguracaoCorredor::get() }}
        {{ $configCorredoresCount= \App\Models\ConfiguracaoCorredor::count() }}
        {{ $owner= $armazem->getOwner }}
        {{ $bases=\App\Models\BaseGestdoc::get() }}
        {{ $funcionario= $owner->getFuncionario }}
        {{ $configIdCadastro=0 }}

    @else

        {{-- Caso o armazém não seja encontrado no sistema, então o usuário será redireccionado a um nível anterior --}}
        <script>
            window.location.replace("{{ route('us.armazem.conf.arm.ver.armazens.base',$idBase) }}");
        </script>
        @php
            exit();
        @endphp
    @endif

</nav>
<nav class="container rounded shadow" style="background: linear-gradient( #013257bb , #01192cbb)">
    <br>
    <div class="tst  d-none animate__animated animate__fadeInDown rounded text-center border border-1  m-4 align-items-center text-white    " role="alert" aria-live="assertive" aria-atomic="true">
        {{-- <div class="  d-nodne animate__animated animate__fadeInDown border border-3 position-absolute top-0 start-50 m-4 align-items-center text-white  border-0 d-nodne animate__animated animate__fadeInDown border border-3 position-absolute top-0 start-50 m-4 align-items-center text-white  border-0" role="alert" aria-live="assertive" aria-atomic="true"> --}}
        <div class="d-flex">
          <div class="toast-body ">
            <p class="toastMessage">
                 <br>
                    Example modal
                 <br>
            </p>
          </div>
          {{-- <button type="button" class="tstClose btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button> --}}
        </div>
    </div>
        <nav class="row p-4">


            <div class="col-12 text-start">
                <div class="row justify-content-center"   >
                    <div class=" p-2">

                        <div class="x_title">
                            <h2>Armazém</h2>
                            <div class="clearfix"></div>
                        </div>
                        <br>
                        <div class=" p-2 tile_count">

                            <div class="x_title">
                                <h2><i class="fa fa-road"></i> ARMAZÉM</h2>
                                <div class="clearfix"></div>
                            </div>
                            <br>
                            <div class="row p-2">
                                <nav class="col-2 colorBigView rounded border border-2 shadow"  style="background-color:{{ $armazem->cor_tema }}">

                                </nav>
                                <nav class="col-3">
                                    <ul style="list-style-type: square">
                                        <li class="p-2">Número identificador: <label for="">{{ $armazem->id }}</label> </li>
                                        <li class="p-2">Nome do armazém: <label for="" class="idNomeArmazem">{{ $armazem->nomearmazem }}</label> </li>

                                        <a href="{{ route('us.armazem.conf.arm.verarmazem',[$idBase,$armazem->id]) }}" class="btn btn-sm btn-outline-light"><i class="fa fa-eye"></i> Ver armazem </a>
                                    </ul>
                                </nav>
                                <nav class="col-7 row ">
                                    <div class="col  tile_stats_count">
                                        <span class="count_top"><i class="fa fa-user"></i> CORREDORES</span>
                                        <div class="count">{{ $modulos }}</div>
                                        {{-- <a href="" class="btn-outline-light btn-sm w-100"> <i class="fa fa-eye"></i> Ver </a> --}}
                                        {{-- <span class="count_bottom">From last Week</span> --}}
                                    </div>
                                    <div class="col  tile_stats_count">
                                        <span class="count_top"><i class="fa fa-user"></i> MÓDULOS</span>
                                        <div class="count">{{ $modulos }}</div>
                                        {{-- <a href="" class="btn-outline-light btn-sm w-100"> <i class="fa fa-eye"></i> Ver </a> --}}
                                        {{-- <span class="count_bottom">From last Week</span> --}}
                                    </div>
                                    <div class="col  tile_stats_count">
                                        <span class="count_top"><i class="fa fa-user"></i> CÉLULAS</span>
                                        <div class="count">{{ $fileiras }}</div>
                                        {{-- <a href="" class="btn-outline-light btn-sm w-100"> <i class="fa fa-eye"></i> Ver </a> --}}
                                        {{-- <span class="count_bottom">From last Week</span> --}}
                                    </div>

                                    <div class="col  tile_stats_count">
                                        <span class="count_top"><i class="fa fa-user"></i> FILEIRAS</span>
                                        <div class="count">{{ $prateleiras }}</div>
                                        {{-- <a href="" class="btn-outline-light btn-sm w-100"> <i class="fa fa-eye"></i> Ver </a> --}}
                                        {{-- <span class="count_bottom"> From last Week</span> --}}
                                    </div>
                                    <div class="col  tile_stats_count">
                                        <span class="count_top"><i class="fa fa-user"></i> ESP. CAIXAS</span>
                                        <div class="count">{{ $caixas }}</div>
                                        {{-- <a href="" class="btn-outline-light btn-sm w-100"> <i class="fa fa-eye"></i> Ver </a> --}}
                                        {{-- <span class="count_bottom"><i class="green"><i class="fa fa-sort-asc"></i>34% </i> From last Week</span> --}}
                                    </div>


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

                    </div>
                    <div class="tile_count ">
                        <div class="x_title">
                            <h2><i class="fa fa-road"></i> CORREDORES</h2>
                            <div class="clearfix"></div>

                        </div>
                        <br><br>
                        <div>
                            {{-- <ul>
                                <li id="draggable" class="ui-state-highlight">Drag me down</li>
                              </ul> --}}

                            <div class="row">
                                <nav class="col-8 row">
                                    <h5>Lista de corredores</h5>

                                </nav>
                                <nav class="col-4 row">
                                    <h5>Configurações</h5>


                                </nav>
                            </div>
                            <hr>
                           <div class="row">
                               <nav class="col-8 row overflow-auto">

                                <div class="d-flex align-items-start  col-12 row">
                                    <div class="nav flex-column nav-pills me-3 col-2" id="v-pills-tab" role="tablist" aria-orientation="vertical">

                                      <button class="nav-link active btn btn-sm mt-1" id="v-pills-home-tab" data-bs-toggle="pill" data-bs-target="#v-pills-home" type="button" role="tab" aria-controls="v-pills-home" aria-selected="true"> <i class="fa fa-arrows-alt"></i> Pln</button>
                                      <button class="nav-link btn btn-sm mt-1" id="v-pills-profile-tab" data-bs-toggle="pill" data-bs-target="#v-pills-profile" type="button" role="tab" aria-controls="v-pills-profile" aria-selected="false"> <i class="fa fa-cube"></i> 3d</button>
                                       </div>
                                    <div class="tab-content col-9" id="v-pills-tabContent">
                                      <div class="tab-pane row fade show active" id="v-pills-home" role="tabpanel" aria-labelledby="v-pills-home-tab">
                                            <div class="vol-12">
                                                <div class="  row" id="sortable">
                                                    @if($corredoresCount>0)
                                                    <label class="d-none"> {{ $i=0 }}</label>

                                                        @foreach($corredores as $corredor)
                                                        <label class="d-none">{{ $i++ }}</label>

                                                            <nav class="col-6">

                                                                <a href="{{ route('us.armazem.conf.arm.ver.corredor.armazem',[$idBase,$id,$corredor->id] ) }}" class="list-group-item  list-group-item-action mt-1 rounded" aria-current="true">
                                                                    <div class="d-flex w-100 justify-content-between">
                                                                    {{-- <h5 class="mb-1">Corredor {{ $corredor->id }}</h5> --}}
                                                                    <h5 class="mb-1">Corredor {{ $i }}</h5>

                                                                </div>
                                                                <small class="mb-1"> <b>
                                                                     {{ $corredor->getConfiguracao->nomeconfiguracao }}</b></small>
                                                                     {{-- <small class="mb-1">Modulos:.</small>
                                                                <small class="mb-1">Fileiras:.</small>
                                                                <small class="mb-1">Prateleiras:.</small>
                                                                <small class="mb-1">Caixas:.</small>
                                                                <small class="mb-1">Indexes:.</small> <br>
                                                                <small class="mb-1">data de cadastro:.</small> --}}
                                                            </a>
                                                            </nav>
                                                        @endforeach
                                                    @else
                                                            <br><br><br>
                                                            <p class="text-center">

                                                                <i><label>"Sem corredores neste armazém"</label></i>
                                                            </p>
                                                    @endif



                                                </div>
                                            </div>
                                      </div>
                                      <div class="tab-pane row fade" id="v-pills-profile" role="tabpanel" aria-labelledby="v-pills-profile-tab">
                                            <div class="vol-12">

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

                               </nav>
                               <nav class="col-4 row overflow-auto">
                                <div class="list-group col-12"    >
                                    <nav id="novaConfiguracao">

                                            <a href="#" class="list-group-item list-group-item-action bg-secondary border border-light border-3 w-100   "  aria-current="true">
                                            <div class="d-flex w-100 justify-content-between">
                                                <h5 class="mb-1 text-light"> <i class="fa  fa-plus"></i> Corredor</h5>

                                            </div>
                                            <p class="mb-1 text-light">Arraste para aqui uma configuração de corredores.</p>
                                            <small  class="mb-1 text-light">(Poderá com isso cadastrar 1 ou mais corredores).</small>
                                        </a>
                                    </nav>
                                    <hr>
                                    <div class="row">
                                        @if($configCorredoresCount>0)
                                            @foreach($configCorredores as $configuracao)
                                                <div class="col-12 btn btn-bd-download blue-gradient  m-1">

                                                    <a data-bs-toggle="modal" data-bs-target="#modalInfoConfiguracao"  class="  text-start  cadastravel   "  >

                                                        <div class="d-flex   justify-content-between">
                                                            <h5 class="mb-1 " >
                                                                <i class="fa fa-cog"></i>
                                                                {{ $configuracao->id }} <br>
                                                                {{$configuracao->nomeconfiguracao}}
                                                            </h5>
                                                        </div>
                                                        <input type="hidden"  class="idConfiguracaoElementFormHidden" value="{{ $configuracao->id}}">
                                                        <input type="hidden" class="nomeConfiguracaoArmazem{{$configuracao->id}}" value="{{ $configuracao->nomeconfiguracao}}">
                                                        <input type="hidden" class="andaresConfiguracaoArmazem{{$configuracao->numeroandares}}" value="{{ $configuracao->numeroandares}}">
                                                        <input type="hidden" class="modulosConfiguracaoArmazem{{$configuracao->numeromodulo}}" value="{{ $configuracao->numeromodulo}}">
                                                        <input type="hidden" class="larguraConfiguracaoArmazem{{$configuracao->larguracorredor}}" value="{{ $configuracao->larguracorredor}}">
                                                        <input type="hidden" class="comprimentoConfiguracaoArmazem{{$configuracao->comprimentocorredor}}" value="{{ $configuracao->comprimentocorredor}}">
                                                        {{-- <small class="mb-1">Altura:</small> (m), --}}
                                                        {{-- <small class="mb-1">Largura: <span >{{ $configuracao->larguracorredor }}</span></small> (m),
                                                        <small class="mb-1">Comprimento:{{ $configuracao->comprimentocorredor }}</small> (m),
                                                        <small class="mb-1">Numero de andares:{{ $configuracao->numeroandares }}</small>,
                                                        <small class="mb-1">Quantidade de modulos:{{ $configuracao->numeromodulo }}</small>
                                                        <small class="mb-1">Base:{{ $configuracao->getBase->base }}</small> --}}
                                                    </a>




                                                </div>
                                            @endforeach
                                        @else
                                                <br>
                                            </div>
                                            <div class="list-group col-12"  id="sortable">



                                                <br><br><br>
                                                <p class="text-center">

                                                    <i><label>"Sem configurações de corredores encontradas"</label></i>
                                                </p>
                                        @endif
                                        </div>


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

                        </div>
                    </div>

                    <div class=" p-3">
                        <div class="x_title">
                            <h2>Configuração</h2>
                            <div class="clearfix"></div>
                        </div>
                        {{-- <button class="btn btn-sm btn-outline-light"><i class="fa fa-plus"></i> Nova entrada</button> --}}
                        <button class="btn btn-sm btn-outline-light" id="botaoCadCorredores"  data-bs-toggle="modal" data-bs-target="#preferenciaArmazem"><i class="fa fa-plus"></i> <i class="fa fa-road"></i> Novo corredor</button>
                        <button class="btn btn-sm btn-outline-light" data-bs-toggle="modal" data-bs-target="#configuracaoArmazem"><i class="fa fa-plus"></i> <i class="fa fa-cog"></i> Nova configuração</button>
                        {{-- <a href="{{ route('us.armazem.conf.arm.ver.armazens.base',$armazem->base_id) }}" class="btn btn-sm btn-outline-light btnOutrosArmazens"><i class="fa fa-list-ul"></i> Outros Armazéns</a> --}}
                        {{-- <button class="btn btn-sm btn-outline-danger" data-bs-toggle="modal" data-bs-target="#deleteArmazemModal"><i class="fa fa-exclamation-triangle"></i> Desactivar armazém</button> --}}
                        {{-- <button class="btn btn-sm btn-outline-success"><i class="fa fa-exclamation-triangle"></i> Restaurar armazém</button> --}}

                    </div>
                </div>

            </div>


        </nav>

    <!-- Button trigger modal -->
    {{-- <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#staticBackdrop">
        Configurar armaz
    </button> --}}
  <!-- Modal -->
  <div class="modal fade" id="configuracaoArmazem" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="configuracaoArmazemLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="configuracaoArmazemLabel">Configuração do armazém</h5>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <form id="formConfigCorredor">
            <div class="modal-body">

                <div class="mb-3">
                    <label for="">Nome da configutação</label> <br> <br>
                    <input type="text" class="form-control" id="nomeconfig" placeholder="Ex: Corredor padrão" required id="">

                </div>
                <div class="mb-3">
                    <label for="exampleFormControlTextarea1" class="form-label">Número de andares : </label>

                    <label id="lblNumeroAndaresLabel" class="form-label">1</label>
                    <input type="range" class="form-range" value="1" required min="1" max="100" step="1" id="idNumeroAndares">

                </div>
                <div class="mb-3">
                    <label for="exampleFormControlTextarea1" class="form-label">Número de Modulos : </label>

                        <label id="lblNumeroCorredoresLabel" class="form-label">1</label>
                        <input type="range" class="form-range" value="1" required min="1" max="100" step="1" id="idNumeroCorredoresModulos">

                </div>
                {{-- <div class="mb-3">
                    <label for="exampleFormControlTextarea1" class="form-label">Largura Corredor (m) : </label>

                    <label id="lblIdLarguraCorredor" class="form-label">1 </label> metros
                    <input type="range" class="form-range" value="1" required min="1" max="100" step="1" id="idLarguraCorredor">

                </div>
                <div class="mb-3">
                    <label for="exampleFormControlTextarea1" class="form-label">Comprimento Corredores (m) : </label>

                        <label id="lblIdCumprimentoCorredor" class="form-label">1 </label> metros
                        <input type="range" class="form-range" value="1" required min="1" max="100" step="1" id="idCumprimentoCorredor">

                </div> --}}
                <input type="hidden" id="base_id" value="{{ $base->id }}">
                <input type="hidden" id="usuario_id" value="{{ Auth::id() }}">


            </div>
            <div class="modal-footer">

                <button type="submit" class="btn btn-primary">Cadastrar</button>
            </div>
        </form>

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

 <!-- Modal -->
 <div class="modal fade" id="preferenciaArmazem" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="preferenciaArmazemLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="preferenciaArmazemLabel">Configuração do armazém</h5>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <form id="formCadCorredor">
            <div class="modal-body">
                Cadastro de corredor(es)
                <br>
                <div class="form-floating">

                    {{-- <label for=""> Quantidade de corredores</label> --}}
                    <select class="form-select" id="listaConfiguracoes" aria-label="Floating label select example">
                        @foreach($configCorredores as $bconfigCorredor)

                                <option value="{{ $bconfigCorredor->id }}">{{ $bconfigCorredor->nomeconfiguracao }}</option>

                        @endforeach
                    </select>
                    <label for="listaConfiguracoes">Configuração</label>
                </div>
                  <br>
                <div class="mb-3">
                    <label for="exampleFormControlTextarea1" class="form-label">Quantidade de corredores: </label>

                        <label id="lblNumeroCorredores" class="form-label">1 </label>
                        <input type="range" class="form-range" value="1" required min="1" max="100" step="1" id="numeroReplicaCorredores">
                </div>

            </div>
            <div class="modal-footer">

              <button type="submit" class="btn btn-primary">Cadastrar</button>
            </div>
        </form>
      </div>
    </div>
  </div>

<div class="modal fade" id="modalInfoConfiguracao" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="modalInfoConfiguracaoLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered modal-fullscreen">
      <div class="modal-content">
        <div class="modal-header">
          <h5 class="modal-title" id="modalInfoConfiguracaoLabel">Configuração do armazém</h5>
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
        </div>
        <form id="formEditConfigCorredor">
            <div class="modal-body">
                <input type="hidden" name="" id="idConfigEdit">
                <div class="mb-3">
                    <label for="">Nome da configutação</label> <br> <br>
                    <input type="text" class="form-control" id="nomeconfig2" placeholder="Ex: Corredor padrão" required id="">

                </div>
                <div class="mb-3">
                    <label for="exampleFormControlTextarea1" class="form-label">Número de andares : </label>

                    <label id="lblNumeroAndaresLabel2" class="form-label">1</label>
                    <input type="range" class="form-range" value="1" required min="1" max="100" step="1" id="idNumeroAndares2">

                </div>
                <div class="mb-3">
                    <label for="exampleFormControlTextarea1" class="form-label">Número de Modulos : </label>

                        <label id="lblNumeroCorredoresLabel2" class="form-label">1</label>
                        <input type="range" class="form-range" value="1" required min="1" max="100" step="1" id="idNumeroCorredoresModulos2">

                </div>
                {{-- <div class="mb-3">
                    <label for="exampleFormControlTextarea1" class="form-label">Largura Corredor (m) : </label>

                    <label id="lblIdLarguraCorredor2" class="form-label">1 </label> metros
                    <input type="range" class="form-range" value="1" required min="1" max="100" step="1" id="idLarguraCorredor2">

                </div>
                <div class="mb-3">
                    <label for="exampleFormControlTextarea1" class="form-label">Comprimento Corredores (m) : </label>

                        <label id="lblIdCumprimentoCorredor2" class="form-label">1 </label> metros
                        <input type="range" class="form-range" value="1" required min="1" max="100" step="1" id="idCumprimentoCorredor2">

                </div> --}}
                <input type="hidden" id="base_id2" value="{{ $base->id }}">


            </div>
            <div class="modal-footer">

                <button type="submit" class="btn btn-sm btn-primary">Salvar alterações</button>
                {{-- <button class="btn btn-sm btn-outline-danger" data-bs-toggle="modal" data-bs-target="#deleteArmazemModal"><i class="fa fa-exclamation-triangle"></i> Eliminar configuração</button> --}}

            </div>
        </form>
      </div>
    </div>
  </div>
  <!-- Scrollable modal -->

  <script>
    $(function(){
        $( "#sortable" ).sortable({
            revert: false
        });

        var idConfiguracaoReplicar=0;
        $("#novaConfiguracao").droppable({
            drop: function(event, ui) {
                $(this).css('padding', '0px');
                $(this).css('background', 'transparent');

                var nomeConfig=$(".nomeConfiguracaoArmazem"+idConfiguracaoReplicar).val()
                // alert(nomeConfig);
                // alert(idConfiguracaoReplicar);
                $("#botaoCadCorredores").click();
                $("#listaConfiguracoes").prepend("<option  class=\"d-none\" value="+idConfiguracaoReplicar+" selected >"+nomeConfig+"</option>");
            },
            over: function(event, ui) {
                $(this).css('background', '#eee');
                $(this).css('padding', '10px');

            },
            out: function(event, ui) {
                $(this).css('background', 'transparent');
                $(this).css('padding', '0px');

            }
        });

        $( ".cadastravel" ).draggable({
            connectToSortable: "#sortable",
            revert: "true",
            helper: "clone",
        } );
        $( ".cadastravel" ).on("mousemove mouseover",function(){
            var input = $(this).find("input[class='idConfiguracaoElementFormHidden']").val();
            idConfiguracaoReplicar=input;
        } );
        $(".cadastravel").click(function(){

            $("#idConfigEdit").val($(this).find('input:eq(0)').val());
            $("#nomeconfig2").val($(this).find('input:eq(1)').val());
            $("#idNumeroAndares2").val($(this).find('input:eq(2)').val());
            $("#lblNumeroAndaresLabel2").text($(this).find('input:eq(2)').val());


            $("#idNumeroCorredoresModulos2").val($(this).find('input:eq(3)').val());
            $("#lblNumeroCorredoresLabel2").text($(this).find('input:eq(3)').val());


            $("#idLarguraCorredor2").val($(this).find('input:eq(4)').val());
            $("#lblIdLarguraCorredor2").text($(this).find('input:eq(4)').val());

            $("#idCumprimentoCorredor2").val($(this).find('input:eq(5)').val());
            $("#lblIdCumprimentoCorredor2").text($(this).find('input:eq(5)').val());



        });


        $("#idNumeroAndares").on('change keypress mousemove',function(){
            $("#lblNumeroAndaresLabel").text($(this).val());
        });
        $("#idNumeroCorredoresModulos").on('change keypress mousemove',function(){
            $("#lblNumeroCorredoresLabel").text($(this).val());
        });
        $("#idLarguraCorredor").on('change keypress mousemove',function(){
            $("#lblIdLarguraCorredor").text($(this).val());
        });
        $("#idCumprimentoCorredor").on('change keypress mousemove',function(){
            $("#lblIdCumprimentoCorredor").text($(this).val());
        });

        $("#idNumeroAndares2").on('change keypress mousemove',function(){
            $("#lblNumeroAndaresLabel2").text($(this).val());
        });
        $("#idNumeroCorredoresModulos2").on('change keypress mousemove',function(){
            $("#lblNumeroCorredoresLabel2").text($(this).val());
        });
        $("#idLarguraCorredor2").on('change keypress mousemove',function(){
            $("#lblIdLarguraCorredor2").text($(this).val());
        });
        $("#idCumprimentoCorredor2").on('change keypress mousemove',function(){
            $("#lblIdCumprimentoCorredor2").text($(this).val());
        });


        $("#numeroReplicaCorredores").on('change keypress mousemove',function(){
            $("#lblNumeroCorredores").text($(this).val());
        });
        $("#numeroModuloPorReplicaCorredores").on('change keypress mousemove',function(){
            $("#lblNumeroModulosCorredores").text($(this).val());
        });




        $("#formConfigCorredor").submit(function(e){

            e.preventDefault();
            var nomeconfig =$("#nomeconfig").val();
            var idNumeroAndares =$("#idNumeroAndares").val();
            var idNumeroCorredoresModulos =$("#idNumeroCorredoresModulos").val();

            var idLarguraCorredor =$("#idLarguraCorredor").val();
            var idCumprimentoCorredor =$("#idCumprimentoCorredor").val();
            var base_id =$("#base_id").val();
            var usuario_id =$("#usuario_id").val();

            $.post("{{ route('us.armazem.conf.arm.add.config.corredor.armazem') }}",
            {
                '_token':  '{{ csrf_token()  }}',
                'nomeconfig':nomeconfig,
                'idNumeroAndares':idNumeroAndares,
                'idNumeroCorredoresModulos':idNumeroCorredoresModulos,
                // 'idLarguraCorredor':idLarguraCorredor,
                // 'idCumprimentoCorredor':idCumprimentoCorredor,
                'base_id':base_id,
                'usuario_id':usuario_id,
            },function(e){

               if (e==1){

                    const Toast = Swal.mixin({
                        toast: true,
                        position: 'top-end',
                        showConfirmButton: false,
                        timer: 3000,
                        timerProgressBar: true,
                        didOpen: (toast) => {
                            toast.addEventListener('mouseenter', Swal.stopTimer)
                            toast.addEventListener('mouseleave', Swal.resumeTimer)
                        }
                    })

                    Toast.fire({
                        icon: 'success',
                        title: 'Configuração cadastrada com sucesso'
                    })
                    location.reload(true);
               }else{
                    const Toast = Swal.mixin({
                        toast: true,
                        position: 'top-end',
                        showConfirmButton: false,
                        timer: 3000,
                        timerProgressBar: true,
                        didOpen: (toast) => {
                            toast.addEventListener('mouseenter', Swal.stopTimer)
                            toast.addEventListener('mouseleave', Swal.resumeTimer)
                        }
                    })

                    Toast.fire({
                        icon: 'warning',
                        title: 'Configuração não cadastrada'
                    })
                    location.reload(true);
               }

            }).fail(function(){
                alert("falha ao cadastrar a configurção do corredor! Por algum motivo não conseguimos cadastrar a configuração do corredor tente novemante mais tarde ou informe ao engenheiro de software.")
            });
        });

        $("#formEditConfigCorredor").submit(function(e){

            e.preventDefault();
            var nomeconfig2 =$("#nomeconfig2").val();
            var idNumeroAndares2 =$("#idNumeroAndares2").val();
            var idNumeroCorredoresModulos2 =$("#idNumeroCorredoresModulos2").val();


            var base_id2 =$("#base_id2").val();

            $.post("{{ route('us.armazem.conf.arm.edit.config.corredor.armazem') }}",
            {
                '_token':  '{{ csrf_token()  }}',
                'nomeconfig':nomeconfig2,
                'idNumeroAndares':idNumeroAndares2,
                'idNumeroCorredoresModulos':idNumeroCorredoresModulos2,
                'base_id':'{{ $idBase }}',

            },function(e){

                if (e==1){

                    const Toast = Swal.mixin({
                        toast: true,
                        position: 'top-end',
                        showConfirmButton: false,
                        timer: 3000,
                        timerProgressBar: true,
                        didOpen: (toast) => {
                            toast.addEventListener('mouseenter', Swal.stopTimer)
                            toast.addEventListener('mouseleave', Swal.resumeTimer)
                        }
                    })

                    Toast.fire({
                        icon: 'success',
                        title: 'Configuração do corredor editada com sucesso'
                    })
                    location.reload(true);
                }else{
                    const Toast = Swal.mixin({
                        toast: true,
                        position: 'top-end',
                        showConfirmButton: false,
                        timer: 3000,
                        timerProgressBar: true,
                        didOpen: (toast) => {
                            toast.addEventListener('mouseenter', Swal.stopTimer)
                            toast.addEventListener('mouseleave', Swal.resumeTimer)
                        }
                    })

                    Toast.fire({
                        icon: 'warning',
                        title: 'Configuração do corredor não editada'
                    })
                    location.reload(true);
                }

            }).fail(function(){
                alert("falha ao cadastrar a configurção do corredor! Por algum motivo não conseguimos cadastrar a configuração do corredor tente novemante mais tarde ou informe ao engenheiro de software.")
            });
        });

        $("#formCadCorredor").submit(function(e){


            e.preventDefault();
            var qtdVezes =$("#numeroReplicaCorredores").val();
            var config_id =$("#listaConfiguracoes").val();
            // var numeroModuloPorReplicaCorredores =$("#numeroModuloPorReplicaCorredores").val();
            // alert(config_id)

            $.post("{{ route('us.armazem.conf.arm.cadastrar.novo.corredor.armazem') }}",
            {
                '_token':  '{{ csrf_token()  }}',
                'qtdVezes':qtdVezes,
                'config_id':config_id,
                'armazem_id':'{{ $armazem->id  }}',

            },function(e){

                if (e==1){

                    const Toast = Swal.mixin({
                        toast: true,
                        position: 'top-end',
                        showConfirmButton: false,
                        timer: 3000,
                        timerProgressBar: true,
                        didOpen: (toast) => {
                            toast.addEventListener('mouseenter', Swal.stopTimer)
                            toast.addEventListener('mouseleave', Swal.resumeTimer)
                        }
                    })

                    Toast.fire({
                        icon: 'success',
                        title: 'Corredor(es) cadastrado(s) com sucesso'
                    })
                    location.reload(true);
                }else{
                    const Toast = Swal.mixin({
                        toast: true,
                        position: 'top-end',
                        showConfirmButton: false,
                        timer: 3000,
                        timerProgressBar: true,
                        didOpen: (toast) => {
                            toast.addEventListener('mouseenter', Swal.stopTimer)
                            toast.addEventListener('mouseleave', Swal.resumeTimer)
                        }
                    })

                    Toast.fire({
                        icon: 'warning',
                        title: 'Corredor(es) não cadastrado(s)'
                    })
                    location.reload(true);
                    }

            }).fail(function(){
                alert("falha ao cadastrar corredor! Por algum motivo não conseguimos cadastrar o corredor tente novemante mais tarde ou informe ao engenheiro de software.")
            });
        });







    });
</script>
@endsection
