Advertisement
Guest User

Devrutas.php

a guest
Mar 15th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.57 KB | None | 0 0
  1. <html>
  2. <head>
  3.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4.     <title>Devolucion de rutas</title>
  5. </head>
  6.  
  7. <?php
  8.     $user = "";
  9.     $password = "";
  10.     $server = "servidorcio";
  11.     $BD = "SQLPRUEBA";
  12.  
  13.     $connection_string = "DRIVER={SQL Server};SERVER=$server;DATABASE=$BD";
  14.     $conn = odbc_connect($connection_string,$user,$password);
  15.   //if ($conn) {echo "Conexion odbc establecida"; } else {die("No se pudo establecer la conexion."); }
  16. ?>
  17.  
  18. <style>
  19.     p {
  20.         border: 1px solid darkblue;
  21.         padding: 1px;
  22.     }
  23.     body {background-color:lightgrey;}
  24.     h1   {color:blue; text-align: left;font-size: 20px; }
  25.     p    {color:darkblue;}
  26.     .boton{  border: 1px solid #DBE1EB;
  27.         font-size: 18px;
  28.         font-family: Arial, Verdana;
  29.         padding-left: 7px;
  30.         padding-right: 7px;
  31.         padding-top: 5px;
  32.         padding-bottom: 5px;
  33.         border-radius: 10px;
  34.         -moz-border-radius: 10px;
  35.         -webkit-border-radius: 10px;
  36.         -o-border-radius: 10px;
  37.         background: #4972B5;
  38.         background: linear-gradient(left, #4972B5, #618ACB);
  39.         background: -moz-linear-gradient(left, #4972B5, #618ACB);
  40.         background: -webkit-linear-gradient(left, #4972B5, #618ACB);
  41.         background: -o-linear-gradient(left, #4972B5, #618ACB);
  42.         color: #FFFFFF;
  43.     }
  44. </style>
  45.  
  46. <body>
  47.     <table  width="1000" border="6" >
  48.       <tr>
  49.         <td>
  50.             <form id="form8" name="form8" method="post" action="">
  51.                 <h1>Fecha de Liquidacion:<input type="text" size="10" name="txtfecha" id="txtfecha" value="<?php echo date("d/m/Y"); ?>"  />
  52.                 <input type="submit" name="VisRutas" id="IdVisRutas" value="Mostrar" class="boton" /> </h1>
  53.             </form>
  54.         </td>
  55.       </tr>
  56.         <td>
  57.             <form id="form9" name="form9" method="post" action="">
  58.                 <?php
  59.                     if(isset($_POST['VisRutas'])) {
  60.                         $Fec_Liq=$_POST["txtfecha"];
  61.                         $sql= odbc_exec($conn,"select Str(IdLiquidacion)+' '+IdSector+' '+Nombre+' '+Apell_Materno+' '+Apell_Paterno AS liquidacion
  62.                                  from cab_liquidacion a inner join cat_personal b on b.idpersonal=a.idvendedor
  63.                                  where fec_liquidacion= '$Fec_Liq' order by idsector");
  64.  
  65.                         echo '<form action="" method="post">';
  66.                             echo 'Seleccione Ruta --&gt;';
  67.                             echo '<select name="cborutas" method="post" id="liquidacion" style="width:35%" onchange="">';
  68.                                 echo '<option value="0">Seleccione Ruta</option>';
  69.                                 if ($row=odbc_fetch_array($sql)) {
  70.                                     do { echo '<option value= "'.$row["liquidacion"].'"> '.$row["liquidacion"].'</option>'; }
  71.                                     while ($row=odbc_fetch_array($sql));
  72.                                 }
  73.                                 echo '</select>';
  74.                             echo '<input type="submit" name="VisProductos" id="IdVisualiza" value="Mostrar_Productos" class="boton" />';
  75.                         echo '</form>';
  76.                     }
  77.                 ?>
  78.             </form>
  79.         </td>
  80.       </tr>
  81.       <tr>
  82.         <td><table width="1000">
  83.           <tr>
  84.             <?php
  85.             if(isset($_POST['VisProductos'])) {
  86.                 echo " <th width='339' scope='col'><p>$_POST[cborutas]</p></th>
  87.                <th width='262' scope='col'><p>Kilometraje --&gt;<input type='text' name='txtKilom' id='txtKilom' /> </p></th>  ";
  88.             }
  89.             ?>
  90.           </tr>
  91.         </td>
  92.         </table>
  93.         <form id="form4" name="form4" method="post" action="">
  94.             <table width="1000" class="TblDetPro" id="TblDetPro">
  95.                   <tr>
  96.                     <th scope="col"><p>TIPO</p> </th>
  97.                     <th scope="col"><p>#PROD</p></th>
  98.                     <th scope="col"><p>PRODUCTO</p></th>
  99.                     <th scope="col"><p>CANT</p></th>
  100.                     <th scope="col"><p>PCIO</p></th>
  101.                     <th scope="col"><p>D.VAC</p></th>
  102.                     <th scope="col"><p>D.LLE</p></th>
  103.                     <th scope="col"><p>RACK DEV</p></th>
  104.                     <th scope="col"><p>SG.CGA</p></th>
  105.                     <th scope="col"><p>RACK S.DIA</p></th>
  106.                   </tr>
  107.                   <?php
  108.                       if(isset($_POST['VisProductos'])) {
  109.                           $numliq = intval(substr($_POST["cborutas"],1,10));
  110.  
  111.                           $sql= odbc_exec($conn,"select Case When Idtipocarga=1 Then 'Carga' Else 'Recarga' End As TipCga, A.IdProducto,Des_producto,
  112.                          cantidad,A.precio,dev_vacio,dev_lleno,rackd From Det_CargasdeRuta A
  113.                          Inner join Cat_Productos b on b.IdProducto=A.IdProducto
  114.                          where IdLiquidacion= $numliq ");
  115.  
  116.                           while ($row = odbc_fetch_array($sql)) {
  117.                               echo " <tr>
  118.                                     <td>$row[TipCga]</td>
  119.                                     <td>$row[IdProducto]</td>
  120.                                     <td>$row[Des_producto]</td>
  121.                                     <td align=right>$row[cantidad]</td>
  122.                                     <td align=right>$row[precio]</td>
  123.                                     <td align=right><input type='text' id='coldv' size='4' maxlength='5' value=$row[dev_vacio] ></td>
  124.                                     <td align=right><input type='text' id='colll' size='4' maxlength='5' value=$row[dev_lleno] ></td>
  125.                                     <td><input type='text' id='colra' size='15' maxlength='15' value=$row[rackd] ></td>
  126.                                     <td><input type='text' id='colsd' size='4' maxlength='5' value='0' ></td>
  127.                                     <td><input type='text' id='colrsd' size='15' maxlength='15'value='' ></td>
  128.                                </tr>";
  129.                           }
  130.                       }
  131.                   ?>
  132.             </table>
  133.             <input type="submit" name="BtnGuardar" id="BtnGuardar" value="Guardar" class="boton" onclick="actualizabd();" />
  134.         </form>
  135.       </tr>
  136.  
  137.       <br><br>
  138.       <?php $sql= odbc_exec($conn,"Select Str(IdProducto)+' '+Des_Producto As Productos From Cat_Productos Order By Des_producto  "); ?>
  139.  
  140.       <form action="" method="post">
  141.           <td><table width="1000" >
  142.               <tr><td> <input type="text" style="visibility:hidden" name="txtliq" id="txtliq" size="1" maxlength="10" readonly="true" value="
  143.                   <?php if(isset($_POST['VisProductos'])) { echo substr($_POST["cborutas"],1,10);}?>" />
  144.               </td></tr>
  145.               <tr>
  146.                 <th scope="col"><p>TipCga</p></th>
  147.                 <th scope="col"><p>Producto</p></th>
  148.                 <th scope="col"><p>Cant.</p></th>
  149.                 <th scope="col"><p>Racks</p></th>
  150.                 <th scope="col"></th>
  151.               </tr>
  152.               <tr>
  153.                 <td>
  154.                   <select name="cbotipcga" id="cbotipcga">
  155.                       <option>Carga</option>
  156.                       <option>Recarga</option>
  157.                   </select>
  158.                 </td>
  159.                 <td>
  160.                   <select name="cboprod" id="cboprod">
  161.                       <?php
  162.                           if ($row=odbc_fetch_array($sql)) {
  163.                           do { echo '<option value= "'.$row["Productos"].'"> '.$row["Productos"].'</option>'; }
  164.                           while ($row=odbc_fetch_array($sql));
  165.                           }
  166.                       ?>
  167.                   </select>
  168.                 </td>
  169.                 <td> <input type="text" name="txtCant" id="txtCant"  onKeyPress="if (event.keyCode < 48 || event.keyCode > 57)event.returnValue = false;" size="5" maxlength="5"/> </td>
  170.                 <td> <input type="text" name="TxtRack" id="TxtRack" size="35" maxlength="35"/> </td>
  171.                 <td><form id="form2" name="form2" method="post" action="">
  172.                     <input type="submit" name="BtnInsertar" id="BtnInsertar" value="Insertar" class="boton1" />
  173.                 </form></td>
  174.               </tr>
  175.           </table></td>
  176.       </form>
  177.     </table>
  178. </body>
  179. <?php
  180.     if(isset($_POST['BtnInsertar'])) {
  181.         if ($_POST['cbotipcga']=="Carga") {$nTipCga=1;};
  182.         if ($_POST['cbotipcga']=="Recarga") {$nTipCga=2;};
  183.  
  184.         $nIdPr=intval(substr($_POST["cboprod"],1,10));
  185.         $sqlprod= odbc_exec($conn,"Select precio From Cat_Productos Where IdProducto= $nIdPr");
  186.         if ($row=odbc_fetch_array($sqlprod)) {$Precio=$row["precio"] ;}
  187.         $numliq= $_POST['txtliq'];
  188.         $nCant=$_POST['txtCant'];
  189.         $cRack=$_POST['TxtRack'];
  190.  
  191.         If (strlen($nCant)>0 and strlen($cRack)>1 And $numliq>0) {
  192.             $sql = odbc_exec($conn, "INSERT INTO Det_CargasdeRuta (Idfilial, IdCedis, IdLiquidacion,IdTipoCarga,IdProducto,Cantidad,Precio,Dev_Vacio,Dev_Lleno,RackD,RackC,IdArticulo) VALUES(1, 2, $numliq,$nTipCga,$nIdPr,$nCant,$Precio,0,0,'.',$cRack,0)");
  193.         }
  194.         IF (strlen($nCant)<=0 OR strlen($cRack)<=1){
  195.             echo '<script language="javascript">alert("Datos incompletos, no se guardara");</script>'; }
  196.     }
  197. ?>
  198. </html>
  199.  
  200. <script>
  201.     function actualizabd() {
  202.         var cCelda,textos = '';
  203.         nNumLiq=document.getElementById('txtliq').value;
  204.         for (var i=1;i<document.getElementById('TblDetPro').rows.length;i++) {
  205.             cCelda=document.getElementById('TblDetPro').rows[i].cells[0].innerHTML
  206.             if (cCelda=='Carga') {nIdTipC=1}
  207.             if (cCelda=='Recarga') {nIdTipC=2}
  208.             nIdProd=document.getElementById('TblDetPro').rows[i].cells[1].innerHTML
  209.             nCanti=document.getElementById('TblDetPro').rows[i].cells[3].innerHTML
  210.             nPcio=document.getElementById('TblDetPro').rows[i].cells[4].innerHTML
  211.             nDevVac=document.getElementById('TblDetPro').rows[i].cells[5].children[0].value
  212.             nDevLle=document.getElementById('TblDetPro').rows[i].cells[6].children[0].value
  213.             nRacDev=document.getElementById('TblDetPro').rows[i].cells[7].children[0].value
  214.             actualizaDato(nDevVac,nDevLle,nRacDev,nNumLiq,nIdProd,nIdTipC,nCanti,nPcio)
  215.         }
  216.         alert('Actualizacion completada');
  217.     }
  218.  
  219.     function objetoAjax(){
  220.         var xmlhttp=false;
  221.         try {
  222.             xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  223.         } catch (e) {
  224.             try {
  225.                 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  226.             } catch (E) {
  227.                 xmlhttp = false;
  228.             }
  229.         }
  230.         if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  231.             xmlhttp = new XMLHttpRequest();
  232.         }
  233.         return xmlhttp;
  234.     }
  235.  
  236.     function actualizaDato(nDevVac,nDevLle,nRacDev,nNumLiq,nIdProd,nIdTipC,nCanti,nPcio) {
  237.         divResultado = document.getElementById('resultado');
  238.         ajax=objetoAjax();
  239.         ajax.open("POST", "rec.php");
  240.         ajax.onreadystatechange=function() {
  241.             if (ajax.readyState==4) {
  242.                 //mostrar resultados en esta capa
  243.                 divResultado.innerHTML = ajax.responseText
  244.             }
  245.         }
  246.         ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
  247.         ajax.send("&nDevVac="+nDevVac+"&nDevLle="+nDevLle+"&nRacDev="+nRacDev+"&nNumLiq="+nNumLiq+"&nIdProd="+nIdProd+"&nIdTipC="+nIdTipC+"&nCanti="+nCanti+"&nPcio="+nPcio)
  248.         alert(nIdProd);
  249.     }
  250. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement