def FoolLoader(self, params): search = util.defaultv(params, "search", "") quantos = util.defaultv(params, "quantos", 50) # s = pyGestorModel.dbsession.getsession() dados = [] info = {} q = s.query(contatos).order_by(contatos.nome).filter(contatos.exc != 1) search = util.asUnicode(search) if len(search) > 0: searchx = search.split(" ") for s in searchx: q = q.filter(contatos.nome.like("%" + s + "%")) q = q.limit(quantos) # nisk.util.dump(q) r = q.all() for a in r: dados.append({"tid": a.id, "id": a.id, "nome": a.nome, "t4a": a.t4a}) # dados[a.tid] = {'tid': a.tid, 'dbid': a.id, 'nome': a.nome, 'pai': a.pai, 'level': a.nivel} return {"dados": dados}
def callback_acts(self, params={}): if util.defaultv(params, 'act', '') == 'add': txt = util.defaultv(params, 'nome', '') self.set_search(txt) if util.defaultv(params, 'act', '') == 'open': txt = util.defaultv(params, 'nome', '') self.set_search(txt)
def FoolLoader(self, params): rtab = params['rtab'] ltab = params['ltab'] search =util.asUnicode( util.defaultv(params, 'search', '')) tree = util.defaultv(params, 'tree', None) quantos = util.defaultv(params, 'quantos', 50) import pyGestorModel from pyGestorModel.orm_listas import grupos, lists_a # s = pyGestorModel.dbsession.getsession() dados = [] info = {} # '''' def my_import(name): mod = __import__(name) components = name.split('.') for comp in components[1:]: mod = getattr(mod, comp) return mod''''' # tabxs = None if rtab == 'lists_a': tabxs = lists_a elif rtab == 'grupos': tabxs = grupos else: return dados if tree: q = s.query(tabxs).filter(tabxs.tab == ltab, tabxs.nome.like('%' + search + '%')) else: q = s.query(tabxs).order_by(tabxs.nome).filter(tabxs.tab == ltab) if search: searchx = search.split(' ') for s in searchx: q = q.filter(tabxs.nome.like('%' + s + '%')) # q = q.filter(tabxs.nome.like('%' + search + '%')) q = q.limit(quantos) r = q.all() if tree: for a in r: dados.append({'tid': a.tid, 'id': a.id, 'nome': a.nome, 'pai': a.pai, 'level': a.nivel}) # dados[a.tid] = {'tid': a.tid, 'dbid': a.id, 'nome': a.nome, 'pai': a.pai, 'level': a.nivel} else: for a in r: dados.append({'tid': a.tid, 'id': a.id, 'nome': a.nome, 'pai': a.tid, 'level': 0}) return {'dados': dados}
def defaultPopupSelector_cb(data): (r, d, params) = data w = util.defaultv(params, 'widget', None) if r == dlger.ok: w.setValue(d['tid']) else: nisk.util.dump(r, d)
def defaultPopupSelector_(wgtFieldBoxDb1, params=None): act = util.defaultv(params, 'act', 'select') if act == 'select': if wgtFieldBoxDb1 is None: return w = None tabela = wgtFieldBoxDb1.tabela ltabela = wgtFieldBoxDb1.ltabela if tabela == 'grupos': w = frmListAScreens2({'rtab': tabela, 'ltab': ltabela, 'widget': wgtFieldBoxDb1}) elif tabela == 'contatos': import frmListContatos w = frmListContatos.frmListContatos2({'widget': wgtFieldBoxDb1}) else: # if tabela == 'lists_a': w = frmListAScreens2({'rtab': 'lists_a', 'ltab': ltabela, 'widget': wgtFieldBoxDb1}) if not w is None: w.Show(_widgetpai=wgtFieldBoxDb1, tocall=defaultPopupSelector_cb) if act == 'edit': if wgtFieldBoxDb1 is None: return d, w, r = None, None, None tabela = wgtFieldBoxDb1.tabela ltabela = wgtFieldBoxDb1.ltabela if tabela == 'grupos': w = frmListAScreens2({'rtab': tabela, 'ltab': ltabela}) elif tabela == 'contatos': import frmListContatos w = frmListContatos.frmListContatos2({}) else: # if tabela == 'lists_a': w = frmListAScreens2({'rtab': 'lists_a', 'ltab': ltabela}) if not w is None: r, d = w.Show(_widgetpai=wgtFieldBoxDb1) if r == dlger.ok: wgtFieldBoxDb1.setValue(d['tid']) else: nisk.util.dump(r, d)
def callback_acts(self, params={}): if util.defaultv(params, "act", "") == "add": if util.defaultv(self._params, "onNew_callback_parent", False): self.r = nisk.dialogs.dlger.ok self.rdata["tid"] = util.defaultv(params, "id", "") self._widgetsession.UnShowWidget() else: txt = util.defaultv(params, "nome", "") self.set_search(txt) if util.defaultv(params, "act", "") == "open": txt = util.defaultv(params, "nome", "") self.set_search(txt)
def imprimir_OS_etiq(params): # util.paralelo(win) osn = nisk.util.defaultv(params, "os", None) sos = consultaOS(osn) if not sos: return var_prnfile = util.getprintfilename() prn = printer.File(devfile=var_prnfile) prn._codepage = cfg_codepage v_cabec = getBlob("etiqos01") v_cabec = v_cabec.replace("<##OS##>", util.astext([(sos, "os")])) v_cabec = v_cabec.replace("<##L1##>", util.astext([(sos, "oscliente", "nome"), "."], 27)) v_cabec = v_cabec.replace("<##L2##>", util.astext([(sos, "oscliente", "t4a"), "."], 27)) v_cabec = v_cabec.replace( "<##L3##>", util.astext([(sos, "ostipo", "nome"), " - "], 15) + util.astext([(sos, "osmarca", "nome"), " - "], 15), ) v_cabec = v_cabec.replace( "<##L4##>", util.astext([(sos, "modelo"), " - "], 15) + util.astext([(sos, "ns"), " - "], 15) ) v_cabec = v_cabec.replace("<##L5##>", "Entrada: " + util.astext([(sos, "dataent"), " - "], 15)) v_cabec = v_cabec.replace("<##L6##>", "") v_cabec = v_cabec.replace("<##L7##>", "") v_cabec = v_cabec.replace("<##C##>", util.astext(util.defaultv(params, "qtd", 1))) v_cabec = v_cabec.replace("<##", "").replace("##>", "") prn.text(v_cabec + "\n", 1) prn.close(reset=0) util.imprimeLPR(cfg_prnetq, var_prnfile)
def imprimir_OS_entrada(params): osn = nisk.util.defaultv(params, "os", None) sos = consultaOS(osn) if not sos: return var_prnfile = util.getprintfilename() prn = printer.File(devfile=var_prnfile) prn.set(codepage=cfg_codepage) v_cabec = getBlob("cabecalho") prn.text(v_cabec, 1) prn.pulal() prn.textline( "{CondensedOn}" + str(datetime.datetime.now()) + "/usr:%s" % sos.usrent + "{CondensedOff}", 1 ) # Datetime prn.set(bold=1, size="2x", align="center") prn.textline("--------------------") prn.textline(" ENTRADA OS %s " % sos.os) prn.textline("--------------------") prn.set(bold=0, size="normal", align="left") if sos.dataent: prn.textline("Entrada em:" + CTL_HT + " %s " % "{:%d-%m-%Y %H:%M}".format(sos.dataent)) prn.textline("Cliente:\t %s " % sos.oscliente.nome if sos.oscliente else "") prn.textline("Telefones:\t %s " % sos.oscliente.t4a if sos.oscliente else "") prn.pulal() prn.textline("Aparelho:\t %s " % sos.ostipo.nome if sos.ostipo else "") prn.textline("Marca:\t %s " % sos.osmarca.nome if sos.osmarca else "") prn.textline("N° Serial:\t %s " % str(sos.modelo)) prn.textline("N° Modelo:\t %s " % str(sos.ns)) if util.slen(sos.nf) > 0: prn.textline("NF:\t %s " % astext(str(sos.nf))) prn.textline(u"Solicitação:\t %s " % astext(sos.solicita)) prn.textline(u"Acessorios:\t %s " % astext(sos.acess)) prn.textline(u"Estado de Conservação:\t %s " % astext(sos.conserva)) prn.textline(u"Prazo de Orçamento:\t %s " % astext(sos.prazoorc)) prn.textline(u"Lembrete:\t %s " % astext(sos.lembrete)) prn.textline(u"Observações: %s " % astext(sos.obsos)) prn.text(getBlob("termoentradaos"), 1) prn.text(getBlob("rodape"), 1) # prn.pulal(10) prn.textline("____________________\n\r\n\r") prn.cut() prn.close() for i in range(util.defaultv(params, "qtd", 1)): util.imprimeLPR(cfg_prntxt, var_prnfile)