/* 
* Copyright 2016 Agencia Estatal de Administración Tibutaria
*
* Licencia con arreglo a la EUPL, Versión 1.1 o –en cuanto
* sean aprobadas por la Comisión Europea– versiones
* posteriores de la EUPL (la «Licencia»);
* Solo podrá usarse esta obra si se respeta la Licencia.
* Puede obtenerse una copia de la Licencia en:
*  
* https://joinup.ec.europa.eu/software/page/eupl
*  
* Salvo cuando lo exija la legislación aplicable o se acuerde
* por escrito, el programa distribuido con arreglo a la
* Licencia se distribuye «TAL CUAL», SIN GARANTÍAS NI CONDICIONES
* DE NINGÚN TIPO, ni expresasni implícitas.
*
* Véase la Licencia en el idioma concreto que rige los permisos y 
* limitaciones que establece la Licencia.
*/ 

package gestor;

import gestor.utiles.*;
import javax.swing.*;

/**
 *
 * @author  f11600za
 */
public class DlgConfirmarNoPresente extends javax.swing.JDialog {

   boolean emitirTicket = false;
   public javax.swing.Timer timerCierraAviso;

   /** Creates new form DlgConfirmarNoPresente */
   public DlgConfirmarNoPresente(JFrame parent) {
      super(parent, true);
      initComponents();
      setLocationRelativeTo(parent);
      preparaTimerAviso();      
      timerCierraAviso.start();
      lbMensaje1.setText("<html>" + Global.trad.valor("SiPulsaCerrar") + "</html>");
      lbMensaje2.setText("<html>" + Global.trad.valor("SiPulsaEmitir") + "</html>");
   }

   public void completarRotulos(Main.Registro reg) {
      lbIdentificacion.setText(reg.nif + "  " + reg.nombre);
      String rotulo = Configuracion.instanciaUnica().infoServicios.get(reg.cola).getDescripcion();
      lbHora.setText(rotulo + " -- " +Fecha.formatoHoraHM(reg.horaCita));
   }
   
   void cerrarCon(boolean valor) {
      emitirTicket = valor;
      timerCierraAviso.stop();
      setVisible(false);
   }

   void preparaTimerAviso() {
      timerCierraAviso = new javax.swing.Timer(Configuracion.instanciaUnica().segundosCierreVentanas  * 1000, new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
            cerrarCon(false);
         }
      });
   }

   /** This method is called from within the constructor to
    * initialize the form.
    * WARNING: Do NOT modify this code. The content of this method is
    * always regenerated by the Form Editor.
    */
   // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
   private void initComponents() {

      jPanel1 = new MiPanel();
      lbIdentificacion = new javax.swing.JLabel();
      lbHora = new javax.swing.JLabel();
      btCerrar = new javax.swing.JButton();
      btEmitir = new javax.swing.JButton();
      lbMensaje1 = new javax.swing.JLabel();
      lbMensaje2 = new javax.swing.JLabel();

      setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
      setModal(true);
      setUndecorated(true);

      jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(210, 210, 210), 4));

      lbIdentificacion.setFont(new java.awt.Font("Arial", 1, 36)); // NOI18N
      lbIdentificacion.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
      lbIdentificacion.setText("Nif y nombre");
      lbIdentificacion.setToolTipText("null");
      lbIdentificacion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

      lbHora.setFont(new java.awt.Font("Arial", 1, 36)); // NOI18N
      lbHora.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
      lbHora.setText("Cola y hora");
      lbHora.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

      btCerrar.setFont(new java.awt.Font("Arial", 1, 24));
      btCerrar.setText(Global.trad.valor("Cerrar"));
      btCerrar.setFocusable(false);
      btCerrar.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
            btCerrarActionPerformed(evt);
         }
      });

      btEmitir.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N
      btEmitir.setForeground(new java.awt.Color(255, 51, 51));
      btEmitir.setText(Global.trad.valor("EmitirTicket"));
      btEmitir.setFocusable(false);
      btEmitir.addActionListener(new java.awt.event.ActionListener() {
         public void actionPerformed(java.awt.event.ActionEvent evt) {
            btEmitirActionPerformed(evt);
         }
      });

      lbMensaje1.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N

      lbMensaje2.setFont(new java.awt.Font("Arial", 1, 24)); // NOI18N

      org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
      jPanel1.setLayout(jPanel1Layout);
      jPanel1Layout.setHorizontalGroup(
         jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
         .add(jPanel1Layout.createSequentialGroup()
            .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
               .add(jPanel1Layout.createSequentialGroup()
                  .addContainerGap()
                  .add(lbMensaje1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 775, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
               .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                  .add(18, 18, 18)
                  .add(btCerrar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 309, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                  .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 131, Short.MAX_VALUE)
                  .add(btEmitir, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 308, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                  .add(19, 19, 19))
               .add(jPanel1Layout.createSequentialGroup()
                  .addContainerGap()
                  .add(lbIdentificacion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 775, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
               .add(jPanel1Layout.createSequentialGroup()
                  .addContainerGap()
                  .add(lbHora, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 775, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
               .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                  .addContainerGap()
                  .add(lbMensaje2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 775, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
            .addContainerGap())
      );
      jPanel1Layout.setVerticalGroup(
         jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
         .add(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .add(lbIdentificacion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 41, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .add(18, 18, 18)
            .add(lbHora, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 41, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .add(44, 44, 44)
            .add(lbMensaje1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 120, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .add(18, 18, 18)
            .add(lbMensaje2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 106, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .add(34, 34, 34)
            .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
               .add(btCerrar, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
               .add(btEmitir, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE))
            .addContainerGap())
      );

      org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
      getContentPane().setLayout(layout);
      layout.setHorizontalGroup(
         layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
         .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
      );
      layout.setVerticalGroup(
         layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
         .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
      );

      pack();
   }// </editor-fold>//GEN-END:initComponents
   private void btEmitirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btEmitirActionPerformed
       cerrarCon(true);
}//GEN-LAST:event_btEmitirActionPerformed

    private void btCerrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btCerrarActionPerformed
       cerrarCon(false);
}//GEN-LAST:event_btCerrarActionPerformed

   // Variables declaration - do not modify//GEN-BEGIN:variables
   private javax.swing.JButton btCerrar;
   private javax.swing.JButton btEmitir;
   private javax.swing.JPanel jPanel1;
   private javax.swing.JLabel lbHora;
   private javax.swing.JLabel lbIdentificacion;
   private javax.swing.JLabel lbMensaje1;
   private javax.swing.JLabel lbMensaje2;
   // End of variables declaration//GEN-END:variables
}
