<?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 "solicitudes_onlineinfo.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
$solicitudes_online_view = new csolicitudes_online_view();
$Page =& $solicitudes_online_view;

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

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

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

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

// extend page with Form_CustomValidate function
solicitudes_online_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) { ?>
solicitudes_online_view.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
solicitudes_online_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: solicitudes online
<br><br>
<?php if ($solicitudes_online->Export == "") { ?>
<a href="solicitudes_onlinelist.php">Regresar al Listado</a>&nbsp;
<?php if ($Security->IsLoggedIn()) { ?>
<a href="<?php echo $solicitudes_online->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 $solicitudes_online->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 $solicitudes_online->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 $solicitudes_online->DeleteUrl() ?>"><img src='images/delete.gif' width='16' height='16' border='0' alt='Borrar'></a>&nbsp;
<?php } ?>
<?php } ?>
</span></p>
<?php $solicitudes_online_view->ShowMessage() ?>
<p>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($solicitudes_online->id->Visible) { // id ?>
	<tr<?php echo $solicitudes_online->id->RowAttributes ?>>
		<td class="ewTableHeader">id</td>
		<td<?php echo $solicitudes_online->id->CellAttributes() ?>>
<div<?php echo $solicitudes_online->id->ViewAttributes() ?>><?php echo $solicitudes_online->id->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($solicitudes_online->empresa->Visible) { // empresa ?>
	<tr<?php echo $solicitudes_online->empresa->RowAttributes ?>>
		<td class="ewTableHeader">empresa</td>
		<td<?php echo $solicitudes_online->empresa->CellAttributes() ?>>
<div<?php echo $solicitudes_online->empresa->ViewAttributes() ?>><?php echo $solicitudes_online->empresa->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($solicitudes_online->contacto->Visible) { // contacto ?>
	<tr<?php echo $solicitudes_online->contacto->RowAttributes ?>>
		<td class="ewTableHeader">contacto</td>
		<td<?php echo $solicitudes_online->contacto->CellAttributes() ?>>
<div<?php echo $solicitudes_online->contacto->ViewAttributes() ?>><?php echo $solicitudes_online->contacto->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($solicitudes_online->email->Visible) { // email ?>
	<tr<?php echo $solicitudes_online->email->RowAttributes ?>>
		<td class="ewTableHeader">email</td>
		<td<?php echo $solicitudes_online->email->CellAttributes() ?>>
<div<?php echo $solicitudes_online->email->ViewAttributes() ?>><?php echo $solicitudes_online->email->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($solicitudes_online->telefono->Visible) { // telefono ?>
	<tr<?php echo $solicitudes_online->telefono->RowAttributes ?>>
		<td class="ewTableHeader">telefono</td>
		<td<?php echo $solicitudes_online->telefono->CellAttributes() ?>>
<div<?php echo $solicitudes_online->telefono->ViewAttributes() ?>><?php echo $solicitudes_online->telefono->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($solicitudes_online->mensaje->Visible) { // mensaje ?>
	<tr<?php echo $solicitudes_online->mensaje->RowAttributes ?>>
		<td class="ewTableHeader">mensaje</td>
		<td<?php echo $solicitudes_online->mensaje->CellAttributes() ?>>
<div<?php echo $solicitudes_online->mensaje->ViewAttributes() ?>><?php echo $solicitudes_online->mensaje->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($solicitudes_online->tipo->Visible) { // tipo ?>
	<tr<?php echo $solicitudes_online->tipo->RowAttributes ?>>
		<td class="ewTableHeader">tipo</td>
		<td<?php echo $solicitudes_online->tipo->CellAttributes() ?>>
<div<?php echo $solicitudes_online->tipo->ViewAttributes() ?>><?php echo $solicitudes_online->tipo->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($solicitudes_online->cod_usuario->Visible) { // cod_usuario ?>
	<tr<?php echo $solicitudes_online->cod_usuario->RowAttributes ?>>
		<td class="ewTableHeader">cod usuario</td>
		<td<?php echo $solicitudes_online->cod_usuario->CellAttributes() ?>>
<div<?php echo $solicitudes_online->cod_usuario->ViewAttributes() ?>><?php echo $solicitudes_online->cod_usuario->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($solicitudes_online->atendido->Visible) { // atendido ?>
	<tr<?php echo $solicitudes_online->atendido->RowAttributes ?>>
		<td class="ewTableHeader">atendido</td>
		<td<?php echo $solicitudes_online->atendido->CellAttributes() ?>>
<div<?php echo $solicitudes_online->atendido->ViewAttributes() ?>><?php echo $solicitudes_online->atendido->ViewValue ?></div></td>
	</tr>
<?php } ?>
<?php if ($solicitudes_online->fecha_registro->Visible) { // fecha_registro ?>
	<tr<?php echo $solicitudes_online->fecha_registro->RowAttributes ?>>
		<td class="ewTableHeader">fecha registro</td>
		<td<?php echo $solicitudes_online->fecha_registro->CellAttributes() ?>>
<div<?php echo $solicitudes_online->fecha_registro->ViewAttributes() ?>><?php echo $solicitudes_online->fecha_registro->ViewValue ?></div></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<?php if ($solicitudes_online->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 csolicitudes_online_view {

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

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

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

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

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

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

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

		// Initialize table object
		$GLOBALS["solicitudes_online"] = new csolicitudes_online();

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

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

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $solicitudes_online;
		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 $solicitudes_online;
		$sReturnUrl = "";
		$bMatchRecord = FALSE;
		if ($this->IsPageRequest()) { // Validate request
			if (@$_GET["id"] <> "") {
				$solicitudes_online->id->setQueryStringValue($_GET["id"]);
			} else {
				$sReturnUrl = "solicitudes_onlinelist.php"; // Return to list
			}

			// Get action
			$solicitudes_online->CurrentAction = "I"; // Display form
			switch ($solicitudes_online->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 = "solicitudes_onlinelist.php"; // No matching record, return to list
					}
			}
		} else {
			$sReturnUrl = "solicitudes_onlinelist.php"; // Not page request, return to list
		}
		if ($sReturnUrl <> "")
			$this->Page_Terminate($sReturnUrl);

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

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

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

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

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

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $solicitudes_online;
		$solicitudes_online->id->setDbValue($rs->fields('id'));
		$solicitudes_online->empresa->setDbValue($rs->fields('empresa'));
		$solicitudes_online->contacto->setDbValue($rs->fields('contacto'));
		$solicitudes_online->email->setDbValue($rs->fields('email'));
		$solicitudes_online->telefono->setDbValue($rs->fields('telefono'));
		$solicitudes_online->mensaje->setDbValue($rs->fields('mensaje'));
		$solicitudes_online->tipo->setDbValue($rs->fields('tipo'));
		$solicitudes_online->cod_usuario->setDbValue($rs->fields('cod_usuario'));
		$solicitudes_online->atendido->setDbValue($rs->fields('atendido'));
		$solicitudes_online->fecha_registro->setDbValue($rs->fields('fecha_registro'));
	}

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

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

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

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

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

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

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

		// telefono
		$solicitudes_online->telefono->CellCssStyle = "";
		$solicitudes_online->telefono->CellCssClass = "";

		// mensaje
		$solicitudes_online->mensaje->CellCssStyle = "";
		$solicitudes_online->mensaje->CellCssClass = "";

		// tipo
		$solicitudes_online->tipo->CellCssStyle = "";
		$solicitudes_online->tipo->CellCssClass = "";

		// cod_usuario
		$solicitudes_online->cod_usuario->CellCssStyle = "";
		$solicitudes_online->cod_usuario->CellCssClass = "";

		// atendido
		$solicitudes_online->atendido->CellCssStyle = "";
		$solicitudes_online->atendido->CellCssClass = "";

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

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

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

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

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

			// telefono
			$solicitudes_online->telefono->ViewValue = $solicitudes_online->telefono->CurrentValue;
			$solicitudes_online->telefono->CssStyle = "";
			$solicitudes_online->telefono->CssClass = "";
			$solicitudes_online->telefono->ViewCustomAttributes = "";

			// mensaje
			$solicitudes_online->mensaje->ViewValue = $solicitudes_online->mensaje->CurrentValue;
			if (!is_null($solicitudes_online->mensaje->ViewValue)) $solicitudes_online->mensaje->ViewValue = str_replace("\n", "<br>", $solicitudes_online->mensaje->ViewValue); 
			$solicitudes_online->mensaje->CssStyle = "";
			$solicitudes_online->mensaje->CssClass = "";
			$solicitudes_online->mensaje->ViewCustomAttributes = "";

			// tipo
			$solicitudes_online->tipo->ViewValue = $solicitudes_online->tipo->CurrentValue;
			$solicitudes_online->tipo->CssStyle = "";
			$solicitudes_online->tipo->CssClass = "";
			$solicitudes_online->tipo->ViewCustomAttributes = "";

			// cod_usuario
			if (strval($solicitudes_online->cod_usuario->CurrentValue) <> "") {
				$sSqlWrk = "SELECT `nom_usuario_sistema` FROM `usuario` WHERE `cod_usuario` = " . ew_AdjustSql($solicitudes_online->cod_usuario->CurrentValue) . "";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup value(s) found
					$solicitudes_online->cod_usuario->ViewValue = $rswrk->fields('nom_usuario_sistema');
					$rswrk->Close();
				} else {
					$solicitudes_online->cod_usuario->ViewValue = $solicitudes_online->cod_usuario->CurrentValue;
				}
			} else {
				$solicitudes_online->cod_usuario->ViewValue = NULL;
			}
			$solicitudes_online->cod_usuario->CssStyle = "";
			$solicitudes_online->cod_usuario->CssClass = "";
			$solicitudes_online->cod_usuario->ViewCustomAttributes = "";

			// atendido
			$solicitudes_online->atendido->ViewValue = $solicitudes_online->atendido->CurrentValue;
			$solicitudes_online->atendido->ViewValue = ew_FormatDateTime($solicitudes_online->atendido->ViewValue, 5);
			$solicitudes_online->atendido->CssStyle = "";
			$solicitudes_online->atendido->CssClass = "";
			$solicitudes_online->atendido->ViewCustomAttributes = "";

			// fecha_registro
			$solicitudes_online->fecha_registro->ViewValue = $solicitudes_online->fecha_registro->CurrentValue;
			$solicitudes_online->fecha_registro->ViewValue = ew_FormatDateTime($solicitudes_online->fecha_registro->ViewValue, 5);
			$solicitudes_online->fecha_registro->CssStyle = "";
			$solicitudes_online->fecha_registro->CssClass = "";
			$solicitudes_online->fecha_registro->ViewCustomAttributes = "";

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

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

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

			// email
			$solicitudes_online->email->HrefValue = "";

			// telefono
			$solicitudes_online->telefono->HrefValue = "";

			// mensaje
			$solicitudes_online->mensaje->HrefValue = "";

			// tipo
			$solicitudes_online->tipo->HrefValue = "";

			// cod_usuario
			$solicitudes_online->cod_usuario->HrefValue = "";

			// atendido
			$solicitudes_online->atendido->HrefValue = "";

			// fecha_registro
			$solicitudes_online->fecha_registro->HrefValue = "";
		}

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

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

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