Ver Mensaje Individual
  #5 (permalink)  
Antiguo 27/05/2011, 10:46
Avatar de rfadgrmm
rfadgrmm
 
Fecha de Ingreso: junio-2009
Mensajes: 74
Antigüedad: 14 años, 10 meses
Puntos: 1
Pregunta Respuesta: Jquery - Combos Multiples

Continuación: archivo mods/combos.cambio.servicios.php (Primera sección)
Este archivo lo estoy manejando por JQuery en servicios.php

Código PHP:
<?php
    
include_once("../bin/class.selector.servicios.php");
    
    
$cn mysql_connect("localhost""usuario""clave");
    
mysql_select_db("mibasedatos"$cn);
    
    
$datos = array(
        
"PSID" => $_POST["PSID"],
        
"Principal" => $_POST["principal"],
        
"Caso" => $_POST["caso"]
    );
    switch (
$datos["Caso"]) {
        case 
1:
            
//PROVEEDOR...
            
$datos["Servicios"][$datos["PSID"]] = array(
                
"Proveedor" => $_POST["proveedor"]
            );
            break;
        case 
2:
            
//CIUDAD...
            
$datos["Servicios"][$datos["PSID"]] = array(
                
"Proveedor" => $_POST["proveedor"],
                
"Ciudad" => $_POST["ciudad"]
            );
            break;
        case 
3:
            
//TIPO DE SERVICIO...
            
$datos["Servicios"][$datos["PSID"]] = array(
                
"Proveedor" => $_POST["proveedor"],
                
"Ciudad" => $_POST["ciudad"],
                
"TipoServicio" => $_POST["tiposervicio"]
            );
            break;
        case 
4:
            
//CATEGORIA DE SERVICIO...
            
$datos["Servicios"][$datos["PSID"]] = array(
                
"Proveedor" => $_POST["proveedor"],
                
"Ciudad" => $_POST["ciudad"],
                
"TipoServicio" => $_POST["tiposervicio"],
                
"CategoriaServicio" => $_POST["categoriaservicio"]
            );
            break;
        case 
5:
            
//SERVICIO...
            
$datos["Servicios"][$datos["PSID"]] = array(
                
"Proveedor" => $_POST["proveedor"],
                
"Ciudad" => $_POST["ciudad"],
                
"TipoServicio" => $_POST["tiposervicio"],
                
"CategoriaServicio" => $_POST["categoriaservicio"],
                
"Servicio" => $_POST["servicio"]
            );
            break;
        default:
            
//NADA...
            
break;
    }
    
    
$tab_index 30;
    
$seleccion = array();
    
    
/**** LEYENDA INICIAL ****/
    
$bloques = array(
        
=> "SELECT s.id AS id, s.descripcion AS servicio FROM servicios s INNER JOIN",
        
=> "propuestaservicios ps ON (ps.servicio = s.id) WHERE ps.id = {$datos["PSID"]}"
    
);
    
$sql implode(" "$bloques);
    
$rs mysql_query($sql$cn);
    
$encontrado mysql_num_rows($rs);
    if (
$encontrado) {
        while (
$ma mysql_fetch_array($rs)) {
            
$leyendas = array(
                
"ID" => $ma["id"],
                
"Servicio" => $ma["servicio"]
            );
        }
        
$ma "";
    }
    
mysql_free_result($rs);
    
/**** FIN: LEYENDA INICIAL ****/
    
    
$selectores = new SelectorProgramaServicios;
    
$selectores->seleccion $datos["Caso"];
    
$selectores->origen $datos["Principal"];
    
$selectores->datos $datos;
    
$datos $selectores->Selecciones($cn);
    unset(
$selectores);
?>
                
                <div style="clear: both; width: 100%;">
                    <div style="float: none; width: 100%;">
                        <p style="padding-bottom: 20px;"><?php echo "Cambiar Servicio Nº {$leyendas["ID"]} - {$leyendas["Servicio"]}"?></p>
                    </div>
                    <div style="clear: both; font-size: 1px; width: 100%;">&nbsp;</div>
                </div>
                <div style="clear: both; width: 100%;">
                    <div style="float: left; width: 30%;">
                        <div style="float: none; width: 100%;">
                            <p><label for="lb_proveedor">Proveedor / Operador :</label></p>
                        </div>
                    </div>
<?php
        
if ($datos["Principal"]) {
            
$limites "AND s.tiposervicio NOT IN (2)";
        } else {
            
$limites "";
        }
        
$bloques = array(
            
=> "SELECT DISTINCT p.id AS id, p.nombrecomercial AS nombre",
            
=> "FROM proveedores p INNER JOIN servicios s ON (s.proveedor = p.id)",
            
=> "INNER JOIN tarifarios t ON (s.id = t.servicio) WHERE s.estado = 1 AND s.eliminado = 0",
            
=> "{$limites}",
            
=> "ORDER BY p.nombrecomercial"
        
);
        
$arreglo = array();
        
$sql implode(" "$bloques);
        
$rs mysql_query($sql$cn);
        
$encontrados mysql_num_rows($rs);
        if (
$encontrados) {
            while (
$ma mysql_fetch_array($rs)) {
                
$arreglo[$ma["id"]] = $ma["nombre"];
            }
            
$ma "";
        }
        
mysql_free_result($rs);
?>
                    <div style="float: left; width: 70%;">
                        <div style="float: none; width: 100%;">
                            <p><select name="sel_proveedores" id="lb_proveedor" class="ComboBox" style="width: 320px;" tabindex="<?php echo $tab_index++; ?>">
<?php
        
if (count($arreglo)) {
            
$llaves array_keys($arreglo);
            foreach (
$llaves as $llave) {
                if (
$llave == $datos["Servicios"][$datos["PSID"]]["Proveedor"]) {
                    
$seleccion[0] = " selected=\"selected\"";
                } else {
                    
$seleccion[0] = "";
                }
?>
                                <option value="<?php echo $llave?>"<?php echo $seleccion[0]; ?>><?php echo $arreglo[$llave]; ?></option>
<?php
            
}
        } else {
?>
                                <option value="0">&nbsp;</option>
<?php
        
}
?>
                            </select></p>
                        </div>
                    </div>
                    <div style="clear: both; font-size: 1px; width: 100%;">&nbsp;</div>
                </div>
                <div style="clear: both; width: 100%;">
                    <div style="float: left; width: 30%;">
                        <div style="float: none; width: 100%;">
                            <p><label for="lb_ciudad">Ciudad / Destino :</label></p>
                        </div>
                    </div>
<?php
        
if ($datos["Principal"]) {
            
$limites "AND s.tiposervicio NOT IN (2)";
        } else {
            
$limites "";
        }
        
$bloques = array(
            
=> "SELECT DISTINCT c.id AS id, c.nombre AS nombre",
            
=> "FROM ciudades c INNER JOIN servicios s ON (s.ciudad = c.id)",
            
=> "INNER JOIN tarifarios t ON (s.id = t.servicio) WHERE s.estado = 1",
            
=> "AND s.eliminado = 0 AND s.proveedor = {$datos["Servicios"][$datos["PSID"]]["Proveedor"]}",
            
=> "{$limites}",
            
=> "ORDER BY c.nombre"
        
);
        
$arreglo = array();
        
$sql implode(" "$bloques);
        
$rs mysql_query($sql$cn);
        
$encontrados mysql_num_rows($rs);
        if (
$encontrados) {
            while (
$ma mysql_fetch_array($rs)) {
                
$arreglo[$ma["id"]] = $ma["nombre"];
            }
            
$ma "";
        }
        
mysql_free_result($rs);
?>
                    <div style="float: left; width: 70%;">
                        <div style="float: none; width: 100%;">
                            <p><select name="sel_ciudades" id="lb_ciudad" class="ComboBox" style="width: 320px;" tabindex="<?php echo $tab_index++; ?>">
<?php
        
if (count($arreglo)) {
            
$llaves array_keys($arreglo);
            foreach (
$llaves as $llave) {
                if (
$llave == $datos["Servicios"][$datos["PSID"]]["Ciudad"]) {
                    
$seleccion[1] = " selected=\"selected\"";
                } else {
                    
$seleccion[1] = "";
                }
?>
                                <option value="<?php echo $llave?>"<?php echo $seleccion[1]; ?>><?php echo $arreglo[$llave]; ?></option>
<?php
            
}
        } else {
?>
                                <option value="0">&nbsp;</option>
<?php
        
}
?>
                            </select></p>
                        </div>
                    </div>
                    <div style="clear: both; font-size: 1px; width: 100%;">&nbsp;</div>
                </div>
                <div style="clear: both; width: 100%;">
                    <div style="float: left; width: 30%;">
                        <div style="float: none; width: 100%;">
                            <p><label for="lb_tiposervicio">Tipo de Servicio :</label></p>
                        </div>
                    </div>
<?php
        
if ($datos["Principal"]) {
            
$limites "AND ts.id NOT IN (2)";
        } else {
            
$limites "";
        }
        
$bloques = array(
            
=> "SELECT DISTINCT ts.id AS id, ts.nombre AS nombre",
            
=> "FROM tiposservicio ts INNER JOIN servicios s ON (s.tiposervicio = ts.id)",
            
=> "INNER JOIN tarifarios t ON (s.id = t.servicio) WHERE s.estado = 1 AND",
            
=> "s.eliminado = 0 AND s.proveedor = {$datos["Servicios"][$datos["PSID"]]["Proveedor"]} AND",
            
=> "s.ciudad = {$datos["Servicios"][$datos["PSID"]]["Ciudad"]}",
            
=> "{$limites}",
            
=> "ORDER BY ts.nombre"
        
);
        
$arreglo = array();
        
$sql implode(" "$bloques);
        
$rs mysql_query($sql$cn);
        
$encontrados mysql_num_rows($rs);
        if (
$encontrados) {
            while (
$ma mysql_fetch_array($rs)) {
                
$arreglo[$ma["id"]] = $ma["nombre"];
            }
            
$ma "";
        }
        
mysql_free_result($rs);
?>
                    <div style="float: left; width: 70%;">
                        <div style="float: none; width: 100%;">
                            <p><select name="sel_tiposservicio" id="lb_tiposervicio" class="ComboBox" style="width: 320px;" tabindex="<?php echo $tab_index++; ?>">
<?php
        
if (count($arreglo)) {
            
$llaves array_keys($arreglo);
            foreach (
$llaves as $llave) {
                if (
$llave == $datos["Servicios"][$datos["PSID"]]["TipoServicio"]) {
                    
$seleccion[2] = " selected=\"selected\"";
                } else {
                    
$seleccion[2] = "";
                }
?>
                                <option value="<?php echo $llave?>"<?php echo $seleccion[2]; ?>><?php echo $arreglo[$llave]; ?></option>
<?php
            
}
        } else {
?>
                                <option value="0">&nbsp;</option>
<?php
        
}
?>
                            </select></p>
                        </div>
                    </div>
                    <div style="clear: both; font-size: 1px; width: 100%;">&nbsp;</div>
                </div>
__________________
"Viajando en el espacio profundo, de nova en nova, y sorteando a veces uno que otro agujero negro..." Peru@D