elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Tutorial básico de Quickjs


  Mostrar Mensajes
Páginas: [1] 2
1  Programación / Desarrollo Web / Re: [AYUDA] Por favor ayuda con imagenes en html en: 24 Febrero 2016, 21:35 pm
Sería meter a la imagen en un div

Código:
<div>
       <img>
</div>


La imagen cogerá el tamaño del div. Tú debes ajustar el div al tamaño que quieras, y la imagen hará lo mismo. En el div es donde debes poner el width en porcentaje, a la imagen no se lo pongas.

Lo del max-width:100% es por si el div se hace demasiado grande, para que la imagen no se pixele
2  Programación / Desarrollo Web / Re: [AYUDA] Por favor ayuda con imagenes en html en: 24 Febrero 2016, 08:48 am
Buenas, prueba con esto:

Código:
.imagen {
     max-width: 100%;
     height: auto;
}

Así el ancho de la imagen se adaptará a su contenedor
3  Programación / Desarrollo Web / Re: No consigo asignar valor a una variable en javascript en: 22 Febrero 2016, 20:43 pm
He conseguido averiguar la solución a mi problema

He depurado a tope y no he conseguido saber dónde había fallado. Así que decidí cambiar el planteamiento de la función y en vez de basarme en la dirección del usuario lo he hecho en sus coordenadas (mucho más fáciles de obtener). Así queda la cosa:

Aquí consigo las coordenadas del usuario:

Código
  1. /********calcularMiUbicacion()*************************************/
  2.    function calcularMiUbicacion(){
  3.  
  4.        if(!navigator.geolocation){
  5.            alert('Tu navegador no soporta geolocalización');
  6.            return;
  7.        }
  8.  
  9.        function success(position){
  10.  
  11.            var latitud = position.coords.latitude;
  12.            var longitud = position.coords.longitude;
  13.  
  14.            var lat = parseFloat(latitud);
  15.            var lng = parseFloat(longitud);
  16.  
  17.            var latlng = {
  18.                lat:lat ,
  19.                lng: lng
  20.            };            
  21.            origen = latlng;
  22.  
  23.            calcularRuta();                    
  24.  
  25.        }          
  26.  
  27.        function error(){
  28.            alert('Incapaz de conseguir tu ubicación');
  29.        }
  30.  
  31.        navigator.geolocation.getCurrentPosition(success,error);
  32.  
  33.  
  34.    }
  35.  
  36.    /********Fin calcularMiUbicacion()*************************************/
  37.  
  38.  


Y aquí creo la ruta:
Código
  1. //****calcularRuta()**************************
  2.    function calcularRuta(){
  3.  
  4.        var request = {
  5.             origin: origen,
  6.             destination: destino,
  7.             travelMode: google.maps.DirectionsTravelMode[$('#modo_viaje').val()],
  8.             unitSystem: google.maps.DirectionsUnitSystem[$('#tipo_sistema').val()],
  9.             provideRouteAlternatives: true
  10.        };
  11.  
  12.        directionsService.route(request, function(response, status) {
  13.            if (status === google.maps.DirectionsStatus.OK) {
  14.                directionsDisplay.setMap(map);
  15.                directionsDisplay.setPanel($("#panel_ruta").get(0));
  16.                directionsDisplay.setDirections(response);
  17.            } else {
  18.                    alert("No existen rutas entre ambos puntos");
  19.            }
  20.        });
  21.    }
  22.    /******Fin calcularRuta()***************************************/
  23.  
4  Programación / Desarrollo Web / (Solucionado) No consigo asignar valor a una variable en javascript en: 12 Febrero 2016, 20:10 pm
Hola a todos, y gracias de antemano por ayudarme.

Estoy trabajando en una web donde necesito saber la dirección del usuario para crear una ruta de su localización hasta la del cliente.

Hasta ahora he conseguido trazarla cuando el usuario introduce una dirección, pero me gustaría que esto funcionase para poner el típico botón de "Usar mi localización actual"

El problema en concreto que tengo es que, como indico en el código, consigo la dirección y la pinto en un alert, pero sin embargo la variable "direccion" me aparece todo el rato, incluso en depuración como UNDEFINED.

Agradezco cualquier ayuda, gracias


Código
  1. function calcularMiUbicacion(){
  2.        debugger;
  3.        var direccion='';
  4.        var output = document.getElementById("out");
  5.  
  6.  
  7.        if(!navigator.geolocation){
  8.  
  9.            output.innerHTML="<p>Tu navegador no soporta Geolocalización</p>";
  10.            return;
  11.        }
  12.  
  13.        function success(position){
  14.            debugger;
  15.            alert('Estoy en success');    
  16.            var latitud = position.coords.latitude;
  17.            var longitud = position.coords.longitude;
  18.            var direccion='';
  19.  
  20.  
  21.            var geocoder = new google.maps.Geocoder;
  22.            var latlng = {
  23.                lat:latitud ,
  24.                lng: longitud
  25.            };
  26.            geo =geocoder.geocode(
  27.                {'location': latlng},
  28.                function(results, status) {
  29.  
  30.                        if (status === google.maps.GeocoderStatus.OK) {
  31.                            if (results[0]) {
  32.  
  33.                                direccion = results[0].formatted_address.toString();
  34.                                /*ESTE ALERT PINTA BIEN LA DIRECCION */
  35.                                alert('direccion: '+direccion);
  36.  
  37.  
  38.                            } else {
  39.                                window.alert('No results found');
  40.                            }
  41.                        } else {
  42.                            window.alert('Geocoder failed due to: ' + status);
  43.                        }
  44.  
  45.  
  46.                });
  47.  
  48.  
  49.        }          
  50.  
  51.        function error(){
  52.            alert('Incapaz de conseguir tu ubicación');
  53.            output.innerHTML="Incapaz de conseguir tu ubicación";
  54.        }
  55.  
  56.        direccion = navigator.geolocation.getCurrentPosition(success,error);
  57.        return direccion;
  58.  
  59.    }
  60.  
5  Foros Generales / Dudas Generales / Re: Duda si puedo crear software a partir de BD de otra empresa en: 7 Marzo 2015, 08:27 am
Es lo que me temo Aberroncho.

Intentaré consultar el contrato, a ver si averiguo algo.

Muchas gracias  ;)
6  Foros Generales / Dudas Generales / Re: Duda si puedo crear software a partir de BD de otra empresa en: 6 Marzo 2015, 20:25 pm
Gracias por contestar, Inquisidor
7  Foros Generales / Dudas Generales / Duda si puedo crear software a partir de BD de otra empresa en: 6 Marzo 2015, 18:29 pm
Hola, tengo un problemilla a ver si alguien me podría ayudar:

Resulta que yo trabajo de empleado en una empresa de transporte, nada que ver con la informática, pero resulta que he desarrollado un aplicación de escritorio para crear rutas de reparto.

El asunto es que, para que mi programa sea viable, he de acceder a la base de datos de mi empresa, que está alojada en un servidor. Esta base de datos la gestiona un empresa de informática independiente de la mía. Mi empresa me autoriza a usar la base de datos.

Entonces la pregunta es: ¿la empresa de informática podría poner algún impedimento, al ser yo ajenos a ellos, o deben ceder porque mi empresa da permiso?

Gracias por vuestra paciencia, un saludo  ;-)
8  Programación / Java / Re: Problema con iReport en: 15 Diciembre 2014, 17:47 pm
Gracias por responder, Elektro.

He mirado en la dirección que me has puesto, y después de investigar he descubierto que el informe lo había realizado con la versión 5.5.0 de iReport, pero las librerías que he adjuntado a mi proyecto eran más antiguas, aquí estaba el error.

Un saludo
9  Programación / Java / [Resuelto] Problema con iReport en: 15 Diciembre 2014, 11:57 am
Hola a todos. Resulta que he creado un informe con iReport. Para ello he utilizado el plugin
de Netbeans. Con este informe accedo a una base de datos que he creado en PostgreSQL.

El problema es que me sale el siguiente error, se agradece cualquier tipo de ayuda:

Código:
Error al producir informe: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. Cannot cast from Integer to String
                value = (java.lang.String)(((java.lang.Integer)field_id_ruta.getValue())); //$JR_EXPR_ID=10$
                        <--------------------------------------------------------------->
2. Cannot cast from Date to String
                value = (java.lang.String)(((java.sql.Date)field_fecha_servicio.getValue())); //$JR_EXPR_ID=11$
                        <------------------------------------------------------------------>
3. Cannot cast from Integer to String
                value = (java.lang.String)(((java.lang.Integer)field_id_empleado.getValue())); //$JR_EXPR_ID=18$
                        <------------------------------------------------------------------->
4. Cannot cast from Integer to String
                value = (java.lang.String)(((java.lang.Integer)field_id_barrio.getValue())); //$JR_EXPR_ID=19$
                        <----------------------------------------------------------------->
5. Cannot cast from BigDecimal to String
                value = (java.lang.String)(((java.math.BigDecimal)field_total_importe.getValue())); //$JR_EXPR_ID=20$
                        <------------------------------------------------------------------------>
6. Cannot cast from Integer to String
                value = (java.lang.String)(((java.lang.Integer)field_id_ruta.getOldValue())); //$JR_EXPR_ID=10$
                        <------------------------------------------------------------------>
7. Cannot cast from Date to String
                value = (java.lang.String)(((java.sql.Date)field_fecha_servicio.getOldValue())); //$JR_EXPR_ID=11$
                        <--------------------------------------------------------------------->
8. Cannot cast from Integer to String
                value = (java.lang.String)(((java.lang.Integer)field_id_empleado.getOldValue())); //$JR_EXPR_ID=18$
                        <---------------------------------------------------------------------->
9. Cannot cast from Integer to String
                value = (java.lang.String)(((java.lang.Integer)field_id_barrio.getOldValue())); //$JR_EXPR_ID=19$
                        <-------------------------------------------------------------------->
10. Cannot cast from BigDecimal to String
                value = (java.lang.String)(((java.math.BigDecimal)field_total_importe.getOldValue())); //$JR_EXPR_ID=20$
                        <--------------------------------------------------------------------------->
11. Cannot cast from Integer to String
                value = (java.lang.String)(((java.lang.Integer)field_id_ruta.getValue())); //$JR_EXPR_ID=10$
                        <--------------------------------------------------------------->
12. Cannot cast from Date to String
                value = (java.lang.String)(((java.sql.Date)field_fecha_servicio.getValue())); //$JR_EXPR_ID=11$
                        <------------------------------------------------------------------>
13. Cannot cast from Integer to String
                value = (java.lang.String)(((java.lang.Integer)field_id_empleado.getValue())); //$JR_EXPR_ID=18$
                        <------------------------------------------------------------------->
14. Cannot cast from Integer to String
                value = (java.lang.String)(((java.lang.Integer)field_id_barrio.getValue())); //$JR_EXPR_ID=19$
                        <----------------------------------------------------------------->
15. Cannot cast from BigDecimal to String
                value = (java.lang.String)(((java.math.BigDecimal)field_total_importe.getValue())); //$JR_EXPR_ID=20$
                        <------------------------------------------------------------------------>
15 errors



Adjunto el código XML del informe:

Código
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="report name" pageWidth="595" pageHeight="842" columnWidth="535" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" >
  3. <property name="ireport.zoom" value="1.0"/>
  4. <property name="ireport.x" value="0"/>
  5. <property name="ireport.y" value="0"/>
  6. <parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
  7. <defaultValueExpression><![CDATA["C:\\Juanan\\Proyecto\\Aplicación\\Cliente\\src\\cliente\\"]]></defaultValueExpression>
  8. </parameter>
  9. <parameter name="FECHA_SERVICIO" class="java.sql.Date">
  10. <defaultValueExpression><![CDATA[]]></defaultValueExpression>
  11. </parameter>
  12. <queryString>
  13. <![CDATA[SELECT * FROM PEDIDO WHERE FECHA_SERVICIO = $P{FECHA_SERVICIO} ORDER BY ID_RUTA;]]>
  14. </queryString>
  15. <field name="id_empleado" class="java.lang.Integer"/>
  16. <field name="id_barrio" class="java.lang.Integer"/>
  17. <field name="fecha_servicio" class="java.sql.Date"/>
  18. <field name="total_importe" class="java.math.BigDecimal"/>
  19. <field name="id_pedido" class="java.lang.Long"/>
  20. <field name="id_cliente" class="java.lang.Integer"/>
  21. <field name="id_ruta" class="java.lang.Integer"/>
  22. <background>
  23. <band splitType="Stretch"/>
  24. </background>
  25. <title>
  26. <band height="79" splitType="Stretch">
  27. <frame>
  28. <reportElement mode="Opaque" x="0" y="16" width="555" height="44" backcolor="#FF0033" />
  29. <textField>
  30. <reportElement x="65" y="13" width="100" height="20" forecolor="#000000" />
  31. <textElement>
  32. <font size="14" isBold="true"/>
  33. </textElement>
  34. <textFieldExpression><![CDATA[$F{id_ruta}]]></textFieldExpression>
  35. </textField>
  36. <staticText>
  37. <reportElement x="15" y="13" width="50" height="20" />
  38. <textElement>
  39. <font size="14" isBold="true"/>
  40. </textElement>
  41. <text><![CDATA[RUTA :]]></text>
  42. </staticText>
  43. <textField>
  44. <reportElement x="328" y="13" width="213" height="20" />
  45. <textElement>
  46. <font size="14" isBold="true"/>
  47. </textElement>
  48. <textFieldExpression><![CDATA[$F{fecha_servicio}]]></textFieldExpression>
  49. </textField>
  50. <staticText>
  51. <reportElement x="176" y="13" width="131" height="20" />
  52. <textElement>
  53. <font size="14" isBold="true"/>
  54. </textElement>
  55. <text><![CDATA[FECHA SERVICIO :]]></text>
  56. </staticText>
  57. </frame>
  58. </band>
  59. </title>
  60. <detail>
  61. <band height="414" splitType="Stretch">
  62. <subreport>
  63. <reportElement x="0" y="314" width="200" height="100" />
  64. <subreportParameter name="ID_PEDIDO">
  65. <subreportParameterExpression><![CDATA[$F{id_cliente}]]></subreportParameterExpression>
  66. </subreportParameter>
  67. <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
  68. <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "SubinformePedidos.jasper"]]></subreportExpression>
  69. </subreport>
  70. <subreport>
  71. <reportElement x="0" y="53" width="200" height="100" />
  72. <subreportParameter name="ID_CLIENTE">
  73. <subreportParameterExpression><![CDATA[$F{id_cliente}]]></subreportParameterExpression>
  74. </subreportParameter>
  75. <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
  76. <subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "SubinformeCliente.jasper"]]></subreportExpression>
  77. </subreport>
  78. <staticText>
  79. <reportElement x="0" y="2" width="100" height="20" />
  80. <text><![CDATA[id_empleado]]></text>
  81. </staticText>
  82. <textField>
  83. <reportElement x="100" y="2" width="100" height="20" />
  84. <textFieldExpression><![CDATA[$F{id_empleado}]]></textFieldExpression>
  85. </textField>
  86. <staticText>
  87. <reportElement x="0" y="22" width="100" height="20" />
  88. <text><![CDATA[id_barrio]]></text>
  89. </staticText>
  90. <textField>
  91. <reportElement x="100" y="22" width="100" height="20" />
  92. <textFieldExpression><![CDATA[$F{id_barrio}]]></textFieldExpression>
  93. </textField>
  94. <staticText>
  95. <reportElement x="0" y="203" width="100" height="20" />
  96. <textElement>
  97. <font size="14" isBold="true"/>
  98. </textElement>
  99. <text><![CDATA[total_importe]]></text>
  100. </staticText>
  101. <textField>
  102. <reportElement x="100" y="203" width="100" height="20" forecolor="#FF3366" />
  103. <textElement>
  104. <font size="14"/>
  105. </textElement>
  106. <textFieldExpression><![CDATA[$F{total_importe}]]></textFieldExpression>
  107. </textField>
  108. </band>
  109. </detail>
  110. </jasperReport>
  111.  


Y éste es el código Java desde donde invoco al informe:

Código
  1. private void imprimirRutas(String mensajeEntrada){
  2.        //Primero he de averiguar la fecha de la ruta
  3.        int indicePrimero = mensajeEntrada.indexOf("$");
  4.        String fechaServicio = mensajeEntrada.substring(indicePrimero+1, mensajeEntrada.length());
  5.        //Ruta del archivo jasper
  6.        String path = "./InformeRutas.jasper";
  7.        JasperReport reporte;      
  8.        try{
  9.            reporte = JasperCompileManager.compileReport("./src/servidor/InformeRutas.jrxml");
  10.            //Cargo parámetros en una tabla hash
  11.            Map parametros = new HashMap();
  12.            parametros.put("FECHA_SERVICIO", fechaServicio);
  13.            //Genero el informe en memoria
  14.            JasperPrint print =
  15.                    JasperFillManager.fillReport(reporte,parametros,conn);
  16.            //Exporto el informe a PDF
  17.            JasperExportManager.exportReportToPdfFile(print,"informe.pdf");
  18.            //Abro el archivo pdf generado
  19.          File direccion = new File("informe.pdf");
  20.          Desktop.getDesktop().open(direccion);
  21.  
  22.        }catch(Exception e){
  23.            System.out.println("Error al producir informe: "+e);
  24.        }
  25.    }
  26.  
10  Programación / Java / ¿Cómo organizar horarios? en: 7 Diciembre 2014, 11:39 am
Hola a todos.

Resulta que estoy desarrollando una aplicación que trata de organizar pedidos de clientes para su posterior reparto.

El horario de los repartos puede ser de varias formas: indiferente, o con una hora de apertura y otra de cierre (por ejemplo de 11 a 12 o de 7 a 8:30)

El problema que tengo es que se supone que el repartidor puede realizar 4 pedidos como máximo en una hora. Entonces, si un pedido tiene horario, debo comprobar si en esa franja horaria se puede realizar el reparto o debo cambiarlo de ruta.

¿Cómo debo afrontar esto? ¿Uso listas o arrays, o algo parecido?

No pido que me lo resolváis, sino un poco de orientación

Gracias y un saludo
Páginas: [1] 2
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines