function obtenerSelectPadres($default = null) { $add = ""; $option = ""; if ($default != '-1') { if ($default != null) { $padre = new Tab_unidad(); $r_padres = $padre->dbselectBy2Field("uni_id", $default, "uni_estado", 1); if (count($r_padres) > 0) { $padre = $r_padres[0]; } } $sql = "SELECT \r\n tu.uni_id, \r\n tu.uni_codigo, \r\n tu.uni_par, \r\n tu.uni_descripcion\r\n FROM tab_unidad tu\r\n WHERE (tu.uni_estado = '10' OR tu.uni_estado = '1') {$add}\r\n ORDER BY tu.uni_cod ASC "; $rows = $this->unidad->dbSelectBySQL($sql); if (count($rows) > 0) { foreach ($rows as $val) { if ($default == $val->uni_id) { $selected = "selected"; } else { $selected = " "; } if ($val->uni_par == -1) { $option .= "<option value='" . $val->uni_id . "' " . $selected . ">" . $val->uni_descripcion . "</option>"; } else { $option .= "<option value='" . $val->uni_id . "' " . $selected . ">" . "-- " . $val->uni_descripcion . "</option>"; } } } } return $option; }