<?php
include 'header.php';
include 'erpc_financeiro_contas_pagar_toolbar.php';
include_once 'connect.php';

$dt_hoje = date("dmY"); 
?>

<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
  <li role="presentation" class="active"><a href="#form1" aria-controls="form1" role="tab" data-toggle="tab">Incluir Conta à Pagar</a></li>
  <!--
  <li role="presentation"><a href="#form2" aria-controls="form2" role="tab" data-toggle="tab">Form #2</a></li>
  <li role="presentation"><a href="#form3" aria-controls="form3" role="tab" data-toggle="tab">Form #3</a></li>
  <li role="presentation"><a href="#form4" aria-controls="form4" role="tab" data-toggle="tab">Form #4</a></li>
  -->
</ul>


<!-- Tab panes -->
<div class="tab-content">
  <div role="tabpanel" class="tab-pane fade in active" id="form1">
<form id=validate_custom method=POST action="erpc_financeiro_contas_pagar_ws.php">
  <div class=block>
        
    <div class="content controls">
      	
	  <div class=form-row>
        <div class=col-md-2>Descrição da Conta:</div>
        <div class=col-md-9> <input type=text name="ds_plano" class="form-control" /> </div>
      </div>		
	  
	  <div class="form-row">
        <div class=col-md-2><label>Valor</label></div>
        <div class=col-md-2><input name="vl_conta" id="vl_conta" type="number" step="0.01" min="0" data-number-to-fixed="2" class="form-control"/></div>
      </div>
		
	  <div class="form-row">
        <div class=col-md-2><label>Número de Parcelas</label></div>
        <div class=col-md-2><input name="nr_parcelas" id="nr_parcelas" type="number" step="1" min="1" data-number-to-fixed="2" class="form-control"/></div>
      </div>		
		
	  <div class="form-row">
        <div class=col-md-2><label>Valor Desconto</label></div>
        <div class=col-md-3><input name="vl_conta" id="vl_conta" type="number" step="0.01" min="0" data-number-to-fixed="2" class="form-control"/></div>
      </div>
		
	  <div class="form-row">
        <div class=col-md-2><label>Valor Juros/Multa</label></div>
        <div class=col-md-3><input name="vl_conta" id="vl_conta" type="number" step="0.01" min="0" data-number-to-fixed="2" class="form-control"/></div>
      </div>		

      <div class="form-row">
      <div class="col-md-2"><label>Plano Financeiro</label></div>
      <div class="col-md-2">
        <div class="input-group">
           <input required type=number name="id_plano_financeiro" id="id_plano_financeiro" min="0" step="1" size="4">
            <div class="input-group-addon">
              <a href="#.php" class='input-helper' data-remote="false"	data-toggle="modal" data-target="#helper-modal-div" data-value="#id_plano_financeiro" data-description="#ds_plano_financeiro" data-title="Selecione:">
              <span class="fa fa-search"></span></a>
            </div></div>
      </div>
      <div class="col-md-3"><input value="Criar um Helper?" id="ds_plano_financeiro" readonly></div>
      </div>
	  
	  
		<!-- Dt Lançamento -->
		<div class=form-row>
                <div class="col-md-2"><label>Data Lançamento</label></div>
                <div class="col-md-3"><input required type=text data-mask="00/00/0000" name="dt_lancamento" id="dt_lancamento" value="<?php echo $dt_hoje; ?>" class="datepicker" /></div>
		</div>

		<!-- Dt Vencimento -->
		<div class=form-row>
                <div class="col-md-2"><label>Data Vencimento</label></div>
                <div class="col-md-3"><input required type=text data-mask="00/00/0000" name="dt_vencimento" id="dt_vencimento" value="" class="datepicker" /></div>
		</div>
	  
	  <!-- Inicio Select Status Título -->
	  <div class=form-row>
        <div class=col-md-2>Status da Conta:</div>
        <div class=col-md-3> 
			
			<select name ="id_status_baixa" required class="form-control"> 
				<?php
					  $consulta = "select * 
									         from erpc_financeiro_status_baixa
									        where st_ativo = 1 
								       order by id ";
					  //echo $consulta;
					  $resultado = mysqli_query($conexao, $consulta) or die ($erro = mysqli_error($conexao));
  					  if (mysqli_num_rows($resultado)>0) {
      						while ($registro = mysqli_fetch_assoc($resultado)){
      						  
      						  $id_status_baixa		  = $registro['id'];
      						  //$id_status_baixa_crip	= base64_encode($id_status_baixa);
      						  $ds_baixa		  = $registro['ds_baixa'];
      						  
      					  echo "<option value=$id_status_baixa>$ds_baixa</option> ";
      						}
  					  }		  
				?>		
			</select>
		</div>
	  </div>	
	  
      <!-- Inicio Select Tipo da Conta -->
	  <div class=form-row>
        <div class=col-md-2>Tipo de Pagamento:</div>
        <div class=col-md-3> 
			
			<select required name="id_tipo_conta" class="form-control"> 
				<?php
					  $consulta = "select * 
									         from erpc_financeiro_tipos_titulo
									        where st_ativo = 1 
								       order by id ";
					  //echo $consulta;
					  $resultado = mysqli_query($conexao, $consulta) or die ($erro = mysqli_error($conexao));
  					  if (mysqli_num_rows($resultado)>0) {
      						while ($registro = mysqli_fetch_assoc($resultado)){
      						  
      						  $id_titulo		  = $registro['id'];
      						  //$id_titulo_crip	= base64_encode($id_titulo);
      						  $ds_tipo_titulo		  = $registro['ds_tipo_titulo'];
      						  
      					  echo "<option value=$id_titulo>$ds_tipo_titulo</option> ";
      						}
  					  }		  
				?>		
			</select>
		</div>
		<div class=col-md-2>Número do Cheque:</div>
        <div class=col-md-2> <input type=text name="ds_nr_cheque" class="form-control" /> </div>
	  </div>	
	  
	  <div class=form-row>
        <div class=col-md-2>Histórico:</div>
        <div class=col-md-9> <input type=text name="ds_historico" class="form-control" /> </div>
      </div>
		

    </div>
    <div class=footer>
      <div class="side pull-right">
        <div class=btn-group> 
		<button class="btn btn-default" type="button" onClick="window.history.go(-1)" value="Voltar">Voltar</button>
              <button class="btn btn-success" type="submit" value="adicionar" onClick="$('#validate_custom').validationEngine('hide');" name="adicionar">Adicionar</button>
			  <!--botao antigo
		<button class="btn btn-default" type=button onClick="$('#validate_custom').validationEngine('hide');">Hide prompts</button>            <button class="btn btn-success" type=submit>Submit</button> 
		-->
		</div>
      </div>
    </div>
  </div>
</form>

  </div>
  
</div>
<?php
include 'footer.php';
?>

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

    $("#dt_lancamento").mask("99/99/9999");
    $("#dt_vencimento").mask("99/99/9999");

		// basic chart
		var flash = [[0, 2], [1, 6], [2,3], [3, 8], [4, 5], [5, 13], [6, 8]];
		var html5 = [[0, 5], [1, 4], [2,4], [3, 1], [4, 9], [5, 10], [6, 13]];

		function showTooltip(x, y, contents) {
			jQuery('<div id="tooltip" class="tooltipflot">' + contents + '</div>').css( {
				position: 'absolute',
				display: 'none',
				top: y + 5,
				left: x + 5
			}).appendTo("body").fadeIn(200);
		}


		var plot = jQuery.plot(jQuery("#chartplace2"),
			   [ { data: flash, label: "Flash(x)", color: "#fb6409"}, { data: html5, label: "HTML5(x)", color: "#8cb840"} ], {
				   series: {
					   lines: { show: true, fill: true, fillColor: { colors: [ { opacity: 0.05 }, { opacity: 0.15 } ] } },
					   points: { show: true }
				   },
				   legend: { position: 'nw'},
				   grid: { hoverable: true, clickable: true, borderColor: '#ccc', borderWidth: 1, labelMargin: 10 },
				   yaxis: { min: 0, max: 15 }
				 });

		var previousPoint = null;
		jQuery("#chartplace2").bind("plothover", function (event, pos, item) {
			jQuery("#x").text(pos.x.toFixed(2));
			jQuery("#y").text(pos.y.toFixed(2));

			if(item) {
				if (previousPoint != item.dataIndex) {
					previousPoint = item.dataIndex;

					jQuery("#tooltip").remove();
					var x = item.datapoint[0].toFixed(2),
					y = item.datapoint[1].toFixed(2);

					showTooltip(item.pageX, item.pageY,
									item.series.label + " of " + x + " = " + y);
				}

			} else {
			   jQuery("#tooltip").remove();
			   previousPoint = null;
			}

		});

		jQuery("#chartplace2").bind("plotclick", function (event, pos, item) {
			if (item) {
				jQuery("#clickdata").text("You clicked point " + item.dataIndex + " in " + item.series.label + ".");
				plot.highlight(item.series, item.datapoint);
			}
		});


		// bar graph
		var d2 = [];
		for (var i = 0; i <= 10; i += 1)
			d2.push([i, parseInt(Math.random() * 30)]);

		var stack = 0, bars = true, lines = false, steps = false;
		jQuery.plot(jQuery("#bargraph2"), [ d2 ], {
			series: {
				stack: stack,
				lines: { show: lines, fill: true, steps: steps },
				bars: { show: bars, barWidth: 0.6 }
			},
			grid: { hoverable: true, clickable: true, borderColor: '#bbb', borderWidth: 1, labelMargin: 10 },
			colors: ["#8cb840"]
		});

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



});
</script>
