<?php
if (isset($_SESSION['usuario'])){
  $user=$_SESSION['usuario'];
}
else{
  ?>
  <script>
  location.href="index.php?errorusuario=3";
</script>
<?php }
?>
<link rel="stylesheet" type="text/css" href="ucaestilos.css"/>
<table width="1200" border="0" align="center" bgcolor="#FFFFFF">
  <tr>
    <td>

      <table border="0" cellpadding="0" cellspacing="5">
        <tr>
          <td style="padding-right:20px;">
            <form action="consulpaquete.php" method="get">
              <span class="style5">Consultar paquete:</span>
              <?php

              include ("conexion.php");
              $cons="SELECT * FROM paquetes ORDER BY nompaquete";
              $res=mysql_query($cons,$conex) or die ("No se pudo consultar las clinicas");
              echo "<select name='paquete' class='cuadrotexto' style='width:200px;'>";
              while ($campo=mysql_fetch_assoc($res))
              {
                echo "<option value=".$campo['idPaquete']." >".$campo['nompaquete']."</option>";
              }
              echo "</select>";
              ?>
              <input name="Submit2" type="submit" class="botonDefault" value="Consultar" />
            </form>
          </td>

          <td width="100"><form id="form6" name="form6" method="post" action="main.php?a=329">
            <input name="button" type="submit" class="botonDefault" id="button" value="Paquetes y productos" />
          </form>            </td>
          <td width="100"><form id="form" name="form6" method="post" action="main.php?a=328">
            <input name="button2" type="submit" class="botonDefault" id="button2" value="Tratamientos y Citas" />
          </form></td>
          <td width="100"><form id="form6" name="form6" method="post" action="main.php?a=3281">
            <input name="button" type="submit" class="botonDefault" id="button" value="Tratamiento por citas y costos" />
          </form>            </td>
        </tr>
      </table>

      <table width="100%" border="0" cellspacing="10" cellpadding="0">
        <tr>
          <td width="46%" valign="top"><p class="style7">Listado de Paquetes</p>
            <table border="0">
              <tr>
                <td style="padding-right:20px;"><form id="form4" name="form1" method="post" action="main.php?a=321">
                  <input name="button4" type="submit" class="botonDefault" id="button4" value="Nuevo paquete" />
                </form></td>

                <td><form id="form5" name="form2" method="post" action="main.php?a=324">
                  <input name="button4" type="submit" class="botonDefault" id="button5" value="Duplicar paquete" />
                </form></td>
              </tr>
            </table>
            <?php
            echo "<table cellpadding='2' class='tablaBordes'>";
            echo "<tr class='tablaCabecera' align='center'>";

            echo "<td> ID </td>";
            echo "<td> Nombre del Paquete o Cita </td>";
            echo "<td> Editar </td>";
            echo "<td> Eliminar </td>";
        

            echo "</tr>";
            include ("conexion.php");
            $cons="SELECT idPaquete,nompaquete FROM paquetes ORDER BY idPaquete ASC" ;
            $res=mysql_query($cons,$conex) or die ("No se realizo con exito la consulta de paquetes");
            $numero_filas=mysql_num_rows($res);
            $numero_campos= mysql_num_fields($res);
            while ($fila=mysql_fetch_row($res)){

              echo "<tr class='tablaBordes'>";
              //id
              echo "<td class='style1' align='center'>$fila[0]</td>";
              //nombre
              echo "<td class='style1'>".utf8_encode($fila[1])."</td>";

              //Editar
              echo "<td align='center'>";
              echo "<a href='main.php?a=323&idpaquete=$fila[0]'> <img src='img/icon_edit.jpg' border='0' alt='Editar paquete'> </a>";
              echo "</td>";

              //Eliminar
              echo "<td align='center'>";
              echo "<a href='javascript:eliminar($fila[0])'> <img src='img/icon_delete.jpg' border='0' alt='Eliminar paquete'> </a>";
              echo "</td>";

              echo "</tr>";
            }
            echo "</table>";
            mysql_free_result($res);

            ?></td>
            <td width="54%" valign="top"><p class="style7">Listado de Tratamientos Completos</p>
              <table border="0">
                <tr>
                  <td width="16%" height="21"><form id="form9" name="form3" method="post" action="main.php?a=325">
                    <input name="button5" type="submit" class="botonDefault" id="button9" value="Nuevo Tratamiento Completo" />
                  </form></td>
                </tr>
              </table>
              <?php
              echo "<table cellpadding='2' class='tablaBordes'>";
              echo "<tr class='tablaCabecera' align='center'>";

              echo "<td>";
              echo "ID";
              echo "</td>";

              echo "<td>";
              echo "Tratamiento completo";
              echo "</td>";

              echo "<td>";
              echo "Precio";
              echo "</td>";

              echo "<td>";
              echo "Editar";
              echo "</td>";

              echo "<td>";
              echo "Contenido";
              echo "</td>";

              /*
              echo "<td>";
              echo "Eliminar";
              echo "</td>";
              */

              echo "</tr>";
              include ("conexion.php");
              $cons="SELECT idTratamiento,tratamientoCompleto,precio FROM tratamientocompleto ORDER BY tratamientoCompleto ASC" ;
              $res=mysql_query($cons,$conex) or die ("No se realizo con exito la consulta de paquetes");
              $numero_filas=mysql_num_rows($res);
              $numero_campos= mysql_num_fields($res);
              while ($fila=mysql_fetch_row($res)){

                echo "<tr class='tablaBordes'>";
                //id
                echo "<td class='style1' align='center'>";
                echo $fila[0];
                echo "</td>";
                //nombre
                echo "<td class='style1'>";
                echo utf8_encode($fila[1]);
                echo "</td>";
                //costo
                echo"<td class='style1' align='center'>";
                printf ("$ %.2f", $fila[2]);
                echo "</td>";

                //Editar
                echo "<td align='center'>";
                echo "<a href='main.php?a=327&tratamiento="; echo $fila[0]; echo "'> <img src='img/icon_edit.jpg' border='0' ALT='Editar tratamiento'> </a>";
                echo "</td>";

                //Contenido
                echo "<td align='center'>";
                echo "<a href='main.php?a=326&tratamiento="; echo $fila[0]; echo "'> <img src='img/icon_new.jpg' border='0' ALT='Contenido del tratamiento'> </a>";
                echo "</td>";

                //Eliminar
                /*
                echo "<td align='center'>";
                echo "<a href='deletetratamientocompleto.php?idtratamiento="; echo $fila[0]; echo "'> <img src='img/icon_delete.jpg' border='0' ALT='Eliminar tratamiento'> </a>";
                echo "</td>";
                */

                echo "</tr>";
              }
              echo "</table>";
              mysql_free_result($res);

              ?></td>
            </tr>
          </table>
        </td>
      </tr>
    </table>

    <script>
      function eliminar(id)
      {
        if(confirm("Desea eliminar el paquete, esto lo eliminará de los tratamientos que lo contiene."))
        {
          location.href="deletepaquete.php?idpaquete="+id;
        }
      }
    </script>