<?php
   require $_SERVER["DOCUMENT_ROOT"].'/inc/topo.php';
   require $_SERVER["DOCUMENT_ROOT"].'/inc/menu.php';
?>
<link rel="stylesheet" href="/assets/vendor_plugins/iCheck/all.css">
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
   <!-- Content Header (Page header) -->
   <section class="content-header">
      <h1>
         Regulamento
         <small>Banca</small>
      </h1>
   </section>
   <!-- Main content -->
   <section class="content">
      <div class="row">
        <form id="paramsForm" method="POST" action="/api/setParams">
           <div class="col-12">
              <div class="box box-solid bg-black">
                 <div class="box-header">
                    <h4 class="box-title"><strong class="event-strong">Regulamento</strong></h4>
                    <a href="javascript:history.back('-1');" class="btn btn-danger btn-md pull-right"><i class="fa fa-reply"></i> &nbsp; Voltar</a>
                 </div>
                 <div class="box-content">
                    <div class="box-body">
                      <div class="row">
                        <div class="col-12"><blockquote class="blockquote" style=" margin: 15px 0; ">Leia com atenção</blockquote></div>
                        <div class="col-12"><?php echo utf8_encode($_SESSION["configs"]["config_regulamento"]); ?></div>
                      </div>
                    </div>
                 </div>
                 <div class="box-footer">
                    <center><b style="color: #000; font-size: 18px;">Ao utilizar este site, você está de acordo com o regulamento acima descrito.</b></center>
                 </div>
              </div>
           </div>
         </form>
      </div>
      <!-- /.row -->
   </section>
   <!-- /.content -->
</div>
<!-- /.content-wrapper -->
<!-- ./wrapper -->
<?php require $_SERVER["DOCUMENT_ROOT"].'/inc/rodape.php'; ?>
<!-- DataTables -->
<script src="/js/moneymask.js"></script>
<script src="/js/jquery.mask.js"></script>
<script src="/assets/vendor_plugins/iCheck/icheck.min.js"></script>
<!-- CK Editor -->
<script src="/assets/vendor_components/ckeditor/ckeditor.js"></script>
<script src="/js/pages/editor.js"></script>
<script>
    let input = document.getElementsByTagName('input')[0];

    // configuration
    SimpleMaskMoney.args = {
        prefix: '',
        suffix: '',
        fixed: true,
        fractionDigits: 2,
        decimalSeparator: ',',
        thousandsSeparator: '.',
        autoCompleteDecimal: false
    };

    // Your send method
    send = (e) => {
        if (e.key !== "Enter") return;
        // This method return value of your input in format number to save in your database
        SimpleMaskMoney.formatToNumber(input.value);
    }

    $(function(){
      $(document).ready(function(){

        $('.datetime').mask('99/99/9999 99:99');
        $('.oddtype').mask('000.00', {reverse: true});

        $('input').iCheck({
          checkboxClass: 'icheckbox_square',
          radioClass: 'iradio_square-red',
          increaseArea: '20%' // optional
        });

        $('#paramsForm').submit(function(){
           $('#submitForm').toggleClass('btn-success btn-info').html('<i class="fa fa-spinner fa-spin"></i> &nbsp; Salvando...');
           var dados = $( this ).serialize();
           var f = $(this);

           $.ajax({
              type: f.attr('method'),
              url: f.attr('action'),
              data: dados,
              success: function( data )
              {
                console.log('DT: '+data);
                 var info = $.parseJSON(data);
                 if(info.error != undefined){ alert(info.error); $('#submitForm').toggleClass('btn-success btn-info').html('<i class="fa fa-check"></i> &nbsp; Salvar'); }
                 else if(info.success != undefined){
                    // alert(info.success);
                    $('#submitForm').css('background', '#1b890e').css('border-color', '#1b890e').html('<i class="fa fa-check"></i> &nbsp; Pronto!');

                    $.toast({
                       heading: 'Pronto!',
                       text: 'Os parâmetros foram salvos com sucesso.',
                       position: 'top-right',
                       loaderBg: '#FFF',
                       icon: 'success',
                       hideAfter: 3500,
                       stack: 6
                    });
                    setTimeout(function(){ $('#submitForm').toggleClass('btn-success btn-info').attr('style', '').html('<i class="fa fa-check"></i> &nbsp Salvar'); }, 2000);
                 }
              }
           });

           return false;
        });

      });
    });
</script>
<style>
  .form-group label { font-weight: bold !important; }
  .input-group .input-group-addon, .input-group .input-group-text {
    background-color: #e5e5e5 !important;
  }
</style>