<?php


error_reporting(E_ALL ^ E_NOTICE);

require "../php/classes/DB.class.php";
require "../php/classes/SevenBase.class.php";
require "../php/classes/Seven.class.php";
require "../php/classes/SevenComprobante.class.php";
require "../php/classes/SevenRegistrar.class.php";

if(get_magic_quotes_gpc()){
	
	// If magic quotes is enabled, strip the extra slashes
	array_walk_recursive($_GET,create_function('&$v,$k','$v = stripslashes($v);'));
	array_walk_recursive($_POST,create_function('&$v,$k','$v = stripslashes($v);'));
}

/* Database Configuration. Add your details below */

$dbOptions = array(
	'db_host' => 'localhost',
	'db_name' => 'appsiete_consultacpe',
	'db_user' => 'appsiete_seven',
	'db_pass' => '3owTCLTvNLw'
);

/* Database Config End */

try{
	
	$res = array();
	DB::init($dbOptions);
	$res = Seven::getEmpresa($_POST['ruc']);

	if ($res['msg']) {
		DB::selectDataBase($res['msg'][0]->nombre_bd);
		$response = array();
		switch($_GET['action']){
	        case 'getEmpresa':
				$response['dominio'] = $res['msg'][0]->subdominio;
				$response['servidor'] = $res['msg'][0]->servidor;
	        	break;    
   
			default:
				throw new Exception('Wrong action');
		}
		echo json_encode($response);
	}
	else{
		echo json_encode(array('msg'  => "error"));
	}
}
catch(Exception $e){
	die(json_encode(array('error' => $e->getMessage())));
}

?>