def __fill_users_list(self, widget=None):
     m_users = DBUser(self.__cursor) 
     users = m_users.get_users()
     self.__users_list.clear()
     self.__search_entry.set_text("")
     for user in users:
         self.__users_list.append((user["id"],user["last_name"]+", "+user["name"]))
 def __fill_users_list(self, widget=None):
     m_users = DBUser(self.__cursor)
     users = m_users.get_users()
     self.__users_list.clear()
     self.__search_entry.set_text("")
     for user in users:
         self.__users_list.append(
             (user["id"], user["last_name"] + ", " + user["name"]))
 def __search_user_cb(self, widget):
     m_users = DBUser(self.__cursor)
     if self.__r_name.get_active():
         users = m_users.search_by_name(self.__search_entry.get_text())
     else:
         users = m_users.search_by_last_name(self.__search_entry.get_text())
     self.__users_list.clear()
     for user in users:
         self.__users_list.append((user["id"],user["last_name"]+", "+user["name"]))
 def __search_user_cb(self, widget):
     m_users = DBUser(self.__cursor)
     if self.__r_name.get_active():
         users = m_users.search_by_name(self.__search_entry.get_text())
     else:
         users = m_users.search_by_last_name(self.__search_entry.get_text())
     self.__users_list.clear()
     for user in users:
         self.__users_list.append(
             (user["id"], user["last_name"] + ", " + user["name"]))
 def __export_report(self, attendance_registry):
     m_users = DBUser(self.__cursor)
     dialog = gtk.FileChooserDialog(_("Ingrese el directorio y el nombre del archivo"), \
                                    None, gtk.FILE_CHOOSER_ACTION_SAVE,
                                    (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                    gtk.STOCK_SAVE, gtk.RESPONSE_OK))
     dialog.set_default_response(gtk.RESPONSE_OK)
     dialog.set_do_overwrite_confirmation(True)
     file_filter = gtk.FileFilter()
     file_filter.set_name(_("Todos"))
     file_filter.add_pattern("*")
     dialog.add_filter(file_filter)
     file_filter = gtk.FileFilter()
     file_filter.set_name("Texto CSV (.csv)")
     file_filter.add_mime_type("txt/csv")
     file_filter.add_pattern("*.csv")
     dialog.add_filter(file_filter)
     response = dialog.run()
     if response == gtk.RESPONSE_OK:
         file_handle = open(dialog.get_filename() + ".csv", 'w')
         if self.__config_param["app"]["events_attendance"] == "True":
             file_handle.write(
                 _('"N°","Nombre","Fecha","Evento","Hora Entrada","Hora Salida","Total Asistencia"\n'
                   ))
         else:
             file_handle.write(
                 _('"N°","Nombre","Fecha","Hora Entrada","Hora Salida","Total Asistencia"\n'
                   ))
         nro = 0
         for attendance in attendance_registry:
             nro += 1
             user = m_users.get_user(attendance["user_id"])
             if self.__config_param["app"]["events_attendance"] == "True":
                 if attendance["event_id"] != 0 and attendance[
                         "event_id"] != None:
                     event = self.__db_manager.get_event_name(
                         attendance["event_id"])
                 else:
                     event = "-----"
                 file_handle.write('"'+str(nro)+'","'+attendance["last_name"]+', '+attendance["name"]+'","'+\
                                   attendance["date"]+'","'+event+'","'+str(attendance["entrance"])+'","'+\
                                   str(attendance["exit"])+'","'+attendance["total"]+'"\n')
             else:
                 file_handle.write('"'+str(nro)+'","'+attendance["last_name"]+', '+attendance["name"]+'","'+\
                                   attendance["date"]+'","'+str(attendance["entrance"])+'","'+\
                                   str(attendance["exit"])+'","'+attendance["total"]+'"\n')
         file_handle.close()
     dialog.destroy()
 def __export_report(self, attendance_registry):
     m_users = DBUser(self.__cursor)
     dialog = gtk.FileChooserDialog(_("Ingrese el directorio y el nombre del archivo"), \
                                    None, gtk.FILE_CHOOSER_ACTION_SAVE,
                                    (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                    gtk.STOCK_SAVE, gtk.RESPONSE_OK))
     dialog.set_default_response(gtk.RESPONSE_OK)
     dialog.set_do_overwrite_confirmation(True)
     file_filter = gtk.FileFilter()
     file_filter.set_name(_("Todos"))
     file_filter.add_pattern("*")
     dialog.add_filter(file_filter)
     file_filter = gtk.FileFilter()
     file_filter.set_name("Texto CSV (.csv)")
     file_filter.add_mime_type("txt/csv")
     file_filter.add_pattern("*.csv")
     dialog.add_filter(file_filter)
     response = dialog.run()                
     if response == gtk.RESPONSE_OK:
         file_handle = open(dialog.get_filename()+".csv",'w')
         if self.__config_param["app"]["events_attendance"] == "True":
             file_handle.write(_('"N°","Nombre","Fecha","Evento","Hora Entrada","Hora Salida","Total Asistencia"\n'))
         else:
             file_handle.write(_('"N°","Nombre","Fecha","Hora Entrada","Hora Salida","Total Asistencia"\n'))
         nro = 0
         for attendance in attendance_registry:
             nro += 1
             user = m_users.get_user(attendance["user_id"])
             if self.__config_param["app"]["events_attendance"] == "True":
                 if attendance["event_id"] != 0 and attendance["event_id"] != None:
                     event = self.__db_manager.get_event_name(attendance["event_id"])
                 else:
                     event = "-----"
                 file_handle.write('"'+str(nro)+'","'+attendance["last_name"]+', '+attendance["name"]+'","'+\
                                   attendance["date"]+'","'+event+'","'+str(attendance["entrance"])+'","'+\
                                   str(attendance["exit"])+'","'+attendance["total"]+'"\n')
             else:
                 file_handle.write('"'+str(nro)+'","'+attendance["last_name"]+', '+attendance["name"]+'","'+\
                                   attendance["date"]+'","'+str(attendance["entrance"])+'","'+\
                                   str(attendance["exit"])+'","'+attendance["total"]+'"\n')
         file_handle.close()
     dialog.destroy()