I'm trying to display a table with the name of some companies with the background color of each TD or DIV dependent of the last day the printers company were checked
this it what I have now: def exibicao_empresas(): #get companies empr = db(auth.accessible_query('read', db.empresa, auth.user_id)).select() tabela_empresa = TABLE( _class='grid_color') tr = TR() columns = 6 count_cl = 0 #for each company get all their printers and the last date it were checked for td in empr: lista_1 = [] count_menos = count_mais = 0 #getting printers impress = db((db.impressora.id_filial_empresa==db.filial_empresa.id )&(db.filial_empresa.id_empresa==td.id))._select(db.impressora.id) quant_impressoras = len(impress) maxdata = db.contadores.data.max() #getting dates dias = db(db.contadores.id_impressora.belongs(impress)).select( maxdata,db.contadores.id_impressora, groupby=db.contadores.id_impressora) # checking to show the indicative background-color for dia in dias: if (((dia_hoje-dia[maxdata]).days >= 1) and ((dia_hoje-dia[maxdata]).days < 5)): count_menos = count_menos+1 if ((dia_hoje-dia[maxdata]).days > 5): count_mais = count_mais+1 bg_td = 'background-color: #99FFCC' if count_menos: bg_td = 'background-color: #EAEA9F' if count_mais == len(dias): bg_td = 'background-color: #FF9999' tr.append(TD(td.nome_fantasia, _style = bg_td)) count_cl = count_cl + 1 if count_cl==columns: tabela_empresa.append(tr) tr=TR() else: if len(tr): tabela_empresa.append(tr) return dict(tabela_empresa =tabela_empresa ) > >