0

tengo el siguiente formulario para hacer update:

    <form action="" method="post" name="form1" id="form1">
<table width="60%" height="169" align="center">
<tr valign="baseline">
<td width="44%" align="right" nowrap="nowrap" class="8px_relleno">Nombre de usuario:</td>
<td width="56%" align="left" class="8px_relleno"><input name="us_nombre" type="text" value="<?php echo($rsValidarRep->getColumnVal("us_nombre")); ?>" size="32" readonly /></td>
</tr>
<tr valign="baseline">
<td width="44%" nowrap="nowrap" align="right" class="8px_relleno">Nombre de documento:</td>
<td width="56%" align="left" class="8px_relleno"><input name="nombreorig_doc" type="text" value="<?php echo($rsValidarRep->getColumnVal("nombreorig_doc")); ?>" size="32" readonly /></td>
</tr>
<tr valign="baseline">
<td width="44%" nowrap="nowrap" align="right" class="8px_relleno">Fecha:</td>
            <td width="56%" align="left" class="8px_relleno"><input name="fecha" type="text" value="<?php echo($rsValidarRep->getColumnVal("fecha")); ?>" size="32" readonly /></td>
        </tr>
        <tr valign="baseline">
            <td width="44%" rowspan="2" align="right" nowrap="nowrap" class="8px_relleno">Estatus:</td>
            <td align="left" valign="baseline" class="8px_relleno">
            <input type="radio" name="estatus" value="0" <?php if(!strcmp($rsValidarRep->getColumnVal("estatus"),0)); {echo "checked=\"checked\"";}?> />

                        No validado (inicial)
            </td>
        </tr>
        <tr valign="baseline">
            <td align="left" valign="baseline" class="8px_relleno"><input type="radio" name="estatus" value="1" <?php if(!strcmp($rsValidarRep->getColumnVal("estatus"),1)); {echo "checked=\"checked\"";}?> style="text-align:left;"/>
Validado </td>
        </tr>
        <tr valign="baseline">
            <td nowrap="nowrap" align="right" class="8px_relleno">&nbsp;</td>
            <td align="left" class="8px_relleno"><input name="ValRepBot" type="submit" id="ValRepBot" value="Actualizar registro" /></td>
        </tr>
    </table>
    <input type="hidden" name="doc_id" value="<?php echo($rsValidarRep->getColumnVal("doc_id")); ?>" />

    </form>

Este formulario actualiza una tabla que se llama docs_subidos y que tiene los siguientes campos:

 `doc_id` int(5) NOT NULL,
 `doc_tipo` enum('TC','CE','RR','') COLLATE utf8_spanish_ci NOT NULL DEFAULT 'TC',
 `us_nombre` varchar(30) COLLATE utf8_spanish_ci NOT NULL,
 `nombreorig_doc` varchar(254) COLLATE utf8_spanish_ci NOT NULL,
 `doc_asunto` varchar(254) COLLATE utf8_spanish_ci NOT NULL,
 `fecha` date NOT NULL,
 `fecha_2` date NOT NULL,
 `fecha_3` date NOT NULL,
 `estatus` tinyint(1) NOT NULL DEFAULT '0'

doc_id es la clave.

Mi script de update (que solo deja posible la modificación del botón del radio y del botón para actualizar el registro) es este.

<?php
if (isset($_POST["ValRepBot"]) || isset($_POST["ValRepBot_x"])) {
  $UpdateQuery = new WA_MySQLi_Query($conexion_i);
  $UpdateQuery->Action = "update";
  $UpdateQuery->Table = "docs_subidos";
  $UpdateQuery->bindColumn("doc_id", "s", "".($rsValidarRep->getColumnVal("doc_id"))  ."", "WA_DEFAULT");
  $UpdateQuery->bindColumn("doc_tipo", "s", "".($rsValidarRep->getColumnVal("doc_tipo"))  ."", "WA_DEFAULT");
  $UpdateQuery->bindColumn("us_nombre", "s", "".($rsValidarRep->getColumnVal("us_nombre"))  ."", "WA_DEFAULT");
  $UpdateQuery->bindColumn("nombreorig_doc", "s", "".($rsValidarRep->getColumnVal("nombreorig_doc"))  ."", "WA_DEFAULT");
  $UpdateQuery->bindColumn("doc_asunto", "s", "".($rsValidarRep->getColumnVal("doc_asunto"))  ."", "WA_DEFAULT");
  $UpdateQuery->bindColumn("fecha", "t", "".($rsValidarRep->getColumnVal("fecha"))  ."", "WA_DEFAULT");
  $UpdateQuery->bindColumn("fecha_2", "t", "", "WA_CURRENT_TIMESTAMP");
  $UpdateQuery->bindColumn("fecha_3", "t", "", "WA_DEFAULT");
  $UpdateQuery->bindColumn("estatus", "i", "".((isset($_POST["estatus"]))?$_POST["estatus"]:"")  ."", "WA_DEFAULT");
  $UpdateQuery->addFilter("doc_id", "=", "i", "".($rsValidarRep->getColumnVal("doc_id"))  ."");
  $UpdateQuery->execute();
  $UpdateGoTo = "";
  if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
  $UpdateQuery->redirect($UpdateGoTo);
}
?>

La idea es que, cuando los usuarios suben documentos a la web, que es una herramienta de gestión, estos son visados por el administrador. En el momento en que son visados y están conformes, el administrador entra a Validar el documento clicando en el botón de radio "estatus" y que, al hacerlo, el valore de la tabla "fecha_2" tome el de la fecha en la que se cambio el estatus a Validado y que "fecha_3" sume seis meses al valor de fecha 2 (que es el tiempo en el que el documento estará accesibel para un subadministrador)... Pero no sé cómo incluir en el script las instrucciones para calcular esas dos fechas.

¿Alguien puede ayudarme? Muchas gracias

1 respuesta 1

0

Hola lo que tenes que hacer es que al validarla tome la fecha que esta guardada y hacerle un update con la fecha de hoy. Con respecto a la otra fecha, al guardar la fecha de validacion otra vez agarrar esa fecha y sumarle 6 meses con la libreria de fechas de PHP http://php.net/manual/es/datetime.add.php

Espero te sirva.

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.