Ver Mensaje Individual
  #5 (permalink)  
Antiguo 06/02/2012, 05:05
Avatar de cpujades
cpujades
 
Fecha de Ingreso: agosto-2011
Mensajes: 40
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: problemas con fechas al quitar calendario

No se si te entiendo, yo lo que pretendo es que se puedan modificar ambas fechas por el usuario... igual si pego todo el código se entienda mejor...

Cita:
<?php


function nuevoPedido()
{

$serie = "";

if(isset($_POST["serie"]))
{
$serie = $_POST["serie"];
$sql2 = "SELECT max(cast(codigo as signed)) as CODIGO FROM pediweb_cab WHERE serie='$serie'";
$registros2=conexion($sql2);
$campo2=mysql_fetch_array($registros2);
$numero = $campo2["CODIGO"]+1;
}
else
{
$sql2 = "SELECT serie,max(cast(codigo as signed)) as CODIGO FROM pediweb_cab GROUP BY serie";
$registros2=conexion($sql2);
$campo2=mysql_fetch_array($registros2);
$numero = $campo2["CODIGO"]+1;
$serie = $campo2["serie"];
}

if($serie=="")
{
$sql = "SELECT cod_serie FROM vista_series";
$registro = conexion($sql);
$campo = mysql_fetch_array($registro);
$serie = $campo["cod_serie"];
}


$sql = "SELECT distinct(cod_serie) as serie FROM vista_series";
$registros=conexion($sql);




echo "<table cellspacing= 5;>";
echo "<tr>";
echo "<td>Serie</td>";
echo "<form action='nuevo_pedido.php' method='post' enctype='multipart/form-data'>";

echo "<td><select class='series' name='serie' onchange='submit();'>";

while ($campo=mysql_fetch_array($registros))
{
echo "<option value=$campo[serie]";

if ($campo['serie'] == $serie)
{
echo (" selected");
}
echo(">$campo[serie]</option>");
}


echo("</select></td></form>");



echo ("<td>Número</td>");
echo "<td><input style='text-align:right' type='text' class ='numero' name='numero' readonly='readonly' value='$numero' class='numero'>";
echo "</td></script>";


echo "<td>";
echo "<form action='comprobar_pedido.php' method='post' enctype='multipart/form-data'>";
echo "<input type='hidden' name='serie' value ='$serie'>";
echo "<input type='hidden' name='numero' value ='$numero'>";
echo "<a href='#' onclick = 'document.forms[1].submit()' class='comprobar' name='comprobar' title='Comprobar Registro'>Comprobar Registro</a>";
echo "</form></td>";


echo "</tr>";


echo "</table>";

}

function nuevoPedido2()
{
$ipw=$_SESSION["ipw"];

$sql="SELECT serie,codigo,fecha,fecentrega,id_clientes,comentar ios,aliasenvio,nombre,comen_fpago,sureferenc FROM pediweb_cab WHERE id_pediweb_cab=$ipw";

$registros =conexion($sql);

$campo = mysql_fetch_array($registros);

$serie = $campo["serie"];
$codigo = $campo["codigo"];
$fecha = $campo["fecha"];
$fecha2 = $campo["fecentrega"];
$id_clientes = $campo["id_clientes"];
$nombrecom = $campo["aliasenvio"];
$nombrefis = $campo["nombre"];
$comentarios = $campo["comentarios"];
$fpago = $campo["comen_fpago"];
$ref = $campo["sureferenc"];

// FUNCTION CAMBIARFORMATOFECHA, cambia a dd/mm/aaaa el formato de fecha que recibe la "fecha por defecto" en el nuevo pedido.

function cambiarFormatoFecha($fecha){
list($anio,$mes,$dia)=explode("-",$fecha);
return $dia."/".$mes."/".$anio;
}

if($fecha!="")
{
$fecha = cambiarFormatoFecha($fecha);
}
else
{
$fecha = date("d/m/Y");
}

if($fecha2!="")
{
$fecha2 = cambiarFormatoFecha($fecha2);
}
else
{
$fecha2 = date("d/m/Y");
}

echo "<table style='border-collapse:collapse';>";


echo "<tr class='serienumero'>";

echo "<td align=center width='87'>Serie</td>";

echo "<td width='150'><input style='text-align:right' type='text' readonly='readonly' value='$serie' class='series'></td>";

echo ("<td align=center width='100'>Número</td>");

echo "<td width='163'><input style='text-align:right' type='text' readonly='readonly' value='$codigo' class='numero'></td>";

echo "</tr>";
echo "</table>";

echo "<br>";
echo "<hr>";


echo "<table cellspacing=10px>";


echo "<tr>";
echo "<td width='83'>Fecha</td>";

echo "<td>";

$fecha3 = date("d-m-Y H:i:s");

?>

<?php

echo "<form name='calendario' method='post' action='guardarfecha.php'>";
echo "<input type='text' name='fecha' value='$fecha' size='10'>";
echo "<input type='submit' value='ok'>";


echo "</td>";

echo "<td width='86'>";


echo "</td>";

echo "<td>";
echo "Fecha Entrega Prevista";
echo "</td>";

echo "<td>";


echo "<form name='calendario2' method='post' action='guardarfecha2.php'>";
echo "<input type='text' name='fecha2' value='$fecha2' size='10'>";
echo "<input type='submit' value='ok'>";



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


$fecha2 = "";

echo "</td>";

echo "</table>";



echo "<table cellspacing=10px>";



echo "</tr>";

echo "<tr>";


echo "<td>Nombre Fiscal</td>";
echo "<td>";


echo "<input type='text' readonly='readonly' value='$nombrefis' class ='cliente' style='text-align:left;'>";
echo "</td>";


echo "<td>Nombre Comercial</td>";
echo "<td><input style='text-align:left' type='text'; readonly='readonly' value='$nombrecom' class ='cliente2'></td>";

$sql="select id_pediweb_lin from pediweb_lin where id_pediweb_cab = '$ipw'";
$registros=conexion($sql);

$lineas = mysql_num_rows($registros);
if($lineas == 0)
{
echo "<td><a href='encontrarcliente.php' class='buscarc' title='Buscar Cliente'>Buscar Cliente </a></td>";
}
echo "</tr>";


echo "</form>";
echo "</td>";

echo "</tr>";

echo "</table>";
}


</body>
</html>
Y ahora uno de los guardarfecha2.php.

Cita:
<?php
session_start();

include_once "conexion.php";

$fecha = $_POST["fecha2"];
$ipw = $_SESSION["ipw"];

function cambiarFormatoFecha($fecha){
list($anio,$mes,$dia)=explode("/",$fecha);
return $dia."-".$mes."-".$anio;
}

$fecha = cambiarFormatoFecha($fecha);
$sql="UPDATE pediweb_cab SET fecentrega = '$fecha' WHERE id_pediweb_cab = $ipw";

conexion($sql);
?>

<script>
window.location.href = "nuevo_pedido.php?ped=2";
</script>
__________________
El PHP me va a quitar la vida :S