<?php
require_once "header.php";
require_once "connect.php";

$ds_email_contab = '';
$export_xml_result = "erpc_report_venda_export_xml_result";

$sql_contabilidade = "Select ds_email from erpc_contabilidades where st_ativo = 1";
$result_contab = mysqli_query($conexao, $sql_contabilidade) or die(mysqli_error($conexao));
if(mysqli_num_rows($result_contab) >0 ){
    while($row = mysqli_fetch_assoc($result_contab)){
        $ds_email_contab = $row['ds_email'];
    }
}

?>


<div class="tab-content">
  <div class="block">
    <div class="header">
       	<h1>Filtro Exportação dos Arquivos XMLs</h1>
	</div><!--breadcrumbs-->
	<div class="content">
          <?php
          displayMessagesAndErrors(true); ?>
    </div>
	<div class="content controls">
      <div class="form-row">
        <div class="col-md-3">
          <h4 >Informe os parametros</h4>
	  </div>
    </div>
	<form id=validate_custom action="erpc_report_venda_export_xml_result.php" method="POST" class="stdform stdform2">
		<div class=form-row>
			<div class="col-md-3"/><label>De:</label></div>
			<div class="col-md-6"/><input required type=text data-mask="00/00/0000" name="dt_inicio" id="dt_inicio"  class="datepicker" /></div>
	    </div>
	    <div class=form-row>
    		<div class="col-md-3"/><label>Ate:</label></div>
    		<div class="col-md-6"><input required type=text data-mask="00/00/0000" name="dt_final" id="dt_final"  class="datepicker" /></div>
	    </div>
		<div class="form-row">
			<div class="col-md-3"><label>Tipo de Venda</label></div>
			<div class="col-md-6">
			  <div class="checked inline"><label> <input type=radio checked required name="id_tipo_venda" value="cfe"/> Cupom Fiscal</label></div>
			  <div class="checked inline"><label> <input type=radio required name="id_tipo_venda" value="nfe"/> Nota Fiscal </label></div>
			</div>
		</div>
		
		<div class=form-row>
		    <div class="col-md-3"><label>Deseja</label></div>
		    <div class="col-md-6">
        		<div class="checked inline"><label> <input type=radio checked required name="tipo_envio" value="download"/> Fazer Download </label></div>
    			<div class="checked inline"><label> <input type=radio required name="tipo_envio" value="email"/> Enviar por E-mail </label></div>
    		</div>
	    </div>
	    <div id='email' hidden class=form-row>
    		<div class="col-md-3"/><label>E-mail:</label></div>
    		<div class="col-md-6"><input required class="nouppercase" type=text name="ds_email" value="<?=$ds_email_contab; ?>" id="ds_email" /></div>
	    </div>
		
		  <div class="row clear"/><br>&nbsp;</div>
			<div class=footer>
			  <div class="side pull-right">
			    <div class=btn-group>
					<button class="btn btn-success" type="submit" onClick="$('#validate_custom').validationEngine('hide');" value="Download" name="download">Prosseguir</button>
					<button class="btn btn-default" type="button" onClick="window.history.go(-1)" value="Voltar">Voltar</button>
					<!-- <input type="submit" class="btn"  value="Buscar" name="buscar"></td> -->
				</div>
			  </div>
			</div>


	</form>
				</div>
      </div>
      </div><!--mainright-->
    <!-- END OF RIGHT PANEL -->

<div class="clearfix"></div>

<?php include "footer.php"; ?>

<script type="text/javascript">
jQuery(document).ready(function(){

    $("#dt_inicio").mask("99/99/9999");
    $("#dt_final").mask("99/99/9999");

		// calendar
		jQuery('#calendar').datepicker();

    $('#validate_custom input').on('change', function() {
        if($('input[name=tipo_envio]:checked', '#validate_custom').val() == 'email'){
            $('#email').show();
            $('#ds_email').attr('required', 'true');
        }else{
            if($('input[name=tipo_envio]:checked', '#validate_custom').val() == 'download'){
                $('#email').hide();
                $('#ds_email').val('');
                $('#ds_email').removeAttr("required");
            }
        }
    });

});


</script>
