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

// Método para post de Query Avançada
  $b_contulta = false;
	$consulta = "SELECT id, ds_unidade_medida FROM erpc_unidade_medida where st_ativo = 1";

// se recebeu os parametros do POST
if(isset($_POST['pesquisar'])){
  $b_contulta = true;
  $id         = $_POST['id'];
  $ds_unidade_medida	= trim($_POST['ds_unidade_medida']);

  $consulta .= (!empty($id)  ? " and id like '%$id%'"            : '');
  $consulta .= (!empty($ds_unidade_medida)  ? " and ds_unidade_medida like '%$ds_unidade_medida%'"            : '');

?>
<script type="text/javascript">
    function alteraDiv(){
        var destino = document.getElementById("minhadiv");
        destino.value = document.getElementById("orcamentoAssuntoForm").value;
    }

    // pega o valor da div e abre outra janela
    function visualizaPdf(){
        var p_html = document.getElementById("print-lista-div").innerHTML;
        var p_link = 'http://192.168.0.200./edival/report_pdf.php?html=' + p_html;
        // var p_link = 'report_pdf.php?html=' + p_html;
        // alert(p_link);
        window.open(p_link);
    }
</script>

<div class="block" id="print-lista-div">
  <div class="header">
  <h2>Unidades de Medida</h2>
  </div>
  <div class="content" >
      <table class="table table-bordered sortable" width="90%">
        <thead>
          <tr>
            <th width=10%>ID</th>
            <th width=90%>Descrição</th>
          </tr>
        </thead>
        <tbody>

      <?php

			$resultado = mysqli_query($conexao, $consulta) or die ($erro = mysqli_error($conexao));
			if (mysqli_num_rows($resultado)>0) {
            while ($registro = mysqli_fetch_assoc($resultado)){

            $id       	= $registro['id'];
            $id_crip	 	= base64_encode($id);
			  		$ds_unidade_medida	= $registro['ds_unidade_medida'];

            echo "<tr>";
            // echo "<td class='text-center'><input type='checkbox' /></td>";
            echo "<td>$id</td>";
            echo "<td>$ds_unidade_medida</td>";

            /*
            echo "<td class='text-center'><a href='erpc_unidade_medida_edit.php?id=$id_crip'>  <i class='glyphicon glyphicon-pencil' title='Editar'><span class='sr-only'>Editar</span></i></a></td>";
            echo "<td class='text-center'><a href='erpc_unidade_medida_remove.php?id=$id_crip'><i class='glyphicon glyphicon-remove' title='Remover'><span class='sr-only'>Remover</span></i></a></td>";
            */
            echo "</tr>";
            }
          }
          ?>
        </tbody>
      </table>
    </div> <!-- table-responsive -->
  </div> <!-- content -->
</div> <!-- block -->

<div class="block">
<div class="form-row">
  <div class="side pull-right">
    <div class=btn-group>
    <button class="btn btn-primary" type="button" value="visualizar" name="visualizar" onclick="visualizaPdf()">Visualizar Impressão</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>

<?
}// fechamento do POST
else{

?>
<!-- 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">Imprimir</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="#">
  <div class=block>
    <div class=header>
      <h2>Parametros para imprimir de Unidade de Medida:</h2>
      <div class="side pull-right"> <button class="btn btn-default btn-clean" onClick="clear_form('#validate_custom');" type=button>Clear form</button>          </div>
    </div>

    <div class="content controls">
  	<div class=form-row>
          <div class=col-md-3>ID:</div>
          <div class=col-md-6><input type=text name="id" value="" class="form-control" /> </div>
        </div>

    <div class=form-row>
          <div class=col-md-3>Descrição:</div>
          <div class=col-md-6><input type=text name="ds_unidade_medida" value="" class="form-control" /> </div>
        </div>

  	  <!-- Elementos
      <div class=form-row>
        <div class=col-md-3>Select:</div>
        <div class=col-md-9> <select name=s_example class=" form-control"> <option value></option> <option value=1>Andorra</option> <option value=2>Antarctica</option> <option value=3>Ukraine</option> </select>            <span class=help-block>Required</span> </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Checkbox:</div>
        <div class=col-md-9>
          <div class=checkbox-inline> <label> <input type=checkbox class=" form-control" name=vcheck value="1"/> Enabled </label>              </div>
          <div class=checkbox-inline> <label> <input name=vcheck value=0 type=checkbox disabled=disabled class=""/> Disabled </label>              </div>
        </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Radio:</div>
        <div class=col-md-9>
          <div class=checkbox-inline> <label> <input type=radio class= name=vradio value="1"/> Enabled </label> </div>
          <div class=checkbox-inline> <label> <input type=radio disabled=disabled class= name=vradio value="0"/> Disabled </label>              </div>
        </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Datepicker:</div>
        <div class=col-md-9> <input type=text class=" datepicker form-control" /> <span class=help-block>Required</span> </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Group required:</div>
        <div class=col-md-9> <input class="validate[groupRequired[payments]] form-control" type=text name=credit id=credit /> <span class=help-block>Any of group fields must be filled</span>            </div>
      </div>
      <div class=form-row>
        <div class=col-md-3></div>
        <div class=col-md-9> <input class="validate[groupRequired[payments]] form-control" type=text name=paypal id=paypal /> <span class=help-block>Any of group fields must be filled</span>            </div>
      </div>
      <div class=form-row>
        <div class=col-md-3>Condition required:</div>
        <div class=col-md-9> <input type=text name=creditcard id=creditcard placeholder="Credit card" class="form-control" /> </div>
      </div>
      <div class=form-row>
        <div class=col-md-3></div>
        <div class=col-md-9> <input class="validate[condRequired[creditcard]] form-control" type=text id=ccv name=ccv placeholder="CCV" />
          <span
            class=help-block>This field is required if "Credit card" field is filled</span>
        </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="pesquisar" name="pesquisar">pesquisar</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>

<?
}
 include 'footer.php';
?>
