<?php
  // This is a sample form for adding a record and it's uploads

  require_once "../w-xr/cmsb/lib/viewer_functions.php";
  $tableName       = 'cvax';
  $recordNum       = null; // you must set either $recordNum or $preSaveTempId to null
  $preSaveTempId   = @$_REQUEST['preSaveTempId'] ? $_REQUEST['preSaveTempId'] : uniqid('x');
  $errorsAndAlerts = '';

  ### insert record
  if (@$_REQUEST['submitForm']) {

    // error checking
  //  if (!@$_REQUEST['title'])    { $errorsAndAlerts .= "Please specify title!<br/>\n"; }

    // update record
    if (!@$errorsAndAlerts) {
      $colsToValues = [
        'createdDate='     => 'NOW()',
        'createdByUserNum' => @$CURRENT_USER['num'],
        'updatedDate='     => 'NOW()',
        'updatedByUserNum' => @$CURRENT_USER['num'],
   //     'title'            => @$_REQUEST['title'],
      ];
      $newRecordNum = mysql_insert($tableName, $colsToValues, true);

      // adopt temp uploads (IMPORTANT - DON'T FORGET THIS STEP!!!)
      adoptUploads($tableName, $preSaveTempId, $newRecordNum);
      removeExpiredUploads(); // erase old expired uploads

      // display thanks message and clear form
      $errorsAndAlerts = "Thanks, we've added your images!";
      $_REQUEST      = array();
    }
  }

?><!doctype html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php include("core-head.php") ?>
<title></title>
</head>
<body>

<?php if (@$errorsAndAlerts): ?>
  <div style="color: #C00; font-weight: bold; font-size: 14px;"><?php echo $errorsAndAlerts; ?></div>
<?php endif ?>

<form method="post" action="<?php echo $_SERVER['SCRIPT_NAME']; ?>">
<input type="hidden" name="submitForm" value="1" />
<input type="hidden" name="num" value="<?php echo $recordNum ?>" />
<input type="hidden" name="preSaveTempId" value="<?php echo htmlencode($preSaveTempId) ?>" />
<input type="hidden" name="title" value="covid vaccination images" />


<div class="table-responsive">
  <table class="table table-borderless">
    <thead>
      <tr>
        <th>Please Upload front and back Images of Vaccination Card or covid medical record</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>
        <iframe src='uploadForm3_iframe.php?table=<?php echo $tableName ?>&amp;field=upload&amp;num=<?php echo $recordNum ?>&amp;preSaveTempId=<?php echo htmlencode($preSaveTempId) ?>'
            height='150' width='100%' frameborder='0' scrolling='yes'>
	    </iframe><br>
	</td>
      </tr>
    </tbody>
  </table>
  <input class="btn btn-sm btn-primary btn-soft opacity-8" type="submit" name="submitForm" value="Add Images" />
</div>
</form>

</body>
</html>
