Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/05/2011, 10:39
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/cambio.servicios.php (Primera sección)

Código PHP:
<?php
    
function PROPUESTA_SERVICIOS_Multiples_Cambios($cn$extras$inicial 0) {
        
$tab_index 30;
        
$seleccion = array();
        
$ids array_keys($extras["Servicios"]);
        foreach (
$ids as $id) {
            
$PSID $id;
        }
        
$selectores = new SelectorProgramaServicios;
        
/**** 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 = {$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 ****/
        
if (!$inicial) {
            
$selectores->origen 1;
            
$selectores->datos $extras;
            
$extras $selectores->ServicioBase($cn);
            
$extras["Servicios"][$PSID]["Bases"] = array(
                
"Proveedor" => $extras["Servicios"][$PSID]["Proveedor"],
                
"Ciudad" => $extras["Servicios"][$PSID]["Ciudad"],
                
"TipoServicio" => $extras["Servicios"][$PSID]["TipoServicio"],
                
"CategoriaServicio" => $extras["Servicios"][$PSID]["CategoriaServicio"],
                
"Servicio" => $extras["Servicios"][$PSID]["Servicio"],
                
"Acomodacion" => $extras["Servicios"][$PSID]["Acomodacion"],
                
"ValorServicio" => $extras["Servicios"][$PSID]["ValorServicio"],
                
"Obligatorio" => $extras["Servicios"][$PSID]["Obligatorio"]
            );
        }
?>
        <form action="servicios.php" method="post">
            
            <div id="frm_servicios" style="clear: both; margin-left: 20px; padding-top: 20px; width: 48%;">
                
                <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 ($extras["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);
        
//SERVICIO BASE... (UNA VEZ)
        
if (!$inicial) {
            
$sql "SELECT p.id AS id, p.nombrecomercial AS nombre FROM proveedores p WHERE p.id = {$extras["Servicios"][$PSID]["Bases"]["Proveedor"]}";
            
$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);
        }
        
//FIN: SERVICIO BASE... (UNA VEZ)
?>
                    <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 == $extras["Servicios"][$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 ($extras["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 = {$extras["Servicios"][$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);
        
//SERVICIO BASE... (UNA VEZ)
        
if (!$inicial) {
            
$sql "SELECT c.id AS id, c.nombre AS nombre FROM ciudades c WHERE c.id = {$extras["Servicios"][$PSID]["Bases"]["Ciudad"]}";
            
$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);
        }
        
//FIN: SERVICIO BASE... (UNA VEZ)
?>
                    <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 == $extras["Servicios"][$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 ($extras["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 = {$extras["Servicios"][$PSID]["Proveedor"]} AND",
            
=> "s.ciudad = {$extras["Servicios"][$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);
        
//SERVICIO BASE... (UNA VEZ)
        
if (!$inicial) {
            
$sql "SELECT ts.id AS id, ts.nombre AS nombre FROM tiposservicio ts WHERE ts.id = {$extras["Servicios"][$PSID]["Bases"]["TipoServicio"]}";
            
$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);
        }
        
//FIN: SERVICIO BASE... (UNA VEZ)
?>
                    <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 == $extras["Servicios"][$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