<?php $page = 'familia'; include('header.php'); ?>
<body class="hold-transition layout-top-nav">
<div class="wrapper">
  <div class="preloader flex-column justify-content-center align-items-center">
    <img class="animation__shake" src="images/logo/<?php echo $rows[9]['valor']; ?>" alt="AdminLTELogo" height="60" width="60">
  </div>
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->
    <section class="content">
      <div class="container-fluid">
        <div class="row">
        <!-- SELECT2 EXAMPLE -->
        <div class="col-md-6">
        <div class="card card-default">
          <div class="card-header">
            <h3 class="card-title">Prazo de Pagamento</h3>

            <div class="card-tools">
              <button type="button" class="btn btn-tool" data-card-widget="collapse">
                <i class="fas fa-minus"></i>
              </button>
              <button type="button" class="btn btn-tool" data-card-widget="remove">
                <i class="fas fa-times"></i>
              </button>
            </div>
          </div>
          <!-- /.card-header -->
          <div class="card-body">
            <div class="row">
              <div class="col-md-12">
                <div class="form-group" style="margin-bottom: 0;">
                  <small class="required">Prazo de Pagamento</small>
                  <input type="text" class="form-control" id="nome" name="nome" placeholder="Prazo de Pagamento" title="Prazo de Pagamento" required>
                  <small>Mensagem de erro</small>
                </div>
                <div class="form-group" style="margin-bottom: 0;">
                  <small class="not-required">Nota</small>
                  <textarea name="nota" id="nota" class="form-control" placeholder="Nota..." rows="4"></textarea>
                  <small>Mensagem de erro</small>
                </div>
              </div>
              <div class="col-md-6"></div>
              <div class="col-md-6">
                <div class="form-group">
                    <button type="submit" name="btn-submit" id="btn-submit" class="btn btn-block btn-primary" >Cadastrar Prazo de Pagamento</button>
                </div>
              </div>
              <!-- /.col -->
            </div>
            <!-- /.row -->
          </div>
          <!-- /.card-body -->
          <div class="card-footer">
            Cadastro Prazo de Pagamento.
          </div>
        </div>
        </div>
        </div>
        <!-- /.card -->
      </div>
      <!-- /.container-fluid -->
    </section>
  </div>
  <!-- /.content-wrapper -->
  <?php include('footer.php'); ?>
</body>
</html>
<script src="./validation/prazoPagamento.js"></script>
<script>

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

$(document).on("click", "#btn-submit", function(e){
  e.preventDefault();
  if(nome.value != ''){
    $.ajax({
        url: "includes/create/prazoPagamento.inc.php",
        type: "post",
        data: {
          nome: nome.value,
          nota: nota.value
      },
      success: function(data){
        swal.fire({
          title: "Cadastro efectuado com sucesso!",
          text: "Prazo de Pagamento "+ nome.value +" cadastrado!",
          confirmButtonText: 'Confirmar',
          icon: "success",
        });
        nome.value = "";
        nome.className = "form-control";
        nota.value = "";
        nota.className = "form-control";
      },
      error: function(data){
        swal.fire({
          title: "Erro ao Cadastrar Prazo de Pagamento!",
          text: "Erro ao Cadastrar Prazo de Pagamento: "+ nome.value +" !",
          confirmButtonText: 'Confirmar',
          icon: "error",
      });
      }
    }).done(function(data){
        console.log(data);
    });
  }
});
</script>
