Foros del Web » Programando para Internet » PHP »

Registro de transacciones

Estas en el tema de Registro de transacciones en el foro de PHP en Foros del Web. Buenas tardes foreros, necesito de ayuda y me orienten sobre lo que tengo que hacer. resulta que necesito incluir detalle en mis formularios pero no ...
  #1 (permalink)  
Antiguo 06/10/2012, 11:09
Avatar de jlct  
Fecha de Ingreso: abril-2012
Ubicación: Venezuela
Mensajes: 148
Antigüedad: 12 años
Puntos: 19
Registro de transacciones

Buenas tardes foreros, necesito de ayuda y me orienten sobre lo que tengo que hacer.

resulta que necesito incluir detalle en mis formularios pero no tengo idea de como hacerlo.. la idea es que el usuario pueda incluir tantos registros como quiera.. y esos pueden ser 1, 2, 3 o hasta mas campos por fila (segun la magnitud del detalle) hasta ahora solo les puedo facilitar como llevo el registro de los formularios normales.

medicina.php
Código PHP:
Ver original
  1. <?
  2. include("../../modelos/config.php");
  3. $c = new Conexion;
  4. $c->Conectar();
  5.  
  6. $registros = 10;
  7.  
  8. if (!$pagina) {
  9.     $inicio = 0;
  10.     $pagina = 1;
  11. }
  12. else {
  13.     $inicio = ($pagina - 1) * $registros;
  14. }
  15. $valor = $_GET['valor'];
  16. $msg = $_REQUEST['alerta'];
  17.  
  18. ?>
  19. <!doctype html>
  20. <html lang="es">
  21. <head>
  22.     <meta http-equiv="Content-Type" content="text/html" charset="utf-8" />
  23.     <title>Unidad de Producción</title>
  24.     <link rel="shortcut icon" href="../../imagenes/icono.png">
  25.     <link rel="stylesheet" href="../../css/estilo.css" />
  26.     <script src="medicina_ajax.js" language="javascript" type="text/javascript"></script>
  27. </head>
  28. <body class="no-js">
  29.     <? include("../../nav/nav_menuprincipal.html"); ?>
  30.     <article>
  31.     <header>
  32.         <br />
  33.         <h1 align="center">Medicinas</h1>
  34.     </header><br /><br />
  35.     <section><p><form name="form1" id="form1" method="post">
  36.     <fieldset>
  37.     <ol>
  38.     <center class="caja">
  39.     <input type="text" size="30" id="texto" onKeyUp="Buscar()" value="<?=$valor?>"/>
  40.     <input type="button" name="insert" id="insert" value="Nuevo" onClick="location.href = 'medicina_nuevo.php' "/>
  41.     </center>
  42.     <?
  43.     if (empty($valor))
  44.     {
  45.     if (!empty($msg))
  46.     {
  47.         echo "<script language='javascript'>alert('$msg');</script>";
  48.     }
  49.     $query = mysql_query("SELECT id_medicina FROM tmedicina");
  50.     $total_registros = mysql_num_rows($query);
  51.     $resultados = mysql_query("SELECT m.id_medicina ID, m.nombre medicina, CASE m.tipo WHEN  'G' THEN  'Medicina General' WHEN  'D' THEN  'Desparacitantes' ELSE  'Vacunas' END tipo, m.existencia, a.nombre almacen FROM tmedicina m INNER JOIN talmacen a ON m.almacen = a.id_almacen ORDER BY m.nombre ASC LIMIT $inicio, $registros");
  52.     }
  53.     else {
  54.     $query = mysql_query("SELECT id_medicina FROM tmedicina where nombre LIKE '%$valor%'");
  55.     $total_registros = mysql_num_rows($query);
  56.     $resultados = mysql_query("SELECT m.id_medicina ID, m.nombre medicina, CASE m.tipo WHEN  'G' THEN  'Medicina General' WHEN  'D' THEN  'Desparacitantes' ELSE  'Vacunas' END tipo, m.existencia, a.nombre almacen FROM tmedicina m INNER JOIN talmacen a ON m.almacen = a.id_almacen WHERE m.nombre LIKE '%$valor%' ORDER BY m.nombre ASC LIMIT $inicio, $registros");
  57.     }  
  58.     $total_paginas = ceil($total_registros / $registros);                  
  59.  
  60.     if($total_registros) {
  61.         echo '<center id="resultados">';
  62.         echo '<table width="400" border="1" cellspacing="0" cellpadding="0">';
  63.         echo '<tr>';
  64.             echo '<td>Medicina</td>';
  65.             echo '<td>Tipo</td>';
  66.             echo '<td>Existencia</td>';
  67.             echo '<td>Almacen</td>';
  68.         echo '<td>Acciones</td>';
  69.         echo '</tr>';
  70.    
  71.         while($row=@mysql_fetch_array($resultados)) {
  72.            
  73.             echo '<tr>';
  74.             echo '<td>'.$row['medicina'].'</td>';
  75.             echo '<td>'.$row['tipo'].'</td>';
  76.             echo '<td>'.$row['existencia'].'</td>';
  77.             echo '<td>'.$row['almacen'].'</td>';
  78.             echo '<td><span style="cursor: pointer;" onclick="location.href = \'medicina_editar.php?ID='.$row['ID'].'\'">Editar</span><br><span style="cursor: pointer;" onclick="Confirmar('.$row['ID'].')">Eliminar</span></td>';
  79.             echo '</tr>';
  80.            
  81.         }
  82.             echo '</table>';
  83.        
  84.     } else {
  85.         echo "<script>alert('sin resultados');</script>";
  86.     }
  87.    
  88.     @mysql_free_result($resultados);               
  89.    
  90.     if($total_registros) {
  91.        
  92.         if(($pagina - 1) > 0) {
  93.             echo "<a href='medicina.php?pagina=".($pagina-1)."&valor=$valor'>< Anterior</a> ";
  94.         }
  95.        
  96.         for ($i=1; $i<=$total_paginas; $i++){
  97.             if ($pagina == $i) {
  98.                 echo "<b>".$pagina."</b> ";
  99.             } else {
  100.                 echo "<a href='medicina.php?pagina=$i&valor=$valor'>$i</a> ";
  101.             }  
  102.         }
  103.      
  104.         if(($pagina + 1)<=$total_paginas) {
  105.             echo " <a href='medicina.php?pagina=".($pagina+1)."&valor=$valor'>Siguiente ></a>";
  106.         }
  107.        
  108.         echo "</center>";
  109.        
  110.     }
  111.     ?>
  112.     </ol>
  113.     </fieldset>
  114.     </p></form><br /><br /></section>
  115.     </article>
  116.     <footer>
  117.         <p>&copy; 2012 Universidad Politécnica Territorial de Portuguesa. Todos los derechos reservados.</p>
  118.     </footer>
  119. </body>
  120. </html>
  121. <? @mysql_close($c);?>

medicina_ajax.js
Código Javascript:
Ver original
  1. &#65279;function Buscador(){
  2. var xmlhttp = false;
  3. try {
  4.     xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  5. } catch (e) {
  6.     try {
  7.         xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  8.     } catch (E) {
  9.         xmlhttp = false;
  10.     }
  11. }
  12. if (!xmlhttp && typeof XMLHttpRequest!='undefined')
  13. {
  14.     xmlhttp = new XMLHttpRequest();
  15. }
  16. return xmlhttp;
  17. }
  18.  
  19. function Buscar()
  20. {
  21.     var Texto = document.getElementById('texto').value;
  22.     var Resultado = document.getElementById('resultados');
  23.     ajax = Buscador();
  24.     ajax.open("GET","medicina_buscador.php?q="+Texto);
  25.     ajax.onreadystatechange = function() {
  26.         if (ajax.readyState == 4) {
  27.             Resultado.innerHTML = ajax.responseText;
  28.         }
  29.     }
  30.     ajax.send(null);
  31. }
  32.  
  33. function Eliminar(Texto)
  34. {
  35.     var Resultado = document.getElementById('resultados');
  36.     ajax = Buscador();
  37.     ajax.open("GET","medicina_eliminar.php?q="+Texto);
  38.     ajax.onreadystatechange = function() {
  39.         if (ajax.readyState == 4) {
  40.             Resultado.innerHTML = ajax.responseText;
  41.         }
  42.     }
  43.     ajax.send(null);
  44. }
  45.  
  46. function Confirmar(Texto)
  47. {
  48.     c = confirm("¿Desea eliminar el registro?");
  49.     if (c)
  50.     {
  51.         Eliminar(Texto);
  52.     }
  53.     else return false;
  54. }

medicina_buscador.php
Código PHP:
Ver original
  1. <?php
  2. include("../../modelos/config.php");
  3. $c = new Conexion;
  4. $c->Conectar();
  5. $valor = $_GET['q'];
  6. $registros = 10;
  7.  
  8. if (!$pagina) {
  9.     $inicio = 0;
  10.     $pagina = 1;
  11. }
  12. else {
  13.     $inicio = ($pagina - 1) * $registros;
  14. }
  15.     $query = mysql_query("SELECT id_medicina FROM tmedicina where nombre LIKE '%$valor%'");
  16.     $total_registros = mysql_num_rows($query);
  17.     $resultados = mysql_query("SELECT m.id_medicina ID, m.nombre medicina, CASE m.tipo WHEN  'G' THEN  'Medicina General' WHEN  'D' THEN  'Desparacitantes' ELSE  'Vacunas' END tipo, m.existencia, a.nombre almacen FROM tmedicina m INNER JOIN talmacen a ON m.almacen = a.id_almacen WHERE m.nombre LIKE '%$valor%' ORDER BY m.nombre ASC LIMIT $inicio, $registros");
  18.     $total_paginas = ceil($total_registros / $registros);                  
  19.  
  20.     if($total_registros) {
  21.         echo '<center id="resultados">';
  22.         echo '<table width="400" border="1" cellspacing="0" cellpadding="0">';
  23.         echo '<tr>';
  24.             echo '<td>Medicina</td>';
  25.             echo '<td>Tipo</td>';
  26.             echo '<td>Existencia</td>';
  27.             echo '<td>Almacen</td>';
  28.         echo '<td>Acciones</td>';
  29.         echo '</tr>';
  30.    
  31.         while($row= @mysql_fetch_array($resultados)) {
  32.            
  33.             echo '<tr>';
  34.             echo '<td>'.$row['medicina'].'</td>';
  35.             echo '<td>'.$row['tipo'].'</td>';
  36.             echo '<td>'.$row['existencia'].'</td>';
  37.             echo '<td>'.$row['almacen'].'</td>';
  38.             echo '<td><a href="pagina.php?id='.$row['ID'].'"><span style="cursor: pointer;">Editar</span></a><br><span style="cursor: pointer;" onclick="Confirmar('.$row['ID'].')">Eliminar</span></td>';
  39.             echo '</tr>';
  40.            
  41.         }
  42.             echo '</table>';
  43.        
  44.     } else {
  45.         echo "<script>alert('sin resultados');</script>";
  46.     }
  47.    
  48.     @mysql_free_result($resultados);               
  49.    
  50.     if($total_registros) {
  51.        
  52.         if(($pagina - 1) > 0) {
  53.             echo "<a href='medicina.php?pagina=".($pagina-1)."&valor=$valor'>< Anterior</a> ";
  54.         }
  55.        
  56.         for ($i=1; $i<=$total_paginas; $i++){
  57.             if ($pagina == $i) {
  58.                 echo "<b>".$pagina."</b> ";
  59.             } else {
  60.                 echo "<a href='medicina.php?pagina=$i&valor=$valor'>$i</a> ";
  61.             }  
  62.         }
  63.      
  64.         if(($pagina + 1)<=$total_paginas) {
  65.             echo " <a href='medicina.php?pagina=".($pagina+1)."&valor=$valor'>Siguiente ></a>";
  66.         }
  67.        
  68.         echo "</center>";
  69.        
  70.     }
  71. ?>

medicina_eliminar.php
Código PHP:
Ver original
  1. <?php
  2. include("../../modelos/config.php");
  3. $c = new Conexion;
  4. $c->Conectar();
  5. $q = $_GET['q'];
  6. $sql = "Delete from tmedicina where id_medicina=$q";
  7. $c = mysql_query($sql);
  8. if ($c)
  9. {
  10.     print "<font color='black'><b>Registro eliminado correctamente </b></font><br /><a href='medicina.php'>Atras</a></b>";
  11. }
  12. else {
  13.     print "<font color='black'><b>No se elimino el registro porque hay registros asociados a la medicina</b></font><br /><a href='medicina.php'>Atras</a>";
  14. }
  15. ?>
  #2 (permalink)  
Antiguo 06/10/2012, 11:12
Avatar de jlct  
Fecha de Ingreso: abril-2012
Ubicación: Venezuela
Mensajes: 148
Antigüedad: 12 años
Puntos: 19
Respuesta: Registro de transacciones

medicina_nuevo.php
Código PHP:
Ver original
  1. <?php
  2.     include("../../modelos/config.php");
  3.     $lcnombre=$_GET["lcnombre"];
  4.     $lnalmacen=$_GET["lnalmacen"]; 
  5.     $lctipo=$_GET["lctipo"];
  6.     $lcexistencia=$_GET["lcexistencia"];   
  7.     $lcindicaciones=$_GET["lcindicaciones"];
  8.     $lnhay=$_GET["lnhay"];
  9.     $lchacer=$_GET["lchacer"];
  10.     $lcoperacion=$_GET["lcoperacion"];
  11. ?>
  12.  
  13. <!doctype html>
  14. <html lang="es">
  15.     <head>
  16.         <meta charset="utf-8" />
  17.         <title>Unidad de Producción Mijagüito</title>
  18.         <link rel="shortcut icon" href="../imagenes/icono.png">
  19.         <link rel="stylesheet" href="../../css/estilo.css" />
  20.         <!--[if IE]>
  21.         <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  22.         <![endif]-->
  23.         <style type="text/css">
  24. <!--
  25. .Estilo1 {
  26.     color: #FF0000;
  27.     font-weight: bold;
  28. }
  29. .Estilo2 {color: #FF0000}
  30. .Estilo3 {font-size: 14px}
  31. -->
  32.         </style>
  33. <noscript>  
  34.         <!--[if IE]>  
  35.             <link rel="stylesheet" href="css/ie.css">  
  36.         <![endif]-->  
  37.         </noscript>
  38.     </head>
  39. <body class="no-js">
  40.  
  41.         <? include("../../nav/nav_menuprincipal.html"); ?>
  42.     <script src="../js/jquery.js"></script>  
  43.     <script src="../js/modernizr.js"></script>
  44.     <article>
  45.         <header><br />
  46.             <!-- <a href="javascript:history.go(-1)" class="Estilo3">Atrás </a><br /> -->
  47.             <br />
  48.             <h1 align="center">Registro de las medicinas o Líneas</h1>
  49.         </header><br />
  50.         <section>
  51.             <p><form name="form1" id="form1" method="post" action="../../controladores/cormedicina.php">
  52.             <input name="txthacer" type="hidden" id="txthacer" value="<? print($lchacer);?>" />
  53.             <input name="txtoperacion" type="hidden" id="txtoperacion" value="<? print($lcoperacion);?>" />
  54.             <input name="txthay" type="hidden" id="txthay" value="<? print($lnhay);?>"/>
  55.             <input name="txtubicacion" type="hidden" id="txtubicacion" value="general"/>
  56.                         <fieldset>
  57.                         <ol>
  58.                             <li>
  59.                               <table width="380" height="46" border="0">
  60.                                 <tr>
  61.                                 <td width="50"><span class="Estilo2">
  62.                                 <label for="nombre">*</label></span>
  63.                                 <label for="nombre">Almacen: </label>
  64.                                 </td>
  65.                                 <td width="125">
  66.                                 <select name="cmbalmacen" id="cmbalmacen">
  67.                                 <option value="-">Seleccione</option>
  68.                                 <?
  69.                                 $c = new Conexion;
  70.                                 $c->Conectar();
  71.                                 $c = mysql_query("Select * from talmacen");
  72.                                 while($row=mysql_fetch_array($c))
  73.                                 {
  74.                                 ?> <option value="<?=$row['id_almacen']?>" <? if($row['id_almacen']==$lnalmacen){print "selected";}?>><? print $row['nombre'];?></option>
  75.                                
  76.                                 <? } @mysql_close($c) ?>
  77.                                 </select>
  78.                                 </td>
  79.                                 </tr>
  80.                                 <tr>
  81.                                 <td width="50"><span class="Estilo2">
  82.                                 <label for="nombre">*</label></span>
  83.                                 <label for="nombre">Nombre: </label>
  84.                                 </td>
  85.                                 <td width="125"><input title="Nombre de la medicina. Ejemplo: Brahman" size="20" id="txtnombre" name="txtnombre" onBlur="focusmedicina()" placeholder="Ingrese el nombre de la medicina" value="<? print($lcnombre);?>">
  86.                                 </td>
  87.                                 </tr>
  88.                                 <tr>
  89.                                 <td><span class="Estilo2">
  90.                                 <label for="nombre">*</label></span>
  91.                                 <label for="nombre">Tipo de Medicina: </label>
  92.                                 </td>
  93.                                 <td width="125">
  94.                                 <select id="cmbtipo" name="cmbtipo" >
  95.                                 <option value="-" >Seleccione</option>
  96.                                 <option value="D" <? if($lctipo=="D"){print "selected";}?>>Desparasitantes</option>
  97.                                 <option value="G" <? if($lctipo=="G"){print "selected";}?>>Medicina General</option>
  98.                                 <option value="V" <? if($lctipo=="V"){print "selected";}?>>Vacunas</option>
  99.                                 </select>
  100.                                 </td>
  101.                                 </tr>
  102.                                 <tr>
  103.                                 <td width="50"><span class="Estilo2">
  104.                                 <label for="nombre">*</label></span>
  105.                                 <label for="nombre">Indicaciones: </label>
  106.                                 </td>
  107.                                 <td width="125">
  108.                                 <textarea name="txtindicaciones" id="txtindicaciones" cols="25" rows="2"><? print $lcindicaciones;?></textarea>
  109.                                 </td>
  110.                                 </tr>
  111.                                 <tr>
  112.                                 <td width="50"><span class="Estilo2">
  113.                                 <label for="nombre">*</label></span>
  114.                                 <label for="nombre">Existencia: </label>
  115.                                 </td>
  116.                                 <td width="125"><input title="Cantidad en existencia de la medicina" size="20" id="txtexistencia" name="txtexistencia" placeholder="Ingrese la cantidad del medicamento" value="<? print $lcexistencia;?>">
  117.                                 </td>
  118.                                 </tr>
  119.                               </table>
  120.                             </li>
  121.                         </ol>
  122.                         </fieldset>
  123.                     <fieldset>
  124.                         <p>
  125.                         <table align="center" width="200" border="0">
  126.                           <tr>
  127.                             <td><div align="center">
  128.                               <input name="btnguardar" type="button" id="button" value="Guardar" onClick="guardar()"/>
  129.                             </div></td>
  130.                             <td><div align="center">
  131.                               <input name="btncancelar" type="button" id="btncancelar" value="Limpiar" onClick="cancelar()"/>
  132.                             </div></td>
  133.                             <td><div align="center">
  134.                               <input name="btnsalir" type="button" id="btnsalir" value="Salir" onClick="location.href = 'medicina.php' "/>
  135.                             </div></td>
  136.                           </tr>
  137.                         </table>
  138.                           <br />
  139.                           <br />
  140.                         </p>
  141.                         <div align="center" class="Estilo1">"Los campos marcados con <span class="Estilo2">(*)</span> son campos obligatorios"</div>
  142.                     </fieldset>
  143.                     </form></p>
  144.         </section><br />
  145.     </article>
  146.     <footer>
  147.         <p>&copy; 2012 Universidad Politécnica Territorial de Portuguesa. Todos los derechos reservados.</p>
  148.     </footer>
  149. </body>
  150.  
  151. <script>
  152.     function validarletras(e)
  153.     { // 1
  154.        
  155.         tecla = (document.all) ? e.keyCode : e.which; // 2
  156.         if (tecla==8) return true; // 3
  157.         patron =/\D/;   // 4
  158.         te = String.fromCharCode(tecla); // 5
  159.         return patron.test(te); // 6
  160.     }
  161. </script>
  162. <script language="javascript">
  163.    inicio();
  164.    function inicio()
  165.    {
  166.       f=document.form1;
  167.       if(f.txtoperacion.value!="buscar")
  168.       {
  169.          if(f.txthacer.value=="listo")
  170.          {
  171.             if(f.txtoperacion.value=="incluir")
  172.             {
  173.                alert("Registro Almacenado");
  174.             }
  175.           }
  176.          cancelar();
  177.       }
  178.       else if(f.txtoperacion.value=="buscar")
  179.       {
  180.          if(f.txthay.value==1)
  181.          {
  182.             alert("Registro ya existe");
  183.                 existe();
  184.          }
  185.        }   
  186.  }//fin inicio             
  187.    
  188.    function existe()
  189.    {
  190.       f=document.form1;
  191.       f.txtnombre.disabled=true;
  192.       f.cmbalmacen.disabled=true;
  193.       f.txtexistencia.disabled=true;
  194.       f.cmbtipo.disabled=true;
  195.       f.txtindicaciones.disabled=true;
  196.            
  197.       f.btnguardar.disabled=true;
  198.       f.btncancelar.disabled=false;
  199.    }
  200.    function cancelar()
  201.    {
  202.       f=document.form1;
  203.       f.txthacer.value="";
  204.       f.txtnombre.value="";
  205.       f.cmbalmacen.value="-";
  206.       f.txtexistencia.value="";
  207.       f.cmbtipo.value="-";
  208.       f.txtindicaciones.value="";
  209.       f.txtnombre.disabled=false;
  210.       f.cmbalmacen.disabled=false;
  211.       f.txtexistencia.disabled=false;
  212.       f.cmbtipo.disabled=false;
  213.       f.txtindicaciones.disabled=false;
  214.    
  215.       f.btnguardar.disabled=false;
  216.       f.btncancelar.disabled=false;
  217.      
  218.       f.txtnombre.focus();//envia el curso a la caja de texto
  219.    }
  220.    
  221.    function focusmedicina()
  222.    {
  223.       f=document.form1;
  224.       if (f.txtnombre.value!="")
  225.       {
  226.          f.txtoperacion.value="buscar";
  227.          f.cmbalmacen.disabled=false;
  228.          f.submit();
  229.       }
  230.       else
  231.       {
  232.          f.txtnombre.focus();
  233.       }
  234.    }
  235.    function guardar()
  236.     {
  237.         f=document.form1;
  238.         f.txtoperacion.value="incluir";
  239.         f.txtnombre.disabled=false;
  240.         if (validar())
  241.         {
  242.             f.submit();
  243.         }
  244.     }
  245.    function validar()
  246.     {
  247.         f=document.form1;
  248.         bueno=false;
  249.         if(f.txtnombre.value=="")
  250.         {
  251.             alert("Debe ingresar el nombre de la medicina");
  252.             f.txtnombre.focus();
  253.         }
  254.         else if(f.cmbalmacen.value=="-")
  255.         {
  256.             alert("Debe seleccionar un almacen");
  257.             f.cmbalmacen.focus();
  258.         }
  259.         else if(f.txtindicaciones.value=="")
  260.         {
  261.             alert("Debe ingresar las indicaciones de la medicina");
  262.             f.txtindicaciones.focus();
  263.         }
  264.         else if(f.cmbtipo.value=="-")
  265.         {
  266.             alert("Debe seleccionar el tipo de medicamento");
  267.             f.cmbtipo.focus();
  268.         }
  269.         else if(f.txtexistencia.value=="")
  270.         {
  271.             alert("Debe ingresar una cantidad");
  272.             f.txtexistencia.focus();
  273.         }
  274.         else
  275.         {
  276.             bueno=true;
  277.         }
  278.         return bueno;
  279.     }//fin valida
  280. </script>
  281. </html>
  #3 (permalink)  
Antiguo 06/10/2012, 11:13
Avatar de jlct  
Fecha de Ingreso: abril-2012
Ubicación: Venezuela
Mensajes: 148
Antigüedad: 12 años
Puntos: 19
Respuesta: Registro de transacciones

medicina_editar.php
Código PHP:
Ver original
  1. <?php
  2.     include("../../modelos/config.php");
  3.     $C = new Conexion;
  4.     $C->Conectar();
  5.     $ID = $_REQUEST['ID'];
  6.     $C = mysql_query("Select * from tmedicina where id_medicina=$ID");
  7.     if ($sql = @mysql_fetch_array($C))
  8.     {
  9.         $lnID = $sql['id_medicina'];
  10.         $lcnombre = $sql['nombre'];
  11.         $lnalmacen = $sql['almacen'];
  12.         $lctipo = $sql['tipo'];
  13.         $lcindicaciones = $sql['indicaciones'];
  14.         $lcexistencia = $sql['existencia'];
  15.     }
  16. ?>
  17.  
  18. <!doctype html>
  19. <html lang="es">
  20.     <head>
  21.         <meta charset="utf-8" />
  22.         <title>Unidad de Producción Mijagüito</title>
  23.         <link rel="shortcut icon" href="../imagenes/icono.png">
  24.         <link rel="stylesheet" href="../../css/estilo.css" />
  25.         <!--[if IE]>
  26.         <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  27.         <![endif]-->
  28.         <style type="text/css">
  29. <!--
  30. .Estilo1 {
  31.     color: #FF0000;
  32.     font-weight: bold;
  33. }
  34. .Estilo2 {color: #FF0000}
  35. .Estilo3 {font-size: 14px}
  36. -->
  37.         </style>
  38. <noscript>  
  39.         <!--[if IE]>  
  40.             <link rel="stylesheet" href="css/ie.css">  
  41.         <![endif]-->  
  42.         </noscript>
  43.     </head>
  44. <body class="no-js">
  45.  
  46.         <? include("../../nav/nav_menuprincipal.html"); ?>
  47.     <script src="../js/jquery.js"></script>  
  48.     <script src="../js/modernizr.js"></script>
  49.     <article>
  50.         <header><br />
  51.             <!-- <a href="javascript:history.go(-1)" class="Estilo3">Atrás </a><br /> -->
  52.             <br />
  53.             <h1 align="center">Registro de las medicinas o Líneas</h1>
  54.         </header><br />
  55.         <section>
  56.             <p><form name="form1" id="form1" method="post" action="../../controladores/cormedicina.php">
  57.                 <input name="txthacer" type="hidden" id="txthacer" value="<? print($lchacer);?>" />
  58.             <input name="txtoperacion" type="hidden" id="txtoperacion" value="<? print($lcoperacion);?>" />
  59.             <input name="txthay" type="hidden" id="txthay" value="<? print($lnhay);?>"/>
  60.             <input name="txtcodigo" type="hidden" id="txtcodigo" value="<? print($lnID);?>"/>
  61.             <input name="txtubicacion" type="hidden" id="txtubicacion" value="general"/>
  62.                         <fieldset>
  63.                         <ol>
  64.                             <li>
  65.                               <table width="380" height="46" border="0">
  66.                                 <tr>
  67.                                 <td width="50"><span class="Estilo2">
  68.                                 <label for="nombre">*</label></span>
  69.                                 <label for="nombre">Almacen: </label>
  70.                                 </td>
  71.                                 <td width="125">
  72.                                 <select name="cmbalmacen" id="cmbalmacen">
  73.                                 <option value="-">Seleccione</option>
  74.                                 <?
  75.                                 $c = new Conexion;
  76.                                 $c->Conectar();
  77.                                 $c = mysql_query("Select * from talmacen");
  78.                                 while($row=mysql_fetch_array($c))
  79.                                 {
  80.                                 ?> <option value="<?=$row['id_almacen']?>" <? if($row['id_almacen']==$lnalmacen){print "selected";}?>><? print $row['nombre'];?></option>
  81.                                
  82.                                 <? } @mysql_close($c) ?>
  83.                                 </select>
  84.                                 </td>
  85.                                 </tr>
  86.                                 <tr>
  87.                                 <td width="50"><span class="Estilo2">
  88.                                 <label for="nombre">*</label></span>
  89.                                 <label for="nombre">Nombre: </label>
  90.                                 </td>
  91.                                 <td width="125"><input title="Nombre de la medicina. Ejemplo: Brahman" size="20" id="txtnombre" name="txtnombre" onBlur="focusmedicina()" placeholder="Ingrese el nombre de la medicina" value="<? print($lcnombre);?>">
  92.                                 </td>
  93.                                 </tr>
  94.                                 <tr>
  95.                                 <td><span class="Estilo2">
  96.                                 <label for="nombre">*</label></span>
  97.                                 <label for="nombre">Tipo de Medicina: </label>
  98.                                 </td>
  99.                                 <td width="125">
  100.                                 <select id="cmbtipo" name="cmbtipo" >
  101.                                 <option value="-" >Seleccione</option>
  102.                                 <option value="D" <? if($lctipo=="D"){print "selected";}?>>Desparasitantes</option>
  103.                                 <option value="G" <? if($lctipo=="G"){print "selected";}?>>Medicina General</option>
  104.                                 <option value="V" <? if($lctipo=="V"){print "selected";}?>>Vacunas</option>
  105.                                 </select>
  106.                                 </td>
  107.                                 </tr>
  108.                                 <tr>
  109.                                 <td width="50"><span class="Estilo2">
  110.                                 <label for="nombre">*</label></span>
  111.                                 <label for="nombre">Indicaciones: </label>
  112.                                 </td>
  113.                                 <td width="125">
  114.                                 <textarea name="txtindicaciones" id="txtindicaciones" cols="25" rows="2"><? print $lcindicaciones;?></textarea>
  115.                                 </td>
  116.                                 </tr>
  117.                                 <tr>
  118.                                 <td width="50"><span class="Estilo2">
  119.                                 <label for="nombre">*</label></span>
  120.                                 <label for="nombre">Existencia: </label>
  121.                                 </td>
  122.                                 <td width="125"><input title="Cantidad en existencia de la medicina" size="20" id="txtexistencia" name="txtexistencia" placeholder="Ingrese la cantidad del medicamento" value="<? print $lcexistencia;?>">
  123.                                 </td>
  124.                                 </tr>
  125.                               </table>
  126.                             </li>
  127.                         </ol>
  128.                         </fieldset>
  129.                     <fieldset>
  130.                         <p>
  131.                         <table align="center" width="200" border="0">
  132.                           <tr>
  133.                             <td><div align="center">
  134.                               <input name="btnguardar" type="button" id="button" value="Guardar" onClick="guardar()"/>
  135.                             </div></td>
  136.                 <td><div align="center">
  137.                               <input name="btnsalir" type="button" id="btnsalir" value="Salir" onClick="location.href = 'medicina.php' "/>
  138.                             </div></td>
  139.                           </tr>
  140.                         </table>
  141.                           <br />
  142.                           <br />
  143.                         </p>
  144.                         <div align="center" class="Estilo1">"Los campos marcados con <span class="Estilo2">(*)</span> son campos obligatorios"</div>
  145.                     </fieldset>
  146.                     </form></p>
  147.         </section><br />
  148.     </article>
  149.     <footer>
  150.         <p>&copy; 2012 Universidad Politécnica Territorial de Portuguesa. Todos los derechos reservados.</p>
  151.     </footer>
  152. </body>
  153. <script language="javascript">
  154.  
  155.    function guardar()
  156.     {
  157.         f=document.form1;
  158.         f.txtoperacion.value="modificar";
  159.         f.txtnombre.disabled=false;
  160.         if (validar())
  161.         {
  162.             f.submit();
  163.         }
  164.     }
  165.    function validar()
  166.     {
  167.         f=document.form1;
  168.         bueno=false;
  169.         if(f.txtnombre.value=="")
  170.         {
  171.             alert("Debe ingresar el nombre de la medicina");
  172.             f.txtnombre.focus();
  173.         }
  174.         else if(f.cmbalmacen.value=="-")
  175.         {
  176.             alert("Debe seleccionar un almacen");
  177.             f.cmbalmacen.focus();
  178.         }
  179.         else if(f.txtindicaciones.value=="")
  180.         {
  181.             alert("Debe ingresar las indicaciones de la medicina");
  182.             f.txtindicaciones.focus();
  183.         }
  184.         else if(f.cmbtipo.value=="-")
  185.         {
  186.             alert("Debe seleccionar el tipo de medicamento");
  187.             f.cmbtipo.focus();
  188.         }
  189.         else if(f.txtexistencia.value=="")
  190.         {
  191.             alert("Debe ingresar una cantidad");
  192.             f.txtexistencia.focus();
  193.         }
  194.         else
  195.         {
  196.             bueno=true;
  197.         }
  198.         return bueno;
  199.     }//fin valida
  200. </script>
  201. </html>
  202. <? @mysql_close($C);?>
  #4 (permalink)  
Antiguo 06/10/2012, 11:14
Avatar de jlct  
Fecha de Ingreso: abril-2012
Ubicación: Venezuela
Mensajes: 148
Antigüedad: 12 años
Puntos: 19
Respuesta: Registro de transacciones

cormedicina.php
Código PHP:
Ver original
  1. <?php
  2.     require_once("../clases/clsmedicina.php");
  3.     if(array_key_exists(txtoperacion,$_POST))
  4.     {
  5.         $lnID=$_POST["txtcodigo"];
  6.         $lcnombre=$_POST["txtnombre"];
  7.         $lnalmacen=$_POST["cmbalmacen"];       
  8.         $lctipo=$_POST["cmbtipo"];
  9.         $lcindicaciones=$_POST["txtindicaciones"]; 
  10.         $lcexistencia=$_POST["txtexistencia"]; 
  11.         $lcoperacion=$_POST["txtoperacion"];
  12.         $lchacer=$_POST["txthacer"];
  13.         $lcubicacion=$_POST["txtubicacion"];
  14.         $lobjmedicina=new clsmedicina($lcnombre, $lnalmacen, $lctipo, $lcindicaciones, $lcexistencia);
  15.     }
  16.     if($lcubicacion=="general")
  17.     {
  18.         if ($lcoperacion=="buscar")
  19.         {
  20.             $lnhay=0;
  21.             $llEnc=$lobjmedicina->buscar();
  22.             if ($llEnc)
  23.             {
  24.                 $lcnombre=$lobjmedicina->getnombre();
  25.                 $lnalmacen=$lobjmedicina->getalmacen();
  26.                 $lctipo=$lobjmedicina->gettipo();
  27.                 $lcindicaciones=$lobjmedicina->getindicaciones();
  28.                 $lcexistencia=$lobjmedicina->getexistencia();
  29.                 $lnhay=1;
  30.             }
  31.             header("location: ../vistasgeneral/medicina/medicina_nuevo.php?lcnombre=$lcnombre&lnalmacen=$lnalmacen&lctipo=$lctipo&lcindicaciones=$lcindicaciones&lcexistencia=$lcexistencia&lnhay=$lnhay&lchacer=$lchacer&lcoperacion=$lcoperacion");
  32.         }
  33.     }
  34.     if($lcubicacion=="especifica")
  35.     {
  36.         if ($lcoperacion=="buscar")
  37.         {
  38.             $lnhay=0;
  39.             $llEnc=$lobjmedicina->buscar();
  40.             if ($llEnc)
  41.             {
  42.                 $lcnombre=$lobjmedicina->getnombre();
  43.                 $lnalmacen=$lobjmedicina->getalmacen();
  44.                 $lctipo=$lobjmedicina->gettipo();
  45.                 $lcindicaciones=$lobjmedicina->getindicaciones();
  46.                 $lcexistencia=$lobjmedicina->getexistencia();
  47.                 $lnhay=1;
  48.             }
  49.             header("location: ../vistasgeneral/medicina/medicina_nuevo.php?lcnombre=$lcnombre&lnalmacen=$lnalmacen&lctipo=$lctipo&lcindicaciones=$lcindicaciones&lcexistencia=$lcexistencia&lnhay=$lnhay&lchacer=$lchacer&lcoperacion=$lcoperacion");
  50.         }
  51.     }
  52.     if ($lcoperacion=="incluir")
  53.     {
  54.         $llhecho=$lobjmedicina->incluir();
  55.         if ($llhecho)
  56.         {
  57.             $lchacer="listo";
  58.         }
  59.     }
  60.     if ($lcoperacion=="modificar")
  61.     {
  62.         $llhecho=$lobjmedicina->modificar($lnID);
  63.         if ($llhecho)
  64.         {
  65.             $lchacer="listo";
  66.         }
  67.     }
  68.     if($lcubicacion=="general")
  69.     {
  70.         if (($lcoperacion!="buscar")&&($lcoperacion=="incluir"))
  71.         {
  72.             header("location: ../vistasgeneral/medicina/medicina_nuevo.php?lchacer=$lchacer&lcoperacion=$lcoperacion");
  73.         }
  74.         else if (($lcoperacion!="buscar")&&($lcoperacion=="modificar"))
  75.         {
  76.             $msg="Registro Modificado";
  77.             header("location: ../vistasgeneral/medicina/medicina.php?alerta=$msg");
  78.         }
  79.     }
  80.     if($lcubicacion=="especifica")
  81.     {
  82.         if (($lcoperacion!="buscar")&&($lcoperacion=="incluir"))
  83.         {
  84.             header("location: ../vistas/medicina/medicina_nuevo.php?lchacer=$lchacer&lcoperacion=$lcoperacion");
  85.         }
  86.         else if (($lcoperacion!="buscar")&&($lcoperacion=="modificar"))
  87.         {
  88.             $msg="Registro Modificado";
  89.             header("location: ../vistas/medicina/medicina.php?alerta=$msg");
  90.         }
  91.     }
  92. ?>

clsmedicina.php
Código PHP:
Ver original
  1. <?php
  2. require_once("clsdatos.php");
  3. class clsmedicina
  4. {
  5.     private $acnombre;
  6.     private $analmacen;
  7.     private $actipo;
  8.     private $acindicaciones;
  9.     private $acexistencia;
  10.  
  11.     public function __construct($pcnombre, $pnalmacen,$pctipo, $pcindicaciones, $pcexistencia)
  12.     {
  13.         $this->acnombre=$pcnombre;     
  14.         $this->analmacen=$pnalmacen;
  15.         $this->actipo=$pctipo;     
  16.         $this->acindicaciones=$pcindicaciones;
  17.         $this->acexistencia=$pcexistencia;     
  18.     }
  19.     public function __destruct()
  20.     {
  21.     }
  22.     public function getnombre()
  23.     {
  24.         return $this->acnombre;
  25.     }
  26.     public function getalmacen()
  27.     {
  28.         return $this->analmacen;
  29.     }
  30.     public function gettipo()
  31.     {
  32.         return $this->actipo;  
  33.     }
  34.     public function getindicaciones()
  35.     {
  36.         return $this->acindicaciones;
  37.     }
  38.     public function getexistencia()
  39.     {
  40.         return $this->acexistencia;
  41.     }
  42.    
  43.     public function buscarespecie($pnmedicina)
  44.     {
  45.         $llEnc=false;//local logico encontrado
  46.         $lcSql="select * from tmedicina where (id_medicina='$pnmedicina')";
  47.         $lobjdatos=new clsdatos();
  48.         $lrTb=$lobjdatos->filtro($lcSql);
  49.         if ($laRow=$lobjdatos->proximo($lrTb))
  50.         {
  51.             $llEnc=true;
  52.             $this->anespecie=$laRow["especie"];
  53.         }
  54.         $lobjdatos->cierrafiltro($lrTb);
  55.         $lobjdatos->desconectar();
  56.         return $llEnc;
  57.     }
  58.     public function buscar()
  59.     {
  60.         $llEnc=false;//local logico encontrado
  61.         $lcSql="select * from tmedicina where nombre='$this->acnombre'";
  62.         $lobjdatos=new clsdatos();
  63.         $lrTb=$lobjdatos->filtro($lcSql);
  64.         if ($laRow=$lobjdatos->proximo($lrTb))
  65.         {
  66.             $llEnc=true;
  67.             $this->acnombre=$laRow["nombre"];
  68.             $this->analmacen=$laRow["almacen"];
  69.             $this->actipo=$laRow["tipo"];
  70.             $this->acindicaciones=$laRow["indicaciones"];
  71.             $this->acexistencia=$laRow["existencia"];
  72.         }
  73.         $lobjdatos->cierrafiltro($lrTb);
  74.         $lobjdatos->desconectar();
  75.         return $llEnc;
  76.     }
  77.     public function incluir()
  78.     {
  79.         $llhecho=false;
  80.         $lobjdatos=new clsdatos();
  81.         $lcSql="insert into tmedicina (nombre, almacen, tipo, indicaciones, existencia) values (ucase('$this->acnombre'),'$this->analmacen','$this->actipo',ucase('$this->acindicaciones'),'$this->acexistencia')";
  82.         $llhecho=$lobjdatos->ejecutar($lcSql);
  83.         $lobjdatos->desconectar();
  84.         return $llhecho;
  85.     }
  86.     public function modificar($id_medicina)
  87.     {
  88.         $llhecho=false;
  89.         $lobjdatos=new clsdatos();
  90.         $lcSql="update tmedicina set nombre=ucase('$this->acnombre'), almacen='$this->analmacen', tipo='$this->actipo', indicaciones=ucase('$this->acindicaciones'), existencia='$this->acexistencia' where id_medicina='$id_medicina'";
  91.         $llhecho=$lobjdatos->ejecutar($lcSql);
  92.         $lobjdatos->desconectar();
  93.         return $llhecho;
  94.     }
  95. }
  96. ?>
  #5 (permalink)  
Antiguo 06/10/2012, 11:16
Avatar de jlct  
Fecha de Ingreso: abril-2012
Ubicación: Venezuela
Mensajes: 148
Antigüedad: 12 años
Puntos: 19
Respuesta: Registro de transacciones

Bueno esa es toda la informacion que les puedo ofrecer... esperando que asi me puedan ayudar.!! de verdad necesito ayudaa.!! la idea es que pueda agregar un detalle a los formularios..! para agregar tantos registros como pueda!

Etiquetas: ajax, detalle, transacciones
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:10.