Slider jquery and variable php

Asked

Viewed 93 times

0

I have the following page:

  <?php 
ini_set('display_errors', 0 );
error_reporting(0);

include"conn_imprep.php";  

if (!isset($_SESSION)) session_start();
if (!isset($_SESSION['s_usu_login'])) {
  session_destroy();
  header("Location:logout.php"); exit;
}

$v_define_query = $_POST['v_desc'];
$v_define_loja  = $_POST['loja'];
$v_define_desc  = $_POST['v_descricao'];

if ($v_define_query == 0){
ini_set('display_errors', 0 );
error_reporting(0);
 echo '<script>alert(\'Por favor escolha uma das opções !\');parent.location =\'menu_principal.php\';</script>';

}else {



/* NOMECLATURA:
 1 - Estoque Negativo (c/ notas em trânsito) -------------------------------------- ESTOQUE + TRANSITO < 0
 2 - Itens com notas em trânsito -------------------------------------------------- TRANSITO > 0
 3 - Itens com Pedido em aberto no DC (bancão) ------------------------------------ BANCAO > 0 (com opção de colocar variável)
 4 - Itens com possível Ruptura (Necessidade abaixo Fator) ------------------------ NECESSIDADE - FATOR <=  0
 5 - Itens com possível Ruptura (Estoque abaixo Fator) --------------------------- Estoque / Fator com resultado <= 10% (com opção de colocar variável  %)
 6 - Itens com Pedido de Compra de Fornecedor ------------------------------------- PEDIDO > 0
 7 - Itens com Quantidade de Gôndola ---------------------------------------------- GONDOLA > 0
 8 - Itens zerados com Estoque no Depósito Central -------------------------------- ESTOQUE DC > 0 e ESTOQUE = 0
*/
if ($v_define_query == 1) {
 $sql_retorno = mysql_query("SELECT  
  imp_loja       AS LOJA,
  imp_item       AS ITEM,
  imp_desc       AS DESCRICAO,
  imp_dias_giro  AS DIAS_DE_GIRO,
  imp_nec        AS NECESSIDADE,
  imp_pedido     AS PEDIDO,
  imp_bancao     AS BANCAO,
  imp_romaneio   AS ROMANEIO, 
  imp_transito   AS TRANSITO,
  imp_gondola    AS GONDOLA,
  imp_fator      AS FATOR,
  imp_reposicao  AS REPOSICAO,
  imp_estoque    AS ESTOQUE,
  imp_estoque_dc AS EST_DC,
  (imp_nec - imp_fator) AS NEC_FAT,
  (imp_estoque / imp_fator) AS EXT_X_FATOR,
  (imp_estoque + imp_transito) AS ESTTRAN,
  imp_data       AS DATA
  FROM importacao HAVING  LOJA='$v_define_loja' AND ESTTRAN < '0' ORDER BY imp_desc ")or die(mysql_error());

} else if ($v_define_query == 2) {
$sql_retorno = mysql_query("SELECT  
  imp_loja       AS LOJA,
  imp_item       AS ITEM,
  imp_desc       AS DESCRICAO,
  imp_dias_giro  AS DIAS_DE_GIRO,
  imp_nec        AS NECESSIDADE,
  imp_pedido     AS PEDIDO,
  imp_bancao     AS BANCAO,
  imp_romaneio   AS ROMANEIO, 
  imp_transito   AS TRANSITO,
  imp_gondola    AS GONDOLA,
  imp_fator      AS FATOR,
  imp_reposicao  AS REPOSICAO,
  imp_estoque    AS ESTOQUE,
  imp_estoque_dc AS EST_DC,
  (imp_nec - imp_fator) AS NEC_FAT,
  (imp_estoque / imp_fator) AS EXT_X_FATOR,
  (imp_estoque + imp_transito) AS ESTTRAN,
  imp_data       AS DATA
  FROM importacao WHERE DATE(imp_data) =  CURDATE() AND imp_loja = '$v_define_loja' AND imp_transito > 0 ORDER BY imp_desc")or die(mysql_error()); 
} else if ($v_define_query == 3) {
$sql_retorno = mysql_query("SELECT  
  imp_loja       AS LOJA,
  imp_item       AS ITEM,
  imp_desc       AS DESCRICAO,
  imp_dias_giro  AS DIAS_DE_GIRO,
  imp_nec        AS NECESSIDADE,
  imp_pedido     AS PEDIDO,
  imp_bancao     AS BANCAO,
  imp_romaneio   AS ROMANEIO, 
  imp_transito   AS TRANSITO,
  imp_gondola    AS GONDOLA,
  imp_fator      AS FATOR,
  imp_reposicao  AS REPOSICAO,
  imp_estoque    AS ESTOQUE,
  imp_estoque_dc AS EST_DC,
  (imp_nec - imp_fator) AS NEC_FAT,
  (imp_estoque / imp_fator) AS EXT_X_FATOR,
  (imp_estoque + imp_transito) AS ESTTRAN,
  imp_data       AS DATA
  FROM importacao WHERE DATE(imp_data) =  CURDATE() AND imp_loja = '$v_define_loja' AND imp_bancao > 0 ORDER BY imp_desc")or die(mysql_error()); 
} else if ($v_define_query == 4) {
$sql_retorno = mysql_query("SELECT  
  imp_loja       AS LOJA,
  imp_item       AS ITEM,
  imp_desc       AS DESCRICAO,
  imp_dias_giro  AS DIAS_DE_GIRO,
  imp_nec        AS NECESSIDADE,
  imp_pedido     AS PEDIDO,
  imp_bancao     AS BANCAO,
  imp_romaneio   AS ROMANEIO, 
  imp_transito   AS TRANSITO,
  imp_gondola    AS GONDOLA,
  imp_fator      AS FATOR,
  imp_reposicao  AS REPOSICAO,
  imp_estoque    AS ESTOQUE,
  imp_estoque_dc AS EST_DC,
  (imp_nec - imp_fator) AS NEC_FAT,
  (imp_estoque / imp_fator) AS EXT_X_FATOR,
  (imp_estoque + imp_transito) AS ESTTRAN,
  (imp_nec - imp_fator) AS NECFAT,
  imp_data       AS DATA
  FROM importacao HAVING DATE(imp_data) =  CURDATE() AND LOJA='$v_define_loja' AND NECFAT <= 0 ORDER BY imp_desc ")or die(mysql_error()); 
} else if ($v_define_query == 5) {
$sql_retorno = mysql_query("SELECT  
  imp_loja       AS LOJA,
  imp_item       AS ITEM,
  imp_desc       AS DESCRICAO,
  imp_dias_giro  AS DIAS_DE_GIRO,
  imp_nec        AS NECESSIDADE,
  imp_pedido     AS PEDIDO,
  imp_bancao     AS BANCAO,
  imp_romaneio   AS ROMANEIO, 
  imp_transito   AS TRANSITO,
  imp_gondola    AS GONDOLA,
  imp_fator      AS FATOR,
  imp_reposicao  AS REPOSICAO,
  imp_estoque    AS ESTOQUE,
  imp_estoque_dc AS EST_DC,
  (imp_nec - imp_fator) AS NEC_FAT,
  (imp_estoque / imp_fator)* 100 AS EXT_X_FATOR,
  (imp_estoque + imp_transito) AS ESTTRAN,
  (imp_nec - imp_fator) AS NECFAT,
  imp_data       AS DATA
  FROM importacao HAVING DATE(imp_data) =  CURDATE() AND LOJA ='$v_define_loja' AND EXT_X_FATOR > 10 ORDER BY imp_desc")or die(mysql_error()); 
} else if ($v_define_query == 6) {
$sql_retorno = mysql_query("SELECT  
  imp_loja       AS LOJA,
  imp_item       AS ITEM,
  imp_desc       AS DESCRICAO,
  imp_dias_giro  AS DIAS_DE_GIRO,
  imp_nec        AS NECESSIDADE,
  imp_pedido     AS PEDIDO,
  imp_bancao     AS BANCAO,
  imp_romaneio   AS ROMANEIO, 
  imp_transito   AS TRANSITO,
  imp_gondola    AS GONDOLA,
  imp_fator      AS FATOR,
  imp_reposicao  AS REPOSICAO,
  imp_estoque    AS ESTOQUE,
  imp_estoque_dc AS EST_DC,
  (imp_nec - imp_fator) AS NEC_FAT,
  (imp_estoque / imp_fator) AS EXT_X_FATOR,
  (imp_estoque + imp_transito) AS ESTTRAN,
  (imp_nec - imp_fator) AS NECFAT,
  imp_data       AS DATA
  FROM importacao WHERE DATE(imp_data) =  CURDATE() AND imp_loja = '$v_define_loja' AND imp_pedido > 0 ORDER BY imp_desc ")or die(mysql_error()); 
} else if ($v_define_query == 7) {
$sql_retorno = mysql_query("SELECT  
  imp_loja       AS LOJA,
  imp_item       AS ITEM,
  imp_desc       AS DESCRICAO,
  imp_dias_giro  AS DIAS_DE_GIRO,
  imp_nec        AS NECESSIDADE,
  imp_pedido     AS PEDIDO,
  imp_bancao     AS BANCAO,
  imp_romaneio   AS ROMANEIO, 
  imp_transito   AS TRANSITO,
  imp_gondola    AS GONDOLA,
  imp_fator      AS FATOR,
  imp_reposicao  AS REPOSICAO,
  imp_estoque    AS ESTOQUE,
  imp_estoque_dc AS EST_DC,
  (imp_nec - imp_fator) AS NEC_FAT,
  (imp_estoque / imp_fator) AS EXT_X_FATOR,
  (imp_estoque + imp_transito) AS ESTTRAN,
  (imp_nec - imp_fator) AS NECFAT,
  imp_data       AS DATA
  FROM importacao WHERE DATE(imp_data) =  CURDATE() AND imp_loja='$v_define_loja' AND imp_gondola > 0 ORDER BY imp_desc  ")or die(mysql_error()); 
} else if ($v_define_query == 8) {
$sql_retorno = mysql_query("  SELECT  
  imp_loja       AS LOJA,
  imp_item       AS ITEM,
  imp_desc       AS DESCRICAO,
  imp_dias_giro  AS DIAS_DE_GIRO,
  imp_nec        AS NECESSIDADE,
  imp_pedido     AS PEDIDO,
  imp_bancao     AS BANCAO,
  imp_romaneio   AS ROMANEIO, 
  imp_transito   AS TRANSITO,
  imp_gondola    AS GONDOLA,
  imp_fator      AS FATOR,
  imp_reposicao  AS REPOSICAO,
  imp_estoque    AS ESTOQUE,
  imp_estoque_dc AS EST_DC,
  (imp_nec - imp_fator) AS NEC_FAT,
  (imp_estoque / imp_fator) AS EXT_X_FATOR,
  (imp_estoque + imp_transito) AS ESTTRAN,
  (imp_nec - imp_fator) AS NECFAT,
  imp_data       AS DATA
  FROM importacao WHERE DATE(imp_data) =  CURDATE() AND imp_loja='$v_define_loja' AND imp_estoque_dc > 0 AND imp_estoque = 0 ORDER BY imp_desc")or die(mysql_error()); 
}
@session_start();
$v_id_usuario = $_SESSION['s_usu_id'];
$v_login      = $_SESSION['s_usu_login'];
$v_nome       = $_SESSION['s_usu_nome'];
$v_sobrenome  = $_SESSION['s_usu_sobrenome'];
$v_senha      = $_SESSION['s_usu_senha'];
$v_nivel      = $_SESSION['s_usu_setor'];
$v_loja       = $_SESSION['s_usu_loja_id'];

     $query_descricao = mysql_query("SELECT * FROM radios_menu WHERE rm_id='$v_define_query'");
    while ($row = mysql_fetch_array($query_descricao)) {
    $v_descricao_categoria = $row["rm_desc"];
    }

    ?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="pt-br" xml:lang="pt-br">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>#
    </title>
    <link rel="stylesheet" href="bootstrap/style.css">
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="includes/css/datatables.css">
    <link rel="stylesheet" type="text/css" href="font-awesome/css/font-awesome.min.css" />
    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/jquery-1.11.3.min.js">
    </script>
    <script src="bootstrap/js/bootstrap.min.js">
    </script>
    <script src="includes/js/jquery.dataTables.min.js">
    </script>
    <script src="includes/js/datatables.js">
    </script> 


    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" />


<style type="text/css">

.button_example{
 border:1px solid #616261;-webkit-box-shadow: #b4b5b5 7px 7px 7px  ;-moz-box-shadow: #b4b5b5 7px 7px 7px ; box-shadow: #b4b5b5 7px 7px 7px  ; -webkit-border-radius: 3px; -moz-border-radius: 3px;border-radius: 3px;font-size:12px;font-family:arial, helvetica, sans-serif; padding: 10px 10px 10px 10px; text-decoration:none; display:inline-block;text-shadow: -1px -1px 0 rgba(0,0,0,0.3);font-weight:bold; color: #FFFFFF;
 background-color: #7d7e7d; background-image: -webkit-gradient(linear, left top, left bottom, from(#7d7e7d), to(#080A0D));
 background-image: -webkit-linear-gradient(top, #7d7e7d, #080A0D);
 background-image: -moz-linear-gradient(top, #7d7e7d, #080A0D);
 background-image: -ms-linear-gradient(top, #7d7e7d, #080A0D);
 background-image: -o-linear-gradient(top, #7d7e7d, #080A0D);
 background-image: linear-gradient(to bottom, #7d7e7d, #080A0D);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#7d7e7d, endColorstr=#080A0D);
}

.button_example:hover{
 border:1px solid #4a4b4a;
 background-color: #646464; background-image: -webkit-gradient(linear, left top, left bottom, from(#646464), to(#1b222d));
 background-image: -webkit-linear-gradient(top, #646464, #1b222d);
 background-image: -moz-linear-gradient(top, #646464, #1b222d);
 background-image: -ms-linear-gradient(top, #646464, #1b222d);
 background-image: -o-linear-gradient(top, #646464, #1b222d);
 background-image: linear-gradient(to bottom, #646464, #1b222d);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#646464, endColorstr=#1b222d);
}

#tblExport tbody tr{
    border:solid 1px;
    cursor:pointer;
}


#tblExport thead th:nth-child(1){
    width:100px;
}

#tblExport input{
    width:100%;
}

</style>
<script> 
$("#slider").slider({
  change: function(event, ui) {

    $("#result").html(ui.value);

    $.ajax({
      url: "reposicao.php",
      type: "POST",
      data: {
        valueChoice: ui.value
      },
      success: function(result) {
      $("#result").html(result);
    }
           });
  }
});
</script> 
    </head>
<body>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="reposicao.php"></a>
      <img src="img/logo.png" height="50" width="100">
    </div>

    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
      </ul>

      </ul>
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">LOJA:&nbsp;&nbsp;<?php echo"00$v_loja ";?></a></li>
        <li><a href="#">USUARIO:&nbsp;&nbsp;<?php echo"$v_nome $v_sobrenome ";?></a></li>&nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;<li><a href="logout.php"><span class="glyphicon glyphicon-off">&nbsp;SAIR</span></a></li>
      </ul>
    </div>
  </div>
</nav>
<div class="container">
  <div class="row">
    <div class="col-md-12">
       <button type='button' class='button_example' onclick="location.href='menu_principal.php'"><span class="glyphicon glyphicon-arrow-left"></span>&nbsp;&nbsp;&nbsp;VOLTAR</button>
       <button type='button' class='button_example' id="btnExport"><span class="fa fa-file-excel-o"></span>&nbsp;&nbsp;&nbsp;EXPORTAR</button>





<div id="slider"></div>
<div id="result"></div>



  <?php
  $query_frase = mysql_query("SELECT 
 frase_id   AS ID, 
 frase_desc AS DESCRICAO
   FROM frases_sistema ");
    while ($row = mysql_fetch_array($query_frase)) {
    $v_frase    = $row["DESCRICAO"];
       }


    ?>

<div align="left"><h4><?php echo"$v_frase";?></h4></div><div align="right"><div class="panel-title">
  <div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title"><center><b><?php echo"$v_descricao_categoria"; ?></center></h3></b>
  </div>
  <div class="panel-body">
  <link rel="stylesheet" type="text/css" href="/Content/font-awesome/css/font-awesome.min.css" />
<table id="tblExport" class='table table-hover table-bordered table-responsiv table-striped' align='center'>
   <thead>
    <tr>
      <th><input type="text" id="txtColuna1"/></th>
      <th><input type="text" id="txtColuna2"/></th>
    </tr> 
     <tr>
        <th align='center'><font size=2>Item</font></th>
        <th align='center'><font size=2>Descricao</font></th>
        <th align='center'><font size=2>Est.DC</font></th>
        <th align='center'><font size=2>Dias de giro</font></th>
        <th align='center'><font size=2>Fator</font></th>
        <th align='center'><font size=2>Estoque</font></th>
        <th align='center'><font size=2>Necessidade</font></th>
        <th align='center'><font size=2>Pedido</font></th>
        <th align='center'><font size=2>Bancao</font></th>
        <th align='center'><font size=2>Romaneio</font></th>
        <th align='center'><font size=2>Transito</font></th>
        <th align='center'><font size=2>Gondula</font></th>
        <th align='center' bgcolor='#00CC00'><font size=2>Reposição</font></th>
     </tr>
   </thead>
  <?php
     echo"<tbody>";   
     while ($row = mysql_fetch_array($sql_retorno)) {
     echo" <tr>";
        echo"<td align='center'><font size=2> ".$row['ITEM'].          "</font></td>";
        echo"<td><font size=2>".$row['DESCRICAO'].                     "</font></td>";
        echo"<td align='center'><font size=2><b>".$row['EST_DC'].      "</font></b></td>";
        echo"<td align='center'><font size=2><b>".$row['DIAS_DE_GIRO']."</font></b></td>";
        echo"<td align='center'><font size=2><b>".$row['FATOR'].       "</font></b></td>";
        echo"<td align='center'><font size=2><b>".$row['ESTOQUE'].     "</font></b></td>";
        echo"<td align='center'><font size=2><b>".$row['NECESSIDADE']. "</font></b></td>";
        echo"<td align='center'><font size=2><b>".$row['PEDIDO'].      "</font></b></td>";
        echo"<td align='center'><font size=2><b>".$row['BANCAO'].      "</font></b></td>";
        echo"<td align='center'><font size=2><b>".$row['ROMANEIO'].    "</font></b></td>";
        echo"<td align='center'><font size=2><b>".$row['TRANSITO'].    "</font></b></td>";
        echo"<td align='center'><font size=2><b>".$row['GONDOLA'].     "</font></b></td>";
        echo"<td align='center' bgcolor='#00CC00'><font size=2><b>".$row['REPOSICAO'].   "</font></b></td>";
     echo" </tr>";
        }   
  echo"  </tbody>";
 echo" </table>";

?>
    </div>
   </div>
  </div>
 </div>
</div>
<script src="jquery.btechco.excelexport.js"></script>
<script src="jquery.base64.js"></script>
<script>
    $(document).ready(function () {
        $("#btnExport").click(function () {
            $("#tblExport").btechco_excelexport({
                containerid: "tblExport"
               , datatype: $datatype.Table
               , filename: 'ReposicaoAutomatica'
            });
        });
    });
$(function(){
    $("#tblExport input").keyup(function(){       
        var index = $(this).parent().index();
        var nth = "#tblExport td:nth-child("+(index+1).toString()+")";
        var valor = $(this).val().toUpperCase();
        $("#tblExport tbody tr").show();
        $(nth).each(function(){
            if($(this).text().toUpperCase().indexOf(valor) < 0){
                $(this).parent().hide();
            }
        });
    });

    $("#tblExport input").blur(function(){
        $(this).val("");
    });
});


</script>
  </body>
</html>
<?php } ?>

In that part:

} else if ($v_define_query == 5) {
$sql_retorno = mysql_query("SELECT  
  imp_loja       AS LOJA,
  imp_item       AS ITEM,
  imp_desc       AS DESCRICAO,
  imp_dias_giro  AS DIAS_DE_GIRO,
  imp_nec        AS NECESSIDADE,
  imp_pedido     AS PEDIDO,
  imp_bancao     AS BANCAO,
  imp_romaneio   AS ROMANEIO, 
  imp_transito   AS TRANSITO,
  imp_gondola    AS GONDOLA,
  imp_fator      AS FATOR,
  imp_reposicao  AS REPOSICAO,
  imp_estoque    AS ESTOQUE,
  imp_estoque_dc AS EST_DC,
  (imp_nec - imp_fator) AS NEC_FAT,
  (imp_estoque / imp_fator)* 100 AS EXT_X_FATOR,
  (imp_estoque + imp_transito) AS ESTTRAN,
  (imp_nec - imp_fator) AS NECFAT,
  imp_data       AS DATA
  FROM importacao HAVING DATE(imp_data) =  CURDATE() AND LOJA ='$v_define_loja' AND EXT_X_FATOR > 10 ORDER BY imp_desc")or die(mysql_error());

Where : EXT_X_FATOR > 10

It is configured to display anything larger than 10, plus to get something that can be more independent for the user would like to use the slider of jquery or any other plugin that is similar and leaves interactive as slider with php more never used, and not knowing how to start, someone could help me how to do.

Follow the jquery slider link

1 answer

1


$("#slider").slider({
  change: function(event, ui) {

    $("#result").html(ui.value);

    $.ajax({
      url: "teste.php",
      type: "POST",
      data: {
        valueChoice: ui.value
      },
      success: function(result) {
      $("#result").html(result);
    }
           });
  }
});
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css" />

<div id="slider"></div>
<div id="result">

</div>

  • In my post I use the POST method and only has a value,there you are adding minimum and maximum, could convert the way I need ?

  • I changed the code, test it and see if that’s it. I suggest you study this code more carefully, it will probably help you a lot.

  • I edited the question with my whole code, because in fact I already gave a POST, and what I want and change the value according to the slider.

  • Yes, where is valueChoice you will have to put the name of the field you are calling via POST

Browser other questions tagged

You are not signed in. Login or sign up in order to post.