<?php
@ini_set("display_errors","1");
@ini_set("display_startup_errors","1");

include("include/dbcommon.php");
include("classes/button.php");
	
$params = (array)my_json_decode(postvalue('params'));
$buttId = $params['buttId'];

// proccess table events
if($buttId=='New_Button1')
{
	include("include/inf_cobros_variables.php");
	buttonHandler_New_Button1($params);
}
if($buttId=='New_Button12')
{
	include("include/det_movimiento_variables.php");
	buttonHandler_New_Button12($params);
}
if($buttId=='New_Button13')
{
	include("include/inf_ventas_articulos_variables.php");
	buttonHandler_New_Button13($params);
}
if($buttId=='New_Button14')
{
	include("include/inf_ventas_proveedores_variables.php");
	buttonHandler_New_Button14($params);
}
if($buttId=='New_Button15')
{
	include("include/ranking_clientes_total_variables.php");
	buttonHandler_New_Button15($params);
}
if($buttId=='New_Button151')
{
	include("include/ranking_clientes_cant_variables.php");
	buttonHandler_New_Button151($params);
}
if($buttId=='New_Button1521')
{
	include("include/v_det_movimiento_variables.php");
	buttonHandler_New_Button1521($params);
}
if($buttId=='New_Button153')
{
	include("include/inf_gastos_variables.php");
	buttonHandler_New_Button153($params);
}

// proccess non table events


// create table and non table handlers
function buttonHandler_New_Button1($params) 
{
	global $strTableName;
	$result = array();
		
	// create new button object for get record data
	$params["keys"] = (array)my_json_decode(postvalue('keys'));
	$params["isManyKeys"] = postvalue('isManyKeys');
	$params["location"] = postvalue('location');
	
	$button = new Button($params);
	$keys = $button->getKeys();
	
	// Capturamos el filtro y el orden de la sesión
$where = $_SESSION[$strTableName."_where"];
$order = $_SESSION[$strTableName."_order"];

// Capturamos el nombre de la tabla actual
$result["tabla"] = $strTableName; 
$result["where"] = base64_encode($where ? $where : "1=1");
$result["order"] = base64_encode($order ? $order : "");;
	echo my_json_encode($result);
}
function buttonHandler_New_Button12($params) 
{
	global $strTableName;
	$result = array();
		
	// create new button object for get record data
	$params["keys"] = (array)my_json_decode(postvalue('keys'));
	$params["isManyKeys"] = postvalue('isManyKeys');
	$params["location"] = postvalue('location');
	
	$button = new Button($params);
	$keys = $button->getKeys();
	
	// Capturamos el filtro y el orden de la sesión
$where = $_SESSION[$strTableName."_where"];
$order = $_SESSION[$strTableName."_order"];

// Capturamos el nombre de la tabla actual
$result["tabla"] = $strTableName; 
$result["where"] = base64_encode($where ? $where : "1=1");
$result["order"] = base64_encode($order ? $order : "");;
	echo my_json_encode($result);
}
function buttonHandler_New_Button13($params) 
{
	global $strTableName;
	$result = array();
		
	// create new button object for get record data
	$params["keys"] = (array)my_json_decode(postvalue('keys'));
	$params["isManyKeys"] = postvalue('isManyKeys');
	$params["location"] = postvalue('location');
	
	$button = new Button($params);
	$keys = $button->getKeys();
	
	// Capturamos el filtro y el orden de la sesión
$where = $_SESSION[$strTableName."_where"];
$order = $_SESSION[$strTableName."_order"];

// Capturamos el nombre de la tabla actual
$result["tabla"] = $strTableName; 
$result["where"] = base64_encode($where ? $where : "1=1");
$result["order"] = base64_encode($order ? $order : "");;
	echo my_json_encode($result);
}
function buttonHandler_New_Button14($params) 
{
	global $strTableName;
	$result = array();
		
	// create new button object for get record data
	$params["keys"] = (array)my_json_decode(postvalue('keys'));
	$params["isManyKeys"] = postvalue('isManyKeys');
	$params["location"] = postvalue('location');
	
	$button = new Button($params);
	$keys = $button->getKeys();
	
	// Capturamos el filtro y el orden de la sesión
$where = $_SESSION[$strTableName."_where"];
$order = $_SESSION[$strTableName."_order"];

// Capturamos el nombre de la tabla actual
$result["tabla"] = $strTableName; 
$result["where"] = base64_encode($where ? $where : "1=1");
$result["order"] = base64_encode($order ? $order : "");;
	echo my_json_encode($result);
}
function buttonHandler_New_Button15($params) 
{
	global $strTableName;
	$result = array();
		
	// create new button object for get record data
	$params["keys"] = (array)my_json_decode(postvalue('keys'));
	$params["isManyKeys"] = postvalue('isManyKeys');
	$params["location"] = postvalue('location');
	
	$button = new Button($params);
	$keys = $button->getKeys();
	
	// Capturamos el filtro y el orden de la sesión
$where = $_SESSION[$strTableName."_where"];
$order = $_SESSION[$strTableName."_order"];

// Capturamos el nombre de la tabla actual
$result["tabla"] = $strTableName; 
$result["where"] = base64_encode($where ? $where : "1=1");
$result["order"] = base64_encode($order ? $order : "");;
	echo my_json_encode($result);
}
function buttonHandler_New_Button151($params) 
{
	global $strTableName;
	$result = array();
		
	// create new button object for get record data
	$params["keys"] = (array)my_json_decode(postvalue('keys'));
	$params["isManyKeys"] = postvalue('isManyKeys');
	$params["location"] = postvalue('location');
	
	$button = new Button($params);
	$keys = $button->getKeys();
	
	// Capturamos el filtro y el orden de la sesión
$where = $_SESSION[$strTableName."_where"];
$order = $_SESSION[$strTableName."_order"];

// Capturamos el nombre de la tabla actual
$result["tabla"] = $strTableName; 
$result["where"] = base64_encode($where ? $where : "1=1");
$result["order"] = base64_encode($order ? $order : "");;
	echo my_json_encode($result);
}
function buttonHandler_New_Button1521($params) 
{
	global $strTableName;
	$result = array();
		
	// create new button object for get record data
	$params["keys"] = (array)my_json_decode(postvalue('keys'));
	$params["isManyKeys"] = postvalue('isManyKeys');
	$params["location"] = postvalue('location');
	
	$button = new Button($params);
	$keys = $button->getKeys();
	
	// Capturamos el filtro y el orden de la sesión
$where = $_SESSION[$strTableName."_where"];
$order = $_SESSION[$strTableName."_order"];

// Capturamos el nombre de la tabla actual
$result["tabla"] = $strTableName; 
$result["where"] = base64_encode($where ? $where : "1=1");
$result["order"] = base64_encode($order ? $order : "");;
	echo my_json_encode($result);
}
function buttonHandler_New_Button153($params) 
{
	global $strTableName;
	$result = array();
		
	// create new button object for get record data
	$params["keys"] = (array)my_json_decode(postvalue('keys'));
	$params["isManyKeys"] = postvalue('isManyKeys');
	$params["location"] = postvalue('location');
	
	$button = new Button($params);
	$keys = $button->getKeys();
	
	// Capturamos el filtro y el orden de la sesión
$where = $_SESSION[$strTableName."_where"];
$order = $_SESSION[$strTableName."_order"];

// Capturamos el nombre de la tabla actual
$result["tabla"] = $strTableName; 
$result["where"] = base64_encode($where ? $where : "1=1");
$result["order"] = base64_encode($order ? $order : "");;
	echo my_json_encode($result);
}
?>
