<?php 
//INSTANCIO LA BASE DE DATOS DEL AVANWS--------------------------------------------------------------------
$bd_conn = new connexion($host_avanws,$user_avanws,$pass_avanws,$name_avanws,$port_avanws);
$bd_conn->query("SET NAMES 'utf8'");
//SERVICES--------------------------------------------------------------------------------------------------
if ( $_SERVER['REQUEST_METHOD'] === "POST" ) {
	if ( isset($_POST["service"])) {
		switch ( $_POST["service"] ) {
			case 'servToken'://OBTIENE TOKEN DE ACCCESO
				include(ROOT . FOLDER_CONTRS ."/token/servToken.php");
				break;
			case 'servAddDoc'://CREAR DOCUMENTO
				include(ROOT . FOLDER_CONTRS ."/documents/servAddDoc.php");
				break;
			case 'servUpdateDoc'://CREAR Y ACTUALIZAR DOCUMENTOS
				include(ROOT . FOLDER_CONTRS ."/documents/servUpdateDoc.php");
				break;
			case 'servUpdateCar'://ACTUALIZA Y CREA VEHICULOS
				include(ROOT . FOLDER_CONTRS ."/cars/servUpdateCar.php");
				break;
			case 'servUpdateContact'://ACTUALIZA Y CREA CONTACTOS
				include(ROOT . FOLDER_CONTRS ."/contacts/ServUpdateContact.php");
				break;
			case 'servUpdateCarPost'://ACTUALIZA Y CREA VEHICULOS ADOPTA UN COCHE
				include(ROOT . FOLDER_CONTRS ."/cars/servUpdateCarPost.php");
				break;
			case 'servPostCarPortal'://PUBLICAR VEHICULOS EN PORTALES
				include(ROOT . FOLDER_CONTRS ."/cars/servPostCarPortal.php");
				break;
			case 'servUndoPosts'://QUITAR LA LAS PUBLICACIONES
				include(ROOT . FOLDER_CONTRS ."/cars/servUndoPosts.php");
				break;
			case 'servPostCarBucket'://SUBIR IMAGENES EN S3 Y BBDD
				include(ROOT . FOLDER_CONTRS ."/cars/servPostCarBucket.php");
				break;
			case 'servPurchaseAUC'://ACTUALIZA Y CREA RESERVAS Y PAGOS AUC
				include(ROOT . FOLDER_CONTRS ."/auc/servUpdateReservaPagoAUC.php");
				break;
			case 'servAddDocSerban'://CREAR DOS DOCUMENTOS GRAPADOS DESDE SERBAN
				include(ROOT . FOLDER_CONTRS ."/documents/servAddDocSerban.php");
				break;
			case 'servUpdateLead'://CREAR LEAD FRIO SERBAN
				include(ROOT . FOLDER_CONTRS ."/leads/servUpdateLeadSalesF.php");
				break;
			case 'servMultiPost'://Multipost
				include(ROOT . FOLDER_CONTRS ."/cars/servMultiPost.php");
				break;
			case 'servBrand'://Eurotax brand
				include(ROOT . FOLDER_CONTRS ."/eurotax/servBrand.php");
				break;
			case 'servModel'://Eurotax model
				include(ROOT . FOLDER_CONTRS ."/eurotax/servModel.php");
				break;
			case 'servType'://Eurotax type
				include(ROOT . FOLDER_CONTRS ."/eurotax/servType.php");
				break;
			case 'servEquipment'://Eurotax equipment
				include(ROOT . FOLDER_CONTRS ."/eurotax/servEquipment.php");
				break; 
			case 'servRadar'://Radar
				include(ROOT . FOLDER_CONTRS ."/eurotax/servRadar.php");
				break;
			case 'servSycnPhotoAUC'://Sincronizacion fotos con AUC
				include(ROOT . FOLDER_CONTRS ."/documents/servSycnPhotoAUC.php");
				break;
			case 'servTriggers'://TRIGGER de EVENTOS 
				include(ROOT . FOLDER_CONTRS ."/utils/servTrigger.php");
				break;
			case 'servPostExpGestorV'://Envio de Expediente a Gestor V
				include(ROOT . FOLDER_CONTRS ."/expedientes/servPostExpGestorV.php");
				break;
			case 'servPostDataGestorV'://Envio de datos del Expediente desde Gestor V
				include(ROOT . FOLDER_CONTRS ."/expedientes/servPostDataGestorV.php");
				break;
			case 'servPostDocGestorV'://Envio de documentos del Expediente desde Gestor V
				include(ROOT . FOLDER_CONTRS ."/expedientes/servPostDocGestorV.php");
				break;
			case 'sendMsjWhatsappMessageBird'://Envio de Msj via Whatsapp por la plataforma MessafeBird
				include(ROOT . FOLDER_CONTRS ."/mensajeria/sendPlantWhatsappMessageBird.php");
				break;
			case 'servDocTipo'://LESTURA DOCUMENTOS POR TIPO 
				include(ROOT . FOLDER_CONTRS ."/documents/servDocsTipo.php");
				break;
			default:
				include(ROOT . FOLDER_CONTRS ."/notFound/ServNotFound.php");
				break;
		}
	}else{
		$uri = explode('/', $_SERVER['REQUEST_URI']);
		$service = ! empty($uri[3]) ? $uri[3] : '';
		switch ($service) {
			case 'servWalcuCrearPedido'://Crear pedidos desde Walcu
				include(ROOT . FOLDER_CONTRS ."/walcu/servCreatePedido.php");
			break;
		}
	}

}elseif ( $_SERVER['REQUEST_METHOD'] === "GET" ) {
	
	$uri = explode('/', $_SERVER['REQUEST_URI']);
	$service = ! empty($uri[3]) ? $uri[3] : '';
	switch ($service) {
		case 'getCarTradeMark'://OBTIENE MARCAS DE COCHES
			include(ROOT . FOLDER_CONTRS ."/cars/ServgetCarTradeMark.php");
			break;
		case 'getCarModels'://OBTIENE MODELOS DE COCHES
			include(ROOT . FOLDER_CONTRS ."/cars/ServgetCarModels.php");
			break;
		case 'getDocs'://OBTIENE UN DOCUMENTO
			include(ROOT . FOLDER_CONTRS ."/documents/ServGetDocs.php");
			break;
		case 'getContacts'://OBTIENE UN CONTACTO
			include(ROOT . FOLDER_CONTRS ."/contacts/ServGetContacts.php");
			break;
		case 'getCar'://OBTIENE UN VEHICULO
			include(ROOT . FOLDER_CONTRS ."/cars/ServGetCar.php");
			break;
		case 'getCommercials'://OBTIENE LISTADO DE COMERCIALES PARA SERBAN
			include(ROOT . FOLDER_CONTRS ."/miscellaneous/servGetCommercials.php");
			break;
		case 'getExpTypes'://OBTIENE LISTADO DE EXPEDIENTES PARA SERBAN
			include(ROOT . FOLDER_CONTRS ."/miscellaneous/servGetExpTypes.php");
			break;
		case 'getOrderTemplate'://OBTIENE LISTADO DE PLANTILLAS DE PEDIDOS
			include(ROOT . FOLDER_CONTRS ."/miscellaneous/servGetOrderTemplate.php");
			break;
		case 'getSignLogalty'://Envio de Documentos a FIRMAR  a la plataforma Logalty
			include(ROOT . FOLDER_CONTRS ."/signs/servSingLogalty.php");
			break;
		case 'getStateLogalty'://Envio de Documentos a FIRMAR  a la plataforma Logalty
			include(ROOT . FOLDER_CONTRS ."/signs/servStateLogalty.php");
			break;
		case 'getCancelSignLogalty'://Envio Cancelacion firma de Documentos  a la plataforma Logalty
			include(ROOT . FOLDER_CONTRS ."/signs/servCancelSignLogalty.php");
			break;
		case 'servLeadsERSM'://Envio de Leads a ERSM
			include(ROOT . FOLDER_CONTRS ."/leads/servLeadsERSM.php");
			break;
		default:
			include(ROOT . FOLDER_CONTRS ."/notFound/ServNotFound.php");
			break;
	}
}
?>