DateTime Picker

<script language="javascript" src="${pageContext.request.contextPath}/js/jquery/jquery-ui-timepicker-addon.js"></script>

var myControl=  {
                    create: function(tp_inst, obj, unit, val, min, max, step){
                            $('<input class="ui-timepicker-input" value="'+val+'" style="width:50%">')
                                    .appendTo(obj)
                                    .spinner({
                                            min: min,
                                            max: max,
                                            step: step,
                                            change: function(e,ui){ // key events
                                                            // don't call if api was used and not key press
                                                            if(e.originalEvent !== undefined)
                                                                    tp_inst._onTimeChange();
                                                            tp_inst._onSelectHandler();
                                                    },
                                            spin: function(e,ui){ // spin events
                                                            tp_inst.control.value(tp_inst, obj, unit, ui.value);
                                                            tp_inst._onTimeChange();
                                                            tp_inst._onSelectHandler();
                                                    }
                                    });
                            return obj;
                    },
                    options: function(tp_inst, obj, unit, opts, val){
                            if(typeof(opts) == 'string' && val !== undefined)
                                    return obj.find('.ui-timepicker-input').spinner(opts, val);
                            return obj.find('.ui-timepicker-input').spinner(opts);
                    },
                    value: function(tp_inst, obj, unit, val){
                            if(val !== undefined)
                                    return obj.find('.ui-timepicker-input').spinner('value', val);
                            return obj.find('.ui-timepicker-input').spinner('value');
                    }
            };

$("#SFechaProgramado").datetimepicker({
                    showOn: "button",
                    buttonImage: "images/calendar.gif",
                    buttonImageOnly: true,
                    defaultDate: "+1w",
                    changeMonth: true,
                    numberOfMonths: 2,
                    dateFormat: 'dd/mm/yy',
                    controlType: myControl,
                    altField: "#SHoraIniProgramado",
                    onClose: function(selectedDate){
                        $("#SFechaEjecucionReal").datepicker( "option", "minDate", selectedDate );
                       
                        var fechaProgramado = $("#SFechaProgramado").val();
                        var fechaEjecucionReal = $("#SFechaEjecucionReal").val();
                       
                        if(fechaProgramado == fechaEjecucionReal){
                            //alert("Son iguales : " + fechaProgramado + "\n" + fechaEjecucionReal);
                            $("#cambioFechaPor").hide();
                        }else{
                            //alert("Son diferentes : " + fechaProgramado + "\n" + fechaEjecucionReal);
                            $("#cambioFechaPor").show();
                        }
                       
                    }
                });

$("#SFechaEjecucionReal").datetimepicker({
                    showOn: "button",
                    buttonImage: "images/calendar.gif",
                    buttonImageOnly: true,
                    defaultDate: "+1w",
                    changeMonth: true,
                    numberOfMonths: 2,
                    dateFormat: 'dd/mm/yy',
                    controlType: myControl,
                    altField: "#SHoraIniEjecucionReal",
                    onClose: function(selectedDate){
                        $("#SFechaProgramado").datepicker( "option", "maxDate", selectedDate );
                       
                        var fechaProgramado = $("#SFechaProgramado").val();
                        var fechaEjecucionReal = $("#SFechaEjecucionReal").val();
                       
                        if(fechaProgramado == fechaEjecucionReal){
                            //alert("Son iguales : " + fechaProgramado + "\n" + fechaEjecucionReal);
                            $("#cambioFechaPor").hide();
                        }else{
                            //alert("Son diferentes : " + fechaProgramado + "\n" + fechaEjecucionReal);
                            $("#cambioFechaPor").show();
                        }
                    }
                });
               
                $('#SHoraFinEjecucionReal').timepicker();

Comentarios

Entradas populares de este blog

Subir proyecto al repositorio existente en Bitbucket

Sonarqube : The component parameter is missing