<?php 
class eventclass_transaccion  extends eventsBase
{ 
	function eventclass_transaccion()
	{
	// fill list of events
		$this->events["AfterAdd"]=true;

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


//	onscreen events


	}
// Captchas functions	

//	handlers

		
		
		
		
		
		
		
		
		
		
		
				// After record added
function AfterAdd(&$values,&$keys,$inline,&$pageObject)
{

		
//**********  Redirect to another page  ************
header("Location: transaccion_list.php?status=success");
exit();




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

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

		
		
		
		
		
		
		
		
		
		
				// Before record added
function BeforeAdd(&$values,&$message,$inline,&$pageObject)
{

		
//**********  Check if specific record exists  ************
global $conn;
$idarticulo = $values["idarticulo"];
$strSQLExists = "select * from articulo where idarticulo=$idarticulo";
$rsExists = db_query($strSQLExists,$conn);
$data=db_fetch_array($rsExists);

$values["costo"] = $data["costo"];
$values["precio"] = $data["precio"];
$values["total"] = $data["precio"]*$values["cant"];
$values["descuento"]= $values["total"] - $values["importe"];
$values["ganancia"] = $values["importe"]-$data["costo"] ;

/*if($values["importe"] > $values["precio"])
{
	header("Location: transaccion_add.php?status=info");
	exit();
}
else
{
	// if dont exist do something else
}*/





// Place event code here.
// Use "Add Action" button to add code snippets.

return true;
;		
} // function BeforeAdd

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
//	onscreen events

} 
?>
