git-svn-id: https://192.168.0.254/svn/Proyectos.Incam_Intranet/trunk@4 e2b1556b-49f8-d141-9351-52d6861a72d9
866 lines
32 KiB
PHP
866 lines
32 KiB
PHP
<?php
|
|
|
|
|
|
/* extrae el nombre de fichero de una ruta */
|
|
function nombre_fichero ($cadena)
|
|
{
|
|
$salida = split("/", $cadena);
|
|
$i = count($salida);
|
|
return $salida[$i-1];
|
|
}
|
|
|
|
/* extrae el nombre de fichero de una ruta */
|
|
function nombre_directorio ($cadena)
|
|
{
|
|
$salida = split("/", $cadena);
|
|
$i = count($salida);
|
|
return $salida[$i-2];
|
|
}
|
|
|
|
/* extrae la extensión del archivo */
|
|
function nombre_extension ($cadena)
|
|
{
|
|
$posicion = strrpos($cadena,".")+1;
|
|
$extension = substr($cadena,$posicion);
|
|
return $extension;
|
|
}
|
|
|
|
|
|
|
|
/* Elimina los espacios en blanco de una cadena */
|
|
function elimina_blancos ($cadena){
|
|
$salida = split(" ",$cadena);
|
|
$cadena_limpia = "";
|
|
foreach($salida as $una)
|
|
$cadena_limpia .= $una;
|
|
return $cadena_limpia;
|
|
}
|
|
|
|
/* Devuelve la provincia a la que pertenece una localidad*/
|
|
function provincia($localidad){
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from localidades where oid = '$localidad'", $link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
return $row["provincia"];
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Rellena una lista desplegable de colores */
|
|
function rellena_desplegable_color($name){
|
|
|
|
echo '<select name="'.$name.'">';
|
|
echo '<option value="red">Rojo</option>';
|
|
echo '<option value="yellow">Amarillo</option>';
|
|
echo '<option value="green">Verde</option>';
|
|
echo '<option value="blue">Azul</option>';
|
|
echo '<option value="white">Blanco</option>';
|
|
echo '<option value="#A8D3FF">Verde claro</option>';
|
|
echo '<option value="#C7FFC6">Azul claro</option>';
|
|
echo '</select>';
|
|
}
|
|
|
|
|
|
/* Rellena una lista desplegable con los empleados con un permiso concreto*/
|
|
function rellena_personal_permiso($nombre, $permiso, $auxiliar, $empleado){
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
$consulta = "select usuarios.oid as oid,nombre from usuarios,rol where usuarios.tipo='usuario' and usuarios.rol = rol.oid and (usuarios.permisos like '%.$permiso%' or usuarios.permisos like '%$permiso.%' or usuarios.permisos = '$permiso' or rol.permisos like '%.$permiso%' or rol.permisos like '%$permiso.%' or rol.permisos = '$permiso')";
|
|
echo '<select name="'.$nombre.'">';
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar($consulta,$link)){
|
|
echo $auxiliar;
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
if($empleado == $row["oid"]){
|
|
echo '<option value="'.$row["oid"].'" selected>'.$row["nombre"].'</option>';
|
|
}else{
|
|
echo '<option value="'.$row["oid"].'">'.$row["nombre"].'</option>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista desplegable con los pedidos que puede ver el usuario*/
|
|
function rellena_desplegable_pedidos($nombre){
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
echo '<select multiple name="'.$nombre.'[]">';
|
|
if ($link = conectar()){
|
|
if(comprobar_permisos("SP")){
|
|
$consulta = "select * from pedidos order by prioridad DESC";
|
|
}else{
|
|
$mioid = $_SESSION["oid"];
|
|
$consulta = "select * from pedidos where gerente='$mioid' order by prioridad DESC";
|
|
}
|
|
if ($resultado = consultar($consulta, $link)){
|
|
echo '<option value="" selected>'.$locale['ns'].'</option>';
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
echo '<option value="'.$row["oid"].'">'.$row["nombre"].'</option>';
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista desplegable con los pedidos que puede ver el usuario*/
|
|
function rellena_desplegable_pedidos_ConParametros($nombre,$seleccionadas){
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
echo '<select multiple name="'.$nombre.'[]">';
|
|
if ($link = conectar()){
|
|
if(comprobar_permisos("SP")){
|
|
$consulta = "select * from pedidos order by prioridad DESC";
|
|
}else{
|
|
$mioid = $_SESSION["oid"];
|
|
$consulta = "select * from pedidos where gerente='$mioid' order by prioridad DESC";
|
|
}
|
|
if ($resultado = consultar($consulta, $link)){
|
|
if($seleccionadas[0]=="")
|
|
echo '<option value="" selected>'.$locale['ns'].'</option>';
|
|
else
|
|
echo '<option value="">'.$locale['ns'].'</option>';
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
if (in_array($row["oid"], $seleccionadas)) {
|
|
echo '<option value="'.$row["oid"].'" selected>'.$row["nombre"].'</option>';
|
|
} else {
|
|
echo '<option value="'.$row["oid"].'">'.$row["nombre"].'</option>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista desplegable con las localidades de una provincia seleccionando una provincia concreta*/
|
|
function rellena_desplegable_localidad($localidad, $nombre){
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
echo '<select name="'.$nombre.'" >';
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from localidades order by provincia", $link)){
|
|
$provincia = "";
|
|
if($localidad == "")
|
|
echo '<option value="" selected>'.$locale['ns'].'</option>';
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
if($provincia != $row["provincia"]){
|
|
if($provincia != "") echo '</optgroup>';
|
|
$provincia = $row["provincia"];
|
|
echo '<optgroup label="'.nombre_provincia($provincia).'">';
|
|
}
|
|
if($localidad == $row["oid"]){
|
|
echo '<option value="'.$row["oid"].'" selected>'.$row["id"].'</option>';
|
|
}else{
|
|
echo '<option value="'.$row["oid"].'">'.$row["id"].'</option>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
function rellena_desplegable_localidad_mult($localidad, $nombre){
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
echo '<select name="'.$nombre.'[]" multiple size="10">';
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from localidades order by provincia", $link)){
|
|
$provincia = "";
|
|
//if($localidad == "")
|
|
//echo '<option value="" selected>'.$locale['ns'].'</option>';
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
if($provincia != $row["provincia"]){
|
|
if($provincia != "") echo '</optgroup>';
|
|
$provincia = $row["provincia"];
|
|
echo '<optgroup label="'.nombre_provincia($provincia).'">';
|
|
}
|
|
if (!in_array($row["oid"], $localidad)) {
|
|
echo '<option value="'.$row["oid"].'">'.$row["id"].'</option>';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
function rellena_desplegable_localidad_multSel($localidad, $nombre){
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
if ($link = conectar()){
|
|
echo '<select name="'.$nombre.'[]" multiple size="10">';
|
|
$consulta="select * from localidades order by provincia";
|
|
if ($resultado = consultar($consulta, $link)){
|
|
$provincia = "";
|
|
//if($localidad == "")
|
|
//echo '<option value="" selected>'.$locale['ns'].'</option>';
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
if($provincia != $row["provincia"]){
|
|
if($provincia != "") echo '</optgroup>';
|
|
$provincia = $row["provincia"];
|
|
echo '<optgroup label="'.nombre_provincia($provincia).'">';
|
|
}
|
|
if (in_array($row["oid"], $localidad)) {
|
|
echo '<option selected value="'.$row["oid"].'">'.$row["id"].'</option>';
|
|
} else {
|
|
echo '<option value="'.$row["oid"].'">'.$row["id"].'</option>';
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
}
|
|
|
|
/* Rellena una lista desplegable */
|
|
function rellena_desplegable($tabla,$name,$auxiliar){
|
|
|
|
echo '<select name="'.$name.'">';
|
|
echo $auxiliar;
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from ".$tabla,$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
echo '<option value="'.$row["id"].'">'.$row["id"].'</option>';
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista desplegable con oid e id*/
|
|
function rellena_desplegable_oid($tabla,$name,$auxiliar){
|
|
|
|
echo '<select name="'.$name.'">';
|
|
echo $auxiliar;
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from ".$tabla,$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
echo '<option value="'.$row["oid"].'">'.$row["id"].'</option>';
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista desplegable de perfiles*/
|
|
function rellena_perfiles($tabla,$name,$auxiliar){
|
|
echo '<select name="'.$name.'">';
|
|
echo $auxiliar;
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from ".$tabla,$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
echo '<option value="'.$row["oid"].'">'.$row["id"].' ('.$row["abrev"].') </option>';
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
|
|
/* Rellena una lista desplegable tipo orden-id */
|
|
function rellena_desplegable_orden($tabla,$name,$auxiliar){
|
|
|
|
echo '<select name="'.$name.'">';
|
|
echo $auxiliar;
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from ".$tabla." order by orden",$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
echo '<option value="'.$row["oid"].'">'.$row["id"].'</option>';
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista desplegable tipo orden-id */
|
|
function rellena_desplegable_select_orden($tabla,$name,$auxiliar,$opcion){
|
|
echo '<select name="'.$name.'">';
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from ".$tabla." order by orden",$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
if($opcion == $row["id"]){
|
|
echo '<option value="'.$row["id"].'" selected>'.$row["id"].'</option>';
|
|
}else{
|
|
echo '<option value="'.$row["id"].'">'.$row["id"].'</option>';
|
|
}
|
|
}
|
|
}
|
|
echo $auxiliar;
|
|
echo '</select>';
|
|
}
|
|
|
|
|
|
/* Rellena una lista desplegable */
|
|
function rellena_desplegable_multi($tabla,$name,$auxiliar){
|
|
|
|
echo '<select multiple name="'.$name.'[]">';
|
|
echo $auxiliar;
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from ".$tabla,$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
echo '<option value="'.$row["id"].'">'.$row["id"].'</option>';
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
//function rellena_desplegable_multi_oid($tabla,$name,$auxiliar){
|
|
//
|
|
// echo '<select multiple name="'.$name.'[]">';
|
|
// echo $auxiliar;
|
|
// if ($link = conectar()){
|
|
// if ($resultado = consultar("select * from ".$tabla,$link)){
|
|
// while ($row = mysql_fetch_array($resultado))
|
|
// echo '<option value="'.$row["oid"].'">'.$row["id"].'</option>';
|
|
// }
|
|
// }
|
|
// echo '</select>';
|
|
//}
|
|
|
|
/*
|
|
* Rellena la lista poniendo select en las que ya se han elegido
|
|
*/
|
|
//function rellena_desplegable_multi_oid_ConParametros($tabla,$name,$auxiliar,$seleccionadas){
|
|
// if ($link = conectar()){
|
|
// $consulta="select * from ".$tabla;
|
|
// if ($resultado = consultar($consulta,$link)){
|
|
// $numResultados=mysql_num_rows($resultado)-count($seleccionadas)+1;
|
|
// echo '<select multiple name="'.$name.'[]" size="'.$numResultados.'">';
|
|
// echo $auxiliar;
|
|
// while ($row = mysql_fetch_array($resultado)){
|
|
// if(gettype($seleccionadas)=="array"){
|
|
// if (!in_array($row["oid"], $seleccionadas)) {
|
|
// echo '<option value="'.$row["oid"].'" >'.$row["id"].'</option>';
|
|
// } else {
|
|
// echo '<option selected value="'.$row["oid"].'" >'.$row["id"].'</option>';
|
|
// }
|
|
// }else {
|
|
// echo '<option value="'.$row["oid"].'">'.$row["id"].'</option>';
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// echo '</select>';
|
|
//}
|
|
/*
|
|
* Rellena la lista poniendo select en las que ya se han elegido
|
|
*/
|
|
//function rellena_desplegable_multi_oid_ConParametrosNo($tabla,$name,$auxiliar,$seleccionadas){
|
|
// if ($link = conectar()){
|
|
// $consulta="select * from ".$tabla;
|
|
// if ($resultado = consultar($consulta,$link)){
|
|
// $numResultados=mysql_num_rows($resultado)-count($seleccionadas)+1;
|
|
// echo '<select multiple name="'.$name.'[]" size="'.$numResultados.'">';
|
|
// echo $auxiliar;
|
|
// while ($row = mysql_fetch_array($resultado)){
|
|
// if(gettype($seleccionadas)=="array"){
|
|
// if (!in_array($row["oid"], $seleccionadas)) {
|
|
// echo '<option value="'.$row["oid"].'" >'.$row["id"].'</option>';
|
|
// }
|
|
// }else {
|
|
// echo '<option value="'.$row["oid"].'">'.$row["id"].'</option>';
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// echo '</select>';
|
|
//}
|
|
|
|
/* Convierte un array en una cadena de texto separada por el valor indicado en separador*/
|
|
function expande($array, $separador){
|
|
$cadena = "";
|
|
|
|
foreach($array as $elem){
|
|
$cadena .= $elem.$separador;
|
|
}
|
|
|
|
//Remueve el último separador:
|
|
if ($valores{strlen($valores) - 2} == $separador)
|
|
$valores = substr($valores,0,strlen($valores) - 2);
|
|
}
|
|
|
|
|
|
/* Rellena una lista desplegable seleccionando una opción */
|
|
function rellena_desplegable_select($tabla,$name,$auxiliar,$opcion){
|
|
echo '<select name="'.$name.'">';
|
|
echo $auxiliar;
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from ".$tabla,$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
if($opcion == $row["id"]){
|
|
echo '<option value="'.$row["id"].'" selected>'.$row["id"].'</option>';
|
|
}else{
|
|
echo '<option value="'.$row["id"].'">'.$row["id"].'</option>';
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista desplegable tipo oid id seleccionando una opción */
|
|
function rellena_desplegable_select_oid($tabla,$name,$auxiliar,$opcion){
|
|
$consulta="select * from ".$tabla;
|
|
echo '<select name="'.$name.'">';
|
|
echo $auxiliar;
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar($consulta,$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
if($opcion == $row["oid"]){
|
|
echo '<option value="'.$row["oid"].'" selected>'.$row["id"].'</option>';
|
|
}else{
|
|
echo '<option value="'.$row["oid"].'">'.$row["id"].'</option>';
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
// Rellena una lista desplegable dando una tabla, el id que quieres sacar, el valor por defecto
|
|
// y la opción que hay ahora seleccionada
|
|
function rellena_desplegable_select_oidCol($tabla,$Ccod,$Cnombre,$name,$auxiliar,$opcion){
|
|
$consulta="select * from ".$tabla;
|
|
echo '<select name="'.$name.'">';
|
|
echo $auxiliar;
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar($consulta,$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
if($opcion == $row[$Ccod]){
|
|
echo '<option value="'.$row[$Ccod].'" selected>'.$row[$Cnombre].'</option>';
|
|
}else{
|
|
echo '<option value="'.$row[$Ccod].'">'.$row[$Cnombre].'</option>';
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista desplegable de procedencias */
|
|
function rellena_procedencias($name, $auxiliar, $opcion){
|
|
|
|
echo '<select name="'.$name.'">';
|
|
echo $auxiliar;
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from procedencia", $link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
if (($opcion == $row["num"]) || ($opcion == '')) {
|
|
echo '<option value="'.$row["num"].'" selected>'.$row["id"].' ('.$row["color"].')</option>';
|
|
$opcion = $row["num"];
|
|
}else{
|
|
echo '<option value="'.$row["num"].'">'.$row["id"].' ('.$row["color"].')</option>';
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
|
|
/* Rellena una lista desplegable con más datos*/
|
|
function rellena_desplegable_datos($tabla,$name,$aux1, $aux2){
|
|
|
|
echo '<select name="'.$name.'">';
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from ".$tabla,$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
if($aux1 != ""){
|
|
echo '<option value="'.$row["id"].'">'.$row[$aux1]." / ".ver_fecha($row[$aux2]).'</option>';
|
|
}else{
|
|
echo '<option value="'.$row["id"].'">'.ver_fecha($row[$aux2]).'</option>';
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista numérica desplegable */
|
|
function rellena_numerico($name, $menor, $num){
|
|
echo '<select name="'.$name.'">';
|
|
for ($i = 0; $i < $num; $i++){
|
|
echo '<option value="'.($menor+$i+1).'">'.($menor+$i+1).'</option>';
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista numérica desplegable seleccionando opción*/
|
|
function rellena_prioridad_select($name, $op){
|
|
echo '<select name="'.$name.'">';
|
|
for ($i = 0; $i < 3; $i++){
|
|
echo '<option value="'.($menor+$i+1).'"';
|
|
if($op == ($menor+$i+1)) echo "selected";
|
|
echo '>'.($menor+$i+1).' ('.discretiza_prioridad($menor+$i+1).')</option>';
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
|
|
/* Rellena una lista numérica desplegable seleccionando opción*/
|
|
function rellena_numerico_select($name, $menor, $num, $op){
|
|
echo '<select name="'.$name.'">';
|
|
for ($i = 0; $i < $num; $i++){
|
|
echo '<option value="'.($menor+$i+1).'"';
|
|
if($op == ($menor+$i+1)) echo "selected";
|
|
echo '>'.($menor+$i+1).'</option>';
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
|
|
/* Rellena una lista desplegable con los días de la semana seleccionando*/
|
|
function rellena_semana_select($name, $activacion){
|
|
echo '<select name="'.$name.'">';
|
|
for ($i = 0; $i < 7; $i++){
|
|
echo '<option value="'.($i+1).'"';
|
|
if($activacion == ($i+1)) echo "selected";
|
|
echo '>'.nombre_dia($i+1).'</option>';
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena un desplegable para elegir fecha*/
|
|
function rellena_fecha(){
|
|
$dia = date("j");
|
|
$mes = date("n");
|
|
$anyo = date('Y');
|
|
echo $locale['318'];
|
|
|
|
rellena_numerico_select("dia",0,31, $dia);
|
|
echo $locale['328'];
|
|
rellena_numerico_select("mes",0,12, $mes);
|
|
echo $locale['329'];
|
|
|
|
rellena_numerico_select("anyo",($anyo-100),100, $anyo);
|
|
}
|
|
|
|
/* Rellena un desplegable para elegir fecha seleccionando la fecha parámetro*/
|
|
function rellena_fecha_nombre_select($fecha){
|
|
rellena_fecha_select($fecha, "");
|
|
}
|
|
|
|
/* Rellena un desplegable para elegir fecha seleccionando la fecha parámetro y nombre del select*/
|
|
function rellena_fecha_select($fecha, $nombre){
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
$tiempo =explode("-",$fecha);
|
|
$dia = $tiempo[2];
|
|
$mes = $tiempo[1];
|
|
$anyo = $tiempo[0];
|
|
if($anyo <= 0) $anyo = date('Y');
|
|
echo $locale['318'];
|
|
rellena_numerico_select("dia".$nombre,0,31, $dia);
|
|
echo $locale['328'];
|
|
rellena_numerico_select("mes".$nombre,0,12, $mes);
|
|
echo $locale['329'];
|
|
rellena_numerico_select("anyo".$nombre,($anyo-100),100, $anyo);
|
|
}
|
|
|
|
/* Rellena una lista a borrar */
|
|
//function rellena_borrable($tabla, $tabla2, $nombre, $oid){
|
|
// if ($link = conectar()){
|
|
// $consulta = "select * from ".$tabla.",".$tabla2." where $tabla.$nombre = $tabla2.oid and oid_i = ".$oid."";
|
|
// if ($resultado = consultar($consulta,$link)){
|
|
// while ($row = mysql_fetch_array($resultado)){
|
|
// echo '<br>'.$row["id"].' - <a href="borrar_datos.php?oid='.$oid.'&tabla='.$tabla.'&'.$nombre.'='.urlencode($row[$nombre]).'">Borrar</a>';
|
|
// }
|
|
// }
|
|
// }
|
|
// echo '</select>';
|
|
//}
|
|
|
|
function rellena_borrable_ConDestino($tabla, $tabla2, $nombre, $oid,$destino){
|
|
if ($link = conectar()){
|
|
$consulta = "select * from ".$tabla.",".$tabla2." where $tabla.$nombre = $tabla2.oid and oid_i = ".$oid."";
|
|
if ($resultado = consultar($consulta,$link)){
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
echo '<br>'.$row["id"].' - <a href="'.$destino.'?oid='.$oid.'&tabla='.$tabla.'&'.$nombre.'='.urlencode($row[$nombre]).'">Borrar</a>';
|
|
}
|
|
}
|
|
}
|
|
echo '</select>';
|
|
}
|
|
|
|
/* Rellena una lista */
|
|
function rellena_lista($tabla, $nombre, $oid){
|
|
if ($link = conectar()){
|
|
$consulta = "select * from ".$tabla." where oid_i = ".$oid."";
|
|
if ($resultado = consultar($consulta,$link)){
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
$res[] = $row[$nombre];
|
|
echo $row[$nombre].'<br>';
|
|
}
|
|
}
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
/* Rellena una lista */
|
|
function rellena_lista_oid($tabla, $tabla2, $nombre, $oid){
|
|
if ($link = conectar()){
|
|
$consulta = "select * from ".$tabla.",".$tabla2." where $tabla.$nombre = $tabla2.oid and oid_i = ".$oid."";
|
|
if ($resultado = consultar($consulta,$link)){
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
$res[] = $row["id"];
|
|
//echo $row["id"].'<br>';
|
|
}
|
|
}
|
|
}
|
|
return $res;
|
|
}
|
|
|
|
/* Muestra los resultados */
|
|
function mostrar_resultados($errores, $aciertos){
|
|
$oid = $_SESSION["oid"];
|
|
$errores = explode(".", $errores);
|
|
$aciertos = explode(".", $aciertos);
|
|
if ($link = conectar()){
|
|
foreach($errores as $error){
|
|
if($error != ""){
|
|
$consulta = "insert into resultado_acciones values ('', '$oid', '$error', curdate(), '0')";
|
|
$resultado = mysql_query($consulta, $link);
|
|
}
|
|
}
|
|
foreach($aciertos as $acierto){
|
|
if($acierto != ""){
|
|
$consulta = "insert into resultado_acciones values ('', '$oid', '$acierto', curdate(), '1')";
|
|
$resultado = mysql_query($consulta, $link);
|
|
}
|
|
}
|
|
$consulta = "select fifo, resultado, tipo from resultado_acciones where oid='$oid' order by fifo DESC limit 0, 5";
|
|
$resultado = mysql_query($consulta, $link);
|
|
if($resultado){
|
|
while($rows = mysql_fetch_array($resultado)){
|
|
$res = $rows["resultado"];
|
|
$tipo = $rows["tipo"];
|
|
$fifo = $rows["fifo"];
|
|
if($tipo == 0){
|
|
echo '<p class=errorcampo>'.$res.'</p>';
|
|
}else if($tipo == 1){
|
|
echo '<p class=okcampo>'.$res.'</p>';
|
|
}
|
|
}
|
|
}
|
|
$consulta = "delete from resultado_acciones where fecha < curdate()";
|
|
$resultado = mysql_query($consulta, $link);
|
|
}
|
|
}
|
|
|
|
/* Muestra los errores */
|
|
function mostrar_errores($errores){
|
|
$errores = explode(".", $errores);
|
|
foreach($errores as $error){
|
|
echo '<p class=errorcampo>'.$error.'</p>';
|
|
}
|
|
}
|
|
|
|
/* Muestra los aciertos */
|
|
function mostrar_aciertos($aciertos){
|
|
$aciertos = explode(".", $aciertos);
|
|
foreach($aciertos as $acierto){
|
|
echo '<p class=okcampo>'.$acierto.'</p>';
|
|
}
|
|
}
|
|
|
|
/* Devuelve un array con los valores de un campo de una tabla */
|
|
function input_array_tabla($nombre, $tabla, $campo, $oid){
|
|
$consulta = "select ".$campo." from ".$tabla." where oid_i=".$oid."";
|
|
//echo ($consulta);
|
|
if ($resultado = consultar($consulta))
|
|
while ($row = mysql_fetch_array($resultado)){
|
|
echo '<input type="hidden" name="'.$nombre.'[]" value="'.$row[$campo].'">';
|
|
}
|
|
}
|
|
|
|
/* Devuelve el color de una procedencia */
|
|
function color_procedencia($procedencia){
|
|
|
|
if ($link = conectar()){
|
|
if ($resultado = consultar("select * from procedencia where num='$procedencia'",$link)){
|
|
while ($row = mysql_fetch_array($resultado))
|
|
return $row["color"];
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// Strip Input Function, prevents HTML in unwanted places
|
|
/*function stripinput($text) {
|
|
include_once("Objects/BD.php");
|
|
$bd = new BD();
|
|
$link = $bd->getLink();
|
|
mysql_real_escape_string($text,$link);
|
|
return $text;
|
|
}*/
|
|
|
|
function stripinput($text) {
|
|
include_once("Objects/BD.php");
|
|
$bd = new BD();
|
|
$link = $bd->getLink();
|
|
if(gettype($text) == "string"){
|
|
mysql_real_escape_string($text,$link);
|
|
}
|
|
if (QUOTES_GPC) $text = stripslashes($text);
|
|
$search = array("\"", "'", "\\", '\"', "\'", "<", ">", " ");
|
|
$replace = array(""", "'", "\", """, "'", "<", ">", " ");
|
|
$text = str_replace($search, $replace, $text);
|
|
return $text;
|
|
}
|
|
|
|
//function menu_candidatos($oid, $pagina, $tabla_cond, $condicion){
|
|
// $tabla = "usuarios";
|
|
// include LOCALE.LOCALESET."lenguaje.php";
|
|
// echo '<table width="100%" class="encabezado"><tr>';
|
|
// if(!strpos($pagina, "?")) $pagina .= '.php?liberar=si';
|
|
// echo '<td class="sinborde"><form action="'.$pagina.'" method=POST>';
|
|
// echo '<input type=hidden name=tabla_lib value="'.$tabla.'">';
|
|
// echo '<input type=hidden name=tabla value="'.$tabla_cond.'">';
|
|
// echo '<input type=hidden name=oid value="'.$oid.'">';
|
|
// echo '<input type="hidden" name="condicion" value="'.$condicion.'">';
|
|
// echo '<input type="image" name="eliminar" src="css/flecha_menos.gif">';
|
|
// echo '</form></td>';
|
|
// if(comprobar_permisos("LC"))
|
|
// echo "<td class=sinborde>
|
|
// <form action='lista.php?liberar=si' method='POST'>
|
|
// <input type=hidden name=tabla_lib value=$tabla>
|
|
// <input type=hidden name=oid value=$oid>
|
|
// <input type=submit value='".$locale['801']."' class=button>
|
|
// </form></td>";
|
|
// if(comprobar_permisos("AC"))
|
|
// echo "<td class=sinborde>
|
|
// <form action='candidatos.php?liberar=si' method='POST'>
|
|
// <input type=hidden name=tabla_lib value=$tabla>
|
|
// <input type=hidden name=oid value=$oid>
|
|
// <input type=submit value='".$locale['802']."' class=button>
|
|
// </form></td>";
|
|
// if(comprobar_permisos("SP"))
|
|
// echo "<td class=sinborde>
|
|
// <form action='formulario_importa_candidato.php?liberar=si' method='POST'>
|
|
// <input type=hidden name=tabla_lib value=$tabla>
|
|
// <input type=hidden name=oid value=$oid>
|
|
// <input type=submit value='".$locale['815']."' class=button>
|
|
// </form></td>";
|
|
// if(comprobar_permisos("LC"))
|
|
// echo "<td class=sinborde>
|
|
// <form action='buscar.php?liberar=si' method='POST'>
|
|
// <input type=hidden name=tabla_lib value=$tabla>
|
|
// <input type=hidden name=oid value=$oid>
|
|
// <input type=submit value='".$locale['816']."' class=button>
|
|
// </form></td>";
|
|
// echo '</tr></table>';
|
|
//}
|
|
|
|
//function menu_usuarios($oid){
|
|
// $tabla = "usuarios";
|
|
// include LOCALE.LOCALESET."lenguaje.php";
|
|
// echo '<table><tr>';
|
|
// if(comprobar_permisos("LU"))
|
|
// echo "<td class=sinborde>
|
|
// <form action='lista_usuarios.php?liberar=si' method='POST'>
|
|
// <input type=hidden name=tabla_lib value=$tabla>
|
|
// <input type=hidden name=oid value=$oid>
|
|
// <input type=submit value='".$locale['806']."' class=button>
|
|
// </form></td>";
|
|
// if(comprobar_permisos("AU"))
|
|
// echo "<td class=sinborde>
|
|
// <form action='usuarios.php?liberar=si' method='POST'>
|
|
// <input type=hidden name=tabla_lib value=$tabla>
|
|
// <input type=hidden name=oid value=$oid>
|
|
// <input type=submit value='".$locale['807']."' class=button>
|
|
// </form></td>";
|
|
// if(comprobar_permisos("LU"))
|
|
// echo "<td class=sinborde>
|
|
// <form action='buscar_usuarios.php?liberar=si' method='POST'>
|
|
// <input type=hidden name=tabla_lib value=$tabla>
|
|
// <input type=hidden name=oid value=$oid>
|
|
// <input type=submit value='".$locale['817']."' class=button>
|
|
// </form></td>";
|
|
// echo '</tr></table>';
|
|
//}
|
|
|
|
function menu_clientes($oid){
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
echo '<table><tr>';
|
|
if(comprobar_permisos("GP") || comprobar_permisos("SP")){
|
|
echo "<td class=sinborde>
|
|
<form action='lista_clientes.php' method='POST'>
|
|
<input type=submit value='".$locale['2200']."' class=button>
|
|
</form></td>";
|
|
echo "<td class=sinborde>
|
|
<form action='formulario_cliente.php' method='POST'>
|
|
<input type=submit value='".$locale['2203']."' class=button>
|
|
</form></td>";
|
|
}
|
|
echo '</tr></table>';
|
|
}
|
|
|
|
function menu_alarmas($oid){
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
echo '<table><tr>';
|
|
if(comprobar_permisos("GP") || comprobar_permisos("SP")){
|
|
echo "<td class=sinborde>
|
|
<form action='administracion_alarmas.php' method='POST'>
|
|
<input type=submit value='".$locale['332']."' class=button>
|
|
</form></td>";
|
|
echo "<td class=sinborde>
|
|
<form action='formulario_alarma.php' method='POST'>
|
|
<input type=submit value='".$locale['333']."' class=button>
|
|
</form></td>";
|
|
}
|
|
echo '</tr></table>';
|
|
}
|
|
|
|
function menu_informes($oid){
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
echo '<table><tr>';
|
|
if(comprobar_permisos("AF")){
|
|
echo "<td class=sinborde>
|
|
<form action='lista_informes.php' method='POST'>
|
|
<input type=submit value='".$locale['2000']."' class=button>
|
|
</form></td>";
|
|
echo "<td class=sinborde>
|
|
<form action='formulario_informe.php' method='POST'>
|
|
<input type=submit value='".$locale['2003']."' class=button>
|
|
</form></td>";
|
|
}
|
|
echo '</tr></table>';
|
|
}
|
|
|
|
function menu_pedidos($oid){
|
|
$tabla = "pedidos";
|
|
include LOCALE.LOCALESET."lenguaje.php";
|
|
echo '<table><tr>';
|
|
if(comprobar_permisos("GP") || comprobar_permisos("SP")){
|
|
echo "<td class=sinborde>
|
|
<form action='lista_pedidos.php?liberar=si' method='POST'>
|
|
<input type=hidden name=tabla_lib value=$tabla>
|
|
<input type=hidden name=oid value=$oid>
|
|
<input type=submit value='".$locale['1006']."' class=button>
|
|
</form></td>";
|
|
echo "<td class=sinborde>
|
|
<form action='pedido.php?liberar=si' method='POST'>
|
|
<input type=hidden name=tabla_lib value=$tabla>
|
|
<input type=hidden name=oid value=$oid>
|
|
<input type=submit value='".$locale['1008']."' class=button>
|
|
</form></td>";
|
|
echo "<td class=sinborde>
|
|
<form action='buscar_pedido.php?liberar=si' method='POST'>
|
|
<input type=hidden name=tabla_lib value=$tabla>
|
|
<input type=hidden name=oid value=$oid>
|
|
<input type=submit value='".$locale['1009']."' class=button>
|
|
</form></td>";
|
|
echo "<td class=sinborde>
|
|
<form action='buscar.php' target=popup onsubmit=window.open('', 'popup', 'width = 200, height = 100') method='POST'>
|
|
<input type='submit' class='button' value='".$locale['816']."'></td>
|
|
<td class=sinborde></form>
|
|
<form action='buscar_usuarios.php' target=popup onsubmit=window.open('', 'popup', 'width = 200, height = 100') method='POST'>
|
|
<input type='submit' class='button' value='".$locale['817']."'></form></td>";
|
|
}
|
|
echo '</tr></table>';
|
|
}
|
|
|
|
//function volver($pagina, $tabla, $oid, $condicion){
|
|
// echo '<form action="'.$pagina.'.php?liberar=si" method=POST>';
|
|
// echo '<input type=hidden name=tabla_lib value="'.$tabla.'">';
|
|
// echo '<input type=hidden name=tabla value="'.$tabla.'">';
|
|
// echo '<input type=hidden name=oid value="'.$oid.'">';
|
|
// echo '<input type="hidden" name="condicion" value="'.$condicion.'">';
|
|
// echo '<input type="image" name="eliminar" src="css/flecha_menos.gif">';
|
|
// echo '</form>';
|
|
//}
|
|
|
|
function consulta($tabla, $campo, $condicion){
|
|
if($link = conectar()){
|
|
$consulta = "select $campo from $tabla where $condicion";
|
|
$resultado = mysql_query($consulta, $link);
|
|
$rows = mysql_fetch_array($resultado);
|
|
return $rows[$campo];
|
|
}
|
|
}
|
|
|
|
?>
|