<?php session_start();
/*
define("DB_name", "apaxbolc_restaurantes");
define("DB_server", "localhost");
define("DB_user", "apaxbolc_diego123");
define("DB_pass", "diego123diego");
define('AppName', 'Restaurant');
define("HOME","/restaurantes/administrar/"); */	
define("DB_name", "restaurantes");
define("DB_server", "localhost");
define("DB_user", "root");
define("DB_pass", "");
define('AppName', 'Restaurantes');
define("HOME","/2024/restaurantes/administrar/");

define("PATH_HOME", "http://" . $_SERVER['HTTP_HOST'] . HOME);
define("PATH_ROOT", $_SERVER['DOCUMENT_ROOT'] . HOME);

$USUARIO='';
	$UssOnLine = new Session();
	if(isset($_SESSION['USUARIO'])){
		$USUARIO = $UssOnLine->Get('USUARIO');
		$USID = $UssOnLine->Get('USID'); 
		$USCODIGO = $UssOnLine->Get('CODIGO');
		$ROL = $UssOnLine->Get('ROL');		
	}
	$code = substr(sha1(uniqid()),1,7);	

function __autoload($class_name) {
	require_once PATH_ROOT.'casa/class.' . $class_name . '.casa.php';	    
}

function Caresp($parrafo){
	$CarEspecial = array("/á/","/é/","/í/","/ó/","/ú/","/ñ/",
				  "/Á/","/É/","/Í/","/Ó/","/Ú/","/Ñ/",
				  "/'/",'/"/');
   $CarConvertido = array("&aacute;","&eacute;","&iacute;","&oacute;","&uacute;","&ntilde;",
				  "&Aacute;","&Eacute;","&Iacute;","&Oacute;","&Uacute;","&Ntilde;",
				  "&apos;",  "&quot;");   
	$parrafo = preg_replace($CarEspecial, $CarConvertido, $parrafo);
	$parrafo = utf8_encode($parrafo);

	return $parrafo;
}

function GeneraPW($Nombres, $Apellidos, $CI, $UssPass){
	$ApPaterno = substr($Apellidos,0,1);
	$ApNombres = substr($Nombres,0,1);
	$ApMaterno = explode(' ',$Apellidos);

	$ci = explode(' ', $CI);
	$ApCI = $ci[0];

	if($UssPass == 'US'){
		if(empty($ApMaterno[1]))
			$Generado = $ApNombres.$ApPaterno.$ApCI;
		else{
			$Materno = substr($ApMaterno[1],0,1);
			$Generado = $ApNombres.$ApPaterno.$Materno.$ApCI;
		}	
	}else{
		$Generado = $ApCI;
	}

	return $Generado;
}
function AlertCASA($mensaje){
	$sms = "swal({
			title: '".AppName."',
				html: '".$mensaje."!!!',
				confirmButtonClass: 'btn bg-dark',
				confirmButtonText: 'ACEPTAR',
			timer: 3500
	}).then();";

  echo $sms;
}
function AlertAjax($mensaje){	
	$sms = "<script>swal({
				title: '".AppName."',	
				html: '".$mensaje."!!!',
				confirmButtonClass: 'btn bg-dark',
				confirmButtonText: 'ACEPTAR',
			timer: 3500
	}).then();</script>";

  echo $sms;
}
?>