<?php session_start();
date_default_timezone_set('America/La_Paz');
$ffhh = time();
$ffhhActual = date("Y-m-d H:i:s", $ffhh);

/*
define("DB_name", "importax_inventario");
define("DB_server", "localhost");
define("DB_user", "importax_diego4");
define("DB_pass", "diego1234diego");
define('AppName', 'El Comercio SyS');
define("HOME","/app/"); */
define("DB_name", "inventarios");
define("DB_server", "localhost");
define("DB_user", "root");
define("DB_pass", "");
define('AppName', 'El Comercio SyS');
define("HOME","/2024/inventarios/app/");

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;

}

?>