Calculate dates in update form


I have the following form to 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 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 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 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)
        <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 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>
    <input type="hidden" name="doc_id" value="<?php echo($rsValidarRep->getColumnVal("doc_id")); ?>" />


This form updates a table called docs_subidos and that has the following fields:

 '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 is the key.

My update script (which only allows modifying the radio button and the button to update the record) is this.

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"))  ."");
  $UpdateGoTo = "";
  if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";

The idea is that when users upload documents to the web, which is a management tool, they are endorsed by the administrator. At the time they are visas and are satisfied, the administrator enters Validate the document by clicking on the radio button "status" and that, in doing so, the value of the table "date_2" takes the date of the date on which change the status to Validated and that "date_3" adds six months to the value of date 2 (which is the time in which the document will be accesibel for a sub-administrator) ... But I do not know how to include in the script the instructions to calculate those two dates

Can someone help me? Thank you very much

asked by Ml Saura 22.11.2018 в 19:17

1 answer


Hello what you have to do is to validate it take the date that is saved and make an update with today's date. With respect to the other date, when saving the validation date again grab that date and add 6 months with the PHP date library link

I hope it serves you.

answered by 22.11.2018 в 19:33