<?php
class eventclass_derecho_propietario  extends TableEventsBase {
	
	function init() {
		$this->events = array(
			'BeforeAdd' => true,
			'BeforeEdit' => true,
			'OnPageLoad' => true,
			'AfterImport' => true,
			'AfterAdd' => true,
			'AfterEdit' => true 
		);
		$this->fieldValues = array(
			'filterLimit' => array(
				 
			),
			'mapIcon' => array(
				 
			),
			'viewCustom' => array(
				 
			),
			'lookupWhere' => array(
				 
			),
			'viewFileText' => array(
				 
			),
			'defaultValue' => array(
				'fecha_Emision' => array(
					'edit' => true 
				),
				'fecha_Inscripcion' => array(
					'edit' => true 
				) 
			),
			'autoUpdateValue' => array(
				 
			),
			'uploadFolder' => array(
				 
			),
			'viewPluginInit' => array(
				 
			),
			'editPluginInit' => array(
				 
			) 
		);
			}
		function BeforeAdd( &$values, &$sqlValues, &$message, $inline, $pageObject ) {
			
	
	require __DIR__ . '/../app/number/convert2.php';
	
	
	return true;
			;
			return true;
		}
	
		function BeforeEdit( &$values, &$sqlValues, $where, &$oldvalues, &$keys, &$message, $inline, $pageObject ) {
			
	
	require __DIR__ . '/../app/number/convert2.php';
	
	return true;
	
	
	
			;
			return true;
		}
	
		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 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 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);
			;
			
		}
	public function default_fecha_Emision_efedit(  ) {
		$defaultValue = now();
		return $defaultValue;
	}
	
	public function default_fecha_Inscripcion_efedit(  ) {
		$defaultValue = now();
		return $defaultValue;
	}	

}


?>