Código PHP:
<?php require_once('../Connections/estudio.php'); ?>
<?phprequire_once('../includes/wdg/WDG.php');require_once('../includes/common/KT_common.php');require_once('../includes/tng/tNG.inc.php');require_once('../includes/nxt/KT_back.php');$tNGs = new tNG_dispatcher("../");$conn_estudio = new KT_connection($estudio, $database_estudio);$formValidation = new tNG_FormValidation();$formValidation->addField("id_causa", true, "numeric", "", "", "", "");$formValidation->addField("archivo", true, "", "", "", "", "");$formValidation->addField("fecha_archivo", true, "date", "", "", "", "");$tNGs->prepareValidation($formValidation);if (!function_exists("GetSQLValueString")) {function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL";break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined":$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue;}}$colname_cliente = "-1";
if (isset($_GET['id_cliente'])) { $colname_cliente = $_GET['id_cliente'];}
mysql_select_db($database_estudio, $estudio);$query_cliente = sprintf("SELECT * FROM clientes WHERE id_cliente = %s", GetSQLValueString($colname_cliente, "int"));$cliente = mysql_query($query_cliente, $estudio) or die(mysql_error());$row_cliente = mysql_fetch_assoc($cliente);$totalRows_cliente = mysql_num_rows($cliente);function Trigger_FileDelete(&$tNG) {$deleteObj = new tNG_FileDelete($tNG);$deleteObj->setFolder("../abogados/archivos/");$deleteObj->setDbFieldName("archivo");return $deleteObj->Execute();}function Trigger_FileUpload(&$tNG) { $uploadObj = new tNG_FileUpload($tNG);$uploadObj->setFormFieldName("archivo");$uploadObj->setDbFieldName("archivo");$uploadObj->setFolder("../abogados/archivos/");$uploadObj->setMaxSize(15000);$uploadObj->setAllowedExtensions("doc, pdf, xls, rtf, jpg, jpeg, png");$uploadObj->setRename("none");return $uploadObj->Execute();
}$ins_adjunto = new tNG_multipleInsert($conn_estudio);$tNGs->addTransaction($ins_adjunto);$ins_adjunto->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Insert1");
$ins_adjunto->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);$ins_adjunto->registerTrigger("END", "Trigger_Default_Redirect", 99, "../includes/nxt/back.php");$ins_adjunto->registerTrigger("AFTER", "Trigger_FileUpload", 97);
$ins_adjunto->setTable("adjunto");$ins_adjunto->addColumn("id_causa", "NUMERIC_TYPE", "POST", "id_causa", "{GET.id_causa}");
$ins_adjunto->addColumn("archivo", "FILE_TYPE", "FILES", "archivo");
$ins_adjunto->addColumn("vista", "STRING_TYPE", "POST", "vista");
$ins_adjunto->addColumn("fecha_archivo", "DATE_TYPE", "POST", "fecha_archivo");$ins_adjunto->setPrimaryKey("id_adjunto", "NUMERIC_TYPE");$upd_adjunto = new tNG_multipleUpdate($conn_estudio);$tNGs->addTransaction($upd_adjunto);
$upd_adjunto->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Update1");$upd_adjunto->registerTrigger("BEFORE", "Trigger_Default_FormValidation", 10, $formValidation);$upd_adjunto->registerTrigger("END", "Trigger_Default_Redirect", 99, "../includes/nxt/back.php");$upd_adjunto->registerTrigger("AFTER", "Trigger_FileUpload", 97);$upd_adjunto->setTable("adjunto");$upd_adjunto->addColumn("archivo", "FILE_TYPE", "FILES", "archivo");$upd_adjunto->addColumn("fecha_archivo", "DATE_TYPE", "POST", "fecha_archivo");$upd_adjunto->addColumn("vista", "STRING_TYPE", "POST", "vista");$upd_adjunto->setPrimaryKey("id_adjunto", "NUMERIC_TYPE", "GET", "id_adjunto");$del_adjunto = new tNG_multipleDelete($conn_estudio);$tNGs->addTransaction($del_adjunto);
$del_adjunto->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "KT_Delete1");$del_adjunto->registerTrigger("END", "Trigger_Default_Redirect", 99, "../includes/nxt/back.php");$del_adjunto->registerTrigger("AFTER", "Trigger_FileDelete", 98);$del_adjunto->setTable("adjunto");$del_adjunto->setPrimaryKey("id_adjunto", "NUMERIC_TYPE", "GET", "id_adjunto");$tNGs->executeTransactions();$rsadjunto = $tNGs->getRecordset("adjunto");
$row_rsadjunto = mysql_fetch_assoc($rsadjunto);$totalRows_rsadjunto = mysql_num_rows($rsadjunto);?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wdg="http://ns.adobe.com/addt"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Documento sin título</title><link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" /><script src="../includes/common/js/base.js" type="text/javascript"></script><script src="../includes/common/js/utility.js" type="text/javascript"></script><script src="../includes/skins/style.js" type="text/javascript"></script><?php echo $tNGs->displayValidationRules();?>
<script src="../includes/nxt/scripts/form.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/form.js.php" type="text/javascript"></script>
<script type="text/javascript">$NXT_FORM_SETTINGS = {
duplicate_buttons: false,show_as_grid: true,merge_down_value: true
}</script><script type="text/javascript" src="../includes/common/js/sigslot_core.js"></script><script type="text/javascript" src="../includes/wdg/classes/MXWidgets.js"></script><script type="text/javascript" src="../includes/wdg/classes/MXWidgets.js.php"></script><script type="text/javascript" src="../includes/wdg/classes/SmartDate.js"></script><style type="text/css">
</style></head><body><table cellspacing="0" cellpadding="0" class="menusuper"> <tr> <td width="840">Ubicación: <a href="cliente.php"><- Clientes o Casos</a> / <a href="causas.php?id_cliente=<?php echo $_GET['id_cliente']; ?>"><- Carpeta</a> / <a href="adjunto.php?id_causa=<?php echo $_GET['id_causa']; ?>&id_cliente=<?php echo $_GET['id_cliente']; ?>"><- Archivos</a> / <?php if (@$_GET['id_adjunto'] == "") {
?> <?php echo NXT_getResource("Insert_FH"); ?><?php } else { ?> <?php echo NXT_getResource("Update_FH"); ?> <?php } ?>Archivo<br />Fecha: <span class="titulos"><?php echo KT_formatDate($row_cliente['fecha_ing']); ?></span>Cliente: <span class="titulos"><?php echo $row_cliente['cliente']; ?></span> Tipo: <span class="titulos"><?php echo $row_cliente['tipo']; ?></span><br /> Caso: <span class="titulos"><?php echo $row_cliente['caso']; ?></td> </tr></table><?php echo $tNGs->getErrorMsg();?><div class="KT_tng"> <div class="KT_tngform"> <form method="post" id="form1" action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>" enctype="multipart/form-data"> <?php $cnt1 = 0; ?>
<?php do { ?><?php $cnt1++; ?><?php if (@$totalRows_rsadjunto > 1) {
?><h2><?php echo NXT_getResource("Record_FH"); ?> <?php echo $cnt1; ?></h2><?php } ?> <table cellpadding="2" cellspacing="0" class="KT_tngtable">
<tr> <td class="KT_th"><label for="archivo_<?php echo $cnt1; ?>">Archivo:</label></td><td><input type="file" name="archivo_<?php echo $cnt1; ?>" id="archivo_<?php echo $cnt1; ?>" size="32" />
<?php echo $tNGs->displayFieldError("adjunto", "archivo", $cnt1); ?> </td> </tr> <tr> <td class="KT_th"><label for="fecha_archivo_<?php echo $cnt1; ?>">Fecha Documento:</label></td> <td><input name="fecha_archivo_<?php echo $cnt1; ?>" id="fecha_archivo_<?php echo $cnt1; ?>" value="<?php echo KT_formatDate($row_rsadjunto['fecha_archivo']); ?>" size="10" maxlength="22" wdg:subtype="SmartDate" wdg:mask="<?php echo $KT_screen_date_format; ?>" wdg:restricttomask="no" wdg:defaultnow="yes" wdg:spinner="yes" wdg:type="widget" /> <?php echo $tNGs->displayFieldHint("fecha_archivo");?> <?php echo $tNGs->displayFieldError("adjunto", "fecha_archivo", $cnt1); ?> </td>
</tr> <tr> <td class="KT_th"><label for="vista_<?php echo $cnt1; ?>">Vista a Publico:</label></td><td><select name="vista_<?php echo $cnt1; ?>" id="vista_<?php echo $cnt1; ?>"> <option value="0" <?php if (!(strcmp(0, KT_escapeAttribute($row_rsadjunto['vista'])))) {echo "SELECTED";} ?>>NO</option><option value="1" <?php if (!(strcmp(1, KT_escapeAttribute($row_rsadjunto['vista'])))) {echo "SELECTED";} ?>>SI</option>
</select> <?php echo $tNGs->displayFieldError("adjunto", "vista", $cnt1); ?> </td> </tr></table><input type="hidden" name="kt_pk_adjunto_<?php echo $cnt1; ?>" class="id_field" value="<?php echo KT_escapeAttribute($row_rsadjunto['kt_pk_adjunto']); ?>" />
<input type="hidden" name="id_causa_<?php echo $cnt1; ?>" id="id_causa_<?php echo $cnt1; ?>" value="<?php echo KT_escapeAttribute($row_rsadjunto['id_causa']); ?>" /> <?php } while ($row_rsadjunto = mysql_fetch_assoc($rsadjunto)); ?><div class="KT_bottombuttons"><div><?php if (@$_GET['id_adjunto'] == "") { ?><input type="submit" name="KT_Insert1" id="KT_Insert1" value="<?php echo NXT_getResource("Insert_FB"); ?>" /><?php } else { ?>
<input type="submit" name="KT_Update1" value="<?php echo NXT_getResource("Update_FB"); ?>" /> <input type="submit" name="KT_Delete1" value="<?php echo NXT_getResource("Delete_FB"); ?>" onclick="return confirm('<?php echo NXT_getResource("Are you sure?"); ?>');" /> <?php }?><input type="button" name="KT_Cancel1" value="<?php echo NXT_getResource("Cancel_FB"); ?>" onclick="return UNI_navigateCancel(event, '../includes/nxt/back.php')" />
</div> </div> </form></div> <br class="clearfixplain" /></div><p> </p>
</body></html><?phpmysql_free_result($cliente);?>