<?php

/**
 * 	Dear developer!
 *	Never modify events.php file, it is autogenerated.
 *  Modify PHP/EventTemplates/events.txt instead.
 *
 */

 class eventclass_derecho_propietario  extends eventsBase
{
	function __construct()
	{
	// fill list of events
		$this->events["BeforeAdd"]=true;

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



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

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

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


	}

//	handlers

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

		

require __DIR__ . '/../app/number/convert2.php';


return true;
;		
} // function BeforeAdd

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
				// Before record updated
function BeforeEdit(&$values, &$sqlValues, $where, &$oldvalues, &$keys, &$message, $inline, $pageObject)
{

		

require __DIR__ . '/../app/number/convert2.php';

return true;



;		
} // function BeforeEdit

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
				// After Import Finished
function AfterImport($count, $skipCount, $pageObject)
{

		$data = array();
$data["id_constitucion"] = $values["id_constitucion"];
$data["id_gestion"] = $values["gestion"];
$data["id_socio"] = $values["accionista"];
DB::Insert("socio_g_d", $data );

$data1 = array();
$data1["id_constitucion"] = $values["id_constitucion"];
$data1["id_dp"] = $values["id_derecho_Propietario"];
$data1["id_gestion"] = $values["gestion"];
$data1["id_socio"] = $values["accionista"];
DB::Insert("socio_dp", $data1);


$data2 = array();
$data2["derecho_propietario"] = $values["id_derecho_Propietario"];
$data2["id_gestion"] = $values["gestion"];
$data2["accionista"] = $values["accionista"];
$data2["estado"] = 65;
DB::Insert("pago_dp", $data2 );



$data3 = array();
$data3["derecho_propietario"] = $values["id_derecho_Propietario"];
$data3["id_gestion"] = $values["gestion"];
$data3["accionista"] = $values["accionista"];
$data3["estado"] = 66;
DB::Insert("entrega_dp", $data3 );

;		
} // function AfterImport

		
		
		
		
		
		
		
		
		
		

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

		
$data6 = array();
$data6["id_constitucion"] = $values["id_constitucion"];
$data6["id_gestion"] = $values["gestion"];
$data6["id_dp"] = $values["id_derecho_Propietario"];
$data6["id_Socio"] = $values["accionista"];

DB::Insert("socio_g_d", $data6 );





$data1 = array();
$data1["id_constitucion"] = $values["id_constitucion"];
$data1["id_dp"] = $values["id_derecho_Propietario"];
$data1["id_gestion"] = $values["gestion"];
$data1["id_socio"] = $values["accionista"];
$data1["tipo_accionista"] =29;

DB::Insert("socio_dp", $data1);



/*
$data9 = array();
$data9["id_constitucion"] = $values["id_constitucion"];
$data9["derecho_Propietario"] = $values["id_derecho_Propietario"];
$data9["gestion"] = $values["gestion"];
$data9["accionista"] = $values["accionista"];
$data9["estado"] = 65;
$data9["tipo_pago"] = 34;
$data9["nro_derecho"] = $values["nro_derecho"];
$data9["nro_Acciones"] = $values["nro_Acciones"];


DB::Insert("pago_dp", $data9); */




//$result['id_Gestion'] = $data["id_Gestion"];
$result['id_dp'] = $values["id_derecho_Propietario"];




global $conn;




$sql= "INSERT INTO pago_dp (fecha_Pago, derecho_Propietario, accionista,  estado, tipo_pago, 
  nro_Acciones, id_constitucion,
 ci, nombre, paterno, materno,casado , procedencia, complemento , nro_derecho, ano ) 

SELECT
dp.fecha_Inscripcion ,
	dp.id_derecho_Propietario,
	dp.accionista,
	65 as estado,
	34 as tipo_pago ,
	
	dp.nro_Acciones,
	dp.id_constitucion,
	s.ci,
	s.nombres,
	s.apellido_Paterno,
	s.apellido_Materno,
	s.apellido_Casada,
	s.ci_procedencia,
	s.ci_complemento,
	dp.nro_derecho ,
	gestion.nombre
FROM
	socio AS s
	INNER JOIN derecho_propietario AS dp ON s.id_Socio = dp.accionista , gestion
WHERE
	dp.id_derecho_Propietario = '".$result['id_dp']."'  and 	gestion.correlativo_pago like '1'
   "        ;
db_exec ($sql,$conn);






$data3 = array();
$data3["derecho_propietario"] = $values["id_derecho_Propietario"];
$data3["id_constitucion"] = $values["id_constitucion"];
$data3["accionista"] = $values["accionista"];
$data3["estado"] = 66;
$data3["correlativo_pendiente"] = $values["id_Entrega"];

DB::Insert("entrega_dp", $data3 );

;		
} // function AfterAdd

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
				// After record updated
function AfterEdit(&$values, $where, &$oldvalues, &$keys, $inline, $pageObject)
{

		$data1 = array();
$data1["id_constitucion"] = $values["id_constitucion"];
$data1["id_dp"] = $values["id_derecho_Propietario"];
$data1["id_gestion"] = $values["gestion"];
$data1["id_socio"] = $values["accionista"];
$data1["tipo_accionista"] =29;
$keyvalues["id_dp"] = $values["id_derecho_Propietario"];

DB::update("socio_dp", $data1, $keyvalues);


$data3 = array();
$data3["derecho_propietario"] = $values["id_derecho_Propietario"];
$data3["id_gestion"] = $values["gestion"];
$data3["accionista"] = $values["accionista"];
$data3["estado"] = 66;


$keyvalues2["derecho_propietario"] = $values["id_derecho_Propietario"];


DB::update("entrega_dp", $data3, $keyvalues2);
;		
} // function AfterEdit

		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		



}
?>
