<?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 "pv_deltron_catinfo.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
$pv_deltron_cat_view = new cpv_deltron_cat_view();
$Page =& $pv_deltron_cat_view;

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

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

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

// page properties
pv_deltron_cat_view.PageID = "view"; // page ID
var EW_PAGE_ID = pv_deltron_cat_view.PageID; // for backward compatibility

// extend page with Form_CustomValidate function
pv_deltron_cat_view.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) { ?>
pv_deltron_cat_view.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
pv_deltron_cat_view.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</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 } ?>
<p><span class="phpmaker"><img src='images/browse.gif' width='16' height='16' border='0' alt='Ver'> TABLA: DTcat
<br><br>
<?php if ($pv_deltron_cat->Export == "") { ?>
<a href="pv_deltron_catlist.php">Regresar al Listado</a>&nbsp;
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $pv_deltron_cat->AddUrl() ?>"><img src='images/add.gif' width='16' height='16' border='0' alt='Agregar'></a>&nbsp;
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $pv_deltron_cat->EditUrl() ?>"><img src='images/edit.gif' width='16' height='16' border='0' alt='Editar'></a>&nbsp;
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $pv_deltron_cat->CopyUrl() ?>"><img src='images/copy.gif' width='16' height='16' border='0' alt='Copiar'></a>&nbsp;
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $pv_deltron_cat->DeleteUrl() ?>"><img src='images/delete.gif' width='16' height='16' border='0' alt='Borrar'></a>&nbsp;
<?php } ?>
<?php if ($Security->IsLoggedIn()) { ?>
<a href="pv_deltronlist.php?<?php echo EW_TABLE_SHOW_MASTER ?>=pv_deltron_cat&categoria=<?php echo urlencode(strval($pv_deltron_cat->categoria->CurrentValue)) ?>">DTprod<img src='images/detail.gif' width='16' height='16' border='0' alt='Detalles'></a>
&nbsp;
<?php } ?>
<?php } ?>
</span></p>
<?php $pv_deltron_cat_view->ShowMessage() ?>
<p>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($pv_deltron_cat->id->Visible) { // id ?>
	<tr<?php echo $pv_deltron_cat->id->RowAttributes ?>>
		<td class="ewTableHeader">Id</td>
		<td<?php echo $pv_deltron_cat->id->CellAttributes() ?>>
<div<?php echo $pv_deltron_cat->id->ViewAttributes() ?>><?php echo $pv_deltron_cat->id->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($pv_deltron_cat->categoria->Visible) { // categoria ?>
	<tr<?php echo $pv_deltron_cat->categoria->RowAttributes ?>>
		<td class="ewTableHeader">Categoria</td>
		<td<?php echo $pv_deltron_cat->categoria->CellAttributes() ?>>
<div<?php echo $pv_deltron_cat->categoria->ViewAttributes() ?>><?php echo $pv_deltron_cat->categoria->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($pv_deltron_cat->margen->Visible) { // margen ?>
	<tr<?php echo $pv_deltron_cat->margen->RowAttributes ?>>
		<td class="ewTableHeader">Margen</td>
		<td<?php echo $pv_deltron_cat->margen->CellAttributes() ?>>
<div<?php echo $pv_deltron_cat->margen->ViewAttributes() ?>><?php echo $pv_deltron_cat->margen->ViewValue ?></div></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<?php if ($pv_deltron_cat->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 cpv_deltron_cat_view {

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

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

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

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

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

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

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

		// Initialize table object
		$GLOBALS["pv_deltron_cat"] = new cpv_deltron_cat();

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

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

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

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

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $pv_deltron_cat;
		global $Security;
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// 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 $lRecCnt;

	//
	// Page main processing
	//
	function Page_Main() {
		global $pv_deltron_cat;
		$sReturnUrl = "";
		$bMatchRecord = FALSE;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET["id"] <> "") {
				$pv_deltron_cat->id->setQueryStringValue($_GET["id"]);
			} else {
				$sReturnUrl = "pv_deltron_catlist.php"; // Return to list
			}

			// Get action
			$pv_deltron_cat->CurrentAction = "I"; // Display form
			switch ($pv_deltron_cat->CurrentAction) {
				case "I": // Get a record to display
					if (!$this->LoadRow()) { // Load record based on key
						$this->setMessage("No se encontraron registros"); // Set no record message
						$sReturnUrl = "pv_deltron_catlist.php"; // No matching record, return to list
					}
			}
		} else {
			$sReturnUrl = "pv_deltron_catlist.php"; // Not page request, return to list
		}
		if ($sReturnUrl <> "")
			$this->Page_Terminate($sReturnUrl);

		// Render row
		$pv_deltron_cat->RowType = EW_ROWTYPE_VIEW;
		$this->RenderRow();
	}

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $pv_deltron_cat;
		$pv_deltron_cat->id->setDbValue($rs->fields('id'));
		$pv_deltron_cat->categoria->setDbValue($rs->fields('categoria'));
		$pv_deltron_cat->margen->setDbValue($rs->fields('margen'));
	}

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

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

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

		$pv_deltron_cat->id->CellCssStyle = "";
		$pv_deltron_cat->id->CellCssClass = "";

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

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

			// id
			$pv_deltron_cat->id->ViewValue = $pv_deltron_cat->id->CurrentValue;
			$pv_deltron_cat->id->CssStyle = "";
			$pv_deltron_cat->id->CssClass = "";
			$pv_deltron_cat->id->ViewCustomAttributes = "";

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

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

			// id
			$pv_deltron_cat->id->HrefValue = "";

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

			// margen
			$pv_deltron_cat->margen->HrefValue = "";
		}

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

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}
}
?>
