<?php
class eventsBase
{
	var $events = array();
	var $maps = array();
	function exists($event, $table = "")
	{
		if($table == "")
			return (array_key_exists($event,$this->events)!==FALSE);
		else
			return isset($this->events[$event]) && isset($this->events[$event][$table]);
	}

	function existsMap($page)
	{
		return (array_key_exists($page,$this->maps)!==FALSE);
	}
}

class class_GlobalEvents extends eventsBase
{
	function __construct()
	{
	// fill list of events

		$this->events["AfterSuccessfulLogin"]=true;


//	onscreen events
		$this->events["_global__snippet"] = true;
		$this->events["_global__snippet1"] = true;
		$this->events["Nro_acciones"] = true;
		$this->events["Socios"] = true;
		$this->events["Acciones"] = true;
		$this->events["Bs"] = true;



		}

//	handlers

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

		
		
		
		
		
		
				// After successful login
function AfterSuccessfulLogin($username, $password, &$data, $pageObject)
{

		$_SESSION['user_id']=$data['ID']; 


// Place event code here.
// Use "Add Action" button to add code snippets.
;		
} // function AfterSuccessfulLogin

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

//	onscreen events
	function event__global__snippet(&$params)
	{
	// Put your code here.
echo "Your message";
	;
}
	function event__global__snippet1(&$params)
	{
	// Put your code here.
echo "Your message";
	;
}
	function event_Nro_acciones(&$params)
	{
	
	;
}
	function event_Socios(&$params)
	{
	$res=DB::query(" 

SELECT
	
	id_constitucion as constitucion,
	count(nro_Acciones) AS Nro_titulos
FROM
	derecho_propietario
	
	where 	estado_titulo = 37 and id_constitucion = 2
	
GROUP BY
	id_constitucion

 ");
$data = $res->fetchAssoc();
$res = "<div class='info-box'>";
$res.= "<span class='info-img img_bgcolor_green glyphicon glyphicon-book'></span>";
$res.= "<div class='dashtext'>";
$res.= "<b>Derechos Propietarios Activos</b><br>";
$res.= $data["Nro_titulos"];
$res.= "</div>";
$res.= "</div>";
echo $res;


	;
}
	function event_Acciones(&$params)
	{
	$res=DB::query("SELECT

	id_constitucion, 
	nombre, 
	numero_Acciones, 
	acciones_Asignado, 
	saldo_Acciones, 

	utilidad_gestion
FROM
	acciones  ");
$data = $res->fetchAssoc();
$res = "<div class='info-box'>";
$res.= "<span class='info-img img_bgcolor_green glyphicon glyphicon-file'></span>";
$res.= "<div class='dashtext'>";
$res.= "<b>Total de acciones asignadas</b><br>";
$res.= number_format( $data["Nro_acciones"],2);
$res.= "</div>";
$res.= "</div>";

echo  $res





	;
}
	function event_Bs(&$params)
	{
	$res=DB::query(" SELECT
	
	id_constitucion as constitucion,
	sum(nro_Acciones) AS Nro_accionesb
FROM
	derecho_propietario
	
	where 	estado_titulo = 37 and id_constitucion = 2
	
GROUP BY
	id_constitucion");
$data = $res->fetchAssoc();
$res = "<div class='info-box'>";
$res.= "<span class='info-img img_bgcolor_green glyphicon glyphicon-piggy-bank'></span>";
$res.= "<div class='dashtext'>";
$res.= "<b>Nro acciones Asignadas</b><br>";

$res.= number_format( $data["Nro_accionesb"],2);


$res.= "</div>";
$res.= "</div>";

echo  $res









	;
}




}
?>
