<?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 "distribuidorinfo.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
$distribuidor_list = new cdistribuidor_list();
$Page =& $distribuidor_list;

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

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

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

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

// extend page with Form_CustomValidate function
distribuidor_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) { ?>
distribuidor_list.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
distribuidor_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 ($distribuidor->Export == "") { ?>
<?php } ?>
<?php
	$bSelectLimit = ($distribuidor->Export == "" && $distribuidor->SelectLimit);
	if (!$bSelectLimit)
		$rs = $distribuidor_list->LoadRecordset();
	$distribuidor_list->lTotalRecs = ($bSelectLimit) ? $distribuidor->SelectRecordCount() : $rs->RecordCount();
	$distribuidor_list->lStartRec = 1;
	if ($distribuidor_list->lDisplayRecs <= 0) // Display all records
		$distribuidor_list->lDisplayRecs = $distribuidor_list->lTotalRecs;
	if (!($distribuidor->ExportAll && $distribuidor->Export <> ""))
		$distribuidor_list->SetUpStartRec(); // Set up start record position
	if ($bSelectLimit)
		$rs = $distribuidor_list->LoadRecordset($distribuidor_list->lStartRec-1, $distribuidor_list->lDisplayRecs);
?>
<p><span class="phpmaker" style="white-space: nowrap;">TABLA: Distribuidor
<?php if ($distribuidor->Export == "" && $distribuidor->CurrentAction == "") { ?>
&nbsp;&nbsp;<a href="<?php echo $distribuidor_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 $distribuidor_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 $distribuidor_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 ($distribuidor->Export == "" && $distribuidor->CurrentAction == "") { ?>
<a href="javascript:ew_ToggleSearchPanel(distribuidor_list);" style="text-decoration: none;"><img id="distribuidor_list_SearchImage" src="images/collapse.gif" alt="" width="9" height="9" border="0"></a><span class="phpmaker">&nbsp;Buscar</span><br>
<div id="distribuidor_list_SearchPanel">
<form name="fdistribuidorlistsrch" id="fdistribuidorlistsrch" class="ewForm" action="<?php echo ew_CurrentPage() ?>">
<input type="hidden" id="t" name="t" value="distribuidor">
<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($distribuidor->getBasicSearchKeyword()) ?>">
			<input type="Submit" name="Submit" id="Submit" value="Buscar (*)">&nbsp;
			<a href="<?php echo $distribuidor_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 ($distribuidor->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 ($distribuidor->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 ($distribuidor->getBasicSearchType() == "OR") { ?> checked="checked"<?php } ?>>Cualquier palabra</label></span></td>
	</tr>
</table>
</form>
</div>
<?php } ?>
<?php } ?>
<?php $distribuidor_list->ShowMessage() ?>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<form name="fdistribuidorlist" id="fdistribuidorlist" class="ewForm" action="" method="post">
<?php if ($distribuidor_list->lTotalRecs > 0) { ?>
<table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<?php
	$distribuidor_list->lOptionCnt = 0;
if ($Security->IsLoggedIn()) {
	$distribuidor_list->lOptionCnt++; // view
}
if ($Security->IsLoggedIn()) {
	$distribuidor_list->lOptionCnt++; // edit
}
if ($Security->IsLoggedIn()) {
	$distribuidor_list->lOptionCnt++; // copy
}
if ($Security->IsLoggedIn()) {
	$distribuidor_list->lOptionCnt++; // Delete
}
	$distribuidor_list->lOptionCnt += count($distribuidor_list->ListOptions->Items); // Custom list options
?>
<?php echo $distribuidor->TableCustomInnerHtml ?>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<?php if ($distribuidor->id_distribuidor->Visible) { // id_distribuidor ?>
	<?php if ($distribuidor->SortUrl($distribuidor->id_distribuidor) == "") { ?>
		<td>Id Distribuidor</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $distribuidor->SortUrl($distribuidor->id_distribuidor) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>Id Distribuidor</td><td style="width: 10px;"><?php if ($distribuidor->id_distribuidor->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($distribuidor->id_distribuidor->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($distribuidor->empresa->Visible) { // empresa ?>
	<?php if ($distribuidor->SortUrl($distribuidor->empresa) == "") { ?>
		<td>Empresa</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $distribuidor->SortUrl($distribuidor->empresa) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>Empresa&nbsp;(*)</td><td style="width: 10px;"><?php if ($distribuidor->empresa->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($distribuidor->empresa->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($distribuidor->contacto->Visible) { // contacto ?>
	<?php if ($distribuidor->SortUrl($distribuidor->contacto) == "") { ?>
		<td>Contacto</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $distribuidor->SortUrl($distribuidor->contacto) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>Contacto&nbsp;(*)</td><td style="width: 10px;"><?php if ($distribuidor->contacto->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($distribuidor->contacto->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($distribuidor->email->Visible) { // email ?>
	<?php if ($distribuidor->SortUrl($distribuidor->email) == "") { ?>
		<td>Email</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $distribuidor->SortUrl($distribuidor->email) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>Email&nbsp;(*)</td><td style="width: 10px;"><?php if ($distribuidor->email->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($distribuidor->email->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($distribuidor->habilitado->Visible) { // habilitado ?>
	<?php if ($distribuidor->SortUrl($distribuidor->habilitado) == "") { ?>
		<td>Habilitado</td>
	<?php } else { ?>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<?php echo $distribuidor->SortUrl($distribuidor->habilitado) ?>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>Habilitado</td><td style="width: 10px;"><?php if ($distribuidor->habilitado->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($distribuidor->habilitado->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></td></tr></table>
		</td>
	<?php } ?>
<?php } ?>		
<?php if ($distribuidor->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

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

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

	// Render row
	$distribuidor_list->RenderRow();
?>
	<tr<?php echo $distribuidor->RowAttributes() ?>>
	<?php if ($distribuidor->id_distribuidor->Visible) { // id_distribuidor ?>
		<td<?php echo $distribuidor->id_distribuidor->CellAttributes() ?>>
<div<?php echo $distribuidor->id_distribuidor->ViewAttributes() ?>><?php echo $distribuidor->id_distribuidor->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($distribuidor->empresa->Visible) { // empresa ?>
		<td<?php echo $distribuidor->empresa->CellAttributes() ?>>
<div<?php echo $distribuidor->empresa->ViewAttributes() ?>><?php echo $distribuidor->empresa->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($distribuidor->contacto->Visible) { // contacto ?>
		<td<?php echo $distribuidor->contacto->CellAttributes() ?>>
<div<?php echo $distribuidor->contacto->ViewAttributes() ?>><?php echo $distribuidor->contacto->ListViewValue() ?></div>
</td>
	<?php } ?>
	<?php if ($distribuidor->email->Visible) { // email ?>
		<td<?php echo $distribuidor->email->CellAttributes() ?>>
<div<?php echo $distribuidor->email->ViewAttributes() ?>>
<?php if ($distribuidor->email->HrefValue <> "") { ?>
<a href="mailto:<?php echo $distribuidor->email->HrefValue ?>"><?php echo $distribuidor->email->ListViewValue() ?></a>
<?php } else { ?>
<?php echo $distribuidor->email->ListViewValue() ?>
<?php } ?>
</div>
</td>
	<?php } ?>
	<?php if ($distribuidor->habilitado->Visible) { // habilitado ?>
		<td<?php echo $distribuidor->habilitado->CellAttributes() ?>>
<div<?php echo $distribuidor->habilitado->ViewAttributes() ?>><?php echo $distribuidor->habilitado->ListViewValue() ?></div>
</td>
	<?php } ?>
<?php if ($distribuidor->Export == "") { ?>
<?php if ($Security->IsLoggedIn()) { ?>
<td style="white-space: nowrap;"><span class="phpmaker">
<a href="<?php echo $distribuidor->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 $distribuidor->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 $distribuidor->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 $distribuidor->DeleteUrl() ?>"><img src='images/delete.gif' width='16' height='16' border='0' alt='Borrar'></a>
</span></td>
<?php } ?>
<?php

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

// Close recordset
if ($rs)
	$rs->Close();
?>
</div>
<?php if ($distribuidor->Export == "") { ?>
<div class="ewGridLowerPanel">
<?php if ($distribuidor->CurrentAction <> "gridadd" && $distribuidor->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($distribuidor_list->Pager)) $distribuidor_list->Pager = new cPrevNextPager($distribuidor_list->lStartRec, $distribuidor_list->lDisplayRecs, $distribuidor_list->lTotalRecs) ?>
<?php if ($distribuidor_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 ($distribuidor_list->Pager->FirstButton->Enabled) { ?>
	<td><a href="<?php echo $distribuidor_list->PageUrl() ?>start=<?php echo $distribuidor_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 ($distribuidor_list->Pager->PrevButton->Enabled) { ?>
	<td><a href="<?php echo $distribuidor_list->PageUrl() ?>start=<?php echo $distribuidor_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 $distribuidor_list->Pager->CurrentPage ?>" size="4"></td>
<!--next page button-->
	<?php if ($distribuidor_list->Pager->NextButton->Enabled) { ?>
	<td><a href="<?php echo $distribuidor_list->PageUrl() ?>start=<?php echo $distribuidor_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 ($distribuidor_list->Pager->LastButton->Enabled) { ?>
	<td><a href="<?php echo $distribuidor_list->PageUrl() ?>start=<?php echo $distribuidor_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 $distribuidor_list->Pager->PageCount ?></span></td>
	</tr></table>
	</td>	
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<span class="phpmaker">Registros <?php echo $distribuidor_list->Pager->FromIndex ?> a <?php echo $distribuidor_list->Pager->ToIndex ?> de <?php echo $distribuidor_list->Pager->RecordCount ?></span>
<?php } else { ?>
	<?php if ($distribuidor_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 ($distribuidor_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="distribuidor">
<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 ($distribuidor_list->lDisplayRecs == 20) { ?> selected="selected"<?php } ?>>20</option>
<option value="50"<?php if ($distribuidor_list->lDisplayRecs == 50) { ?> selected="selected"<?php } ?>>50</option>
<option value="ALL"<?php if ($distribuidor->getRecordsPerPage() == -1) { ?> selected="selected"<?php } ?>>Todos</option>
</select></td></tr></table>
		</td>
<?php } ?>
	</tr>
</table>
</form>
<?php } ?>
<?php //if ($distribuidor_list->lTotalRecs > 0) { ?>
<span class="phpmaker">
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $distribuidor->AddUrl() ?>">Agregar</a>&nbsp;&nbsp;
<?php } ?>
</span>
<?php //} ?>
</div>
<?php } ?>
</td></tr></table>
<?php if ($distribuidor->Export == "" && $distribuidor->CurrentAction == "") { ?>
<script type="text/javascript">
<!--

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

</script>
<?php } ?>
<?php if ($distribuidor->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 cdistribuidor_list {

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

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

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

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

	// Page Url
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $distribuidor;
		if ($distribuidor->UseTokenInUrl) $PageUrl .= "t=" . $distribuidor->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, $distribuidor;
		if ($distribuidor->UseTokenInUrl) {

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

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

		// Initialize table object
		$GLOBALS["distribuidor"] = new cdistribuidor();

		// 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", 'distribuidor', TRUE);

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

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

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

		// Save search criteria
		if ($this->sSrchWhere <> "") {
			if ($sSrchBasic == "")
				$this->ResetBasicSearchParms();
			$distribuidor->setSearchWhere($this->sSrchWhere); // Save to Session
			$this->lStartRec = 1; // Reset start record counter
			$distribuidor->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
		$distribuidor->setSessionWhere($sFilter);
		$distribuidor->CurrentFilter = "";

		// Export data only
		if (in_array($distribuidor->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 $distribuidor;
		$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
				}
			}
			$distribuidor->setRecordsPerPage($this->lDisplayRecs); // Save to Session

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

	// Return Basic Search sql
	function BasicSearchSQL($Keyword) {
		global $distribuidor;
		$sKeyword = ew_AdjustSql($Keyword);
		$sql = "";
		$sql .= $distribuidor->empresa->FldExpression . " LIKE '%" . $sKeyword . "%' OR ";
		$sql .= $distribuidor->contacto->FldExpression . " LIKE '%" . $sKeyword . "%' OR ";
		$sql .= $distribuidor->email->FldExpression . " LIKE '%" . $sKeyword . "%' OR ";
		$sql .= $distribuidor->direccion->FldExpression . " LIKE '%" . $sKeyword . "%' OR ";
		$sql .= $distribuidor->telefonos->FldExpression . " LIKE '%" . $sKeyword . "%' OR ";
		$sql .= $distribuidor->password->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, $distribuidor;
		$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 <> "") {
			$distribuidor->setBasicSearchKeyword($sSearchKeyword);
			$distribuidor->setBasicSearchType($sSearchType);
		}
		return $sSearchStr;
	}

	// Clear all search parameters
	function ResetSearchParms() {

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

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

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

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

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

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

		// Check for an Order parameter
		if (@$_GET["order"] <> "") {
			$distribuidor->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
			$distribuidor->CurrentOrderType = @$_GET["ordertype"];
			$distribuidor->UpdateSort($distribuidor->id_distribuidor); // Field 
			$distribuidor->UpdateSort($distribuidor->empresa); // Field 
			$distribuidor->UpdateSort($distribuidor->contacto); // Field 
			$distribuidor->UpdateSort($distribuidor->email); // Field 
			$distribuidor->UpdateSort($distribuidor->habilitado); // Field 
			$distribuidor->setStartRecordNumber(1); // Reset start position
		}
	}

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

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

		// 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 = "";
				$distribuidor->setSessionOrderBy($sOrderBy);
				$distribuidor->id_distribuidor->setSort("");
				$distribuidor->empresa->setSort("");
				$distribuidor->contacto->setSort("");
				$distribuidor->email->setSort("");
				$distribuidor->habilitado->setSort("");
			}

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

	// Set up Starting Record parameters based on Pager Navigation
	function SetUpStartRec() {
		global $distribuidor;
		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];
				$distribuidor->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;
					}
					$distribuidor->setStartRecordNumber($this->lStartRec);
				}
			}
		}
		$this->lStartRec = $distribuidor->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
			$distribuidor->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
			$distribuidor->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
			$distribuidor->setStartRecordNumber($this->lStartRec);
		}
	}

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

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

		// Load list page SQL
		$sSql = $distribuidor->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
		$distribuidor->Recordset_Selected($rs);
		return $rs;
	}

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

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

		// Load sql based on filter
		$distribuidor->CurrentFilter = $sFilter;
		$sSql = $distribuidor->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
				$distribuidor->Row_Selected($rs);
			}
			$rs->Close();
		} else {
			$LoadRow = FALSE;
		}
		return $LoadRow;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $distribuidor;
		$distribuidor->id_distribuidor->setDbValue($rs->fields('id_distribuidor'));
		$distribuidor->empresa->setDbValue($rs->fields('empresa'));
		$distribuidor->contacto->setDbValue($rs->fields('contacto'));
		$distribuidor->email->setDbValue($rs->fields('email'));
		$distribuidor->direccion->setDbValue($rs->fields('direccion'));
		$distribuidor->telefonos->setDbValue($rs->fields('telefonos'));
		$distribuidor->password->setDbValue($rs->fields('password'));
		$distribuidor->habilitado->setDbValue($rs->fields('habilitado'));
	}

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

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

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

		$distribuidor->id_distribuidor->CellCssStyle = "";
		$distribuidor->id_distribuidor->CellCssClass = "";

		// empresa
		$distribuidor->empresa->CellCssStyle = "";
		$distribuidor->empresa->CellCssClass = "";

		// contacto
		$distribuidor->contacto->CellCssStyle = "";
		$distribuidor->contacto->CellCssClass = "";

		// email
		$distribuidor->email->CellCssStyle = "";
		$distribuidor->email->CellCssClass = "";

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

			// id_distribuidor
			$distribuidor->id_distribuidor->ViewValue = $distribuidor->id_distribuidor->CurrentValue;
			$distribuidor->id_distribuidor->CssStyle = "";
			$distribuidor->id_distribuidor->CssClass = "";
			$distribuidor->id_distribuidor->ViewCustomAttributes = "";

			// empresa
			$distribuidor->empresa->ViewValue = $distribuidor->empresa->CurrentValue;
			$distribuidor->empresa->CssStyle = "";
			$distribuidor->empresa->CssClass = "";
			$distribuidor->empresa->ViewCustomAttributes = "";

			// contacto
			$distribuidor->contacto->ViewValue = $distribuidor->contacto->CurrentValue;
			$distribuidor->contacto->CssStyle = "";
			$distribuidor->contacto->CssClass = "";
			$distribuidor->contacto->ViewCustomAttributes = "";

			// email
			$distribuidor->email->ViewValue = $distribuidor->email->CurrentValue;
			$distribuidor->email->CssStyle = "";
			$distribuidor->email->CssClass = "";
			$distribuidor->email->ViewCustomAttributes = "";

			// direccion
			$distribuidor->direccion->ViewValue = $distribuidor->direccion->CurrentValue;
			$distribuidor->direccion->CssStyle = "";
			$distribuidor->direccion->CssClass = "";
			$distribuidor->direccion->ViewCustomAttributes = "";

			// telefonos
			$distribuidor->telefonos->ViewValue = $distribuidor->telefonos->CurrentValue;
			$distribuidor->telefonos->CssStyle = "";
			$distribuidor->telefonos->CssClass = "";
			$distribuidor->telefonos->ViewCustomAttributes = "";

			// password
			$distribuidor->password->ViewValue = "********";
			$distribuidor->password->CssStyle = "";
			$distribuidor->password->CssClass = "";
			$distribuidor->password->ViewCustomAttributes = "";

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

			// id_distribuidor
			$distribuidor->id_distribuidor->HrefValue = "";

			// empresa
			$distribuidor->empresa->HrefValue = "";

			// contacto
			$distribuidor->contacto->HrefValue = "";

			// email
			if (!is_null($distribuidor->email->CurrentValue)) {
				$distribuidor->email->HrefValue = ((!empty($distribuidor->email->ViewValue)) ? $distribuidor->email->ViewValue : $distribuidor->email->CurrentValue);
				if ($distribuidor->Export <> "") $distribuidor->email->HrefValue = ew_ConvertFullUrl($distribuidor->email->HrefValue);
			} else {
				$distribuidor->email->HrefValue = "";
			}

			// habilitado
			$distribuidor->habilitado->HrefValue = "";
		}

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

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

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

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

		// Export all
		if ($distribuidor->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 ($distribuidor->Export == "xml") {
			$XmlDoc = new cXMLDocument();
		} else {
			echo ew_ExportHeader($distribuidor->Export);

			// Horizontal format, write header
			if ($sExportStyle <> "v" || $distribuidor->Export == "csv") {
				$sExportStr = "";
				ew_ExportAddValue($sExportStr, 'id_distribuidor', $distribuidor->Export);
				ew_ExportAddValue($sExportStr, 'empresa', $distribuidor->Export);
				ew_ExportAddValue($sExportStr, 'contacto', $distribuidor->Export);
				ew_ExportAddValue($sExportStr, 'email', $distribuidor->Export);
				ew_ExportAddValue($sExportStr, 'direccion', $distribuidor->Export);
				ew_ExportAddValue($sExportStr, 'telefonos', $distribuidor->Export);
				ew_ExportAddValue($sExportStr, 'password', $distribuidor->Export);
				ew_ExportAddValue($sExportStr, 'habilitado', $distribuidor->Export);
				echo ew_ExportLine($sExportStr, $distribuidor->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
				$distribuidor->RowType = EW_ROWTYPE_VIEW; // Render view
				$this->RenderRow();
				if ($distribuidor->Export == "xml") {
					$XmlDoc->BeginRow();
					$XmlDoc->AddField('id_distribuidor', $distribuidor->id_distribuidor->CurrentValue);
					$XmlDoc->AddField('empresa', $distribuidor->empresa->CurrentValue);
					$XmlDoc->AddField('contacto', $distribuidor->contacto->CurrentValue);
					$XmlDoc->AddField('email', $distribuidor->email->CurrentValue);
					$XmlDoc->AddField('direccion', $distribuidor->direccion->CurrentValue);
					$XmlDoc->AddField('telefonos', $distribuidor->telefonos->CurrentValue);
					$XmlDoc->AddField('password', $distribuidor->password->CurrentValue);
					$XmlDoc->AddField('habilitado', $distribuidor->habilitado->CurrentValue);
					$XmlDoc->EndRow();
				} else {
					if ($sExportStyle == "v" && $distribuidor->Export <> "csv") { // Vertical format
						echo ew_ExportField('id_distribuidor', $distribuidor->id_distribuidor->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						echo ew_ExportField('empresa', $distribuidor->empresa->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						echo ew_ExportField('contacto', $distribuidor->contacto->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						echo ew_ExportField('email', $distribuidor->email->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						echo ew_ExportField('direccion', $distribuidor->direccion->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						echo ew_ExportField('telefonos', $distribuidor->telefonos->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						echo ew_ExportField('password', $distribuidor->password->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						echo ew_ExportField('habilitado', $distribuidor->habilitado->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
					}	else { // Horizontal format
						$sExportStr = "";
						ew_ExportAddValue($sExportStr, $distribuidor->id_distribuidor->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						ew_ExportAddValue($sExportStr, $distribuidor->empresa->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						ew_ExportAddValue($sExportStr, $distribuidor->contacto->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						ew_ExportAddValue($sExportStr, $distribuidor->email->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						ew_ExportAddValue($sExportStr, $distribuidor->direccion->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						ew_ExportAddValue($sExportStr, $distribuidor->telefonos->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						ew_ExportAddValue($sExportStr, $distribuidor->password->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						ew_ExportAddValue($sExportStr, $distribuidor->habilitado->ExportValue($distribuidor->Export, $distribuidor->ExportOriginalValue), $distribuidor->Export);
						echo ew_ExportLine($sExportStr, $distribuidor->Export);
					}
				}
			}
			$rs->MoveNext();
		}

		// Close recordset
		$rs->Close();
		if ($distribuidor->Export == "xml") {
			header("Content-Type: text/xml");
			echo $XmlDoc->XML();
		} else {
			echo ew_ExportFooter($distribuidor->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;
	}
}
?>
