<?php
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg6.php" ?>
<?php include "ewmysql6.php" ?>
<?php include "phpfn6.php" ?>
<?php include "categoriainfo.php" ?>
<?php include "usuarioinfo.php" ?>
<?php include "userfn6.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Define page object
$categoria_list = new ccategoria_list();
$Page =& $categoria_list;

// Page init processing
$categoria_list->Page_Init();

// Page main processing
$categoria_list->Page_Main();
?>
<?php include "header.php" ?>
<?php if ($categoria->Export == "") { ?>
<script type="text/javascript">
<!--

// Create page object
var categoria_list = new ew_Page("categoria_list");

// page properties
categoria_list.PageID = "list"; // page ID
var EW_PAGE_ID = categoria_list.PageID; // for backward compatibility

// extend page with Form_CustomValidate function
categoria_list.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
categoria_list.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
categoria_list.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<?php } ?>
<?php if ($categoria->Export == "") { ?>
<?php } ?>
<?php
	$bSelectLimit = ($categoria->Export == "" && $categoria->SelectLimit);
	if (!$bSelectLimit)
		$rs = $categoria_list->LoadRecordset();
	$categoria_list->lTotalRecs = ($bSelectLimit) ? $categoria->SelectRecordCount() : $rs->RecordCount();
	$categoria_list->lStartRec = 1;
	if ($categoria_list->lDisplayRecs <= 0) // Display all records
		$categoria_list->lDisplayRecs = $categoria_list->lTotalRecs;
	if (!($categoria->ExportAll && $categoria->Export <> ""))
		$categoria_list->SetUpStartRec(); // Set up start record position
	if ($bSelectLimit)
		$rs = $categoria_list->LoadRecordset($categoria_list->lStartRec-1, $categoria_list->lDisplayRecs);
?>
<p><span class="phpmaker" style="white-space: nowrap;">TABLA: categorias
<?php if ($categoria->Export == "" && $categoria->CurrentAction == "") { ?>
&nbsp;&nbsp;<a href="<?php echo $categoria_list->PageUrl() ?>export=excel"><img src='images/exportxls.gif' width='16' height='16' border='0' alt='Exportar a Excel'></a>
&nbsp;&nbsp;<a href="<?php echo $categoria_list->PageUrl() ?>export=word"><img src='images/exportdoc.gif' width='16' height='16' border='0' alt='Exportar a Word'></a>
&nbsp;&nbsp;<a href="<?php echo $categoria_list->PageUrl() ?>export=csv"><img src='images/exportcsv.gif' width='16' height='16' border='0' alt='Exportar a CSV'></a>
<?php } ?>
</span></p>
<?php if ($Security->IsLoggedIn()) { ?>
<?php if ($categoria->Export == "" && $categoria->CurrentAction == "") { ?>
<a href="javascript:ew_ToggleSearchPanel(categoria_list);" style="text-decoration: none;"><img id="categoria_list_SearchImage" src="images/collapse.gif" alt="" width="9" height="9" border="0"></a><span class="phpmaker">&nbsp;Buscar</span><br>
<div id="categoria_list_SearchPanel">
<form name="fcategorialistsrch" id="fcategorialistsrch" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<input type="hidden" id="t" name="t" value="categoria">
<table class="ewBasicSearch">
	<tr>
		<td><span class="phpmaker">
			<input type="text" name="<?php echo EW_TABLE_BASIC_SEARCH ?>" id="<?php echo EW_TABLE_BASIC_SEARCH ?>" size="20" value="<?php echo ew_HtmlEncode($categoria->getBasicSearchKeyword()) ?>">
			<input type="Submit" name="Submit" id="Submit" value="Buscar (*)">&nbsp;
			<a href="<?php echo $categoria_list->PageUrl() ?>cmd=reset">Ver Todo</a>&nbsp;
		</span></td>
	</tr>
	<tr>
	<td><span class="phpmaker"><label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value=""<?php if ($categoria->getBasicSearchType() == "") { ?> checked="checked"<?php } ?>>Frase exacta</label>&nbsp;&nbsp;<label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="AND"<?php if ($categoria->getBasicSearchType() == "AND") { ?> checked="checked"<?php } ?>>Todas las palabras</label>&nbsp;&nbsp;<label><input type="radio" name="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" id="<?php echo EW_TABLE_BASIC_SEARCH_TYPE ?>" value="OR"<?php if ($categoria->getBasicSearchType() == "OR") { ?> checked="checked"<?php } ?>>Cualquier palabra</label></span></td>
	</tr>
</table>
</form>
</div>
<?php } ?>
<?php } ?>
<?php $categoria_list->ShowMessage() ?>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<form name="fcategorialist" id="fcategorialist" class="ewForm" action="" method="post">
<?php if ($categoria_list->lTotalRecs > 0) { ?>
<table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<?php
	$categoria_list->lOptionCnt = 0;
if ($Security->IsLoggedIn()) {
	$categoria_list->lOptionCnt++; // view
}
if ($Security->IsLoggedIn()) {
	$categoria_list->lOptionCnt++; // edit
}
if ($Security->IsLoggedIn()) {
	$categoria_list->lOptionCnt++; // copy
}
if ($Security->IsLoggedIn()) {
	$categoria_list->lOptionCnt++; // Delete
}
if ($Security->IsLoggedIn()) {
	$categoria_list->lOptionCnt++; // Detail
}
if ($Security->IsLoggedIn()) {
	$categoria_list->lOptionCnt++; // Detail
}
	$categoria_list->lOptionCnt += count($categoria_list->ListOptions->Items); // Custom list options
?>
<?php echo $categoria->TableCustomInnerHtml ?>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<?php if ($categoria->cod_categoria->Visible) { // cod_categoria ?>
	<?php if ($categoria->SortUrl($categoria->cod_categoria) == "") { ?>
		<td>cod.</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $categoria->SortUrl($categoria->cod_categoria) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>cod.&nbsp;(*)</td><td style="width: 10px;"><?php if ($categoria->cod_categoria->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($categoria->cod_categoria->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($categoria->des_categoria->Visible) { // des_categoria ?>
	<?php if ($categoria->SortUrl($categoria->des_categoria) == "") { ?>
		<td>descripción</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $categoria->SortUrl($categoria->des_categoria) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>descripción&nbsp;(*)</td><td style="width: 10px;"><?php if ($categoria->des_categoria->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($categoria->des_categoria->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($categoria->des_imagen->Visible) { // des_imagen ?>
	<?php if ($categoria->SortUrl($categoria->des_imagen) == "") { ?>
		<td>imagen</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $categoria->SortUrl($categoria->des_imagen) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>imagen</td><td style="width: 10px;"><?php if ($categoria->des_imagen->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($categoria->des_imagen->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($categoria->margen->Visible) { // margen ?>
	<?php if ($categoria->SortUrl($categoria->margen) == "") { ?>
		<td>margen</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $categoria->SortUrl($categoria->margen) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>margen</td><td style="width: 10px;"><?php if ($categoria->margen->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($categoria->margen->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($categoria->displayCat->Visible) { // displayCat ?>
	<?php if ($categoria->SortUrl($categoria->displayCat) == "") { ?>
		<td>cat</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $categoria->SortUrl($categoria->displayCat) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>cat</td><td style="width: 10px;"><?php if ($categoria->displayCat->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($categoria->displayCat->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($categoria->orden->Visible) { // orden ?>
	<?php if ($categoria->SortUrl($categoria->orden) == "") { ?>
		<td>orden</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $categoria->SortUrl($categoria->orden) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>orden</td><td style="width: 10px;"><?php if ($categoria->orden->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($categoria->orden->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($categoria->Export == "") { ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;">&nbsp;</td>
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;">&nbsp;</td>
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;">&nbsp;</td>
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;">&nbsp;</td>
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;">&nbsp;</td>
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;">&nbsp;</td>
<?php } ?>
<?php

// Custom list options
foreach ($categoria_list->ListOptions->Items as $ListOption) {
	if ($ListOption->Visible)
		echo $ListOption->HeaderCellHtml;
}
?>
<?php } ?>
	</tr>
</thead>
<?php
if ($categoria->ExportAll && $categoria->Export <> "") {
	$categoria_list->lStopRec = $categoria_list->lTotalRecs;
} else {
	$categoria_list->lStopRec = $categoria_list->lStartRec + $categoria_list->lDisplayRecs - 1; // Set the last record to display
}
$categoria_list->lRecCount = $categoria_list->lStartRec - 1;
if ($rs && !$rs->EOF) {
	$rs->MoveFirst();
	if (!$categoria->SelectLimit && $categoria_list->lStartRec > 1)
		$rs->Move($categoria_list->lStartRec - 1);
}
$categoria_list->lRowCnt = 0;
while (($categoria->CurrentAction == "gridadd" || !$rs->EOF) &&
	$categoria_list->lRecCount < $categoria_list->lStopRec) {
	$categoria_list->lRecCount++;
	if (intval($categoria_list->lRecCount) >= intval($categoria_list->lStartRec)) {
		$categoria_list->lRowCnt++;

	// Init row class and style
	$categoria->CssClass = "";
	$categoria->CssStyle = "";
	$categoria->RowClientEvents = "onmouseover='ew_MouseOver(event, this);' onmouseout='ew_MouseOut(event, this);' onclick='ew_Click(event, this);'";
	if ($categoria->CurrentAction == "gridadd") {
		$categoria_list->LoadDefaultValues(); // Load default values
	} else {
		$categoria_list->LoadRowValues($rs); // Load row values
	}
	$categoria->RowType = EW_ROWTYPE_VIEW; // Render view

	// Render row
	$categoria_list->RenderRow();
?>
	<tr<?php echo $categoria->RowAttributes() ?>>
	<?php if ($categoria->cod_categoria->Visible) { // cod_categoria ?>
		<td<?php echo $categoria->cod_categoria->CellAttributes() ?>>
<div<?php echo $categoria->cod_categoria->ViewAttributes() ?>><?php echo $categoria->cod_categoria->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($categoria->des_categoria->Visible) { // des_categoria ?>
		<td<?php echo $categoria->des_categoria->CellAttributes() ?>>
<div<?php echo $categoria->des_categoria->ViewAttributes() ?>><?php echo $categoria->des_categoria->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($categoria->des_imagen->Visible) { // des_imagen ?>
		<td<?php echo $categoria->des_imagen->CellAttributes() ?>>
<?php if ($categoria->des_imagen->HrefValue <> "") { ?>
<?php if (!is_null($categoria->des_imagen->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, EW_UPLOAD_DEST_PATH) . $categoria->des_imagen->Upload->DbValue ?>" border=0<?php echo $categoria->des_imagen->ViewAttributes() ?>>
<?php } elseif (!in_array($categoria->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } else { ?>
<?php if (!is_null($categoria->des_imagen->Upload->DbValue)) { ?>
<img src="<?php echo ew_UploadPathEx(FALSE, EW_UPLOAD_DEST_PATH) . $categoria->des_imagen->Upload->DbValue ?>" border=0<?php echo $categoria->des_imagen->ViewAttributes() ?>>
<?php } elseif (!in_array($categoria->CurrentAction, array("I", "edit", "gridedit"))) { ?>	
&nbsp;
<?php } ?>
<?php } ?>
</td>
	<?php } ?>
	<?php if ($categoria->margen->Visible) { // margen ?>
		<td<?php echo $categoria->margen->CellAttributes() ?>>
<div<?php echo $categoria->margen->ViewAttributes() ?>><?php echo $categoria->margen->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($categoria->displayCat->Visible) { // displayCat ?>
		<td<?php echo $categoria->displayCat->CellAttributes() ?>>
<div<?php echo $categoria->displayCat->ViewAttributes() ?>><?php echo $categoria->displayCat->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($categoria->orden->Visible) { // orden ?>
		<td<?php echo $categoria->orden->CellAttributes() ?>>
<div<?php echo $categoria->orden->ViewAttributes() ?>><?php echo $categoria->orden->ListViewValue() ?></div>
</td>
	<?php } ?>
<?php if ($categoria->Export == "") { ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;"><span class="phpmaker">
<a href="<?php echo $categoria->ViewUrl() ?>"><img src='images/browse.gif' width='16' height='16' border='0' alt='Ver'></a>
</span></td>
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;"><span class="phpmaker">
<a href="<?php echo $categoria->EditUrl() ?>"><img src='images/edit.gif' width='16' height='16' border='0' alt='Editar'></a>
</span></td>
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;"><span class="phpmaker">
<a href="<?php echo $categoria->CopyUrl() ?>"><img src='images/copy.gif' width='16' height='16' border='0' alt='Copiar'></a>
</span></td>
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;"><span class="phpmaker">
<a href="<?php echo $categoria->DeleteUrl() ?>"><img src='images/delete.gif' width='16' height='16' border='0' alt='Borrar'></a>
</span></td>
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;"><span class="phpmaker">
<a href="linea_productolist.php?<?php echo EW_TABLE_SHOW_MASTER ?>=categoria&cod_categoria=<?php echo urlencode(strval($categoria->cod_categoria->CurrentValue)) ?>">lineas<img src='images/detail.gif' width='16' height='16' border='0' alt='Detalles'></a>
</span></td>
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;"><span class="phpmaker">
<a href="productolist.php?<?php echo EW_TABLE_SHOW_MASTER ?>=categoria&cod_categoria=<?php echo urlencode(strval($categoria->cod_categoria->CurrentValue)) ?>">productos<img src='images/detail.gif' width='16' height='16' border='0' alt='Detalles'></a>
</span></td>
<?php } ?>
<?php

// Custom list options
foreach ($categoria_list->ListOptions->Items as $ListOption) {
	if ($ListOption->Visible)
		echo $ListOption->BodyCellHtml;
}
?>
<?php } ?>
	</tr>
<?php
	}
	if ($categoria->CurrentAction <> "gridadd")
		$rs->MoveNext();
}
?>
</tbody>
</table>
<?php } ?>
</form>
<?php

// Close recordset
if ($rs)
	$rs->Close();
?>
</div>
<?php if ($categoria->Export == "") { ?>
<div class="ewGridLowerPanel">
<?php if ($categoria->CurrentAction <> "gridadd" && $categoria->CurrentAction <> "gridedit") { ?>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
	<tr>
		<td nowrap>
<?php if (!isset($categoria_list->Pager)) $categoria_list->Pager = new cPrevNextPager($categoria_list->lStartRec, $categoria_list->lDisplayRecs, $categoria_list->lTotalRecs) ?>
<?php if ($categoria_list->Pager->RecordCount > 0) { ?>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="phpmaker">Página&nbsp;</span></td>
<!--first page button-->
	<?php if ($categoria_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $categoria_list->PageUrl() ?>start=<?php echo $categoria_list->Pager->FirstButton->Start ?>"><img src="images/first.gif" alt="Primera" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/firstdisab.gif" alt="Primera" width="16" height="16" border="0"></td>
	<?php } ?>
<!--previous page button-->
	<?php if ($categoria_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $categoria_list->PageUrl() ?>start=<?php echo $categoria_list->Pager->PrevButton->Start ?>"><img src="images/prev.gif" alt="Previo" width="16" height="16" border="0"></a></td>
	<?php } else { ?>
	<td><img src="images/prevdisab.gif" alt="Previo" width="16" height="16" border="0"></td>
	<?php } ?>
<!--current page number-->
	<td><input type="text" name="<?php echo EW_TABLE_PAGE_NO ?>" id="<?php echo EW_TABLE_PAGE_NO ?>" value="<?php echo $categoria_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($categoria_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $categoria_list->PageUrl() ?>start=<?php echo $categoria_list->Pager->NextButton->Start ?>"><img src="images/next.gif" alt="Siguiente" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/nextdisab.gif" alt="Siguiente" width="16" height="16" border="0"></td>
	<?php } ?>
<!--last page button-->
	<?php if ($categoria_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $categoria_list->PageUrl() ?>start=<?php echo $categoria_list->Pager->LastButton->Start ?>"><img src="images/last.gif" alt="Ultima" width="16" height="16" border="0"></a></td>	
	<?php } else { ?>
	<td><img src="images/lastdisab.gif" alt="Ultima" width="16" height="16" border="0"></td>
	<?php } ?>
	<td><span class="phpmaker">&nbsp;de <?php echo $categoria_list->Pager->PageCount ?></span></td>
	</tr></table>
	</td>	
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<span class="phpmaker">Registros <?php echo $categoria_list->Pager->FromIndex ?> a <?php echo $categoria_list->Pager->ToIndex ?> de <?php echo $categoria_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($categoria_list->sSrchWhere == "0=101") { ?>
	<span class="phpmaker">Ingresar criterio de búsqueda</span>
	<?php } else { ?>
	<span class="phpmaker">No se encontraron registros</span>
	<?php } ?>
<?php } ?>
		</td>
<?php if ($categoria_list->lTotalRecs > 0) { ?>
		<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
		<td><table border="0" cellspacing="0" cellpadding="0"><tr><td>Tamaño&nbsp;</td><td>
<input type="hidden" id="t" name="t" value="categoria">
<select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onchange="this.form.submit();" class="phpmaker">
<option value="20"<?php if ($categoria_list->lDisplayRecs == 20) { ?> selected="selected"<?php } ?>>20</option>
<option value="50"<?php if ($categoria_list->lDisplayRecs == 50) { ?> selected="selected"<?php } ?>>50</option>
<option value="ALL"<?php if ($categoria->getRecordsPerPage() == -1) { ?> selected="selected"<?php } ?>>Todos</option>
</select></td></tr></table>
		</td>
<?php } ?>
	</tr>
</table>
</form>
<?php } ?>
<?php //if ($categoria_list->lTotalRecs > 0) { ?>
<span class="phpmaker">
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $categoria->AddUrl() ?>">Agregar</a>&nbsp;&nbsp;
<?php } ?>
</span>
<?php //} ?>
</div>
<?php } ?>
</td></tr></table>
<?php if ($categoria->Export == "" && $categoria->CurrentAction == "") { ?>
<script type="text/javascript">
<!--

//ew_ToggleSearchPanel(categoria_list); // uncomment to init search panel as collapsed
//-->

</script>
<?php } ?>
<?php if ($categoria->Export == "") { ?>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php } ?>
<?php include "footer.php" ?>
<?php

//
// Page Class
//
class ccategoria_list {

	// Page ID
	var $PageID = 'list';

	// Table Name
	var $TableName = 'categoria';

	// Page Object Name
	var $PageObjName = 'categoria_list';

	// Page Name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page Url
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $categoria;
		if ($categoria->UseTokenInUrl) $PageUrl .= "t=" . $categoria->TableVar . "&"; // add page token
		return $PageUrl;
	}

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show Message
	function ShowMessage() {
		if ($this->getMessage() <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $this->getMessage() . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate Page request
	function IsPageRequest() {
		global $objForm, $categoria;
		if ($categoria->UseTokenInUrl) {

			//IsPageRequest = False
			if ($objForm)
				return ($categoria->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($categoria->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

	//
	//  Class initialize
	//  - init objects
	//  - open connection
	//
	function ccategoria_list() {
		global $conn;

		// Initialize table object
		$GLOBALS["categoria"] = new ccategoria();

		// Initialize other table object
		$GLOBALS['usuario'] = new cusuario();

		// Intialize page id (for backward compatibility)
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'list', TRUE);

		// Initialize table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'categoria', TRUE);

		// Open connection to the database
		$conn = ew_Connect();

		// Initialize list options
		$this->ListOptions = new cListOptions();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $categoria;
		global $Security;
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}
	$categoria->Export = @$_GET["export"]; // Get export parameter
	$gsExport = $categoria->Export; // Get export parameter, used in header
	$gsExportFile = $categoria->TableVar; // Get export file, used in header
	if ($categoria->Export == "excel") {
		header('Content-Type: application/vnd.ms-excel');
		header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
	}
	if ($categoria->Export == "word") {
		header('Content-Type: application/vnd.ms-word');
		header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
	}
	if ($categoria->Export == "csv") {
		header('Content-Type: application/csv');
		header('Content-Disposition: attachment; filename=' . $gsExportFile .'.csv');
	}

		// Global page loading event (in userfn6.php)
		Page_Loading();

		// Page load event, used in current page
		$this->Page_Load();
	}

	//
	//  Page_Terminate
	//  - called when exit page
	//  - if URL specified, redirect to the URL
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page unload event, used in current page
		$this->Page_Unload();

		// Global page unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close Connection
		$conn->Close();

		// Go to URL if specified
		if ($url <> "") {
			ob_end_clean();
			header("Location: $url");
		}
		exit();
	}
	var $lDisplayRecs; // Number of display records
	var $lStartRec;
	var $lStopRec;
	var $lTotalRecs;
	var $lRecRange;
	var $sSrchWhere;
	var $lRecCnt;
	var $lEditRowCnt;
	var $lRowCnt;
	var $lRowIndex;
	var $lOptionCnt;
	var $lRecPerRow;
	var $lColCnt;
	var $sDeleteConfirmMsg; // Delete confirm message
	var $sDbMasterFilter;
	var $sDbDetailFilter;
	var $bMasterRecordExists;	
	var $ListOptions;
	var $sMultiSelectKey;

	//
	// Page main processing
	//
	function Page_Main() {
		global $objForm, $gsSearchError, $Security, $categoria;
		$this->lDisplayRecs = 50;
		$this->lRecRange = 10;
		$this->lRecCnt = 0; // Record count

		// Search filters
		$sSrchAdvanced = ""; // Advanced search filter
		$sSrchBasic = ""; // Basic search filter
		$sFilter = "";
		$this->sSrchWhere = ""; // Search WHERE clause

		// Master/Detail
		$this->sDbMasterFilter = ""; // Master filter
		$this->sDbDetailFilter = ""; // Detail filter
		if ($this->IsPageRequest()) { // Validate request

			// Set up records per page dynamically
			$this->SetUpDisplayRecs();

			// Handle reset command
			$this->ResetCmd();

			// Get basic search criteria
			if ($gsSearchError == "")
				$sSrchBasic = $this->BasicSearchWhere();

			// Set Up Sorting Order
			$this->SetUpSortOrder();
		} // End Validate Request

		// Restore display records
		if ($categoria->getRecordsPerPage() <> "") {
			$this->lDisplayRecs = $categoria->getRecordsPerPage(); // Restore from Session
		} else {
			$this->lDisplayRecs = 50; // Load default
		}

		// Load Sorting Order
		$this->LoadSortOrder();

		// Build search criteria
		if ($sSrchAdvanced <> "")
			$this->sSrchWhere = ($this->sSrchWhere <> "") ? "($this->sSrchWhere) AND ($sSrchAdvanced)" : $sSrchAdvanced;
		if ($sSrchBasic <> "")
			$this->sSrchWhere = ($this->sSrchWhere <> "") ? "($this->sSrchWhere) AND ($sSrchBasic)" : $sSrchBasic;

		// Call Recordset_Searching event
		$categoria->Recordset_Searching($this->sSrchWhere);

		// Save search criteria
		if ($this->sSrchWhere <> "") {
			if ($sSrchBasic == "")
				$this->ResetBasicSearchParms();
			$categoria->setSearchWhere($this->sSrchWhere); // Save to Session
			$this->lStartRec = 1; // Reset start record counter
			$categoria->setStartRecordNumber($this->lStartRec);
		} else {
			$this->RestoreSearchParms();
		}

		// Build filter
		$sFilter = "";
		if ($this->sDbDetailFilter <> "")
			$sFilter = ($sFilter <> "") ? "($sFilter) AND (" . $this->sDbDetailFilter . ")" : $this->sDbDetailFilter;
		if ($this->sSrchWhere <> "")
			$sFilter = ($sFilter <> "") ? "($sFilter) AND (". $this->sSrchWhere . ")" : $this->sSrchWhere;

		// Set up filter in Session
		$categoria->setSessionWhere($sFilter);
		$categoria->CurrentFilter = "";

		// Export data only
		if (in_array($categoria->Export, array("html","word","excel","xml","csv"))) {
			$this->ExportData();
			$this->Page_Terminate(); // Terminate response
			exit();
		}
	}

	// Set up number of records displayed per page
	function SetUpDisplayRecs() {
		global $categoria;
		$sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];
		if ($sWrk <> "") {
			if (is_numeric($sWrk)) {
				$this->lDisplayRecs = intval($sWrk);
			} else {
				if (strtolower($sWrk) == "all") { // Display all records
					$this->lDisplayRecs = -1;
				} else {
					$this->lDisplayRecs = 50; // Non-numeric, load default
				}
			}
			$categoria->setRecordsPerPage($this->lDisplayRecs); // Save to Session

			// Reset start position
			$this->lStartRec = 1;
			$categoria->setStartRecordNumber($this->lStartRec);
		}
	}

	// Return Basic Search sql
	function BasicSearchSQL($Keyword) {
		global $categoria;
		$sKeyword = ew_AdjustSql($Keyword);
		$sql = "";
		$sql .= $categoria->cod_categoria->FldExpression . " LIKE '%" . $sKeyword . "%' OR ";
		$sql .= $categoria->des_categoria->FldExpression . " LIKE '%" . $sKeyword . "%' OR ";
		$sql .= $categoria->des_imagen->FldExpression . " LIKE '%" . $sKeyword . "%' OR ";
		$sql .= $categoria->ind_activo->FldExpression . " LIKE '%" . $sKeyword . "%' OR ";
		if (substr($sql, -4) == " OR ") $sql = substr($sql, 0, strlen($sql)-4);
		return $sql;
	}

	// Return Basic Search Where based on search keyword and type
	function BasicSearchWhere() {
		global $Security, $categoria;
		$sSearchStr = "";
		$sSearchKeyword = ew_StripSlashes(@$_GET[EW_TABLE_BASIC_SEARCH]);
		$sSearchType = @$_GET[EW_TABLE_BASIC_SEARCH_TYPE];
		if ($sSearchKeyword <> "") {
			$sSearch = trim($sSearchKeyword);
			if ($sSearchType <> "") {
				while (strpos($sSearch, "  ") !== FALSE)
					$sSearch = str_replace("  ", " ", $sSearch);
				$arKeyword = explode(" ", trim($sSearch));
				foreach ($arKeyword as $sKeyword) {
					if ($sSearchStr <> "") $sSearchStr .= " " . $sSearchType . " ";
					$sSearchStr .= "(" . $this->BasicSearchSQL($sKeyword) . ")";
				}
			} else {
				$sSearchStr = $this->BasicSearchSQL($sSearch);
			}
		}
		if ($sSearchKeyword <> "") {
			$categoria->setBasicSearchKeyword($sSearchKeyword);
			$categoria->setBasicSearchType($sSearchType);
		}
		return $sSearchStr;
	}

	// Clear all search parameters
	function ResetSearchParms() {

		// Clear search where
		global $categoria;
		$this->sSrchWhere = "";
		$categoria->setSearchWhere($this->sSrchWhere);

		// Clear basic search parameters
		$this->ResetBasicSearchParms();
	}

	// Clear all basic search parameters
	function ResetBasicSearchParms() {

		// Clear basic search parameters
		global $categoria;
		$categoria->setBasicSearchKeyword("");
		$categoria->setBasicSearchType("");
	}

	// Restore all search parameters
	function RestoreSearchParms() {
		global $gsSearchError, $categoria;
		$this->sSrchWhere = $categoria->getSearchWhere();
	}

	// Set up Sort parameters based on Sort Links clicked
	function SetUpSortOrder() {
		global $categoria;

		// Check for an Order parameter
		if (@$_GET["order"] <> "") {
			$categoria->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
			$categoria->CurrentOrderType = @$_GET["ordertype"];
			$categoria->UpdateSort($categoria->cod_categoria); // Field 
			$categoria->UpdateSort($categoria->des_categoria); // Field 
			$categoria->UpdateSort($categoria->des_imagen); // Field 
			$categoria->UpdateSort($categoria->margen); // Field 
			$categoria->UpdateSort($categoria->displayCat); // Field 
			$categoria->UpdateSort($categoria->orden); // Field 
			$categoria->setStartRecordNumber(1); // Reset start position
		}
	}

	// Load Sort Order parameters
	function LoadSortOrder() {
		global $categoria;
		$sOrderBy = $categoria->getSessionOrderBy(); // Get order by from Session
		if ($sOrderBy == "") {
			if ($categoria->SqlOrderBy() <> "") {
				$sOrderBy = $categoria->SqlOrderBy();
				$categoria->setSessionOrderBy($sOrderBy);
				$categoria->orden->setSort("ASC");
			}
		}
	}

	// Reset command based on querystring parameter cmd=
	// - RESET: reset search parameters
	// - RESETALL: reset search & master/detail parameters
	// - RESETSORT: reset sort parameters
	function ResetCmd() {
		global $categoria;

		// Get reset cmd
		if (@$_GET["cmd"] <> "") {
			$sCmd = $_GET["cmd"];

			// Reset search criteria
			if (strtolower($sCmd) == "reset" || strtolower($sCmd) == "resetall")
				$this->ResetSearchParms();

			// Reset sort criteria
			if (strtolower($sCmd) == "resetsort") {
				$sOrderBy = "";
				$categoria->setSessionOrderBy($sOrderBy);
				$categoria->cod_categoria->setSort("");
				$categoria->des_categoria->setSort("");
				$categoria->des_imagen->setSort("");
				$categoria->margen->setSort("");
				$categoria->displayCat->setSort("");
				$categoria->orden->setSort("");
			}

			// Reset start position
			$this->lStartRec = 1;
			$categoria->setStartRecordNumber($this->lStartRec);
		}
	}

	// Set up Starting Record parameters based on Pager Navigation
	function SetUpStartRec() {
		global $categoria;
		if ($this->lDisplayRecs == 0)
			return;
		if ($this->IsPageRequest()) { // Validate request			
			if (@$_GET[EW_TABLE_START_REC] <> "") { // Check for "start" parameter
				$this->lStartRec = $_GET[EW_TABLE_START_REC];
				$categoria->setStartRecordNumber($this->lStartRec);
			} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
				$this->nPageNo = $_GET[EW_TABLE_PAGE_NO];
				if (is_numeric($this->nPageNo)) {
					$this->lStartRec = ($this->nPageNo-1)*$this->lDisplayRecs+1;
					if ($this->lStartRec <= 0) {
						$this->lStartRec = 1;
					} elseif ($this->lStartRec >= intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1) {
						$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1;
					}
					$categoria->setStartRecordNumber($this->lStartRec);
				}
			}
		}
		$this->lStartRec = $categoria->getStartRecordNumber();

		// Check if correct start record counter
		if (!is_numeric($this->lStartRec) || $this->lStartRec == "") { // Avoid invalid start record counter
			$this->lStartRec = 1; // Reset start record counter
			$categoria->setStartRecordNumber($this->lStartRec);
		} elseif (intval($this->lStartRec) > intval($this->lTotalRecs)) { // Avoid starting record > total records
			$this->lStartRec = intval(($this->lTotalRecs-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to last page first record
			$categoria->setStartRecordNumber($this->lStartRec);
		} elseif (($this->lStartRec-1) % $this->lDisplayRecs <> 0) {
			$this->lStartRec = intval(($this->lStartRec-1)/$this->lDisplayRecs)*$this->lDisplayRecs+1; // Point to page boundary
			$categoria->setStartRecordNumber($this->lStartRec);
		}
	}

	// Load recordset
	function LoadRecordset($offset = -1, $rowcnt = -1) {
		global $conn, $categoria;

		// Call Recordset Selecting event
		$categoria->Recordset_Selecting($categoria->CurrentFilter);

		// Load list page SQL
		$sSql = $categoria->SelectSQL();
		if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt";

		// Load recordset
		$conn->raiseErrorFn = 'ew_ErrorFn';	
		$rs = $conn->Execute($sSql);
		$conn->raiseErrorFn = '';

		// Call Recordset Selected event
		$categoria->Recordset_Selected($rs);
		return $rs;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $categoria;
		$sFilter = $categoria->KeyFilter();

		// Call Row Selecting event
		$categoria->Row_Selecting($sFilter);

		// Load sql based on filter
		$categoria->CurrentFilter = $sFilter;
		$sSql = $categoria->SQL();
		if ($rs = $conn->Execute($sSql)) {
			if ($rs->EOF) {
				$LoadRow = FALSE;
			} else {
				$LoadRow = TRUE;
				$rs->MoveFirst();
				$this->LoadRowValues($rs); // Load row values

				// Call Row Selected event
				$categoria->Row_Selected($rs);
			}
			$rs->Close();
		} else {
			$LoadRow = FALSE;
		}
		return $LoadRow;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $categoria;
		$categoria->cod_categoria->setDbValue($rs->fields('cod_categoria'));
		$categoria->des_categoria->setDbValue($rs->fields('des_categoria'));
		$categoria->des_imagen->Upload->DbValue = $rs->fields('des_imagen');
		$categoria->ind_activo->setDbValue($rs->fields('ind_activo'));
		$categoria->margen->setDbValue($rs->fields('margen'));
		$categoria->displayConf->setDbValue($rs->fields('displayConf'));
		$categoria->displayCat->setDbValue($rs->fields('displayCat'));
		$categoria->ind_cat->setDbValue($rs->fields('ind_cat'));
		$categoria->orden->setDbValue($rs->fields('orden'));
		$categoria->cod_usuario_registro->setDbValue($rs->fields('cod_usuario_registro'));
		$categoria->fec_registro->setDbValue($rs->fields('fec_registro'));
		$categoria->cod_usuario_modificacion->setDbValue($rs->fields('cod_usuario_modificacion'));
		$categoria->fec_ultima_modificacion->setDbValue($rs->fields('fec_ultima_modificacion'));
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $categoria;

		// Call Row_Rendering event
		$categoria->Row_Rendering();

		// Common render codes for all row types
		// cod_categoria

		$categoria->cod_categoria->CellCssStyle = "";
		$categoria->cod_categoria->CellCssClass = "";

		// des_categoria
		$categoria->des_categoria->CellCssStyle = "";
		$categoria->des_categoria->CellCssClass = "";

		// des_imagen
		$categoria->des_imagen->CellCssStyle = "";
		$categoria->des_imagen->CellCssClass = "";

		// margen
		$categoria->margen->CellCssStyle = "";
		$categoria->margen->CellCssClass = "";

		// displayCat
		$categoria->displayCat->CellCssStyle = "";
		$categoria->displayCat->CellCssClass = "";

		// orden
		$categoria->orden->CellCssStyle = "";
		$categoria->orden->CellCssClass = "";
		if ($categoria->RowType == EW_ROWTYPE_VIEW) { // View row

			// cod_categoria
			$categoria->cod_categoria->ViewValue = $categoria->cod_categoria->CurrentValue;
			$categoria->cod_categoria->CssStyle = "";
			$categoria->cod_categoria->CssClass = "";
			$categoria->cod_categoria->ViewCustomAttributes = "";

			// des_categoria
			$categoria->des_categoria->ViewValue = $categoria->des_categoria->CurrentValue;
			$categoria->des_categoria->CssStyle = "";
			$categoria->des_categoria->CssClass = "";
			$categoria->des_categoria->ViewCustomAttributes = "";

			// des_imagen
			if (!is_null($categoria->des_imagen->Upload->DbValue)) {
				$categoria->des_imagen->ViewValue = $categoria->des_imagen->Upload->DbValue;
				$categoria->des_imagen->ImageWidth = 120;
				$categoria->des_imagen->ImageHeight = 0;
				$categoria->des_imagen->ImageAlt = "";
			} else {
				$categoria->des_imagen->ViewValue = "";
			}
			$categoria->des_imagen->CssStyle = "";
			$categoria->des_imagen->CssClass = "";
			$categoria->des_imagen->ViewCustomAttributes = "";

			// margen
			$categoria->margen->ViewValue = $categoria->margen->CurrentValue;
			$categoria->margen->CssStyle = "";
			$categoria->margen->CssClass = "";
			$categoria->margen->ViewCustomAttributes = "";

			// displayCat
			if (strval($categoria->displayCat->CurrentValue) <> "") {
				switch ($categoria->displayCat->CurrentValue) {
					case "1":
						$categoria->displayCat->ViewValue = "Si";
						break;
					case "0":
						$categoria->displayCat->ViewValue = "No";
						break;
					default:
						$categoria->displayCat->ViewValue = $categoria->displayCat->CurrentValue;
				}
			} else {
				$categoria->displayCat->ViewValue = NULL;
			}
			$categoria->displayCat->CssStyle = "";
			$categoria->displayCat->CssClass = "";
			$categoria->displayCat->ViewCustomAttributes = "";

			// orden
			$categoria->orden->ViewValue = $categoria->orden->CurrentValue;
			$categoria->orden->CssStyle = "";
			$categoria->orden->CssClass = "";
			$categoria->orden->ViewCustomAttributes = "";

			// cod_categoria
			$categoria->cod_categoria->HrefValue = "";

			// des_categoria
			$categoria->des_categoria->HrefValue = "";

			// des_imagen
			$categoria->des_imagen->HrefValue = "";

			// margen
			$categoria->margen->HrefValue = "";

			// displayCat
			$categoria->displayCat->HrefValue = "";

			// orden
			$categoria->orden->HrefValue = "";
		}

		// Call Row Rendered event
		$categoria->Row_Rendered();
	}

	// Export data in XML or CSV format
	function ExportData() {
		global $categoria;
		$sCsvStr = "";

		// Default export style
		$sExportStyle = "h";

		// Load recordset
		$rs = $this->LoadRecordset();
		$this->lTotalRecs = $rs->RecordCount();
		$this->lStartRec = 1;

		// Export all
		if ($categoria->ExportAll) {
			$this->lStopRec = $this->lTotalRecs;
		} else { // Export 1 page only
			$this->SetUpStartRec(); // Set up start record position

			// Set the last record to display
			if ($this->lDisplayRecs < 0) {
				$this->lStopRec = $this->lTotalRecs;
			} else {
				$this->lStopRec = $this->lStartRec + $this->lDisplayRecs - 1;
			}
		}
		if ($categoria->Export == "xml") {
			$XmlDoc = new cXMLDocument();
		} else {
			echo ew_ExportHeader($categoria->Export);

			// Horizontal format, write header
			if ($sExportStyle <> "v" || $categoria->Export == "csv") {
				$sExportStr = "";
				ew_ExportAddValue($sExportStr, 'cod_categoria', $categoria->Export);
				ew_ExportAddValue($sExportStr, 'des_categoria', $categoria->Export);
				ew_ExportAddValue($sExportStr, 'des_imagen', $categoria->Export);
				ew_ExportAddValue($sExportStr, 'margen', $categoria->Export);
				ew_ExportAddValue($sExportStr, 'displayCat', $categoria->Export);
				ew_ExportAddValue($sExportStr, 'orden', $categoria->Export);
				echo ew_ExportLine($sExportStr, $categoria->Export);
			}
		}

		// Move to first record
		$this->lRecCnt = $this->lStartRec - 1;
		if (!$rs->EOF) {
			$rs->MoveFirst();
			$rs->Move($this->lStartRec - 1);
		}
		while (!$rs->EOF && $this->lRecCnt < $this->lStopRec) {
			$this->lRecCnt++;
			if (intval($this->lRecCnt) >= intval($this->lStartRec)) {
				$this->LoadRowValues($rs);

				// Render row for display
				$categoria->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->RenderRow();
				if ($categoria->Export == "xml") {
					$XmlDoc->BeginRow();
					$XmlDoc->AddField('cod_categoria', $categoria->cod_categoria->CurrentValue);
					$XmlDoc->AddField('des_categoria', $categoria->des_categoria->CurrentValue);
					$XmlDoc->AddField('des_imagen', $categoria->des_imagen->CurrentValue);
					$XmlDoc->AddField('margen', $categoria->margen->CurrentValue);
					$XmlDoc->AddField('displayCat', $categoria->displayCat->CurrentValue);
					$XmlDoc->AddField('orden', $categoria->orden->CurrentValue);
					$XmlDoc->EndRow();
				} else {
					if ($sExportStyle == "v" && $categoria->Export <> "csv") { // Vertical format
						echo ew_ExportField('cod_categoria', $categoria->cod_categoria->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						echo ew_ExportField('des_categoria', $categoria->des_categoria->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						echo ew_ExportField('des_imagen', $categoria->des_imagen->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						echo ew_ExportField('margen', $categoria->margen->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						echo ew_ExportField('displayCat', $categoria->displayCat->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						echo ew_ExportField('orden', $categoria->orden->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
					}	else { // Horizontal format
						$sExportStr = "";
						ew_ExportAddValue($sExportStr, $categoria->cod_categoria->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						ew_ExportAddValue($sExportStr, $categoria->des_categoria->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						ew_ExportAddValue($sExportStr, $categoria->des_imagen->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						ew_ExportAddValue($sExportStr, $categoria->margen->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						ew_ExportAddValue($sExportStr, $categoria->displayCat->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						ew_ExportAddValue($sExportStr, $categoria->orden->ExportValue($categoria->Export, $categoria->ExportOriginalValue), $categoria->Export);
						echo ew_ExportLine($sExportStr, $categoria->Export);
					}
				}
			}
			$rs->MoveNext();
		}

		// Close recordset
		$rs->Close();
		if ($categoria->Export == "xml") {
			header("Content-Type: text/xml");
			echo $XmlDoc->XML();
		} else {
			echo ew_ExportFooter($categoria->Export);
		}
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>
