Tarea #646 -> Crear la acción "Creación de oferta" que cree una oferta relacionada con la solicitud de oferta que se está mostrando. Tarea #607 -> Nueva entidad 'Oferta' con estados nuevos Tarea #606 -> Nuevos estados y transiciones para una solicitud de oferta Tarea #601 -> Nuevos estados y transiciones para un candidato Tarea #599 -> Repasar los registros que se meten en el historial de cambios Tarea #586 -> Cuando una solicitud tiene varios perfiles, hay que visualizarlos ocupando las menos filas posibles Tarea #585 -> Cuando un candidato tiene varios perfiles, hay que visualizarlos ocupando las menos filas posibles git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_Intranet/trunk/src@65 e2b1556b-49f8-d141-9351-52d6861a72d9
348 lines
11 KiB
PHP
348 lines
11 KiB
PHP
<?php
|
|
|
|
ini_set("memory_limit", "32M");
|
|
//require_once ('Excel/reader.php');
|
|
|
|
// Función para imprimir cosas
|
|
// Sacado de http://php.net/manual/de/debugger.php
|
|
// USO:
|
|
// > dbug(<loquesea>);
|
|
// > " "
|
|
// > echo dbug('print');
|
|
function dbug() {
|
|
static $output = '', $doc_root;
|
|
$args = func_get_args();
|
|
if (!empty($args) && $args[0] === 'print') {
|
|
$_output = $output;
|
|
$output = '';
|
|
return $_output;
|
|
}
|
|
// do not repeat the obvious (matter of taste)
|
|
if (!isset($doc_root)) {
|
|
$doc_root = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']);
|
|
}
|
|
$backtrace = debug_backtrace();
|
|
// you may want not to htmlspecialchars here
|
|
$line = htmlspecialchars($backtrace[0]['line']);
|
|
$file = htmlspecialchars(str_replace(array('\\', $doc_root), array('/', ''), $backtrace[0]['file']));
|
|
$class = !empty($backtrace[1]['class']) ? htmlspecialchars($backtrace[1]['class']) . '::' : '';
|
|
$function = !empty($backtrace[1]['function']) ? htmlspecialchars($backtrace[1]['function']) . '() ' : '';
|
|
$output .= "<b style='color: red;'>$class$function =>$file #$line</b><pre style='color: red;'>";
|
|
ob_start();
|
|
foreach ($args as $arg) {
|
|
var_dump($arg);
|
|
}
|
|
$output .= htmlspecialchars(ob_get_contents(), ENT_COMPAT, 'UTF-8');
|
|
ob_end_clean();
|
|
$output .= '</pre>';
|
|
}
|
|
|
|
|
|
/* Conexión a la base de datos */
|
|
function conectar()
|
|
{
|
|
include_once LOCALE.LOCALESET."lenguaje.php";
|
|
if (!($puntero=mysql_connect("localhost","root","password")))
|
|
{
|
|
echo $locale['bd'];
|
|
return false;
|
|
}
|
|
if (!mysql_select_db("selfor",$puntero))
|
|
{
|
|
echo $locale['bd'];
|
|
return false;
|
|
}
|
|
mysql_query("SET NAMES 'latin1'");
|
|
return $puntero;
|
|
}
|
|
|
|
/* Conexión a la base de datos de tablas */
|
|
function conectar_info()
|
|
{
|
|
include_once LOCALE.LOCALESET."lenguaje.php";
|
|
if (!($puntero=mysql_connect("localhost","root","password")))
|
|
{
|
|
echo $locale['bd'];
|
|
return false;
|
|
}
|
|
if (!mysql_select_db("information_schema",$puntero))
|
|
{
|
|
echo $locale['bd'];
|
|
return false;
|
|
}
|
|
mysql_query("SET NAMES 'latin1'");
|
|
return $puntero;
|
|
}
|
|
|
|
/* Envía un correo */
|
|
function envia_correo($direccion, $asunto, $email){
|
|
$headers = "MIME-Version: 1.0 \n" ;
|
|
$from_email = constante("email");
|
|
$headers .= "From: " .
|
|
"".mb_encode_mimeheader (mb_convert_encoding($from_email,"ISO-8859-1","AUTO")) ."" .
|
|
"<".$from_email."> \n";
|
|
$headers .= "Reply-To: " .
|
|
"".mb_encode_mimeheader (mb_convert_encoding($from_email,"ISO-8859-1","AUTO")) ."" .
|
|
"<".$from_email."> \n";
|
|
|
|
$headers .= "Content-Type: text/html;charset=ISO-8859-1 \n";
|
|
|
|
$email = explode(".", $email);
|
|
$texto = "";
|
|
foreach($email as $linea){
|
|
$encoding = mb_detect_encoding($linea, 'ASCII,UTF-8,ISO-8859-1');
|
|
if ($encoding == "UTF-8") {
|
|
$texto .= utf8_decode($linea);
|
|
}else{
|
|
$texto .= $linea;
|
|
}
|
|
}
|
|
|
|
return mail($direccion, $asunto, $texto, $headers);
|
|
}
|
|
|
|
/* Envía un correo */
|
|
function envia_correo_empleados($direccion, $asunto, $email){
|
|
$headers = "MIME-Version: 1.0 \n" ;
|
|
$from_email = constante("email_rrhh");
|
|
$headers .= "From: " .
|
|
"".mb_encode_mimeheader (mb_convert_encoding($from_email,"ISO-8859-1","AUTO")) ."" .
|
|
"<".$from_email."> \n";
|
|
$headers .= "Reply-To: " .
|
|
"".mb_encode_mimeheader (mb_convert_encoding($from_email,"ISO-8859-1","AUTO")) ."" .
|
|
"<".$from_email."> \n";
|
|
|
|
$headers .= "Content-Type: text/html;charset=ISO-8859-1 \n";
|
|
|
|
$email = explode(".", $email);
|
|
$texto = "";
|
|
foreach($email as $linea){
|
|
$encoding = mb_detect_encoding($linea, 'ASCII,UTF-8,ISO-8859-1');
|
|
if ($encoding == "UTF-8") {
|
|
$texto .= utf8_decode($linea);
|
|
}else{
|
|
$texto .= $linea;
|
|
}
|
|
}
|
|
return mail($direccion, $asunto, $texto, $headers);
|
|
}
|
|
|
|
/* Consulta a la base de datos */
|
|
function consultar($cadena)
|
|
{
|
|
if ($puntero = conectar()){
|
|
|
|
if ($resultado = mysql_query($cadena, $puntero))
|
|
return $resultado;
|
|
else
|
|
return false;
|
|
}
|
|
else
|
|
return false;
|
|
}
|
|
|
|
/* Devuelve el valor de una constante de sistema */
|
|
function constante($nombre){
|
|
if ($link = conectar()){
|
|
if ($resultado = mysql_query("select * from sistema where id='$nombre'",$link)){
|
|
$cont = mysql_num_rows($resultado);
|
|
$row = mysql_fetch_array($resultado);
|
|
$valor = $row["valor"];
|
|
}
|
|
}
|
|
return $valor;
|
|
}
|
|
|
|
/* Devuelve si la tabla está siendo modificada */
|
|
//function ocupado ($oid, $tabla){
|
|
// $seguimos = false;
|
|
// if ($link = conectar()){
|
|
// if ($resultado = mysql_query("select mutex,tiempo from $tabla where oid = '".$oid."'",$link)){
|
|
// while ($row = mysql_fetch_array($resultado)){
|
|
// $mutex = $row["mutex"];
|
|
// $fecha = $row["tiempo"];
|
|
// $seguimos = true;
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// //Si está bloqueado por el usuario que tiene sesión no se considera ocupado y puede entrar.
|
|
// if($mutex == $_SESSION["oid"]) return false;
|
|
//
|
|
// if ($seguimos && ($mutex > 0)){
|
|
// /* Ahora tenemos que comparar la fecha almacenada con la actual. Si
|
|
// la diferencia es mayor de 20 minutos, volvemos a poner el mutex a 0
|
|
// */
|
|
// list($a_m_d, $h_m_s) = split(" ",$fecha);
|
|
// list($anio, $mes, $dia) = split("-",$a_m_d);
|
|
// list($hora, $minuto, $segundo) = split(":",$h_m_s);
|
|
//
|
|
// $fecha_mutex = mktime($hora,$minuto,$segundo,$mes,$dia,$anio);
|
|
// $fecha_ahora = mktime(date("H"),date("i"),date("s"),date("m"),date("d"),date("Y"));
|
|
//
|
|
// //Han pasado 1200 segundos?
|
|
// $diferencia = $fecha_ahora - $fecha_mutex;
|
|
// if ($diferencia >= 1200){
|
|
// //Ha caducado el semáforo, lo ponemos a cero
|
|
//
|
|
// if ($resultado = mysql_query("update $tabla set mutex=0 where oid = '".$oid."'",$link)){
|
|
// return false;
|
|
// }
|
|
// else return false;
|
|
// }
|
|
// else return true;
|
|
// }
|
|
// else{
|
|
// return false;
|
|
// }
|
|
//
|
|
//}
|
|
|
|
function formulario_campos(){
|
|
$contenido = '<select multiple name="campos[]">';
|
|
if ($link2 = conectar_info()){
|
|
if ($resultado = consultar("select * from information_schema.columns where table_schema='selfor'",$link2)){
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
$reg = $row["TABLE_NAME"].".".$row["COLUMN_NAME"];
|
|
$contenido .= '<option value="'.$reg.'">'.$reg.'</option>';
|
|
}
|
|
}else echo mysql_error();
|
|
}
|
|
else mysql_error();
|
|
$contenido .= '</select>';
|
|
return $contenido;
|
|
}
|
|
|
|
function formulario_tablas(){
|
|
$contenido = '<select style="width:200px; height:400px" multiple name="tablas[]">';
|
|
if ($link2 = conectar_info()){
|
|
if ($resultado = consultar("select * from information_schema.tables where table_schema='selfor'",$link2)){
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
$reg = $row["TABLE_NAME"];
|
|
$contenido .= '<option value="'.$reg.'">'.$reg.'</option>';
|
|
}
|
|
}else echo mysql_error();
|
|
}
|
|
else mysql_error();
|
|
$contenido .= '</select>';
|
|
return $contenido;
|
|
}
|
|
|
|
/* Comprueba y libera un semáforo */
|
|
function liberacion(){
|
|
$liberar = stripinput($_GET["liberar"]);
|
|
$tabla = stripinput($_POST["tabla_lib"]);
|
|
$oid = stripinput($_POST["oid"]);
|
|
|
|
if ($liberar == "si")
|
|
$salida = liberar($oid, $tabla);
|
|
}
|
|
|
|
///* Libera el semáforo de modificar tabla */
|
|
//function liberar ($oid, $tabla){
|
|
// $seguimos = false;
|
|
// if ($link = conectar()){
|
|
// if ($resultado = mysql_query("select mutex,tiempo from $tabla where oid = '".$oid."'",$link)){
|
|
// while ($row = mysql_fetch_array($resultado)){
|
|
// $mutex = $row["mutex"];
|
|
// $fecha = $row["tiempo"];
|
|
// $seguimos = true;
|
|
// }
|
|
// }
|
|
// }
|
|
//
|
|
// //No se pueden liberar semáforos de otros usuarios.
|
|
// if($mutex != $_SESSION["oid"]) return false;
|
|
//
|
|
// if ($link = conectar()){
|
|
// if ($resultado = mysql_query("update $tabla set mutex=0 where oid = '".$oid."'",$link)){
|
|
// return true;
|
|
// }
|
|
// else return false;
|
|
// }
|
|
// else return false;
|
|
//}
|
|
//
|
|
//
|
|
///** Bloquea el semáforo */
|
|
//function bloquear($oid, $tabla){
|
|
// if ($link = conectar()){
|
|
// $usr = $_SESSION["oid"];
|
|
// $consulta = "update ".$tabla." set mutex = '".$usr."' ,tiempo=now() where oid = '".$oid."'";
|
|
//
|
|
// if ($resultado = mysql_query($consulta,$link)){
|
|
// return true;
|
|
// }
|
|
// else return false;
|
|
// }
|
|
// else return false;
|
|
//}
|
|
|
|
|
|
// Comprueba si un usuario tiene permisos para realizar una función.
|
|
//TODO Deprecated
|
|
function comprobar_permisos($right) {
|
|
if ((in_array($right, explode(".", $_SESSION["permisos"]))) || (in_array($right, explode(".", $_SESSION["permisos_rol"])))) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function menu_rol($rol){
|
|
if($link = conectar()){
|
|
$resultado = mysql_query("select * from opciones where menu='$rol'", $link);
|
|
while($rows = mysql_fetch_array($resultado)){
|
|
$add = false;
|
|
$permisos = explode(".", $rows['permisos']);
|
|
foreach($permisos as $permiso){
|
|
if(comprobar_permisos($permiso)){
|
|
if($add == false){
|
|
echo '<td class="sinborde" width=20%><a title="'.$rows['nombre'].'" href="'.$rows['link'].'.php"><p align=center><img src="css/'.$rows['img'].'.gif" alt="'.$rows['nombre'].'"><br>'.$rows['nombre'].'</a></p></td>';
|
|
}
|
|
$add = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function ver_menus(){
|
|
if($link = conectar()){
|
|
$resultado = mysql_query("select distinct menu from opciones", $link);
|
|
while($rows = mysql_fetch_array($resultado)){
|
|
ver_menu($rows["menu"]);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Muestra el menú lateral.
|
|
function ver_menu($rol){
|
|
if($link = conectar()){
|
|
$add = false;
|
|
$resultado = mysql_query("select * from opciones where menu='$rol'", $link);
|
|
while(($add == false) && ($rows = mysql_fetch_array($resultado))){
|
|
$permisos = explode(".", $rows['permisos']);
|
|
$add = false;
|
|
foreach($permisos as $permiso){
|
|
if(comprobar_permisos($permiso)) $add = true;
|
|
}
|
|
if($add == true){
|
|
$nombre_rol = $rol;
|
|
if($nombre_rol == "Mantenimiento del sistema"){
|
|
$nombre_rol = "Mantenimiento<br>del sistema";
|
|
}
|
|
echo '<li><a title="'.$rol.'" href="administracion_principal.php?rol='.$rol.'">'.$nombre_rol.'</a></li>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function dia_semana ($dia, $mes, $ano) {
|
|
$dias = array('7', '1', '2', '3', '4', '5', '6');
|
|
return $dias[date("w", mktime(0, 0, 0, $mes, $dia, $ano))];
|
|
}
|
|
|
|
?>
|