示例#1
0
def verificar(request, pk, output=None):

    if request.user.has_perm('esocial.can_see_s2210evtCAT'):

        s2210_evtcat = get_object_or_404(s2210evtCAT, id=pk)
        s2210_evtcat_lista = s2210evtCAT.objects.filter(id=pk).all()

        s2210_idelocalacid_lista = s2210ideLocalAcid.objects.filter(
            s2210_evtcat_id__in=listar_ids(s2210_evtcat_lista)).all()
        s2210_parteatingida_lista = s2210parteAtingida.objects.filter(
            s2210_evtcat_id__in=listar_ids(s2210_evtcat_lista)).all()
        s2210_agentecausador_lista = s2210agenteCausador.objects.filter(
            s2210_evtcat_id__in=listar_ids(s2210_evtcat_lista)).all()
        s2210_atestado_lista = s2210atestado.objects.filter(
            s2210_evtcat_id__in=listar_ids(s2210_evtcat_lista)).all()
        s2210_catorigem_lista = s2210catOrigem.objects.filter(
            s2210_evtcat_id__in=listar_ids(s2210_evtcat_lista)).all()

        request.session['return_pk'] = pk
        request.session['return_page'] = request.META.get('HTTP_REFERER')

        context = {
            's2210_evtcat_lista': s2210_evtcat_lista,
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            's2210_evtcat': s2210_evtcat,
            's2210_idelocalacid_lista': s2210_idelocalacid_lista,
            's2210_parteatingida_lista': s2210_parteatingida_lista,
            's2210_agentecausador_lista': s2210_agentecausador_lista,
            's2210_atestado_lista': s2210_atestado_lista,
            's2210_catorigem_lista': s2210_catorigem_lista,
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's2210_evtcat',
            ],
            'data': datetime.now(),
            'output': output,
        }

        if output == 'pdf':

            response = PDFTemplateResponse(
                request=request,
                template='s2210_evtcat_verificar.html',
                filename="s2210_evtcat.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 20,
                    'zoom': 1,
                    'viewport-size': '1366 x 513',
                    'javascript-delay': 1000,
                    'footer-center': u'Página [page]/[topage]',
                    'footer-font-size': 10,
                    'no-stop-slow-scripts': True
                })

            return response

        elif output == 'xls':

            response = render_to_response('s2210_evtcat_verificar.html',
                                          context)
            filename = "%s.xls" % s2210_evtcat.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            response = render_to_response('s2210_evtcat_verificar.html',
                                          context)
            filename = "%s.csv" % s2210_evtcat.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response

        else:

            return render(request, 's2210_evtcat_verificar.html', context)

    else:

        context = {
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's2210_evtcat',
            ],
            'data': datetime.now(),
        }

        return render(request, 'permissao_negada.html', context)
示例#2
0
def salvar(request, hash):
    from emensageriapro.settings import VERSAO_EMENSAGERIA, VERSAO_LAYOUT_ESOCIAL, TP_AMB
    db_slug = 'default'
    try:
        usuario_id = request.user.id
        dict_hash = get_hash_url( hash )
        s1202_evtrmnrpps_id = int(dict_hash['id'])
        if 'tab' not in dict_hash.keys():
            dict_hash['tab'] = ''
        for_print = int(dict_hash['print'])
    except:
        usuario_id = False
        return redirect('login')
    usuario = get_object_or_404(Usuarios.objects.using( db_slug ), excluido = False, id = usuario_id)
    pagina = ConfigPaginas.objects.using( db_slug ).get(excluido = False, endereco='s1202_evtrmnrpps')
    permissao = ConfigPermissoes.objects.using( db_slug ).get(excluido = False, config_paginas=pagina, config_perfis=usuario.config_perfis)
    if s1202_evtrmnrpps_id:
        s1202_evtrmnrpps = get_object_or_404(s1202evtRmnRPPS.objects.using( db_slug ), excluido = False, id = s1202_evtrmnrpps_id)
    dict_permissoes = json_to_dict(usuario.config_perfis.permissoes)
    paginas_permitidas_lista = usuario.config_perfis.paginas_permitidas
    modulos_permitidos_lista = usuario.config_perfis.modulos_permitidos

    if s1202_evtrmnrpps_id:
        if s1202_evtrmnrpps.status != 0:
            dict_permissoes['s1202_evtrmnrpps_apagar'] = 0
            dict_permissoes['s1202_evtrmnrpps_editar'] = 0

    if permissao.permite_visualizar:
        mensagem = None
        if s1202_evtrmnrpps_id:
            s1202_evtrmnrpps_form = form_s1202_evtrmnrpps(request.POST or None, instance = s1202_evtrmnrpps, slug = db_slug)
        else:
            s1202_evtrmnrpps_form = form_s1202_evtrmnrpps(request.POST or None, slug = db_slug, initial={'versao': VERSAO_LAYOUT_ESOCIAL, 'status': 0, 'processamento_codigo_resposta': 0, 'tpamb': TP_AMB, 'procemi': 1, 'verproc': VERSAO_EMENSAGERIA})
        if request.method == 'POST':
            if s1202_evtrmnrpps_form.is_valid():
                dados = s1202_evtrmnrpps_form.cleaned_data
                import json
                from django.forms.models import model_to_dict
                if s1202_evtrmnrpps_id:
                    if s1202_evtrmnrpps.status == 0:
                        dados['modificado_por_id'] = usuario_id
                        dados['modificado_em'] = datetime.datetime.now()
                        #s1202_evtrmnrpps_campos_multiple_passo1
                        s1202evtRmnRPPS.objects.using(db_slug).filter(id=s1202_evtrmnrpps_id).update(**dados)
                        obj = s1202evtRmnRPPS.objects.using(db_slug).get(id=s1202_evtrmnrpps_id)
                        #s1202_evtrmnrpps_editar_custom
                        #s1202_evtrmnrpps_campos_multiple_passo2
                        messages.success(request, 'Alterado com sucesso!')
                        gravar_auditoria(json.dumps(model_to_dict(s1202_evtrmnrpps), indent=4, sort_keys=True, default=str),
                                         json.dumps(model_to_dict(obj), indent=4, sort_keys=True, default=str),
                                         's1202_evtrmnrpps', s1202_evtrmnrpps_id, usuario_id, 2)
                    else:
                        obj = s1202evtRmnRPPS.objects.using(db_slug).get(id=s1202_evtrmnrpps_id)
                        messages.error(request, 'Não é possível salvar o evento, pois o mesmo não está com o status "Cadastrado"!')

                else:

                    dados['criado_por_id'] = usuario_id
                    dados['criado_em'] = datetime.datetime.now()
                    dados['excluido'] = False
                    #s1202_evtrmnrpps_cadastrar_campos_multiple_passo1
                    obj = s1202evtRmnRPPS(**dados)
                    obj.save(using = db_slug)
                    #s1202_evtrmnrpps_cadastrar_custom
                    #s1202_evtrmnrpps_cadastrar_campos_multiple_passo2
                    identidade_evento(obj.id, db_slug)
                    messages.success(request, 'Cadastrado com sucesso!')
                    s1202_evtrmnrpps_form = form_s1202_evtrmnrpps(request.POST or None, instance = obj, slug = db_slug)
                    gravar_auditoria('{}',
                                     json.dumps(model_to_dict(obj), indent=4, sort_keys=True, default=str),
                                     's1202_evtrmnrpps', obj.id, usuario_id, 1)
                if request.session['retorno_pagina'] not in ('s1202_evtrmnrpps_apagar', 's1202_evtrmnrpps_salvar', 's1202_evtrmnrpps'):
                    return redirect(request.session['retorno_pagina'], hash=request.session['retorno_hash'])
                if s1202_evtrmnrpps_id != obj.id:
                    url_hash = base64.urlsafe_b64encode( '{"print": "0", "id": "%s"}' % (obj.id) )
                    return redirect('s1202_evtrmnrpps_salvar', hash=url_hash)

            else:
                messages.error(request, 'Erro ao salvar!')
        s1202_evtrmnrpps_form = disabled_form_fields(s1202_evtrmnrpps_form, permissao.permite_editar)
    
        if s1202_evtrmnrpps_id:
            if s1202_evtrmnrpps.status != 0:
                s1202_evtrmnrpps_form = disabled_form_fields(s1202_evtrmnrpps_form, False)
        #s1202_evtrmnrpps_campos_multiple_passo3

        for field in s1202_evtrmnrpps_form.fields.keys():
            s1202_evtrmnrpps_form.fields[field].widget.attrs['ng-model'] = 's1202_evtrmnrpps_'+field
        if int(dict_hash['print']):
            s1202_evtrmnrpps_form = disabled_form_for_print(s1202_evtrmnrpps_form)
   
        s1202_procjudtrab_form = None
        s1202_procjudtrab_lista = None
        s1202_dmdev_form = None
        s1202_dmdev_lista = None
        if s1202_evtrmnrpps_id:
            s1202_evtrmnrpps = get_object_or_404(s1202evtRmnRPPS.objects.using( db_slug ), excluido = False, id = s1202_evtrmnrpps_id)
       
            s1202_procjudtrab_form = form_s1202_procjudtrab(initial={ 's1202_evtrmnrpps': s1202_evtrmnrpps }, slug=db_slug)
            s1202_procjudtrab_form.fields['s1202_evtrmnrpps'].widget.attrs['readonly'] = True
            s1202_procjudtrab_lista = s1202procJudTrab.objects.using( db_slug ).filter(excluido = False, s1202_evtrmnrpps_id=s1202_evtrmnrpps.id).all()
            s1202_dmdev_form = form_s1202_dmdev(initial={ 's1202_evtrmnrpps': s1202_evtrmnrpps }, slug=db_slug)
            s1202_dmdev_form.fields['s1202_evtrmnrpps'].widget.attrs['readonly'] = True
            s1202_dmdev_lista = s1202dmDev.objects.using( db_slug ).filter(excluido = False, s1202_evtrmnrpps_id=s1202_evtrmnrpps.id).all()
        else:
            s1202_evtrmnrpps = None
        #s1202_evtrmnrpps_salvar_custom_variaveis#
        tabelas_secundarias = []
        #[FUNCOES_ESPECIAIS_SALVAR]
        if 's1202_evtrmnrpps'[1] == '5':
            evento_totalizador = True
        else:
            evento_totalizador = False
        if not evento_totalizador:
            s1202_evtrmnrpps_form.fields['tpamb'].widget.attrs['disabled'] = True
            s1202_evtrmnrpps_form.fields['tpamb'].widget.attrs['readonly'] = True
            s1202_evtrmnrpps_form.fields['tpamb'].value = TP_AMB
            s1202_evtrmnrpps_form.fields['procemi'].widget.attrs['disabled'] = True
            s1202_evtrmnrpps_form.fields['procemi'].widget.attrs['readonly'] = True
            s1202_evtrmnrpps_form.fields['procemi'].value = 1
            s1202_evtrmnrpps_form.fields['verproc'].widget.attrs['readonly'] = True
            s1202_evtrmnrpps_form.fields['verproc'].value = VERSAO_EMENSAGERIA
    
        if dict_hash['tab'] or 's1202_evtrmnrpps' in request.session['retorno_pagina']:
            request.session["retorno_hash"] = hash
            request.session["retorno_pagina"] = 's1202_evtrmnrpps_salvar'
        controle_alteracoes = Auditoria.objects.using( db_slug ).filter(identidade=s1202_evtrmnrpps_id, tabela='s1202_evtrmnrpps').all()
        context = {
            'evento_totalizador': evento_totalizador,
            'controle_alteracoes': controle_alteracoes,
            's1202_evtrmnrpps': s1202_evtrmnrpps,
            's1202_evtrmnrpps_form': s1202_evtrmnrpps_form,
            'mensagem': mensagem,
            's1202_evtrmnrpps_id': int(s1202_evtrmnrpps_id),
            'usuario': usuario,
            
            'hash': hash,
       
            's1202_procjudtrab_form': s1202_procjudtrab_form,
            's1202_procjudtrab_lista': s1202_procjudtrab_lista,
            's1202_dmdev_form': s1202_dmdev_form,
            's1202_dmdev_lista': s1202_dmdev_lista,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
            'for_print': int(dict_hash['print']),
            'tabelas_secundarias': tabelas_secundarias,
            'tab': dict_hash['tab'],
            #s1202_evtrmnrpps_salvar_custom_variaveis_context#
        }
    
        if for_print in (0,1 ):
            return render(request, 's1202_evtrmnrpps_salvar.html', context)
        elif for_print == 2:
            from wkhtmltopdf.views import PDFTemplateResponse
            response = PDFTemplateResponse(
                request=request,
                template='s1202_evtrmnrpps_salvar.html',
                filename="s1202_evtrmnrpps.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={'margin-top': 10,
                             'margin-bottom': 10,
                             'margin-right': 10,
                             'margin-left': 10,
                             'zoom': 1,
                             'dpi': 72,
                             'orientation': 'Landscape',
                             "viewport-size": "1366 x 513",
                             'javascript-delay': 1000,
                             'footer-center': '[page]/[topage]',
                             "no-stop-slow-scripts": True},
            )
            return response
        elif for_print == 3:
            from django.shortcuts import render_to_response
            response = render_to_response('s1202_evtrmnrpps_salvar.html', context)
            filename = "s1202_evtrmnrpps.xls"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response
    else:
        context = {
            'usuario': usuario,
            
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
        }
        return render(request, 'permissao_negada.html', context)
示例#3
0
def salvar(request, hash):
    db_slug = 'default'
    try:
        usuario_id = request.user.id
        dict_hash = get_hash_url( hash )
        s2200_trabtemporario_id = int(dict_hash['id'])
        if 'tab' not in dict_hash.keys():
            dict_hash['tab'] = ''
        for_print = int(dict_hash['print'])
    except:
        usuario_id = False
        return redirect('login')
    usuario = get_object_or_404(Usuarios.objects.using( db_slug ), excluido = False, id = usuario_id)
    pagina = ConfigPaginas.objects.using( db_slug ).get(excluido = False, endereco='s2200_trabtemporario')
    permissao = ConfigPermissoes.objects.using( db_slug ).get(excluido = False, config_paginas=pagina, config_perfis=usuario.config_perfis)
    if s2200_trabtemporario_id:
        s2200_trabtemporario = get_object_or_404(s2200trabTemporario.objects.using( db_slug ), excluido = False, id = s2200_trabtemporario_id)
    dict_permissoes = json_to_dict(usuario.config_perfis.permissoes)
    paginas_permitidas_lista = usuario.config_perfis.paginas_permitidas
    modulos_permitidos_lista = usuario.config_perfis.modulos_permitidos
    dados_evento = {}
    dados_evento['status'] = 0
    if s2200_trabtemporario_id:
        dados_evento = s2200_trabtemporario.evento()
        if dados_evento['status'] != 0:
            dict_permissoes['s2200_trabtemporario_apagar'] = 0
            dict_permissoes['s2200_trabtemporario_editar'] = 0

    if permissao.permite_visualizar:
        mensagem = None
        if s2200_trabtemporario_id:
            s2200_trabtemporario_form = form_s2200_trabtemporario(request.POST or None, instance = s2200_trabtemporario, slug = db_slug)
        else:
            s2200_trabtemporario_form = form_s2200_trabtemporario(request.POST or None, slug = db_slug, initial={})
        if request.method == 'POST':
            if s2200_trabtemporario_form.is_valid():
                dados = s2200_trabtemporario_form.cleaned_data
                import json
                from django.forms.models import model_to_dict
                if s2200_trabtemporario_id:
                    if dados_evento['status'] == 0:
                        dados['modificado_por_id'] = usuario_id
                        dados['modificado_em'] = datetime.datetime.now()
                        #s2200_trabtemporario_campos_multiple_passo1
                        s2200trabTemporario.objects.using(db_slug).filter(id=s2200_trabtemporario_id).update(**dados)
                        obj = s2200trabTemporario.objects.using(db_slug).get(id=s2200_trabtemporario_id)
                        #s2200_trabtemporario_editar_custom
                        #s2200_trabtemporario_campos_multiple_passo2
                        messages.success(request, 'Alterado com sucesso!')
                        gravar_auditoria(json.dumps(model_to_dict(s2200_trabtemporario), indent=4, sort_keys=True, default=str),
                                         json.dumps(model_to_dict(obj), indent=4, sort_keys=True, default=str),
                                         's2200_trabtemporario', s2200_trabtemporario_id, usuario_id, 2)
                    else:
                        messages.error(request, 'Somente é possível alterar eventos com status "Cadastrado"!')
                else:

                    dados['criado_por_id'] = usuario_id
                    dados['criado_em'] = datetime.datetime.now()
                    dados['excluido'] = False
                    #s2200_trabtemporario_cadastrar_campos_multiple_passo1
                    obj = s2200trabTemporario(**dados)
                    obj.save(using = db_slug)
                    #s2200_trabtemporario_cadastrar_custom
                    #s2200_trabtemporario_cadastrar_campos_multiple_passo2
                    messages.success(request, 'Cadastrado com sucesso!')
                    gravar_auditoria('{}',
                                     json.dumps(model_to_dict(obj), indent=4, sort_keys=True, default=str),
                                     's2200_trabtemporario', obj.id, usuario_id, 1)
                    if request.session['retorno_pagina'] not in ('s2200_trabtemporario_apagar', 's2200_trabtemporario_salvar', 's2200_trabtemporario'):
                        return redirect(request.session['retorno_pagina'], hash=request.session['retorno_hash'])
                    if s2200_trabtemporario_id != obj.id:
                        url_hash = base64.urlsafe_b64encode( '{"print": "0", "id": "%s"}' % (obj.id) )
                        return redirect('s2200_trabtemporario_salvar', hash=url_hash)
            else:
                messages.error(request, 'Erro ao salvar!')
        s2200_trabtemporario_form = disabled_form_fields(s2200_trabtemporario_form, permissao.permite_editar)
        if s2200_trabtemporario_id:
            if dados_evento['status'] != 0:
                s2200_trabtemporario_form = disabled_form_fields(s2200_trabtemporario_form, 0)
        #s2200_trabtemporario_campos_multiple_passo3

        for field in s2200_trabtemporario_form.fields.keys():
            s2200_trabtemporario_form.fields[field].widget.attrs['ng-model'] = 's2200_trabtemporario_'+field
        if int(dict_hash['print']):
            s2200_trabtemporario_form = disabled_form_for_print(s2200_trabtemporario_form)
   
        s2200_ideestabvinc_form = None
        s2200_ideestabvinc_lista = None
        s2200_idetrabsubstituido_form = None
        s2200_idetrabsubstituido_lista = None
        if s2200_trabtemporario_id:
            s2200_trabtemporario = get_object_or_404(s2200trabTemporario.objects.using( db_slug ), excluido = False, id = s2200_trabtemporario_id)
       
            s2200_ideestabvinc_form = form_s2200_ideestabvinc(initial={ 's2200_trabtemporario': s2200_trabtemporario }, slug=db_slug)
            s2200_ideestabvinc_form.fields['s2200_trabtemporario'].widget.attrs['readonly'] = True
            s2200_ideestabvinc_lista = s2200ideEstabVinc.objects.using( db_slug ).filter(excluido = False, s2200_trabtemporario_id=s2200_trabtemporario.id).all()
            s2200_idetrabsubstituido_form = form_s2200_idetrabsubstituido(initial={ 's2200_trabtemporario': s2200_trabtemporario }, slug=db_slug)
            s2200_idetrabsubstituido_form.fields['s2200_trabtemporario'].widget.attrs['readonly'] = True
            s2200_idetrabsubstituido_lista = s2200ideTrabSubstituido.objects.using( db_slug ).filter(excluido = False, s2200_trabtemporario_id=s2200_trabtemporario.id).all()
        else:
            s2200_trabtemporario = None
        #s2200_trabtemporario_salvar_custom_variaveis#
        tabelas_secundarias = []
        #[FUNCOES_ESPECIAIS_SALVAR]
        if dict_hash['tab'] or 's2200_trabtemporario' in request.session['retorno_pagina']:
            request.session["retorno_hash"] = hash
            request.session["retorno_pagina"] = 's2200_trabtemporario_salvar'
        controle_alteracoes = Auditoria.objects.using( db_slug ).filter(identidade=s2200_trabtemporario_id, tabela='s2200_trabtemporario').all()
        context = {
            'ocorrencias': dados_evento['ocorrencias'],
            'validacao_precedencia': dados_evento['validacao_precedencia'],
            'validacoes': dados_evento['validacoes'],
            'status': dados_evento['status'],
            'controle_alteracoes': controle_alteracoes,
            's2200_trabtemporario': s2200_trabtemporario,
            's2200_trabtemporario_form': s2200_trabtemporario_form,
            'mensagem': mensagem,
            's2200_trabtemporario_id': int(s2200_trabtemporario_id),
            'usuario': usuario,
            
            'hash': hash,
       
            's2200_ideestabvinc_form': s2200_ideestabvinc_form,
            's2200_ideestabvinc_lista': s2200_ideestabvinc_lista,
            's2200_idetrabsubstituido_form': s2200_idetrabsubstituido_form,
            's2200_idetrabsubstituido_lista': s2200_idetrabsubstituido_lista,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
            'for_print': int(dict_hash['print']),
            'tabelas_secundarias': tabelas_secundarias,
            'tab': dict_hash['tab'],
            #s2200_trabtemporario_salvar_custom_variaveis_context#
        }
        if for_print in (0,1 ):
            return render(request, 's2200_trabtemporario_salvar.html', context)
        elif for_print == 2:
            from wkhtmltopdf.views import PDFTemplateResponse
            response = PDFTemplateResponse(
                request=request,
                template='s2200_trabtemporario_salvar.html',
                filename="s2200_trabtemporario.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={'margin-top': 10,
                             'margin-bottom': 10,
                             'margin-right': 10,
                             'margin-left': 10,
                             'zoom': 1,
                             'dpi': 72,
                             'orientation': 'Landscape',
                             "viewport-size": "1366 x 513",
                             'javascript-delay': 1000,
                             'footer-center': '[page]/[topage]',
                             "no-stop-slow-scripts": True},
            )
            return response
        elif for_print == 3:
            from django.shortcuts import render_to_response
            response = render_to_response('s2200_trabtemporario_salvar.html', context)
            filename = "s2200_trabtemporario.xls"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response

    else:
        context = {
            'usuario': usuario,
            
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
        }
        return render(request, 'permissao_negada.html', context)
示例#4
0
def salvar(request, pk=None, tab='master', output=None):

    from emensageriapro.esocial.models import STATUS_EVENTO_CADASTRADO
    
    evento_dados = {}
    evento_dados['status'] = STATUS_EVENTO_CADASTRADO
    
    if pk:
    
        s5011_infoemprparcial = get_object_or_404(s5011infoEmprParcial, id=pk)
        evento_dados = s5011_infoemprparcial.evento()

    if request.user.has_perm('s5011.can_see_s5011infoEmprParcial'):
        
        if pk:
        
            s5011_infoemprparcial_form = form_s5011_infoemprparcial(
                request.POST or None, 
                instance=s5011_infoemprparcial)
                                         
        else:
        
            s5011_infoemprparcial_form = form_s5011_infoemprparcial(request.POST or None)
                                         
        if request.method == 'POST':
        
            if s5011_infoemprparcial_form.is_valid():
            
                obj = s5011_infoemprparcial_form.save(request=request)
                messages.success(request, u'Salvo com sucesso!')
                
                if not pk:
                
                    gravar_auditoria(
                        '{}',
                        json.dumps(
                            model_to_dict(obj), 
                            indent=4, 
                            sort_keys=True, 
                            default=str), 
                        's5011_infoemprparcial', 
                        obj.id, 
                        request.user.id, 1)
                                 
                else:
                
                    gravar_auditoria(
                        json.dumps(
                            model_to_dict(s5011_infoemprparcial), 
                            indent=4, 
                            sort_keys=True, 
                            default=str),
                        json.dumps(
                            model_to_dict(obj), 
                            indent=4, 
                            sort_keys=True, 
                            default=str), 
                        's5011_infoemprparcial', 
                        pk, 
                        request.user.id, 2)
                                     
                if request.session['return_page'] not in (
                    's5011_infoemprparcial_apagar', 
                    's5011_infoemprparcial_salvar', 
                    's5011_infoemprparcial'):
                    
                    return redirect(
                        request.session['return_page'], 
                        pk=request.session['return_pk'])
                    
                if pk != obj.id:
                
                    return redirect(
                        's5011_infoemprparcial_salvar', 
                        pk=obj.id)
                    
            else:
            
                messages.error(request, u'Erro ao salvar!')
               
        s5011_infoemprparcial_form = disabled_form_fields(
            s5011_infoemprparcial_form, 
            request.user.has_perm('s5011.change_s5011infoEmprParcial'))
        
        if pk:
        
            if evento_dados['status'] != STATUS_EVENTO_CADASTRADO:
            
                s5011_infoemprparcial_form = disabled_form_fields(s5011_infoemprparcial_form, 0)
                
        if output:
        
            s5011_infoemprparcial_form = disabled_form_for_print(s5011_infoemprparcial_form)
            
        
        
        if pk:
        
            s5011_infoemprparcial = get_object_or_404(s5011infoEmprParcial, id=pk)
            
                
        else:
        
            s5011_infoemprparcial = None
            
        tabelas_secundarias = []
        
        if tab or 's5011_infoemprparcial' in request.session['return_page']:
        
            request.session['return_pk'] = pk
            request.session['return_tab'] = tab
            request.session['return_page'] = 's5011_infoemprparcial_salvar'
            
        controle_alteracoes = Auditoria.objects.filter(identidade=pk, tabela='s5011_infoemprparcial').all()
        
        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'output': output,
            'evento_dados': evento_dados,
            'controle_alteracoes': controle_alteracoes, 
            's5011_infoemprparcial': s5011_infoemprparcial, 
            's5011_infoemprparcial_form': s5011_infoemprparcial_form, 
            'modulos': ['s5011', ],
            'paginas': ['s5011_infoemprparcial', ],
            'data': datetime.datetime.now(),
            'tabelas_secundarias': tabelas_secundarias,
            'tab': tab,
            #s5011_infoemprparcial_salvar_custom_variaveis_context#
        }
        
        if output == 'pdf':
        
            from wkhtmltopdf.views import PDFTemplateResponse
            
            response = PDFTemplateResponse(
                request=request,
                template='s5011_infoemprparcial_salvar.html',
                filename="s5011_infoemprparcial.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={'margin-top': 10,
                             'margin-bottom': 10,
                             'margin-right': 10,
                             'margin-left': 10,
                             'zoom': 1,
                             'dpi': 72,
                             'orientation': 'Landscape',
                             "viewport-size": "1366 x 513",
                             'javascript-delay': 1000,
                             'footer-center': '[page]/[topage]',
                             "no-stop-slow-scripts": True}, )
            
            return response
            
        elif output == 'xls':
        
            from django.shortcuts import render_to_response
            
            response = render_to_response('s5011_infoemprparcial_salvar.html', context)
            filename = "s5011_infoemprparcial.xls"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            
            return response
            
        else:
        
            return render(request, 's5011_infoemprparcial_salvar.html', context)

    else:
    
        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'output': output,
            'tab': tab,
            'modulos': ['s5011', ],
            'paginas': ['s5011_infoemprparcial', ],
            'data': datetime.datetime.now(),
        }
        
        return render(request, 
                      'permissao_negada.html', 
                      context)
示例#5
0
def salvar(request, pk=None, tab='master', output=None):

    from emensageriapro.esocial.models import STATUS_EVENTO_CADASTRADO

    evento_dados = {}
    evento_dados['status'] = STATUS_EVENTO_CADASTRADO

    if pk:

        s1000_alteracao_softwarehouse = get_object_or_404(s1000alteracaosoftwareHouse, id=pk)
        evento_dados = s1000_alteracao_softwarehouse.evento()

    if request.user.has_perm('s1000.can_see_s1000alteracaosoftwareHouse'):

        if pk:

            s1000_alteracao_softwarehouse_form = form_s1000_alteracao_softwarehouse(
                request.POST or None,
                instance=s1000_alteracao_softwarehouse)
                     
        else:

            s1000_alteracao_softwarehouse_form = form_s1000_alteracao_softwarehouse(request.POST or None)
                     
        if request.method == 'POST':

            if s1000_alteracao_softwarehouse_form.is_valid():

                obj = s1000_alteracao_softwarehouse_form.save(request=request)
                messages.success(request, u'Salvo com sucesso!')
                 
                if 'return_page' in request.session and request.session['return_page'] and 's1000-alteracao-softwarehouse' not in request.session['return_page']:

                    return HttpResponseRedirect(request.session['return_page'])

                if pk != obj.id:

                    return redirect(
                        's1000_alteracao_softwarehouse_salvar',
                        pk=obj.id)

            else:

                messages.error(request, u'Erro ao salvar!')

        s1000_alteracao_softwarehouse_form = disabled_form_fields(
            s1000_alteracao_softwarehouse_form,
            request.user.has_perm('s1000.change_s1000alteracaosoftwareHouse'))

        if pk:

            if evento_dados['status'] != STATUS_EVENTO_CADASTRADO:

                s1000_alteracao_softwarehouse_form = disabled_form_fields(s1000_alteracao_softwarehouse_form, 0)

        if output:

            s1000_alteracao_softwarehouse_form = disabled_form_for_print(s1000_alteracao_softwarehouse_form)



        if pk:

            s1000_alteracao_softwarehouse = get_object_or_404(s1000alteracaosoftwareHouse, id=pk)


        else:

            s1000_alteracao_softwarehouse = None

        tabelas_secundarias = []

        controle_alteracoes = Auditoria.objects.filter(identidade=pk, tabela='s1000_alteracao_softwarehouse').all()

        if not request.POST:
            request.session['return_page'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'output': output,
            'evento_dados': evento_dados,
            'controle_alteracoes': controle_alteracoes,
            's1000_alteracao_softwarehouse': s1000_alteracao_softwarehouse,
            's1000_alteracao_softwarehouse_form': s1000_alteracao_softwarehouse_form,
            'modulos': ['s1000', ],
            'paginas': ['s1000_alteracao_softwarehouse', ],
            'data': datetime.datetime.now(),
            'tabelas_secundarias': tabelas_secundarias,
            'tab': tab,
            #s1000_alteracao_softwarehouse_salvar_custom_variaveis_context#
        }

        if output == 'pdf':

            from wkhtmltopdf.views import PDFTemplateResponse

            response = PDFTemplateResponse(
                request=request,
                template='s1000_alteracao_softwarehouse_salvar.html',
                filename="s1000_alteracao_softwarehouse.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={'margin-top': 10,
                             'margin-bottom': 10,
                             'margin-right': 10,
                             'margin-left': 10,
                             'zoom': 1,
                             'dpi': 72,
                             'orientation': 'Landscape',
                             "viewport-size": "1366 x 513",
                             'javascript-delay': 1000,
                             'footer-center': '[page]/[topage]',
                             "no-stop-slow-scripts": True}, )

            return response

        elif output == 'xls':

            from django.shortcuts import render_to_response

            response = render_to_response('s1000_alteracao_softwarehouse_salvar.html', context)
            filename = "s1000_alteracao_softwarehouse.xls"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        else:

            return render(request, 's1000_alteracao_softwarehouse_salvar.html', context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'output': output,
            'tab': tab,
            'modulos': ['s1000', ],
            'paginas': ['s1000_alteracao_softwarehouse', ],
            'data': datetime.datetime.now(),
        }

        return render(request,
                      'permissao_negada.html',
                      context)
示例#6
0
def listar(request, output=None):

    if request.user.has_perm('efdreinf.can_see_r3010evtEspDesportivo'):

        filtrar = False
        dict_fields = {}
        show_fields = {
            'show_reinf': 0,
            'show_evtespdesportivo': 0,
            'show_identidade': 1,
            'show_ideevento': 0,
            'show_indretif': 1,
            'show_nrrecibo': 0,
            'show_dtapuracao': 1,
            'show_tpamb': 0,
            'show_procemi': 0,
            'show_verproc': 0,
            'show_idecontri': 0,
            'show_tpinsc': 0,
            'show_nrinsc': 0,
            'show_ideestab': 0,
            'show_tpinscestab': 0,
            'show_nrinscestab': 0,
            'show_receitatotal': 0,
            'show_vlrreceitatotal': 0,
            'show_vlrcp': 0,
            'show_vlrcpsusptotal': 0,
            'show_vlrreceitaclubes': 0,
            'show_vlrretparc': 0,
            'show_versao': 0,
            'show_transmissor_lote_efdreinf': 0,
            'show_retornos_r5001': 0,
            'show_retornos_r5011': 0,
            'show_retornos_r9001': 0,
            'show_retornos_r9002': 0,
            'show_retornos_r9011': 0,
            'show_retornos_r9012': 0,
            'show_ocorrencias': 0,
            'show_validacao_precedencia': 0,
            'show_validacoes': 0,
            'show_arquivo_original': 0,
            'show_arquivo': 0,
            'show_status': 1,
            'show_cdretorno': 1,
            'show_descretorno': 0,
            'show_dhprocess': 0,
            'show_transmissor_lote_efdreinf_error': 0,
        }

        post = False

        if request.method == 'POST':

            post = True
            dict_fields = {
                'reinf': 'reinf',
                'evtespdesportivo': 'evtespdesportivo',
                'identidade__icontains': 'identidade__icontains',
                'ideevento': 'ideevento',
                'indretif__icontains': 'indretif__icontains',
                'nrrecibo__icontains': 'nrrecibo__icontains',
                'dtapuracao__range': 'dtapuracao__range',
                'tpamb__icontains': 'tpamb__icontains',
                'procemi__icontains': 'procemi__icontains',
                'verproc__icontains': 'verproc__icontains',
                'idecontri': 'idecontri',
                'tpinsc__icontains': 'tpinsc__icontains',
                'nrinsc__icontains': 'nrinsc__icontains',
                'ideestab': 'ideestab',
                'tpinscestab__icontains': 'tpinscestab__icontains',
                'nrinscestab__icontains': 'nrinscestab__icontains',
                'receitatotal': 'receitatotal',
                'vlrreceitatotal__icontains': 'vlrreceitatotal__icontains',
                'vlrcp__icontains': 'vlrcp__icontains',
                'vlrcpsusptotal__icontains': 'vlrcpsusptotal__icontains',
                'vlrreceitaclubes__icontains': 'vlrreceitaclubes__icontains',
                'vlrretparc__icontains': 'vlrretparc__icontains',
                'versao__icontains': 'versao__icontains',
                'transmissor_lote_efdreinf__icontains':
                'transmissor_lote_efdreinf__icontains',
                'status__icontains': 'status__icontains',
                'cdretorno__icontains': 'cdretorno__icontains',
            }

            for a in dict_fields:
                dict_fields[a] = request.POST.get(a or None)

            for a in show_fields:
                show_fields[a] = request.POST.get(a or None)

            if request.method == 'POST':
                dict_fields = {
                    'reinf': 'reinf',
                    'evtespdesportivo': 'evtespdesportivo',
                    'identidade__icontains': 'identidade__icontains',
                    'ideevento': 'ideevento',
                    'indretif__icontains': 'indretif__icontains',
                    'nrrecibo__icontains': 'nrrecibo__icontains',
                    'dtapuracao__range': 'dtapuracao__range',
                    'tpamb__icontains': 'tpamb__icontains',
                    'procemi__icontains': 'procemi__icontains',
                    'verproc__icontains': 'verproc__icontains',
                    'idecontri': 'idecontri',
                    'tpinsc__icontains': 'tpinsc__icontains',
                    'nrinsc__icontains': 'nrinsc__icontains',
                    'ideestab': 'ideestab',
                    'tpinscestab__icontains': 'tpinscestab__icontains',
                    'nrinscestab__icontains': 'nrinscestab__icontains',
                    'receitatotal': 'receitatotal',
                    'vlrreceitatotal__icontains': 'vlrreceitatotal__icontains',
                    'vlrcp__icontains': 'vlrcp__icontains',
                    'vlrcpsusptotal__icontains': 'vlrcpsusptotal__icontains',
                    'vlrreceitaclubes__icontains':
                    'vlrreceitaclubes__icontains',
                    'vlrretparc__icontains': 'vlrretparc__icontains',
                    'versao__icontains': 'versao__icontains',
                    'transmissor_lote_efdreinf__icontains':
                    'transmissor_lote_efdreinf__icontains',
                    'status__icontains': 'status__icontains',
                    'cdretorno__icontains': 'cdretorno__icontains',
                }
                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)

        dict_qs = clear_dict_fields(dict_fields)
        r3010_evtespdesportivo_lista = r3010evtEspDesportivo.objects.filter(
            **dict_qs).filter().exclude(id=0).all()

        if not post and len(r3010_evtespdesportivo_lista) > 100:
            filtrar = True
            r3010_evtespdesportivo_lista = None
            messages.warning(
                request,
                u'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!'
            )

        #[VARIAVEIS_LISTA_FILTRO_RELATORIO]
        #r3010_evtespdesportivo_listar_custom

        request.session['return'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            'r3010_evtespdesportivo_lista': r3010_evtespdesportivo_lista,
            'dict_fields': dict_fields,
            'data': datetime.datetime.now(),
            'modulos': [
                'efdreinf',
            ],
            'paginas': [
                'r3010_evtespdesportivo',
            ],
            'show_fields': show_fields,
            'filtrar': filtrar,
            #[VARIAVEIS_FILTRO_RELATORIO]
        }

        if output == 'pdf':

            from emensageriapro.functions import render_to_pdf
            from wkhtmltopdf.views import PDFTemplateResponse

            response = PDFTemplateResponse(
                request=request,
                template='r3010_evtespdesportivo_listar.html',
                filename="r3010_evtespdesportivo.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 10,
                    'zoom': 1,
                    'dpi': 72,
                    'orientation': 'Landscape',
                    'viewport-size': "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )
            return response

        elif output == 'xls':

            response = render_to_response('r3010_evtespdesportivo_listar.html',
                                          context)
            filename = "r3010_evtespdesportivo.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            response = render_to_response('csv/r3010_evtespdesportivo.csv',
                                          context)
            filename = "r3010_evtespdesportivo.csv"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'

            return response

        else:

            return render(request, 'r3010_evtespdesportivo_listar.html',
                          context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'data': datetime.datetime.now(),
            'modulos': [
                'efdreinf',
            ],
            'paginas': [
                'r3010_evtespdesportivo',
            ],
        }
        return render(request, 'permissao_negada.html', context)
def verificar(request, hash):
    for_print = 0
    db_slug = 'default'
    try:
        usuario_id = request.user.id
        dict_hash = get_hash_url(hash)
        s1298_evtreabreevper_id = int(dict_hash['id'])
        for_print = int(dict_hash['print'])
    except:
        usuario_id = False
        return redirect('login')
    usuario = get_object_or_404(Usuarios.objects.using(db_slug),
                                excluido=False,
                                id=usuario_id)
    pagina = ConfigPaginas.objects.using(db_slug).get(
        excluido=False, endereco='s1298_evtreabreevper')
    permissao = ConfigPermissoes.objects.using(db_slug).get(
        excluido=False,
        config_paginas=pagina,
        config_perfis=usuario.config_perfis)
    dict_permissoes = json_to_dict(usuario.config_perfis.permissoes)
    paginas_permitidas_lista = usuario.config_perfis.paginas_permitidas
    modulos_permitidos_lista = usuario.config_perfis.modulos_permitidos

    if permissao.permite_listar:
        s1298_evtreabreevper = get_object_or_404(
            s1298evtReabreEvPer.objects.using(db_slug),
            excluido=False,
            id=s1298_evtreabreevper_id)
        s1298_evtreabreevper_lista = s1298evtReabreEvPer.objects.using(
            db_slug).filter(id=s1298_evtreabreevper_id, excluido=False).all()

        request.session["retorno_hash"] = hash
        request.session["retorno_pagina"] = 's1298_evtreabreevper'
        context = {
            's1298_evtreabreevper_lista': s1298_evtreabreevper_lista,
            's1298_evtreabreevper_id': s1298_evtreabreevper_id,
            's1298_evtreabreevper': s1298_evtreabreevper,
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
            'for_print': for_print,
            'hash': hash,
        }
        if for_print == 2:

            from wkhtmltopdf.views import PDFTemplateResponse
            response = PDFTemplateResponse(
                request=request,
                template='s1298_evtreabreevper_verificar.html',
                filename="s1298_evtreabreevper.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 5,
                    'margin-bottom': 5,
                    'margin-right': 5,
                    'margin-left': 5,
                    "zoom": 3,
                    "viewport-size": "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )
            return response
        elif for_print == 3:
            from django.shortcuts import render_to_response
            response = render_to_response(
                's1298_evtreabreevper_verificar.html', context)
            filename = "%s.xls" % s1298_evtreabreevper.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response
        elif for_print == 4:
            from django.shortcuts import render_to_response
            response = render_to_response(
                's1298_evtreabreevper_verificar.html', context)
            filename = "%s.csv" % s1298_evtreabreevper.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response
        else:
            return render(request, 's1298_evtreabreevper_verificar.html',
                          context)
    else:
        context = {
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
        }
        return render(request, 'permissao_negada.html', context)
示例#8
0
def verificar(request, hash):
    for_print = 0
    db_slug = 'default'
    try:
        usuario_id = request.user.id
        dict_hash = get_hash_url( hash )
        r2070_evtpgtosdivs_id = int(dict_hash['id'])
        for_print = int(dict_hash['print'])
    except:
        usuario_id = False
        return redirect('login')
    usuario = get_object_or_404(Usuarios.objects.using( db_slug ), excluido = False, id = usuario_id)
    pagina = ConfigPaginas.objects.using( db_slug ).get(excluido = False, endereco='r2070_evtpgtosdivs')
    permissao = ConfigPermissoes.objects.using( db_slug ).get(excluido = False, config_paginas=pagina, config_perfis=usuario.config_perfis)
    dict_permissoes = json_to_dict(usuario.config_perfis.permissoes)
    paginas_permitidas_lista = usuario.config_perfis.paginas_permitidas
    modulos_permitidos_lista = usuario.config_perfis.modulos_permitidos

    if permissao.permite_listar:
        r2070_evtpgtosdivs = get_object_or_404(r2070evtPgtosDivs.objects.using( db_slug ), excluido = False, id = r2070_evtpgtosdivs_id)
        r2070_evtpgtosdivs_lista = r2070evtPgtosDivs.objects.using( db_slug ).filter(id=r2070_evtpgtosdivs_id, excluido = False).all()


        r2070_inforesidext_lista = r2070infoResidExt.objects.using(db_slug).filter(r2070_evtpgtosdivs_id__in = listar_ids(r2070_evtpgtosdivs_lista) ).filter(excluido=False).all()
        r2070_infomolestia_lista = r2070infoMolestia.objects.using(db_slug).filter(r2070_evtpgtosdivs_id__in = listar_ids(r2070_evtpgtosdivs_lista) ).filter(excluido=False).all()
        r2070_ideestab_lista = r2070ideEstab.objects.using(db_slug).filter(r2070_evtpgtosdivs_id__in = listar_ids(r2070_evtpgtosdivs_lista) ).filter(excluido=False).all()
        r2070_pgtopf_lista = r2070pgtoPF.objects.using(db_slug).filter(r2070_ideestab_id__in = listar_ids(r2070_ideestab_lista) ).filter(excluido=False).all()
        r2070_detdeducao_lista = r2070detDeducao.objects.using(db_slug).filter(r2070_pgtopf_id__in = listar_ids(r2070_pgtopf_lista) ).filter(excluido=False).all()
        r2070_rendisento_lista = r2070rendIsento.objects.using(db_slug).filter(r2070_pgtopf_id__in = listar_ids(r2070_pgtopf_lista) ).filter(excluido=False).all()
        r2070_detcompet_lista = r2070detCompet.objects.using(db_slug).filter(r2070_pgtopf_id__in = listar_ids(r2070_pgtopf_lista) ).filter(excluido=False).all()
        r2070_compjud_lista = r2070compJud.objects.using(db_slug).filter(r2070_pgtopf_id__in = listar_ids(r2070_pgtopf_lista) ).filter(excluido=False).all()
        r2070_inforra_lista = r2070infoRRA.objects.using(db_slug).filter(r2070_pgtopf_id__in = listar_ids(r2070_pgtopf_lista) ).filter(excluido=False).all()
        r2070_inforra_despprocjud_lista = r2070infoRRAdespProcJud.objects.using(db_slug).filter(r2070_inforra_id__in = listar_ids(r2070_inforra_lista) ).filter(excluido=False).all()
        r2070_inforra_ideadvogado_lista = r2070infoRRAideAdvogado.objects.using(db_slug).filter(r2070_inforra_despprocjud_id__in = listar_ids(r2070_inforra_despprocjud_lista) ).filter(excluido=False).all()
        r2070_infoprocjud_lista = r2070infoProcJud.objects.using(db_slug).filter(r2070_pgtopf_id__in = listar_ids(r2070_pgtopf_lista) ).filter(excluido=False).all()
        r2070_infoprocjud_despprocjud_lista = r2070infoProcJuddespProcJud.objects.using(db_slug).filter(r2070_infoprocjud_id__in = listar_ids(r2070_infoprocjud_lista) ).filter(excluido=False).all()
        r2070_infoprocjud_ideadvogado_lista = r2070infoProcJudideAdvogado.objects.using(db_slug).filter(r2070_infoprocjud_despprocjud_id__in = listar_ids(r2070_infoprocjud_despprocjud_lista) ).filter(excluido=False).all()
        r2070_infoprocjud_origemrecursos_lista = r2070infoProcJudorigemRecursos.objects.using(db_slug).filter(r2070_infoprocjud_id__in = listar_ids(r2070_infoprocjud_lista) ).filter(excluido=False).all()
        r2070_depjudicial_lista = r2070depJudicial.objects.using(db_slug).filter(r2070_pgtopf_id__in = listar_ids(r2070_pgtopf_lista) ).filter(excluido=False).all()
        r2070_pgtopj_lista = r2070pgtoPJ.objects.using(db_slug).filter(r2070_ideestab_id__in = listar_ids(r2070_ideestab_lista) ).filter(excluido=False).all()
        r2070_pgtopj_infoprocjud_lista = r2070pgtoPJinfoProcJud.objects.using(db_slug).filter(r2070_pgtopj_id__in = listar_ids(r2070_pgtopj_lista) ).filter(excluido=False).all()
        r2070_pgtopj_despprocjud_lista = r2070pgtoPJdespProcJud.objects.using(db_slug).filter(r2070_pgtopj_infoprocjud_id__in = listar_ids(r2070_pgtopj_infoprocjud_lista) ).filter(excluido=False).all()
        r2070_pgtopj_ideadvogado_lista = r2070pgtoPJideAdvogado.objects.using(db_slug).filter(r2070_pgtopj_despprocjud_id__in = listar_ids(r2070_pgtopj_despprocjud_lista) ).filter(excluido=False).all()
        r2070_pgtopj_origemrecursos_lista = r2070pgtoPJorigemRecursos.objects.using(db_slug).filter(r2070_pgtopj_infoprocjud_id__in = listar_ids(r2070_pgtopj_infoprocjud_lista) ).filter(excluido=False).all()
        r2070_pgtoresidext_lista = r2070pgtoResidExt.objects.using(db_slug).filter(r2070_ideestab_id__in = listar_ids(r2070_ideestab_lista) ).filter(excluido=False).all()
        request.session["retorno_hash"] = hash
        request.session["retorno_pagina"] = 'r2070_evtpgtosdivs'
        context = {
            'r2070_evtpgtosdivs_lista': r2070_evtpgtosdivs_lista,
            'r2070_evtpgtosdivs_id': r2070_evtpgtosdivs_id,
            'r2070_evtpgtosdivs': r2070_evtpgtosdivs,
  
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
  
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
            'for_print': for_print,
            'hash': hash,

            'r2070_inforesidext_lista': r2070_inforesidext_lista,
            'r2070_infomolestia_lista': r2070_infomolestia_lista,
            'r2070_ideestab_lista': r2070_ideestab_lista,
            'r2070_pgtopf_lista': r2070_pgtopf_lista,
            'r2070_detdeducao_lista': r2070_detdeducao_lista,
            'r2070_rendisento_lista': r2070_rendisento_lista,
            'r2070_detcompet_lista': r2070_detcompet_lista,
            'r2070_compjud_lista': r2070_compjud_lista,
            'r2070_inforra_lista': r2070_inforra_lista,
            'r2070_inforra_despprocjud_lista': r2070_inforra_despprocjud_lista,
            'r2070_inforra_ideadvogado_lista': r2070_inforra_ideadvogado_lista,
            'r2070_infoprocjud_lista': r2070_infoprocjud_lista,
            'r2070_infoprocjud_despprocjud_lista': r2070_infoprocjud_despprocjud_lista,
            'r2070_infoprocjud_ideadvogado_lista': r2070_infoprocjud_ideadvogado_lista,
            'r2070_infoprocjud_origemrecursos_lista': r2070_infoprocjud_origemrecursos_lista,
            'r2070_depjudicial_lista': r2070_depjudicial_lista,
            'r2070_pgtopj_lista': r2070_pgtopj_lista,
            'r2070_pgtopj_infoprocjud_lista': r2070_pgtopj_infoprocjud_lista,
            'r2070_pgtopj_despprocjud_lista': r2070_pgtopj_despprocjud_lista,
            'r2070_pgtopj_ideadvogado_lista': r2070_pgtopj_ideadvogado_lista,
            'r2070_pgtopj_origemrecursos_lista': r2070_pgtopj_origemrecursos_lista,
            'r2070_pgtoresidext_lista': r2070_pgtoresidext_lista,
        }
        if for_print == 2:

            from wkhtmltopdf.views import PDFTemplateResponse
            response = PDFTemplateResponse(request=request,
                                           template='r2070_evtpgtosdivs_verificar.html',
                                           filename="r2070_evtpgtosdivs.pdf",
                                           context=context,
                                           show_content_in_browser=True,
                                           cmd_options={'margin-top': 5,
                                                        'margin-bottom': 5,
                                                        'margin-right': 5,
                                                        'margin-left': 5,
                                                        "zoom": 3,
                                                        "viewport-size": "1366 x 513",
                                                        'javascript-delay': 1000,
                                                        'footer-center': '[page]/[topage]',
                                                        "no-stop-slow-scripts": True},
                                           )
            return response
        elif for_print == 3:
            from django.shortcuts import render_to_response
            response =  render_to_response('r2070_evtpgtosdivs_verificar.html', context)
            filename = "%s.xls" % r2070_evtpgtosdivs.identidade
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response
        elif for_print == 4:
            from django.shortcuts import render_to_response
            response =  render_to_response('r2070_evtpgtosdivs_verificar.html', context)
            filename = "%s.csv" % r2070_evtpgtosdivs.identidade
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response
        else:
            return render(request, 'r2070_evtpgtosdivs_verificar.html', context)
    else:
        context = {
            'usuario': usuario,
  
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
  
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
        }
        return render(request, 'permissao_negada.html', context)
示例#9
0
def verificar(request, pk, output=None):

    if request.user.has_perm('esocial.can_see_s1298evtReabreEvPer'):

        s1298_evtreabreevper = get_object_or_404(s1298evtReabreEvPer, id=pk)
        s1298_evtreabreevper_lista = s1298evtReabreEvPer.objects.filter(
            id=pk).all()

        request.session['return_pk'] = pk
        request.session['return_page'] = request.META.get('HTTP_REFERER')

        context = {
            's1298_evtreabreevper_lista': s1298_evtreabreevper_lista,
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            's1298_evtreabreevper': s1298_evtreabreevper,
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1298_evtreabreevper',
            ],
            'data': datetime.now(),
            'output': output,
        }

        if output == 'pdf':

            response = PDFTemplateResponse(
                request=request,
                template='s1298_evtreabreevper_verificar.html',
                filename="s1298_evtreabreevper.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 20,
                    'zoom': 1,
                    'viewport-size': '1366 x 513',
                    'javascript-delay': 1000,
                    'footer-center': u'Página [page]/[topage]',
                    'footer-font-size': 10,
                    'no-stop-slow-scripts': True
                })

            return response

        elif output == 'xls':

            response = render_to_response(
                's1298_evtreabreevper_verificar.html', context)
            filename = "%s.xls" % s1298_evtreabreevper.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            response = render_to_response(
                's1298_evtreabreevper_verificar.html', context)
            filename = "%s.csv" % s1298_evtreabreevper.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response

        else:

            return render(request, 's1298_evtreabreevper_verificar.html',
                          context)

    else:

        context = {
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1298_evtreabreevper',
            ],
            'data': datetime.now(),
        }

        return render(request, 'permissao_negada.html', context)
示例#10
0
def verificar(request, hash):
    for_print = 0
    db_slug = 'default'
    try:
        usuario_id = request.user.id
        dict_hash = get_hash_url(hash)
        s2399_evttsvtermino_id = int(dict_hash['id'])
        for_print = int(dict_hash['print'])
    except:
        usuario_id = False
        return redirect('login')
    usuario = get_object_or_404(Usuarios.objects.using(db_slug),
                                excluido=False,
                                id=usuario_id)
    pagina = ConfigPaginas.objects.using(db_slug).get(
        excluido=False, endereco='s2399_evttsvtermino')
    permissao = ConfigPermissoes.objects.using(db_slug).get(
        excluido=False,
        config_paginas=pagina,
        config_perfis=usuario.config_perfis)
    dict_permissoes = json_to_dict(usuario.config_perfis.permissoes)
    paginas_permitidas_lista = usuario.config_perfis.paginas_permitidas
    modulos_permitidos_lista = usuario.config_perfis.modulos_permitidos

    if permissao.permite_listar:
        s2399_evttsvtermino = get_object_or_404(
            s2399evtTSVTermino.objects.using(db_slug),
            excluido=False,
            id=s2399_evttsvtermino_id)
        s2399_evttsvtermino_lista = s2399evtTSVTermino.objects.using(
            db_slug).filter(id=s2399_evttsvtermino_id, excluido=False).all()

        s2399_verbasresc_lista = s2399verbasResc.objects.using(db_slug).filter(
            s2399_evttsvtermino_id__in=listar_ids(
                s2399_evttsvtermino_lista)).filter(excluido=False).all()
        s2399_dmdev_lista = s2399dmDev.objects.using(db_slug).filter(
            s2399_verbasresc_id__in=listar_ids(s2399_verbasresc_lista)).filter(
                excluido=False).all()
        s2399_ideestablot_lista = s2399ideEstabLot.objects.using(
            db_slug).filter(
                s2399_dmdev_id__in=listar_ids(s2399_dmdev_lista)).filter(
                    excluido=False).all()
        s2399_detverbas_lista = s2399detVerbas.objects.using(db_slug).filter(
            s2399_ideestablot_id__in=listar_ids(
                s2399_ideestablot_lista)).filter(excluido=False).all()
        s2399_infosaudecolet_lista = s2399infoSaudeColet.objects.using(
            db_slug).filter(s2399_ideestablot_id__in=listar_ids(
                s2399_ideestablot_lista)).filter(excluido=False).all()
        s2399_detoper_lista = s2399detOper.objects.using(db_slug).filter(
            s2399_infosaudecolet_id__in=listar_ids(
                s2399_infosaudecolet_lista)).filter(excluido=False).all()
        s2399_detplano_lista = s2399detPlano.objects.using(db_slug).filter(
            s2399_detoper_id__in=listar_ids(s2399_detoper_lista)).filter(
                excluido=False).all()
        s2399_infoagnocivo_lista = s2399infoAgNocivo.objects.using(
            db_slug).filter(s2399_ideestablot_id__in=listar_ids(
                s2399_ideestablot_lista)).filter(excluido=False).all()
        s2399_infosimples_lista = s2399infoSimples.objects.using(
            db_slug).filter(s2399_ideestablot_id__in=listar_ids(
                s2399_ideestablot_lista)).filter(excluido=False).all()
        s2399_procjudtrab_lista = s2399procJudTrab.objects.using(
            db_slug).filter(s2399_verbasresc_id__in=listar_ids(
                s2399_verbasresc_lista)).filter(excluido=False).all()
        s2399_infomv_lista = s2399infoMV.objects.using(db_slug).filter(
            s2399_verbasresc_id__in=listar_ids(s2399_verbasresc_lista)).filter(
                excluido=False).all()
        s2399_remunoutrempr_lista = s2399remunOutrEmpr.objects.using(
            db_slug).filter(
                s2399_infomv_id__in=listar_ids(s2399_infomv_lista)).filter(
                    excluido=False).all()
        s2399_quarentena_lista = s2399quarentena.objects.using(db_slug).filter(
            s2399_evttsvtermino_id__in=listar_ids(
                s2399_evttsvtermino_lista)).filter(excluido=False).all()
        request.session["retorno_hash"] = hash
        request.session["retorno_pagina"] = 's2399_evttsvtermino'
        context = {
            's2399_evttsvtermino_lista': s2399_evttsvtermino_lista,
            's2399_evttsvtermino_id': s2399_evttsvtermino_id,
            's2399_evttsvtermino': s2399_evttsvtermino,
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
            'for_print': for_print,
            'hash': hash,
            's2399_verbasresc_lista': s2399_verbasresc_lista,
            's2399_dmdev_lista': s2399_dmdev_lista,
            's2399_ideestablot_lista': s2399_ideestablot_lista,
            's2399_detverbas_lista': s2399_detverbas_lista,
            's2399_infosaudecolet_lista': s2399_infosaudecolet_lista,
            's2399_detoper_lista': s2399_detoper_lista,
            's2399_detplano_lista': s2399_detplano_lista,
            's2399_infoagnocivo_lista': s2399_infoagnocivo_lista,
            's2399_infosimples_lista': s2399_infosimples_lista,
            's2399_procjudtrab_lista': s2399_procjudtrab_lista,
            's2399_infomv_lista': s2399_infomv_lista,
            's2399_remunoutrempr_lista': s2399_remunoutrempr_lista,
            's2399_quarentena_lista': s2399_quarentena_lista,
        }
        if for_print == 2:
            #return render_to_pdf('%s/s2399_evttsvtermino_verificar.html' % s2399_evttsvtermino.versao, context)
            from wkhtmltopdf.views import PDFTemplateResponse
            response = PDFTemplateResponse(
                request=request,
                template='%s/s2399_evttsvtermino_verificar.html' %
                s2399_evttsvtermino.versao,
                filename="s2399_evttsvtermino.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 5,
                    'margin-bottom': 5,
                    'margin-right': 5,
                    'margin-left': 5,
                    "zoom": 3,
                    "viewport-size": "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )
            return response
        elif for_print == 3:
            from django.shortcuts import render_to_response
            response = render_to_response(
                '%s/s2399_evttsvtermino_verificar.html' %
                s2399_evttsvtermino.versao, context)
            filename = "%s.xls" % s2399_evttsvtermino.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response
        elif for_print == 4:
            from django.shortcuts import render_to_response
            response = render_to_response(
                '%s/s2399_evttsvtermino_verificar.html' %
                s2399_evttsvtermino.versao, context)
            filename = "%s.csv" % s2399_evttsvtermino.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response
        else:
            return render(
                request, '%s/s2399_evttsvtermino_verificar.html' %
                s2399_evttsvtermino.versao, context)
    else:
        context = {
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
        }
        return render(request, 'permissao_negada.html', context)
示例#11
0
def verificar(request, pk, output=None):

    if request.user.has_perm('esocial.can_see_s1210evtPgtos'):

        s1210_evtpgtos = get_object_or_404(s1210evtPgtos, id=pk)
        s1210_evtpgtos_lista = s1210evtPgtos.objects.filter(id=pk).all()

        s1210_deps_lista = s1210deps.objects.filter(
            s1210_evtpgtos_id__in=listar_ids(s1210_evtpgtos_lista)).all()
        s1210_infopgto_lista = s1210infoPgto.objects.filter(
            s1210_evtpgtos_id__in=listar_ids(s1210_evtpgtos_lista)).all()
        s1210_detpgtofl_lista = s1210detPgtoFl.objects.filter(
            s1210_infopgto_id__in=listar_ids(s1210_infopgto_lista)).all()
        s1210_detpgtofl_retpgtotot_lista = s1210detPgtoFlretPgtoTot.objects.filter(
            s1210_detpgtofl_id__in=listar_ids(s1210_detpgtofl_lista)).all()
        s1210_detpgtofl_penalim_lista = s1210detPgtoFlpenAlim.objects.filter(
            s1210_detpgtofl_retpgtotot_id__in=listar_ids(
                s1210_detpgtofl_retpgtotot_lista)).all()
        s1210_detpgtofl_infopgtoparc_lista = s1210detPgtoFlinfoPgtoParc.objects.filter(
            s1210_detpgtofl_id__in=listar_ids(s1210_detpgtofl_lista)).all()
        s1210_detpgtobenpr_lista = s1210detPgtoBenPr.objects.filter(
            s1210_infopgto_id__in=listar_ids(s1210_infopgto_lista)).all()
        s1210_detpgtobenpr_retpgtotot_lista = s1210detPgtoBenPrretPgtoTot.objects.filter(
            s1210_detpgtobenpr_id__in=listar_ids(
                s1210_detpgtobenpr_lista)).all()
        s1210_detpgtobenpr_infopgtoparc_lista = s1210detPgtoBenPrinfoPgtoParc.objects.filter(
            s1210_detpgtobenpr_id__in=listar_ids(
                s1210_detpgtobenpr_lista)).all()
        s1210_detpgtofer_lista = s1210detPgtoFer.objects.filter(
            s1210_infopgto_id__in=listar_ids(s1210_infopgto_lista)).all()
        s1210_detpgtofer_detrubrfer_lista = s1210detPgtoFerdetRubrFer.objects.filter(
            s1210_detpgtofer_id__in=listar_ids(s1210_detpgtofer_lista)).all()
        s1210_detpgtofer_penalim_lista = s1210detPgtoFerpenAlim.objects.filter(
            s1210_detpgtofer_detrubrfer_id__in=listar_ids(
                s1210_detpgtofer_detrubrfer_lista)).all()
        s1210_detpgtoant_lista = s1210detPgtoAnt.objects.filter(
            s1210_infopgto_id__in=listar_ids(s1210_infopgto_lista)).all()
        s1210_detpgtoant_infopgtoant_lista = s1210detPgtoAntinfoPgtoAnt.objects.filter(
            s1210_detpgtoant_id__in=listar_ids(s1210_detpgtoant_lista)).all()
        s1210_idepgtoext_lista = s1210idePgtoExt.objects.filter(
            s1210_infopgto_id__in=listar_ids(s1210_infopgto_lista)).all()

        request.session['return_pk'] = pk
        request.session['return_page'] = request.META.get('HTTP_REFERER')

        context = {
            's1210_evtpgtos_lista': s1210_evtpgtos_lista,
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            's1210_evtpgtos': s1210_evtpgtos,
            's1210_deps_lista': s1210_deps_lista,
            's1210_infopgto_lista': s1210_infopgto_lista,
            's1210_detpgtofl_lista': s1210_detpgtofl_lista,
            's1210_detpgtofl_retpgtotot_lista':
            s1210_detpgtofl_retpgtotot_lista,
            's1210_detpgtofl_penalim_lista': s1210_detpgtofl_penalim_lista,
            's1210_detpgtofl_infopgtoparc_lista':
            s1210_detpgtofl_infopgtoparc_lista,
            's1210_detpgtobenpr_lista': s1210_detpgtobenpr_lista,
            's1210_detpgtobenpr_retpgtotot_lista':
            s1210_detpgtobenpr_retpgtotot_lista,
            's1210_detpgtobenpr_infopgtoparc_lista':
            s1210_detpgtobenpr_infopgtoparc_lista,
            's1210_detpgtofer_lista': s1210_detpgtofer_lista,
            's1210_detpgtofer_detrubrfer_lista':
            s1210_detpgtofer_detrubrfer_lista,
            's1210_detpgtofer_penalim_lista': s1210_detpgtofer_penalim_lista,
            's1210_detpgtoant_lista': s1210_detpgtoant_lista,
            's1210_detpgtoant_infopgtoant_lista':
            s1210_detpgtoant_infopgtoant_lista,
            's1210_idepgtoext_lista': s1210_idepgtoext_lista,
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1210_evtpgtos',
            ],
            'data': datetime.now(),
            'output': output,
        }

        if output == 'pdf':

            response = PDFTemplateResponse(
                request=request,
                template='s1210_evtpgtos_verificar.html',
                filename="s1210_evtpgtos.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 20,
                    'zoom': 1,
                    'viewport-size': '1366 x 513',
                    'javascript-delay': 1000,
                    'footer-center': u'Página [page]/[topage]',
                    'footer-font-size': 10,
                    'no-stop-slow-scripts': True
                })

            return response

        elif output == 'xls':

            response = render_to_response('s1210_evtpgtos_verificar.html',
                                          context)
            filename = "%s.xls" % s1210_evtpgtos.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            response = render_to_response('s1210_evtpgtos_verificar.html',
                                          context)
            filename = "%s.csv" % s1210_evtpgtos.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response

        else:

            return render(request, 's1210_evtpgtos_verificar.html', context)

    else:

        context = {
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1210_evtpgtos',
            ],
            'data': datetime.now(),
        }

        return render(request, 'permissao_negada.html', context)
示例#12
0
def listar(request, hash):
    for_print = 0
    db_slug = 'default'
    try:
        usuario_id = request.user.id
        dict_hash = get_hash_url(hash)
        #retorno_pagina = dict_hash['retorno_pagina']
        #retorno_hash = dict_hash['retorno_hash']
        #retornos_eventos_id = int(dict_hash['id'])
        for_print = int(dict_hash['print'])
    except:
        usuario_id = False
        return redirect('login')
    usuario = get_object_or_404(Usuarios.objects.using(db_slug),
                                excluido=False,
                                id=usuario_id)
    pagina = ConfigPaginas.objects.using(db_slug).get(
        excluido=False, endereco='retornos_eventos')
    permissao = ConfigPermissoes.objects.using(db_slug).get(
        excluido=False,
        config_paginas=pagina,
        config_perfis=usuario.config_perfis)
    dict_permissoes = json_to_dict(usuario.config_perfis.permissoes)
    paginas_permitidas_lista = usuario.config_perfis.paginas_permitidas
    modulos_permitidos_lista = usuario.config_perfis.modulos_permitidos

    if permissao.permite_listar:
        filtrar = False
        dict_fields = {}
        show_fields = {
            'show_cargo': 0,
            'show_categoria': 0,
            'show_celetista': 0,
            'show_clauasseg': 0,
            'show_cnpjsindcategprof': 0,
            'show_codcargo': 0,
            'show_codcateg': 0,
            'show_codcbocargo': 0,
            'show_codcbofuncao': 0,
            'show_codfuncao': 0,
            'show_cpftrab': 1,
            'show_deficiencia': 0,
            'show_dscfuncao': 0,
            'show_dscsalvar': 0,
            'show_dsctpjorn': 0,
            'show_dtadm': 0,
            'show_dtbase': 0,
            'show_dtexercicio': 0,
            'show_dtposse': 0,
            'show_dtterm': 0,
            'show_duracao': 0,
            'show_empregador': 0,
            'show_empregador_nrinsc': 1,
            'show_empregador_tpinsc': 1,
            'show_estatutario': 0,
            'show_funcao': 0,
            'show_horarios_contratuais': 0,
            'show_identidade': 1,
            'show_infocota': 0,
            'show_local_cnae': 0,
            'show_local_nrinsc': 0,
            'show_local_tpinsc': 0,
            'show_local_trab': 0,
            'show_matricula': 0,
            'show_nistrab': 0,
            'show_nmcargo': 0,
            'show_nmtrab': 1,
            'show_nrinsc': 1,
            'show_processamento': 0,
            'show_processamento': 0,
            'show_processamento_codigo_resposta': 1,
            'show_processamento_data_hora': 0,
            'show_processamento_descricao_resposta': 0,
            'show_processamento_versao_app_processamento': 0,
            'show_qtdhrssem': 0,
            'show_recepcao_data_hora': 0,
            'show_recepcao_protocolo_envio_lote': 0,
            'show_recepcao_tp_amb': 0,
            'show_recepcao_versao_app': 0,
            'show_recibo': 0,
            'show_recibo_hash': 0,
            'show_recibo_numero': 0,
            'show_remuneracao': 0,
            'show_tmpparc': 0,
            'show_tpcontr': 0,
            'show_tpinsc': 1,
            'show_tpjornada': 0,
            'show_tpregjor': 0,
            'show_trabalhador': 0,
            'show_transmissor_lote_esocial': 1,
            'show_undsalfixo': 0,
            'show_vinculo': 0,
            'show_vrsalfx': 0,
        }
        post = False
        #ANTES-POST-LISTAGEM
        if request.method == 'POST':
            post = True
            dict_fields = {
                'cargo': 'cargo',
                'categoria': 'categoria',
                'celetista': 'celetista',
                'clauasseg__icontains': 'clauasseg__icontains',
                'cnpjsindcategprof__icontains': 'cnpjsindcategprof__icontains',
                'codcargo__icontains': 'codcargo__icontains',
                'codcateg': 'codcateg',
                'codcbocargo__icontains': 'codcbocargo__icontains',
                'codcbofuncao__icontains': 'codcbofuncao__icontains',
                'codfuncao__icontains': 'codfuncao__icontains',
                'cpftrab__icontains': 'cpftrab__icontains',
                'deficiencia': 'deficiencia',
                'dscfuncao__icontains': 'dscfuncao__icontains',
                'dscsalvar__icontains': 'dscsalvar__icontains',
                'dsctpjorn__icontains': 'dsctpjorn__icontains',
                'dtadm__range': 'dtadm__range',
                'dtbase': 'dtbase',
                'dtexercicio__range': 'dtexercicio__range',
                'dtposse__range': 'dtposse__range',
                'dtterm__range': 'dtterm__range',
                'duracao': 'duracao',
                'empregador': 'empregador',
                'empregador_nrinsc__icontains': 'empregador_nrinsc__icontains',
                'empregador_tpinsc': 'empregador_tpinsc',
                'estatutario': 'estatutario',
                'funcao': 'funcao',
                'horarios_contratuais': 'horarios_contratuais',
                'identidade__icontains': 'identidade__icontains',
                'infocota__icontains': 'infocota__icontains',
                'local_cnae': 'local_cnae',
                'local_nrinsc__icontains': 'local_nrinsc__icontains',
                'local_tpinsc': 'local_tpinsc',
                'local_trab': 'local_trab',
                'matricula__icontains': 'matricula__icontains',
                'nistrab__icontains': 'nistrab__icontains',
                'nmcargo__icontains': 'nmcargo__icontains',
                'nmtrab__icontains': 'nmtrab__icontains',
                'nrinsc__icontains': 'nrinsc__icontains',
                'processamento': 'processamento',
                'processamento': 'processamento',
                'processamento_codigo_resposta__icontains':
                'processamento_codigo_resposta__icontains',
                'processamento_data_hora__range':
                'processamento_data_hora__range',
                'processamento_descricao_resposta__icontains':
                'processamento_descricao_resposta__icontains',
                'processamento_versao_app_processamento__icontains':
                'processamento_versao_app_processamento__icontains',
                'qtdhrssem': 'qtdhrssem',
                'recepcao_data_hora__range': 'recepcao_data_hora__range',
                'recepcao_protocolo_envio_lote__icontains':
                'recepcao_protocolo_envio_lote__icontains',
                'recepcao_tp_amb': 'recepcao_tp_amb',
                'recepcao_versao_app__icontains':
                'recepcao_versao_app__icontains',
                'recibo': 'recibo',
                'recibo_hash__icontains': 'recibo_hash__icontains',
                'recibo_numero__icontains': 'recibo_numero__icontains',
                'remuneracao': 'remuneracao',
                'tmpparc': 'tmpparc',
                'tpcontr': 'tpcontr',
                'tpinsc': 'tpinsc',
                'tpjornada': 'tpjornada',
                'tpregjor': 'tpregjor',
                'trabalhador': 'trabalhador',
                'transmissor_lote_esocial': 'transmissor_lote_esocial',
                'undsalfixo': 'undsalfixo',
                'vinculo': 'vinculo',
                'vrsalfx': 'vrsalfx',
            }
            for a in dict_fields:
                dict_fields[a] = request.POST.get(a or None)
            for a in show_fields:
                show_fields[a] = request.POST.get(a or None)
            if request.method == 'POST':
                dict_fields = {
                    'cargo': 'cargo',
                    'categoria': 'categoria',
                    'celetista': 'celetista',
                    'clauasseg__icontains': 'clauasseg__icontains',
                    'cnpjsindcategprof__icontains':
                    'cnpjsindcategprof__icontains',
                    'codcargo__icontains': 'codcargo__icontains',
                    'codcateg': 'codcateg',
                    'codcbocargo__icontains': 'codcbocargo__icontains',
                    'codcbofuncao__icontains': 'codcbofuncao__icontains',
                    'codfuncao__icontains': 'codfuncao__icontains',
                    'cpftrab__icontains': 'cpftrab__icontains',
                    'deficiencia': 'deficiencia',
                    'dscfuncao__icontains': 'dscfuncao__icontains',
                    'dscsalvar__icontains': 'dscsalvar__icontains',
                    'dsctpjorn__icontains': 'dsctpjorn__icontains',
                    'dtadm__range': 'dtadm__range',
                    'dtbase': 'dtbase',
                    'dtexercicio__range': 'dtexercicio__range',
                    'dtposse__range': 'dtposse__range',
                    'dtterm__range': 'dtterm__range',
                    'duracao': 'duracao',
                    'empregador': 'empregador',
                    'empregador_nrinsc__icontains':
                    'empregador_nrinsc__icontains',
                    'empregador_tpinsc': 'empregador_tpinsc',
                    'estatutario': 'estatutario',
                    'funcao': 'funcao',
                    'horarios_contratuais': 'horarios_contratuais',
                    'identidade__icontains': 'identidade__icontains',
                    'infocota__icontains': 'infocota__icontains',
                    'local_cnae': 'local_cnae',
                    'local_nrinsc__icontains': 'local_nrinsc__icontains',
                    'local_tpinsc': 'local_tpinsc',
                    'local_trab': 'local_trab',
                    'matricula__icontains': 'matricula__icontains',
                    'nistrab__icontains': 'nistrab__icontains',
                    'nmcargo__icontains': 'nmcargo__icontains',
                    'nmtrab__icontains': 'nmtrab__icontains',
                    'nrinsc__icontains': 'nrinsc__icontains',
                    'processamento': 'processamento',
                    'processamento': 'processamento',
                    'processamento_codigo_resposta__icontains':
                    'processamento_codigo_resposta__icontains',
                    'processamento_data_hora__range':
                    'processamento_data_hora__range',
                    'processamento_descricao_resposta__icontains':
                    'processamento_descricao_resposta__icontains',
                    'processamento_versao_app_processamento__icontains':
                    'processamento_versao_app_processamento__icontains',
                    'qtdhrssem': 'qtdhrssem',
                    'recepcao_data_hora__range': 'recepcao_data_hora__range',
                    'recepcao_protocolo_envio_lote__icontains':
                    'recepcao_protocolo_envio_lote__icontains',
                    'recepcao_tp_amb': 'recepcao_tp_amb',
                    'recepcao_versao_app__icontains':
                    'recepcao_versao_app__icontains',
                    'recibo': 'recibo',
                    'recibo_hash__icontains': 'recibo_hash__icontains',
                    'recibo_numero__icontains': 'recibo_numero__icontains',
                    'remuneracao': 'remuneracao',
                    'tmpparc': 'tmpparc',
                    'tpcontr': 'tpcontr',
                    'tpinsc': 'tpinsc',
                    'tpjornada': 'tpjornada',
                    'tpregjor': 'tpregjor',
                    'trabalhador': 'trabalhador',
                    'transmissor_lote_esocial': 'transmissor_lote_esocial',
                    'undsalfixo': 'undsalfixo',
                    'vinculo': 'vinculo',
                    'vrsalfx': 'vrsalfx',
                }
                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)
        dict_qs = clear_dict_fields(dict_fields)
        retornos_eventos_lista = RetornosEventos.objects.using(db_slug).filter(
            **dict_qs).filter(excluido=False).exclude(id=0).all()
        if not post and len(retornos_eventos_lista) > 100:
            filtrar = True
            retornos_eventos_lista = None
            messages.warning(
                request,
                'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!'
            )

        transmissor_lote_esocial_lista = TransmissorLoteEsocial.objects.using(
            db_slug).filter(excluido=False).all()
        #retornos_eventos_listar_custom
        request.session["retorno_hash"] = hash
        request.session["retorno_pagina"] = 'retornos_eventos'
        context = {
            'retornos_eventos_lista': retornos_eventos_lista,
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            'permissao': permissao,
            'dict_fields': dict_fields,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
            'show_fields': show_fields,
            'for_print': for_print,
            'hash': hash,
            'filtrar': filtrar,
            'transmissor_lote_esocial_lista': transmissor_lote_esocial_lista,
        }
        if for_print in (0, 1):
            return render(request, 'retornos_eventos_listar.html', context)
        elif for_print == 2:
            #return render_to_pdf('tables/s1000_evtinfoempregador_pdf_xls.html', context)
            from wkhtmltopdf.views import PDFTemplateResponse
            response = PDFTemplateResponse(
                request=request,
                template='retornos_eventos_listar.html',
                filename="retornos_eventos.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 10,
                    'zoom': 1,
                    'dpi': 72,
                    'orientation': 'Landscape',
                    "viewport-size": "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )
            return response
        elif for_print == 3:
            from django.shortcuts import render_to_response
            response = render_to_response('retornos_eventos_listar.html',
                                          context)
            filename = "retornos_eventos.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response
        elif for_print == 4:
            from django.shortcuts import render_to_response
            response = render_to_response('tables/retornos_eventos_csv.html',
                                          context)
            filename = "retornos_eventos.csv"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response
    else:
        context = {
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
        }
        return render(request, 'permissao_negada.html', context)
示例#13
0
def verificar(request, pk, output=None):

    if request.user.has_perm('esocial.can_see_s1200evtRemun'):

        s1200_evtremun = get_object_or_404(s1200evtRemun, id=pk)
        s1200_evtremun_lista = s1200evtRemun.objects.filter(id=pk).all()


        s1200_infomv_lista = s1200infoMV.objects.filter(s1200_evtremun_id__in = listar_ids(s1200_evtremun_lista) ).all()
        s1200_remunoutrempr_lista = s1200remunOutrEmpr.objects.filter(s1200_infomv_id__in = listar_ids(s1200_infomv_lista) ).all()
        s1200_infocomplem_lista = s1200infoComplem.objects.filter(s1200_evtremun_id__in = listar_ids(s1200_evtremun_lista) ).all()
        s1200_sucessaovinc_lista = s1200sucessaoVinc.objects.filter(s1200_infocomplem_id__in = listar_ids(s1200_infocomplem_lista) ).all()
        s1200_procjudtrab_lista = s1200procJudTrab.objects.filter(s1200_evtremun_id__in = listar_ids(s1200_evtremun_lista) ).all()
        s1200_infointerm_lista = s1200infoInterm.objects.filter(s1200_evtremun_id__in = listar_ids(s1200_evtremun_lista) ).all()
        s1200_dmdev_lista = s1200dmDev.objects.filter(s1200_evtremun_id__in = listar_ids(s1200_evtremun_lista) ).all()
        s1200_infoperapur_lista = s1200infoPerApur.objects.filter(s1200_dmdev_id__in = listar_ids(s1200_dmdev_lista) ).all()
        s1200_infoperapur_ideestablot_lista = s1200infoPerApurideEstabLot.objects.filter(s1200_infoperapur_id__in = listar_ids(s1200_infoperapur_lista) ).all()
        s1200_infoperapur_remunperapur_lista = s1200infoPerApurremunPerApur.objects.filter(s1200_infoperapur_ideestablot_id__in = listar_ids(s1200_infoperapur_ideestablot_lista) ).all()
        s1200_infoperapur_itensremun_lista = s1200infoPerApuritensRemun.objects.filter(s1200_infoperapur_remunperapur_id__in = listar_ids(s1200_infoperapur_remunperapur_lista) ).all()
        s1200_infoperapur_infosaudecolet_lista = s1200infoPerApurinfoSaudeColet.objects.filter(s1200_infoperapur_remunperapur_id__in = listar_ids(s1200_infoperapur_remunperapur_lista) ).all()
        s1200_infoperapur_detoper_lista = s1200infoPerApurdetOper.objects.filter(s1200_infoperapur_infosaudecolet_id__in = listar_ids(s1200_infoperapur_infosaudecolet_lista) ).all()
        s1200_infoperapur_detplano_lista = s1200infoPerApurdetPlano.objects.filter(s1200_infoperapur_detoper_id__in = listar_ids(s1200_infoperapur_detoper_lista) ).all()
        s1200_infoperapur_infoagnocivo_lista = s1200infoPerApurinfoAgNocivo.objects.filter(s1200_infoperapur_remunperapur_id__in = listar_ids(s1200_infoperapur_remunperapur_lista) ).all()
        s1200_infoperapur_infotrabinterm_lista = s1200infoPerApurinfoTrabInterm.objects.filter(s1200_infoperapur_remunperapur_id__in = listar_ids(s1200_infoperapur_remunperapur_lista) ).all()
        s1200_infoperant_lista = s1200infoPerAnt.objects.filter(s1200_dmdev_id__in = listar_ids(s1200_dmdev_lista) ).all()
        s1200_infoperant_ideadc_lista = s1200infoPerAntideADC.objects.filter(s1200_infoperant_id__in = listar_ids(s1200_infoperant_lista) ).all()
        s1200_infoperant_ideperiodo_lista = s1200infoPerAntidePeriodo.objects.filter(s1200_infoperant_ideadc_id__in = listar_ids(s1200_infoperant_ideadc_lista) ).all()
        s1200_infoperant_ideestablot_lista = s1200infoPerAntideEstabLot.objects.filter(s1200_infoperant_ideperiodo_id__in = listar_ids(s1200_infoperant_ideperiodo_lista) ).all()
        s1200_infoperant_remunperant_lista = s1200infoPerAntremunPerAnt.objects.filter(s1200_infoperant_ideestablot_id__in = listar_ids(s1200_infoperant_ideestablot_lista) ).all()
        s1200_infoperant_itensremun_lista = s1200infoPerAntitensRemun.objects.filter(s1200_infoperant_remunperant_id__in = listar_ids(s1200_infoperant_remunperant_lista) ).all()
        s1200_infoperant_infoagnocivo_lista = s1200infoPerAntinfoAgNocivo.objects.filter(s1200_infoperant_remunperant_id__in = listar_ids(s1200_infoperant_remunperant_lista) ).all()
        s1200_infoperant_infotrabinterm_lista = s1200infoPerAntinfoTrabInterm.objects.filter(s1200_infoperant_remunperant_id__in = listar_ids(s1200_infoperant_remunperant_lista) ).all()
        s1200_infoperant_infocomplcont_lista = s1200infoPerAntinfoComplCont.objects.filter(s1200_dmdev_id__in = listar_ids(s1200_dmdev_lista) ).all()

        request.session['return_pk'] = pk
        request.session['return_page'] = request.META.get('HTTP_REFERER')

        context = {
            's1200_evtremun_lista': s1200_evtremun_lista,
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            's1200_evtremun': s1200_evtremun,
            's1200_infomv_lista': s1200_infomv_lista,
            's1200_remunoutrempr_lista': s1200_remunoutrempr_lista,
            's1200_infocomplem_lista': s1200_infocomplem_lista,
            's1200_sucessaovinc_lista': s1200_sucessaovinc_lista,
            's1200_procjudtrab_lista': s1200_procjudtrab_lista,
            's1200_infointerm_lista': s1200_infointerm_lista,
            's1200_dmdev_lista': s1200_dmdev_lista,
            's1200_infoperapur_lista': s1200_infoperapur_lista,
            's1200_infoperapur_ideestablot_lista': s1200_infoperapur_ideestablot_lista,
            's1200_infoperapur_remunperapur_lista': s1200_infoperapur_remunperapur_lista,
            's1200_infoperapur_itensremun_lista': s1200_infoperapur_itensremun_lista,
            's1200_infoperapur_infosaudecolet_lista': s1200_infoperapur_infosaudecolet_lista,
            's1200_infoperapur_detoper_lista': s1200_infoperapur_detoper_lista,
            's1200_infoperapur_detplano_lista': s1200_infoperapur_detplano_lista,
            's1200_infoperapur_infoagnocivo_lista': s1200_infoperapur_infoagnocivo_lista,
            's1200_infoperapur_infotrabinterm_lista': s1200_infoperapur_infotrabinterm_lista,
            's1200_infoperant_lista': s1200_infoperant_lista,
            's1200_infoperant_ideadc_lista': s1200_infoperant_ideadc_lista,
            's1200_infoperant_ideperiodo_lista': s1200_infoperant_ideperiodo_lista,
            's1200_infoperant_ideestablot_lista': s1200_infoperant_ideestablot_lista,
            's1200_infoperant_remunperant_lista': s1200_infoperant_remunperant_lista,
            's1200_infoperant_itensremun_lista': s1200_infoperant_itensremun_lista,
            's1200_infoperant_infoagnocivo_lista': s1200_infoperant_infoagnocivo_lista,
            's1200_infoperant_infotrabinterm_lista': s1200_infoperant_infotrabinterm_lista,
            's1200_infoperant_infocomplcont_lista': s1200_infoperant_infocomplcont_lista,
            'modulos': ['esocial', ],
            'paginas': ['s1200_evtremun', ],
            'data': datetime.now(),
            'output': output,
        }

        if output == 'pdf':

            response = PDFTemplateResponse(
                request=request,
                template='s1200_evtremun_verificar.html',
                filename="s1200_evtremun.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={'margin-top': 10,
                             'margin-bottom': 10,
                             'margin-right': 10,
                             'margin-left': 20,
                             'zoom': 1,
                             'viewport-size': '1366 x 513',
                             'javascript-delay': 1000,
                             'footer-center': u'Página [page]/[topage]',
                             'footer-font-size': 10,
                             'no-stop-slow-scripts': True})
        
            return response

        elif output == 'xls':

            response = render_to_response('s1200_evtremun_verificar.html', context)
            filename = "%s.xls" % s1200_evtremun.identidade
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            response = render_to_response('s1200_evtremun_verificar.html', context)
            filename = "%s.csv" % s1200_evtremun.identidade
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response

        else:

            return render(request, 's1200_evtremun_verificar.html', context)

    else:

        context = {
            'modulos': ['esocial', ],
            'paginas': ['s1200_evtremun', ],
            'data': datetime.now(),
        }

        return render(request, 'permissao_negada.html', context)
示例#14
0
def listar(request, output=None):

    if request.user.has_perm('mensageiro.can_see_ImportacaoArquivosEventos'):

        filtrar = False

        dict_fields = {}
        show_fields = {
            'show_importacao_arquivos': 0,
            'show_arquivo': 1,
            'show_evento': 1,
            'show_versao': 0,
            'show_identidade_evento': 1,
            'show_identidade': 1,
            'show_status': 1,
            'show_data_hora': 1,
            'show_validacoes': 0,
        }

        post = False
        #ANTES-POST-LISTAGEM

        if request.method == 'POST':

            post = True

            dict_fields = {
                'arquivo__icontains': 'arquivo__icontains',
                'evento__icontains': 'evento__icontains',
                'versao__icontains': 'versao__icontains',
                'identidade_evento__icontains': 'identidade_evento__icontains',
                'status__icontains': 'status__icontains',
            }

            for a in dict_fields:
                dict_fields[a] = request.POST.get(a or None)

            for a in show_fields:
                show_fields[a] = request.POST.get(a or None)

            if request.method == 'POST':

                dict_fields = {
                    'arquivo__icontains': 'arquivo__icontains',
                    'evento__icontains': 'evento__icontains',
                    'versao__icontains': 'versao__icontains',
                    'identidade_evento__icontains':
                    'identidade_evento__icontains',
                    'status__icontains': 'status__icontains',
                }

                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)

        dict_qs = clear_dict_fields(dict_fields)

        importacao_arquivos_eventos_lista = ImportacaoArquivosEventos.objects.filter(
            **dict_qs).exclude(id=0).all()

        if not post and len(importacao_arquivos_eventos_lista) > 100:

            filtrar = True
            importacao_arquivos_eventos_lista = None
            messages.warning(
                request,
                u'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!'
            )

        importacao_arquivos_lista = ImportacaoArquivos.objects.all()
        #importacao_arquivos_eventos_listar_custom

        request.session['return'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            'importacao_arquivos_eventos_lista':
            importacao_arquivos_eventos_lista,
            'modulos': [
                'mensageiro',
            ],
            'paginas': [
                'importacao_arquivos_eventos',
            ],
            'dict_fields': dict_fields,
            'data': datetime.datetime.now(),
            'show_fields': show_fields,
            'filtrar': filtrar,
            'importacao_arquivos_lista': importacao_arquivos_lista,
        }

        if output == 'pdf':

            from wkhtmltopdf.views import PDFTemplateResponse

            response = PDFTemplateResponse(
                request=request,
                template='importacao_arquivos_eventos_listar.html',
                filename="importacao_arquivos_eventos.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 10,
                    'zoom': 1,
                    'dpi': 72,
                    'orientation': 'Landscape',
                    "viewport-size": "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )

            return response

        elif output == 'xls':

            from django.shortcuts import render_to_response

            response = render_to_response(
                'importacao_arquivos_eventos_listar.html', context)
            filename = "importacao_arquivos_eventos.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            from django.shortcuts import render_to_response

            response = render_to_response(
                'csv/importacao_arquivos_eventos.csv', context)
            filename = "importacao_arquivos_eventos.csv"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'

            return response

        else:

            return render(request, 'importacao_arquivos_eventos_listar.html',
                          context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            'data': datetime.datetime.now(),
            'modulos': [
                'mensageiro',
            ],
            'paginas': [
                'importacao_arquivos_eventos',
            ],
        }

        return render(request, 'permissao_negada.html', context)
示例#15
0
    def test_pdf_template_response(self, show_content=False):
        """Test PDFTemplateResponse."""

        context = {'title': 'Heading'}
        request = RequestFactory().get('/')
        response = PDFTemplateResponse(request=request,
                                       template=self.template,
                                       context=context,
                                       show_content_in_browser=show_content)
        self.assertEqual(response._request, request)
        self.assertEqual(response.template_name, self.template)
        self.assertEqual(response.context_data, context)
        self.assertEqual(response.filename, None)
        self.assertEqual(response.header_template, None)
        self.assertEqual(response.footer_template, None)
        self.assertEqual(response.cmd_options, {})
        self.assertFalse(response.has_header('Content-Disposition'))

        # Render to temporary file
        template = loader.get_template(self.template)
        tempfile = render_to_temporary_file(template, context=context)
        tempfile.seek(0)
        html_content = smart_str(tempfile.read())
        self.assertTrue(html_content.startswith('<html>'))
        self.assertTrue('<h1>{title}</h1>'.format(**context) in html_content)

        pdf_content = response.rendered_content
        self.assertTrue(pdf_content.startswith(b'%PDF-'))
        self.assertTrue(pdf_content.endswith(b'%%EOF\n'))

        # Footer
        cmd_options = {'title': 'Test PDF'}
        response = PDFTemplateResponse(request=request,
                                       template=self.template,
                                       context=context,
                                       filename=self.pdf_filename,
                                       show_content_in_browser=show_content,
                                       footer_template=self.footer_template,
                                       cmd_options=cmd_options)
        self.assertEqual(response.filename, self.pdf_filename)
        self.assertEqual(response.header_template, None)
        self.assertEqual(response.footer_template, self.footer_template)
        self.assertEqual(response.cmd_options, cmd_options)
        self.assertTrue(response.has_header('Content-Disposition'))

        footer_template = loader.get_template(self.footer_template)
        tempfile = render_to_temporary_file(footer_template,
                                            context=context,
                                            request=request)
        tempfile.seek(0)
        footer_content = smart_str(tempfile.read())
        footer_content = make_absolute_paths(footer_content)

        media_url = 'file://{0}/'.format(settings.MEDIA_ROOT)
        self.assertTrue(media_url in footer_content, True)

        static_url = 'file://{0}/'.format(settings.STATIC_ROOT)
        self.assertTrue(static_url in footer_content, True)

        pdf_content = response.rendered_content
        title = '\0'.join(cmd_options['title'])
        self.assertIn(six.b(title), pdf_content)
示例#16
0
def listar(request, output=None):

    if request.user.has_perm('efdreinf.can_see_r2099evtFechaEvPer'):

        filtrar = False
        dict_fields = {}
        show_fields = {
            'show_reinf': 0,
            'show_evtfechaevper': 0,
            'show_identidade': 1,
            'show_ideevento': 0,
            'show_perapur': 1,
            'show_tpamb': 0,
            'show_procemi': 0,
            'show_verproc': 0,
            'show_idecontri': 0,
            'show_tpinsc': 1,
            'show_nrinsc': 0,
            'show_infofech': 0,
            'show_evtservtm': 0,
            'show_evtservpr': 0,
            'show_evtassdesprec': 0,
            'show_evtassdesprep': 0,
            'show_evtcomprod': 0,
            'show_evtcprb': 0,
            'show_evtpgtos': 0,
            'show_compsemmovto': 0,
            'show_versao': 0,
            'show_transmissor_lote_efdreinf': 0,
            'show_retornos_r5001': 0,
            'show_retornos_r5011': 0,
            'show_retornos_r9001': 0,
            'show_retornos_r9002': 0,
            'show_retornos_r9011': 0,
            'show_retornos_r9012': 0,
            'show_ocorrencias': 0,
            'show_validacao_precedencia': 0,
            'show_validacoes': 0,
            'show_arquivo_original': 0,
            'show_arquivo': 0,
            'show_status': 1,
            'show_cdretorno': 1,
            'show_descretorno': 0,
            'show_dhprocess': 0,
            'show_transmissor_lote_efdreinf_error': 0,
        }

        post = False

        if request.method == 'POST':

            post = True
            dict_fields = {
                'reinf': 'reinf',
                'evtfechaevper': 'evtfechaevper',
                'identidade__icontains': 'identidade__icontains',
                'ideevento': 'ideevento',
                'perapur__icontains': 'perapur__icontains',
                'tpamb__icontains': 'tpamb__icontains',
                'procemi__icontains': 'procemi__icontains',
                'verproc__icontains': 'verproc__icontains',
                'idecontri': 'idecontri',
                'tpinsc__icontains': 'tpinsc__icontains',
                'nrinsc__icontains': 'nrinsc__icontains',
                'infofech': 'infofech',
                'evtservtm__icontains': 'evtservtm__icontains',
                'evtservpr__icontains': 'evtservpr__icontains',
                'evtassdesprec__icontains': 'evtassdesprec__icontains',
                'evtassdesprep__icontains': 'evtassdesprep__icontains',
                'evtcomprod__icontains': 'evtcomprod__icontains',
                'evtcprb__icontains': 'evtcprb__icontains',
                'evtpgtos__icontains': 'evtpgtos__icontains',
                'compsemmovto__icontains': 'compsemmovto__icontains',
                'versao__icontains': 'versao__icontains',
                'transmissor_lote_efdreinf__icontains':
                'transmissor_lote_efdreinf__icontains',
                'status__icontains': 'status__icontains',
                'cdretorno__icontains': 'cdretorno__icontains',
            }

            for a in dict_fields:
                dict_fields[a] = request.POST.get(a or None)

            for a in show_fields:
                show_fields[a] = request.POST.get(a or None)

            if request.method == 'POST':
                dict_fields = {
                    'reinf': 'reinf',
                    'evtfechaevper': 'evtfechaevper',
                    'identidade__icontains': 'identidade__icontains',
                    'ideevento': 'ideevento',
                    'perapur__icontains': 'perapur__icontains',
                    'tpamb__icontains': 'tpamb__icontains',
                    'procemi__icontains': 'procemi__icontains',
                    'verproc__icontains': 'verproc__icontains',
                    'idecontri': 'idecontri',
                    'tpinsc__icontains': 'tpinsc__icontains',
                    'nrinsc__icontains': 'nrinsc__icontains',
                    'infofech': 'infofech',
                    'evtservtm__icontains': 'evtservtm__icontains',
                    'evtservpr__icontains': 'evtservpr__icontains',
                    'evtassdesprec__icontains': 'evtassdesprec__icontains',
                    'evtassdesprep__icontains': 'evtassdesprep__icontains',
                    'evtcomprod__icontains': 'evtcomprod__icontains',
                    'evtcprb__icontains': 'evtcprb__icontains',
                    'evtpgtos__icontains': 'evtpgtos__icontains',
                    'compsemmovto__icontains': 'compsemmovto__icontains',
                    'versao__icontains': 'versao__icontains',
                    'transmissor_lote_efdreinf__icontains':
                    'transmissor_lote_efdreinf__icontains',
                    'status__icontains': 'status__icontains',
                    'cdretorno__icontains': 'cdretorno__icontains',
                }
                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)

        dict_qs = clear_dict_fields(dict_fields)
        r2099_evtfechaevper_lista = r2099evtFechaEvPer.objects.filter(
            **dict_qs).filter().exclude(id=0).all()

        if not post and len(r2099_evtfechaevper_lista) > 100:
            filtrar = True
            r2099_evtfechaevper_lista = None
            messages.warning(
                request,
                u'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!'
            )

        transmissor_lote_efdreinf_lista = TransmissorLoteEfdreinf.objects.all()
        retornos_r5001_lista = r5001evtTotal.objects.all()
        retornos_r5011_lista = r5011evtTotalContrib.objects.all()
        retornos_r9001_lista = r9001evtTotal.objects.all()
        retornos_r9002_lista = r9002evtRet.objects.all()
        retornos_r9011_lista = r9011evtTotalContrib.objects.all()
        retornos_r9012_lista = r9012evtRetCons.objects.all()
        transmissor_lote_efdreinf_error_lista = TransmissorLoteEfdreinf.objects.all(
        )
        #r2099_evtfechaevper_listar_custom

        request.session['return'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario':
            Usuarios.objects.get(user_id=request.user.id),
            'output':
            output,
            'r2099_evtfechaevper_lista':
            r2099_evtfechaevper_lista,
            'dict_fields':
            dict_fields,
            'data':
            datetime.datetime.now(),
            'modulos': [
                'efdreinf',
            ],
            'paginas': [
                'r2099_evtfechaevper',
            ],
            'show_fields':
            show_fields,
            'filtrar':
            filtrar,
            'transmissor_lote_efdreinf_lista':
            transmissor_lote_efdreinf_lista,
            'retornos_r5001_lista':
            retornos_r5001_lista,
            'retornos_r5011_lista':
            retornos_r5011_lista,
            'retornos_r9001_lista':
            retornos_r9001_lista,
            'retornos_r9002_lista':
            retornos_r9002_lista,
            'retornos_r9011_lista':
            retornos_r9011_lista,
            'retornos_r9012_lista':
            retornos_r9012_lista,
            'transmissor_lote_efdreinf_error_lista':
            transmissor_lote_efdreinf_error_lista,
        }

        if output == 'pdf':

            from emensageriapro.functions import render_to_pdf
            from wkhtmltopdf.views import PDFTemplateResponse

            response = PDFTemplateResponse(
                request=request,
                template='r2099_evtfechaevper_listar.html',
                filename="r2099_evtfechaevper.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 10,
                    'zoom': 1,
                    'dpi': 72,
                    'orientation': 'Landscape',
                    'viewport-size': "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )
            return response

        elif output == 'xls':

            response = render_to_response('r2099_evtfechaevper_listar.html',
                                          context)
            filename = "r2099_evtfechaevper.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            response = render_to_response('csv/r2099_evtfechaevper.csv',
                                          context)
            filename = "r2099_evtfechaevper.csv"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'

            return response

        else:

            return render(request, 'r2099_evtfechaevper_listar.html', context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'data': datetime.datetime.now(),
            'modulos': [
                'efdreinf',
            ],
            'paginas': [
                'r2099_evtfechaevper',
            ],
        }
        return render(request, 'permissao_negada.html', context)
示例#17
0
def verificar(request, pk, output=None):

    if request.user.has_perm('esocial.can_see_s1020evtTabLotacao'):

        s1020_evttablotacao = get_object_or_404(s1020evtTabLotacao, id=pk)
        s1020_evttablotacao_lista = s1020evtTabLotacao.objects.filter(
            id=pk).all()

        s1020_inclusao_lista = s1020inclusao.objects.filter(
            s1020_evttablotacao_id__in=listar_ids(
                s1020_evttablotacao_lista)).all()
        s1020_inclusao_infoprocjudterceiros_lista = s1020inclusaoinfoProcJudTerceiros.objects.filter(
            s1020_inclusao_id__in=listar_ids(s1020_inclusao_lista)).all()
        s1020_inclusao_procjudterceiro_lista = s1020inclusaoprocJudTerceiro.objects.filter(
            s1020_inclusao_infoprocjudterceiros_id__in=listar_ids(
                s1020_inclusao_infoprocjudterceiros_lista)).all()
        s1020_inclusao_infoemprparcial_lista = s1020inclusaoinfoEmprParcial.objects.filter(
            s1020_inclusao_id__in=listar_ids(s1020_inclusao_lista)).all()
        s1020_alteracao_lista = s1020alteracao.objects.filter(
            s1020_evttablotacao_id__in=listar_ids(
                s1020_evttablotacao_lista)).all()
        s1020_alteracao_infoprocjudterceiros_lista = s1020alteracaoinfoProcJudTerceiros.objects.filter(
            s1020_alteracao_id__in=listar_ids(s1020_alteracao_lista)).all()
        s1020_alteracao_procjudterceiro_lista = s1020alteracaoprocJudTerceiro.objects.filter(
            s1020_alteracao_infoprocjudterceiros_id__in=listar_ids(
                s1020_alteracao_infoprocjudterceiros_lista)).all()
        s1020_alteracao_infoemprparcial_lista = s1020alteracaoinfoEmprParcial.objects.filter(
            s1020_alteracao_id__in=listar_ids(s1020_alteracao_lista)).all()
        s1020_alteracao_novavalidade_lista = s1020alteracaonovaValidade.objects.filter(
            s1020_alteracao_id__in=listar_ids(s1020_alteracao_lista)).all()
        s1020_exclusao_lista = s1020exclusao.objects.filter(
            s1020_evttablotacao_id__in=listar_ids(
                s1020_evttablotacao_lista)).all()

        request.session['return_pk'] = pk
        request.session['return_page'] = request.META.get('HTTP_REFERER')

        context = {
            's1020_evttablotacao_lista': s1020_evttablotacao_lista,
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            's1020_evttablotacao': s1020_evttablotacao,
            's1020_inclusao_lista': s1020_inclusao_lista,
            's1020_inclusao_infoprocjudterceiros_lista':
            s1020_inclusao_infoprocjudterceiros_lista,
            's1020_inclusao_procjudterceiro_lista':
            s1020_inclusao_procjudterceiro_lista,
            's1020_inclusao_infoemprparcial_lista':
            s1020_inclusao_infoemprparcial_lista,
            's1020_alteracao_lista': s1020_alteracao_lista,
            's1020_alteracao_infoprocjudterceiros_lista':
            s1020_alteracao_infoprocjudterceiros_lista,
            's1020_alteracao_procjudterceiro_lista':
            s1020_alteracao_procjudterceiro_lista,
            's1020_alteracao_infoemprparcial_lista':
            s1020_alteracao_infoemprparcial_lista,
            's1020_alteracao_novavalidade_lista':
            s1020_alteracao_novavalidade_lista,
            's1020_exclusao_lista': s1020_exclusao_lista,
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1020_evttablotacao',
            ],
            'data': datetime.now(),
            'output': output,
        }

        if output == 'pdf':

            response = PDFTemplateResponse(
                request=request,
                template='s1020_evttablotacao_verificar.html',
                filename="s1020_evttablotacao.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 20,
                    'zoom': 1,
                    'viewport-size': '1366 x 513',
                    'javascript-delay': 1000,
                    'footer-center': u'Página [page]/[topage]',
                    'footer-font-size': 10,
                    'no-stop-slow-scripts': True
                })

            return response

        elif output == 'xls':

            response = render_to_response('s1020_evttablotacao_verificar.html',
                                          context)
            filename = "%s.xls" % s1020_evttablotacao.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            response = render_to_response('s1020_evttablotacao_verificar.html',
                                          context)
            filename = "%s.csv" % s1020_evttablotacao.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response

        else:

            return render(request, 's1020_evttablotacao_verificar.html',
                          context)

    else:

        context = {
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1020_evttablotacao',
            ],
            'data': datetime.now(),
        }

        return render(request, 'permissao_negada.html', context)
示例#18
0
def listar(request, output=None):

    if request.user.has_perm('controle_de_acesso.can_see_Usuarios'):

        filtrar = False

        dict_fields = {}
        show_fields = {
            'show_foto': 0,
            'show_username': 1,
            'show_password': 0,
            'show_first_name': 1,
            'show_last_name': 1,
            'show_email': 1,
            'show_is_superuser': 0,
            'show_is_staff': 0,
            'show_is_active': 1,
            'show_last_login': 0,
            'show_date_joined': 0,
            'show_config_perfis': 1,
            'show_name': 1, }

        post = False
        #ANTES-POST-LISTAGEM

        if request.method == 'POST':

            post = True

            dict_fields = {
                'username__icontains': 'username__icontains',
                'first_name__icontains': 'first_name__icontains',
                'last_name__icontains': 'last_name__icontains',
                'email__icontains': 'email__icontains',
                'config_perfis__icontains': 'config_perfis__icontains',
                'name__icontains': 'name__icontains', }

            for a in dict_fields:
                dict_fields[a] = request.POST.get(a or None)

            for a in show_fields:
                show_fields[a] = request.POST.get(a or None)

            if request.method == 'POST':

                dict_fields = {
                    'username__icontains': 'username__icontains',
                    'first_name__icontains': 'first_name__icontains',
                    'last_name__icontains': 'last_name__icontains',
                    'email__icontains': 'email__icontains',
                    'config_perfis__icontains': 'config_perfis__icontains',
                    'name__icontains': 'name__icontains', }

                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)

        dict_qs = clear_dict_fields(dict_fields)

        usuarios_lista = Usuarios.objects.filter(**dict_qs).exclude(id=0).all()

        if not post and len(usuarios_lista) > 100:

            filtrar = True
            usuarios_lista = None
            messages.warning(request, u'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!')

        #[VARIAVEIS_LISTA_FILTRO_RELATORIO]
        #usuarios_listar_custom

        request.session['return'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            'usuarios_lista': usuarios_lista,
            'modulos': ['controle_de_acesso', ],
            'paginas': ['usuarios', ],
            'dict_fields': dict_fields,
            'data': datetime.datetime.now(),
            'show_fields': show_fields,
            'filtrar': filtrar,
            #[VARIAVEIS_FILTRO_RELATORIO]
        }

        if output == 'pdf':

            from wkhtmltopdf.views import PDFTemplateResponse

            response = PDFTemplateResponse(
                request=request,
                template='usuarios_listar.html',
                filename="usuarios.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={'margin-top': 10,
                             'margin-bottom': 10,
                             'margin-right': 10,
                             'margin-left': 10,
                             'zoom': 1,
                             'dpi': 72,
                             'orientation': 'Landscape',
                             "viewport-size": "1366 x 513",
                             'javascript-delay': 1000,
                             'footer-center': '[page]/[topage]',
                             "no-stop-slow-scripts": True}, )

            return response

        elif output == 'xls':

            from django.shortcuts import render_to_response

            response = render_to_response('usuarios_listar.html', context)
            filename = "usuarios.xls"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            from django.shortcuts import render_to_response

            response = render_to_response('csv/usuarios.csv', context)
            filename = "usuarios.csv"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'

            return response

        else:

            return render(request, 'usuarios_listar.html', context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            'data': datetime.datetime.now(),
            'modulos': ['controle_de_acesso', ],
            'paginas': ['usuarios', ],
        }

        return render(request,
            'permissao_negada.html',
            context)
示例#19
0
def verificar(request, pk, output=None):

    if request.user.has_perm('esocial.can_see_s5003evtBasesFGTS'):

        s5003_evtbasesfgts = get_object_or_404(s5003evtBasesFGTS, id=pk)
        s5003_evtbasesfgts_lista = s5003evtBasesFGTS.objects.filter(
            id=pk).all()

        s5003_ideestablot_lista = s5003ideEstabLot.objects.filter(
            s5003_evtbasesfgts_id__in=listar_ids(
                s5003_evtbasesfgts_lista)).all()
        s5003_infotrabfgts_lista = s5003infoTrabFGTS.objects.filter(
            s5003_ideestablot_id__in=listar_ids(
                s5003_ideestablot_lista)).all()
        s5003_infobasefgts_lista = s5003infoBaseFGTS.objects.filter(
            s5003_infotrabfgts_id__in=listar_ids(
                s5003_infotrabfgts_lista)).all()
        s5003_baseperapur_lista = s5003basePerApur.objects.filter(
            s5003_infobasefgts_id__in=listar_ids(
                s5003_infobasefgts_lista)).all()
        s5003_infobaseperante_lista = s5003infoBasePerAntE.objects.filter(
            s5003_infobasefgts_id__in=listar_ids(
                s5003_infobasefgts_lista)).all()
        s5003_baseperante_lista = s5003basePerAntE.objects.filter(
            s5003_infobaseperante_id__in=listar_ids(
                s5003_infobaseperante_lista)).all()
        s5003_infodpsfgts_lista = s5003infoDpsFGTS.objects.filter(
            s5003_evtbasesfgts_id__in=listar_ids(
                s5003_evtbasesfgts_lista)).all()
        s5003_infotrabdps_lista = s5003infoTrabDps.objects.filter(
            s5003_infodpsfgts_id__in=listar_ids(
                s5003_infodpsfgts_lista)).all()
        s5003_dpsperapur_lista = s5003dpsPerApur.objects.filter(
            s5003_infotrabdps_id__in=listar_ids(
                s5003_infotrabdps_lista)).all()
        s5003_infodpsperante_lista = s5003infoDpsPerAntE.objects.filter(
            s5003_infotrabdps_id__in=listar_ids(
                s5003_infotrabdps_lista)).all()
        s5003_dpsperante_lista = s5003dpsPerAntE.objects.filter(
            s5003_infodpsperante_id__in=listar_ids(
                s5003_infodpsperante_lista)).all()

        request.session['return_pk'] = pk
        request.session['return_page'] = 's5003_evtbasesfgts'

        context = {
            's5003_evtbasesfgts_lista': s5003_evtbasesfgts_lista,
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            's5003_evtbasesfgts': s5003_evtbasesfgts,
            's5003_ideestablot_lista': s5003_ideestablot_lista,
            's5003_infotrabfgts_lista': s5003_infotrabfgts_lista,
            's5003_infobasefgts_lista': s5003_infobasefgts_lista,
            's5003_baseperapur_lista': s5003_baseperapur_lista,
            's5003_infobaseperante_lista': s5003_infobaseperante_lista,
            's5003_baseperante_lista': s5003_baseperante_lista,
            's5003_infodpsfgts_lista': s5003_infodpsfgts_lista,
            's5003_infotrabdps_lista': s5003_infotrabdps_lista,
            's5003_dpsperapur_lista': s5003_dpsperapur_lista,
            's5003_infodpsperante_lista': s5003_infodpsperante_lista,
            's5003_dpsperante_lista': s5003_dpsperante_lista,
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's5003_evtbasesfgts',
            ],
            'data': datetime.now(),
            'output': output,
        }

        if output == 'pdf':

            response = PDFTemplateResponse(
                request=request,
                template='s5003_evtbasesfgts_verificar.html',
                filename="s5003_evtbasesfgts.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 20,
                    'zoom': 1,
                    'viewport-size': '1366 x 513',
                    'javascript-delay': 1000,
                    'footer-center': u'Página [page]/[topage]',
                    'footer-font-size': 10,
                    'no-stop-slow-scripts': True
                })

            return response

        elif output == 'xls':

            response = render_to_response('s5003_evtbasesfgts_verificar.html',
                                          context)
            filename = "%s.xls" % s5003_evtbasesfgts.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            response = render_to_response('s5003_evtbasesfgts_verificar.html',
                                          context)
            filename = "%s.csv" % s5003_evtbasesfgts.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response

        else:

            return render(request, 's5003_evtbasesfgts_verificar.html',
                          context)

    else:

        context = {
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's5003_evtbasesfgts',
            ],
            'data': datetime.now(),
        }

        return render(request, 'permissao_negada.html', context)
示例#20
0
def listar(request, output=None):

    if request.user.has_perm('s2240.can_see_s2240iniExpRiscofatRisco'):

        filtrar = False

        dict_fields = {}
        show_fields = {
            'show_s2240_evtexprisco': 1,
            'show_codfatris': 1,
            'show_tpaval': 1,
            'show_intconc': 0,
            'show_limtol': 0,
            'show_unmed': 0,
            'show_tecmedicao': 0,
            'show_insalubridade': 0,
            'show_periculosidade': 0,
            'show_aposentesp': 0,
            'show_dscfatrisc': 0,
            'show_epcepi': 0,
            'show_utilizepc': 0,
            'show_eficepc': 0,
            'show_utilizepi': 0, }

        post = False

        if request.method == 'POST':

            post = True
            dict_fields = {
                's2240_evtexprisco__icontains': 's2240_evtexprisco__icontains',
                'codfatris__icontains': 'codfatris__icontains',
                'tpaval__icontains': 'tpaval__icontains',
                'intconc__icontains': 'intconc__icontains',
                'limtol__icontains': 'limtol__icontains',
                'unmed__icontains': 'unmed__icontains',
                'tecmedicao__icontains': 'tecmedicao__icontains',
                'insalubridade__icontains': 'insalubridade__icontains',
                'periculosidade__icontains': 'periculosidade__icontains',
                'aposentesp__icontains': 'aposentesp__icontains',
                'dscfatrisc__icontains': 'dscfatrisc__icontains',
                'epcepi': 'epcepi',
                'utilizepc__icontains': 'utilizepc__icontains',
                'eficepc__icontains': 'eficepc__icontains',
                'utilizepi__icontains': 'utilizepi__icontains', }

            for a in dict_fields:

                dict_fields[a] = request.POST.get(a or None)

            for a in show_fields:

                show_fields[a] = request.POST.get(a or None)

            if request.method == 'POST':

                dict_fields = {
                    's2240_evtexprisco__icontains': 's2240_evtexprisco__icontains',
                    'codfatris__icontains': 'codfatris__icontains',
                    'tpaval__icontains': 'tpaval__icontains',
                    'intconc__icontains': 'intconc__icontains',
                    'limtol__icontains': 'limtol__icontains',
                    'unmed__icontains': 'unmed__icontains',
                    'tecmedicao__icontains': 'tecmedicao__icontains',
                    'insalubridade__icontains': 'insalubridade__icontains',
                    'periculosidade__icontains': 'periculosidade__icontains',
                    'aposentesp__icontains': 'aposentesp__icontains',
                    'dscfatrisc__icontains': 'dscfatrisc__icontains',
                    'epcepi': 'epcepi',
                    'utilizepc__icontains': 'utilizepc__icontains',
                    'eficepc__icontains': 'eficepc__icontains',
                    'utilizepi__icontains': 'utilizepi__icontains', }

                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)

        dict_qs = clear_dict_fields(dict_fields)
        s2240_iniexprisco_fatrisco_lista = s2240iniExpRiscofatRisco.objects.filter(**dict_qs).filter().exclude(id=0).all()

        if not post and len(s2240_iniexprisco_fatrisco_lista) > 100:

            filtrar = True
            s2240_iniexprisco_fatrisco_lista = None
            messages.warning(request, u'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!')

        #[VARIAVEIS_LISTA_FILTRO_RELATORIO]
        #s2240_iniexprisco_fatrisco_listar_custom

        request.session['return'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            's2240_iniexprisco_fatrisco_lista': s2240_iniexprisco_fatrisco_lista,
            'modulos': ['s2240', ],
            'paginas': ['s2240_iniexprisco_fatrisco', ],
            'dict_fields': dict_fields,
            'data': datetime.datetime.now(),
            'show_fields': show_fields,
            'filtrar': filtrar,
            #[VARIAVEIS_FILTRO_RELATORIO]
        }

        if output == 'pdf':

            from wkhtmltopdf.views import PDFTemplateResponse

            response = PDFTemplateResponse(
                request=request,
                template='s2240_iniexprisco_fatrisco_listar.html',
                filename="s2240_iniexprisco_fatrisco.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={'margin-top': 10,
                             'margin-bottom': 10,
                             'margin-right': 10,
                             'margin-left': 10,
                             'zoom': 1,
                             'dpi': 72,
                             'orientation': 'Landscape',
                             "viewport-size": "1366 x 513",
                             'javascript-delay': 1000,
                             'footer-center': '[page]/[topage]',
                             "no-stop-slow-scripts": True}, )
         
            return response

        elif output == 'xls':

            from django.shortcuts import render_to_response
            response = render_to_response('s2240_iniexprisco_fatrisco_listar.html', context)
            filename = "s2240_iniexprisco_fatrisco.xls"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response

        elif output == 'csv':

            from django.shortcuts import render_to_response
            response = render_to_response('csv/s2240_iniexprisco_fatrisco.csv', context)
            filename = "s2240_iniexprisco_fatrisco.csv"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response

        else:

            return render(request, 's2240_iniexprisco_fatrisco_listar.html', context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            'data': datetime.datetime.now(),
            'modulos': ['s2240', ],
            'paginas': ['s2240_iniexprisco_fatrisco', ],
        }

        return render(request,
                      'permissao_negada.html',
                      context)
示例#21
0
def listar(request, output=None):

    if request.user.has_perm('esocial.can_see_s1200evtRemun'):

        filtrar = False
        dict_fields = {}
        show_fields = {
            'show_esocial': 0,
            'show_evtremun': 0,
            'show_identidade': 1,
            'show_ideevento': 0,
            'show_indretif': 1,
            'show_nrrecibo': 0,
            'show_indapuracao': 1,
            'show_perapur': 0,
            'show_tpamb': 0,
            'show_procemi': 0,
            'show_verproc': 0,
            'show_ideempregador': 0,
            'show_tpinsc': 0,
            'show_nrinsc': 0,
            'show_idetrabalhador': 0,
            'show_cpftrab': 0,
            'show_nistrab': 0,
            'show_versao': 0,
            'show_transmissor_lote_esocial': 0,
            'show_validacao_precedencia': 0,
            'show_validacoes': 0,
            'show_arquivo_original': 0,
            'show_arquivo': 0,
            'show_status': 1,
            'show_transmissor_lote_esocial_error': 0,
            'show_retorno_envio_json': 0,
            'show_retorno_consulta_json': 0,
            'show_evento_json': 0,
            'show_ocorrencias_json': 0,
        }

        post = False

        if request.method == 'POST':

            post = True
            dict_fields = {
                'esocial': 'esocial',
                'evtremun': 'evtremun',
                'identidade__icontains': 'identidade__icontains',
                'ideevento': 'ideevento',
                'indretif__icontains': 'indretif__icontains',
                'nrrecibo__icontains': 'nrrecibo__icontains',
                'indapuracao__icontains': 'indapuracao__icontains',
                'perapur__icontains': 'perapur__icontains',
                'tpamb__icontains': 'tpamb__icontains',
                'procemi__icontains': 'procemi__icontains',
                'verproc__icontains': 'verproc__icontains',
                'ideempregador': 'ideempregador',
                'tpinsc__icontains': 'tpinsc__icontains',
                'nrinsc__icontains': 'nrinsc__icontains',
                'idetrabalhador': 'idetrabalhador',
                'cpftrab__icontains': 'cpftrab__icontains',
                'nistrab__icontains': 'nistrab__icontains',
                'versao__icontains': 'versao__icontains',
                'transmissor_lote_esocial__icontains':
                'transmissor_lote_esocial__icontains',
                'status__icontains': 'status__icontains',
            }

            for a in dict_fields:
                dict_fields[a] = request.POST.get(a or None)

            for a in show_fields:
                show_fields[a] = request.POST.get(a or None)

            if request.method == 'POST':
                dict_fields = {
                    'esocial': 'esocial',
                    'evtremun': 'evtremun',
                    'identidade__icontains': 'identidade__icontains',
                    'ideevento': 'ideevento',
                    'indretif__icontains': 'indretif__icontains',
                    'nrrecibo__icontains': 'nrrecibo__icontains',
                    'indapuracao__icontains': 'indapuracao__icontains',
                    'perapur__icontains': 'perapur__icontains',
                    'tpamb__icontains': 'tpamb__icontains',
                    'procemi__icontains': 'procemi__icontains',
                    'verproc__icontains': 'verproc__icontains',
                    'ideempregador': 'ideempregador',
                    'tpinsc__icontains': 'tpinsc__icontains',
                    'nrinsc__icontains': 'nrinsc__icontains',
                    'idetrabalhador': 'idetrabalhador',
                    'cpftrab__icontains': 'cpftrab__icontains',
                    'nistrab__icontains': 'nistrab__icontains',
                    'versao__icontains': 'versao__icontains',
                    'transmissor_lote_esocial__icontains':
                    'transmissor_lote_esocial__icontains',
                    'status__icontains': 'status__icontains',
                }
                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)

        dict_qs = clear_dict_fields(dict_fields)
        s1200_evtremun_lista = s1200evtRemun.objects.filter(
            **dict_qs).filter().exclude(id=0).all()

        if not post and len(s1200_evtremun_lista) > 100:
            filtrar = True
            s1200_evtremun_lista = None
            messages.warning(
                request,
                u'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!'
            )

        transmissor_lote_esocial_lista = TransmissorLoteEsocial.objects.all()
        transmissor_lote_esocial_error_lista = TransmissorLoteEsocial.objects.all(
        )
        #s1200_evtremun_listar_custom

        request.session['return'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario':
            Usuarios.objects.get(user_id=request.user.id),
            'output':
            output,
            's1200_evtremun_lista':
            s1200_evtremun_lista,
            'dict_fields':
            dict_fields,
            'data':
            datetime.datetime.now(),
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1200_evtremun',
            ],
            'show_fields':
            show_fields,
            'filtrar':
            filtrar,
            'transmissor_lote_esocial_lista':
            transmissor_lote_esocial_lista,
            'transmissor_lote_esocial_error_lista':
            transmissor_lote_esocial_error_lista,
        }

        if output == 'pdf':

            from emensageriapro.functions import render_to_pdf
            from wkhtmltopdf.views import PDFTemplateResponse

            response = PDFTemplateResponse(
                request=request,
                template='s1200_evtremun_listar.html',
                filename="s1200_evtremun.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 10,
                    'zoom': 1,
                    'dpi': 72,
                    'orientation': 'Landscape',
                    'viewport-size': "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )
            return response

        elif output == 'xls':

            response = render_to_response('s1200_evtremun_listar.html',
                                          context)
            filename = "s1200_evtremun.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            response = render_to_response('csv/s1200_evtremun.csv', context)
            filename = "s1200_evtremun.csv"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'

            return response

        else:

            return render(request, 's1200_evtremun_listar.html', context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'data': datetime.datetime.now(),
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1200_evtremun',
            ],
        }
        return render(request, 'permissao_negada.html', context)
示例#22
0
def salvar(request, pk=None, tab='master', output=None):

    if pk:

        relatorios = get_object_or_404(Relatorios, id=pk)

    if request.user.has_perm('mensageiro.can_see_Relatorios'):

        if pk:

            relatorios_form = form_relatorios(request.POST or None,
                                              instance=relatorios)

        else:

            relatorios_form = form_relatorios(request.POST or None)

        if request.method == 'POST':

            if relatorios_form.is_valid():

                #relatorios_campos_multiple_passo1

                obj = relatorios_form.save(request=request)
                messages.success(request, 'Salvo com sucesso!')
                #relatorios_campos_multiple_passo2

                if 'return_page' in request.session and request.session[
                        'return_page'] and 'relatorios' not in request.session[
                            'return_page']:

                    return HttpResponseRedirect(request.session['return_page'])

                if pk != obj.id:

                    return redirect('relatorios_salvar', pk=obj.id)

            else:

                messages.error(request, 'Erro ao salvar!')

        relatorios_form = disabled_form_fields(
            relatorios_form,
            request.user.has_perm('mensageiro.change_Relatorios'))
        #relatorios_campos_multiple_passo3

        if output:

            relatorios_form = disabled_form_for_print(relatorios_form)

        if pk:

            relatorios = get_object_or_404(Relatorios, id=pk)

        else:

            relatorios = None

        #relatorios_salvar_custom_variaveis#
        tabelas_secundarias = []
        #[FUNCOES_ESPECIAIS_SALVAR]

        if not request.POST:
            request.session['return_page'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'output': output,
            'tab': tab,
            'relatorios': relatorios,
            'relatorios_form': relatorios_form,
            'modulos': [
                'mensageiro',
            ],
            'paginas': [
                'relatorios',
            ],
            'data': datetime.datetime.now(),
            'tabelas_secundarias': tabelas_secundarias,
            #relatorios_salvar_custom_variaveis_context#
        }

        if output == 'pdf':

            from wkhtmltopdf.views import PDFTemplateResponse

            response = PDFTemplateResponse(request=request,
                                           template='relatorios_salvar.html',
                                           filename="relatorios.pdf",
                                           context=context,
                                           show_content_in_browser=True,
                                           cmd_options={
                                               'margin-top': 10,
                                               'margin-bottom': 10,
                                               'margin-right': 10,
                                               'margin-left': 10,
                                               'zoom': 1,
                                               'dpi': 72,
                                               'orientation': 'Landscape',
                                               "viewport-size": "1366 x 513",
                                               'javascript-delay': 1000,
                                               'footer-center':
                                               '[page]/[topage]',
                                               "no-stop-slow-scripts": True
                                           })

            return response

        elif output == 'xls':

            from django.shortcuts import render_to_response

            response = render_to_response('relatorios_salvar.html', context)
            filename = "relatorios.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        else:

            return render(request, 'relatorios_salvar.html', context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'output': output,
            'tab': tab,
            'modulos': [
                'mensageiro',
            ],
            'paginas': [
                'relatorios',
            ],
            'data': datetime.datetime.now(),
        }

        return render(request, 'permissao_negada.html', context)
def salvar(request, hash):
    db_slug = 'default'
    try:
        usuario_id = request.user.id
        dict_hash = get_hash_url(hash)
        importacao_arquivos_eventos_id = int(dict_hash['id'])
        if 'tab' not in dict_hash.keys():
            dict_hash['tab'] = ''
        for_print = int(dict_hash['print'])
    except:
        usuario_id = False
        return redirect('login')
    usuario = get_object_or_404(Usuarios.objects.using(db_slug),
                                excluido=False,
                                id=usuario_id)
    pagina = ConfigPaginas.objects.using(db_slug).get(
        excluido=False, endereco='importacao_arquivos_eventos')
    permissao = ConfigPermissoes.objects.using(db_slug).get(
        excluido=False,
        config_paginas=pagina,
        config_perfis=usuario.config_perfis)
    if importacao_arquivos_eventos_id:
        importacao_arquivos_eventos = get_object_or_404(
            ImportacaoArquivosEventos.objects.using(db_slug),
            excluido=False,
            id=importacao_arquivos_eventos_id)
    dict_permissoes = json_to_dict(usuario.config_perfis.permissoes)
    paginas_permitidas_lista = usuario.config_perfis.paginas_permitidas
    modulos_permitidos_lista = usuario.config_perfis.modulos_permitidos

    if permissao.permite_visualizar:
        mensagem = None
        if importacao_arquivos_eventos_id:
            importacao_arquivos_eventos_form = form_importacao_arquivos_eventos(
                request.POST or None,
                instance=importacao_arquivos_eventos,
                slug=db_slug)
        else:
            importacao_arquivos_eventos_form = form_importacao_arquivos_eventos(
                request.POST or None, slug=db_slug, initial={})
        if request.method == 'POST':
            if importacao_arquivos_eventos_form.is_valid():
                dados = importacao_arquivos_eventos_form.cleaned_data
                if importacao_arquivos_eventos_id:
                    dados['modificado_por_id'] = usuario_id
                    dados['modificado_em'] = datetime.datetime.now()
                    #importacao_arquivos_eventos_campos_multiple_passo1
                    ImportacaoArquivosEventos.objects.using(db_slug).filter(
                        id=importacao_arquivos_eventos_id).update(**dados)
                    obj = ImportacaoArquivosEventos.objects.using(db_slug).get(
                        id=importacao_arquivos_eventos_id)
                    #importacao_arquivos_eventos_editar_custom
                    #importacao_arquivos_eventos_campos_multiple_passo2
                    messages.success(request, 'Alterado com sucesso!')
                else:

                    dados['criado_por_id'] = usuario_id
                    dados['criado_em'] = datetime.datetime.now()
                    dados['excluido'] = False
                    #importacao_arquivos_eventos_cadastrar_campos_multiple_passo1
                    obj = ImportacaoArquivosEventos(**dados)
                    obj.save(using=db_slug)
                    #importacao_arquivos_eventos_cadastrar_custom
                    #importacao_arquivos_eventos_cadastrar_campos_multiple_passo2
                    messages.success(request, 'Cadastrado com sucesso!')
                if request.session['retorno_pagina'] not in (
                        'importacao_arquivos_eventos_apagar',
                        'importacao_arquivos_eventos_salvar',
                        'importacao_arquivos_eventos'):
                    return redirect(request.session['retorno_pagina'],
                                    hash=request.session['retorno_hash'])
                if importacao_arquivos_eventos_id != obj.id:
                    url_hash = base64.urlsafe_b64encode(
                        '{"print": "0", "id": "%s"}' % (obj.id))
                    return redirect('importacao_arquivos_eventos_salvar',
                                    hash=url_hash)
            else:
                messages.error(request, 'Erro ao salvar!')
        importacao_arquivos_eventos_form = disabled_form_fields(
            importacao_arquivos_eventos_form, permissao.permite_editar)
        #importacao_arquivos_eventos_campos_multiple_passo3

        for field in importacao_arquivos_eventos_form.fields.keys():
            importacao_arquivos_eventos_form.fields[field].widget.attrs[
                'ng-model'] = 'importacao_arquivos_eventos_' + field
        if int(dict_hash['print']):
            importacao_arquivos_eventos_form = disabled_form_for_print(
                importacao_arquivos_eventos_form)
        #[VARIAVEIS_SECUNDARIAS_VAZIAS]
        if importacao_arquivos_eventos_id:
            importacao_arquivos_eventos = get_object_or_404(
                ImportacaoArquivosEventos.objects.using(db_slug),
                excluido=False,
                id=importacao_arquivos_eventos_id)
            pass
        else:
            importacao_arquivos_eventos = None
        #importacao_arquivos_eventos_salvar_custom_variaveis#
        tabelas_secundarias = []
        #[FUNCOES_ESPECIAIS_SALVAR]
        if dict_hash['tab'] or 'importacao_arquivos_eventos' in request.session[
                'retorno_pagina']:
            request.session["retorno_hash"] = hash
            request.session[
                "retorno_pagina"] = 'importacao_arquivos_eventos_salvar'
        context = {
            'importacao_arquivos_eventos': importacao_arquivos_eventos,
            'importacao_arquivos_eventos_form':
            importacao_arquivos_eventos_form,
            'mensagem': mensagem,
            'importacao_arquivos_eventos_id':
            int(importacao_arquivos_eventos_id),
            'usuario': usuario,
            'hash': hash,
            #[VARIAVEIS_SECUNDARIAS]
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
            'for_print': int(dict_hash['print']),
            'tabelas_secundarias': tabelas_secundarias,
            'tab': dict_hash['tab'],
            #importacao_arquivos_eventos_salvar_custom_variaveis_context#
        }
        if for_print in (0, 1):
            return render(request, 'importacao_arquivos_eventos_salvar.html',
                          context)
        elif for_print == 2:
            from wkhtmltopdf.views import PDFTemplateResponse
            response = PDFTemplateResponse(
                request=request,
                template='importacao_arquivos_eventos_salvar.html',
                filename="importacao_arquivos_eventos.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 10,
                    'zoom': 1,
                    'dpi': 72,
                    'orientation': 'Landscape',
                    "viewport-size": "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )
            return response
        elif for_print == 3:
            from django.shortcuts import render_to_response
            response = render_to_response(
                'importacao_arquivos_eventos_salvar.html', context)
            filename = "importacao_arquivos_eventos.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response

    else:
        context = {
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
        }
        return render(request, 'permissao_negada.html', context)
示例#24
0
def salvar(request, pk=None, tab='master', output=None):

    from emensageriapro.esocial.models import STATUS_EVENTO_CADASTRADO
    from emensageriapro.settings import VERSAO_EMENSAGERIA, VERSAO_LAYOUT_ESOCIAL
    TP_AMB = config.ESOCIAL_TP_AMB

    if pk:

        s1070_evttabprocesso = get_object_or_404(s1070evtTabProcesso, id=pk)

    if request.user.has_perm('esocial.can_see_s1070evtTabProcesso'):

        if pk:

            s1070_evttabprocesso_form = form_s1070_evttabprocesso(
                request.POST or None,
                instance=s1070_evttabprocesso,
                initial={'ativo': True})

        else:

            s1070_evttabprocesso_form = form_s1070_evttabprocesso(
                request.POST or None,
                initial={
                    'versao': VERSAO_LAYOUT_ESOCIAL,
                    'status': STATUS_EVENTO_CADASTRADO,
                    'tpamb': TP_AMB,
                    'procemi': 1,
                    'verproc': VERSAO_EMENSAGERIA,
                    'ativo': True
                })

        if request.method == 'POST':

            if s1070_evttabprocesso_form.is_valid():

                obj = s1070_evttabprocesso_form.save(request=request)
                messages.success(request, u'Salvo com sucesso!')

                if not pk:

                    from emensageriapro.functions import identidade_evento
                    identidade_evento(obj, 'esocial')

                if 'return_page' in request.session and request.session[
                        'return_page'] and 's1070-evttabprocesso' not in request.session[
                            'return_page']:

                    return HttpResponseRedirect(request.session['return_page'])

                if pk != obj.id:

                    return redirect('s1070_evttabprocesso_salvar', pk=obj.id)

            else:
                messages.error(request, u'Erro ao salvar!')

        s1070_evttabprocesso_form = disabled_form_fields(
            s1070_evttabprocesso_form,
            request.user.has_perm('esocial.change_s1070evtTabProcesso'))

        if pk:

            if s1070_evttabprocesso.status != 0:

                s1070_evttabprocesso_form = disabled_form_fields(
                    s1070_evttabprocesso_form, False)

        for field in s1070_evttabprocesso_form.fields.keys():

            s1070_evttabprocesso_form.fields[field].widget.attrs[
                'ng-model'] = 's1070_evttabprocesso_' + field

        if output:

            s1070_evttabprocesso_form = disabled_form_for_print(
                s1070_evttabprocesso_form)

        s1070_inclusao_lista = None
        s1070_inclusao_form = None
        s1070_alteracao_lista = None
        s1070_alteracao_form = None
        s1070_exclusao_lista = None
        s1070_exclusao_form = None

        if pk:

            s1070_evttabprocesso = get_object_or_404(s1070evtTabProcesso,
                                                     id=pk)

            s1070_inclusao_form = form_s1070_inclusao(
                initial={'s1070_evttabprocesso': s1070_evttabprocesso})
            s1070_inclusao_form.fields['s1070_evttabprocesso'].widget.attrs[
                'readonly'] = True
            s1070_inclusao_lista = s1070inclusao.objects.\
                filter(s1070_evttabprocesso_id=s1070_evttabprocesso.id).all()
            s1070_alteracao_form = form_s1070_alteracao(
                initial={'s1070_evttabprocesso': s1070_evttabprocesso})
            s1070_alteracao_form.fields['s1070_evttabprocesso'].widget.attrs[
                'readonly'] = True
            s1070_alteracao_lista = s1070alteracao.objects.\
                filter(s1070_evttabprocesso_id=s1070_evttabprocesso.id).all()
            s1070_exclusao_form = form_s1070_exclusao(
                initial={'s1070_evttabprocesso': s1070_evttabprocesso})
            s1070_exclusao_form.fields['s1070_evttabprocesso'].widget.attrs[
                'readonly'] = True
            s1070_exclusao_lista = s1070exclusao.objects.\
                filter(s1070_evttabprocesso_id=s1070_evttabprocesso.id).all()

        else:

            s1070_evttabprocesso = None

        tabelas_secundarias = []

        controle_alteracoes = Auditoria.objects.filter(
            identidade=pk, tabela='s1070_evttabprocesso').all()

        if not request.POST:
            request.session['return_page'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'output': output,
            'evento_totalizador': False,
            'controle_alteracoes': controle_alteracoes,
            's1070_evttabprocesso': s1070_evttabprocesso,
            's1070_evttabprocesso_form': s1070_evttabprocesso_form,
            's1070_inclusao_form': s1070_inclusao_form,
            's1070_inclusao_lista': s1070_inclusao_lista,
            's1070_alteracao_form': s1070_alteracao_form,
            's1070_alteracao_lista': s1070_alteracao_lista,
            's1070_exclusao_form': s1070_exclusao_form,
            's1070_exclusao_lista': s1070_exclusao_lista,
            'data': datetime.datetime.now(),
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1070_evttabprocesso',
            ],
            'tabelas_secundarias': tabelas_secundarias,
            'tab': tab,
        }

        if output == 'pdf':

            response = PDFTemplateResponse(
                request=request,
                template='s1070_evttabprocesso_salvar.html',
                filename="s1070_evttabprocesso.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 10,
                    'zoom': 1,
                    'dpi': 72,
                    'orientation': 'Landscape',
                    "viewport-size": "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )

            return response

        elif output == 'xls':

            response = render_to_response('s1070_evttabprocesso_salvar.html',
                                          context)
            filename = "s1070_evttabprocesso.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        else:

            return render(request, 's1070_evttabprocesso_salvar.html', context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'tab': tab,
            'output': output,
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1070_evttabprocesso',
            ],
            'data': datetime.datetime.now(),
        }

        return render(request, 'permissao_negada.html', context)
示例#25
0
def listar(request, hash):
    for_print = 0
    db_slug = 'default'
    try:
        usuario_id = request.user.id
        dict_hash = get_hash_url( hash )
        #retorno_pagina = dict_hash['retorno_pagina']
        #retorno_hash = dict_hash['retorno_hash']
        #s1202_evtrmnrpps_id = int(dict_hash['id'])
        for_print = int(dict_hash['print'])
    except:
        usuario_id = False
        return redirect('login')
    usuario = get_object_or_404(Usuarios.objects.using( db_slug ), excluido = False, id = usuario_id)
    pagina = ConfigPaginas.objects.using( db_slug ).get(excluido = False, endereco='s1202_evtrmnrpps')
    permissao = ConfigPermissoes.objects.using( db_slug ).get(excluido = False, config_paginas=pagina, config_perfis=usuario.config_perfis)
    dict_permissoes = json_to_dict(usuario.config_perfis.permissoes)
    paginas_permitidas_lista = usuario.config_perfis.paginas_permitidas
    modulos_permitidos_lista = usuario.config_perfis.modulos_permitidos

    if permissao.permite_listar:
        filtrar = False
        dict_fields = {}
        show_fields = {
            'show_arquivo': 0,
            'show_arquivo_original': 0,
            'show_cpftrab': 1,
            'show_evtrmnrpps': 0,
            'show_ideempregador': 0,
            'show_ideevento': 0,
            'show_identidade': 1,
            'show_idetrabalhador': 0,
            'show_indapuracao': 1,
            'show_indretif': 1,
            'show_nistrab': 0,
            'show_nrinsc': 1,
            'show_nrrecibo': 0,
            'show_ocorrencias': 0,
            'show_perapur': 1,
            'show_procemi': 1,
            'show_processamento_codigo_resposta': 1,
            'show_processamento_data_hora': 0,
            'show_processamento_descricao_resposta': 0,
            'show_processamento_versao_app_processamento': 0,
            'show_qtddepfp': 0,
            'show_recepcao_data_hora': 0,
            'show_recepcao_protocolo_envio_lote': 0,
            'show_recepcao_tp_amb': 0,
            'show_recepcao_versao_app': 0,
            'show_recibo_hash': 0,
            'show_recibo_numero': 0,
            'show_retornos_eventos': 0,
            'show_status': 1,
            'show_tpamb': 1,
            'show_tpinsc': 1,
            'show_transmissor_lote_esocial': 0,
            'show_validacao_precedencia': 0,
            'show_validacoes': 0,
            'show_verproc': 1,
            'show_versao': 0, }
        post = False
        if request.method == 'POST':
            post = True
            dict_fields = {
                'cpftrab__icontains': 'cpftrab__icontains',
                'evtrmnrpps': 'evtrmnrpps',
                'ideempregador': 'ideempregador',
                'ideevento': 'ideevento',
                'identidade__icontains': 'identidade__icontains',
                'idetrabalhador': 'idetrabalhador',
                'indapuracao': 'indapuracao',
                'indretif': 'indretif',
                'nistrab__icontains': 'nistrab__icontains',
                'nrinsc__icontains': 'nrinsc__icontains',
                'nrrecibo__icontains': 'nrrecibo__icontains',
                'perapur__icontains': 'perapur__icontains',
                'procemi': 'procemi',
                'qtddepfp': 'qtddepfp',
                'status': 'status',
                'tpamb': 'tpamb',
                'tpinsc': 'tpinsc',
                'transmissor_lote_esocial': 'transmissor_lote_esocial',
                'verproc__icontains': 'verproc__icontains',
                'versao__icontains': 'versao__icontains',}
            for a in dict_fields:
                dict_fields[a] = request.POST.get(a or None)
            for a in show_fields:
                show_fields[a] = request.POST.get(a or None)
            if request.method == 'POST':
                dict_fields = {
                'cpftrab__icontains': 'cpftrab__icontains',
                'evtrmnrpps': 'evtrmnrpps',
                'ideempregador': 'ideempregador',
                'ideevento': 'ideevento',
                'identidade__icontains': 'identidade__icontains',
                'idetrabalhador': 'idetrabalhador',
                'indapuracao': 'indapuracao',
                'indretif': 'indretif',
                'nistrab__icontains': 'nistrab__icontains',
                'nrinsc__icontains': 'nrinsc__icontains',
                'nrrecibo__icontains': 'nrrecibo__icontains',
                'perapur__icontains': 'perapur__icontains',
                'procemi': 'procemi',
                'qtddepfp': 'qtddepfp',
                'status': 'status',
                'tpamb': 'tpamb',
                'tpinsc': 'tpinsc',
                'transmissor_lote_esocial': 'transmissor_lote_esocial',
                'verproc__icontains': 'verproc__icontains',
                'versao__icontains': 'versao__icontains',}
                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)
        dict_qs = clear_dict_fields(dict_fields)
        s1202_evtrmnrpps_lista = s1202evtRmnRPPS.objects.using( db_slug ).filter(**dict_qs).filter(excluido = False).exclude(id=0).all()
        if not post and len(s1202_evtrmnrpps_lista) > 100:
            filtrar = True
            s1202_evtrmnrpps_lista = None
            messages.warning(request, 'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!')
   
        transmissor_lote_esocial_lista = TransmissorLoteEsocial.objects.using( db_slug ).filter(excluido = False).all()
        #s1202_evtrmnrpps_listar_custom
        request.session["retorno_hash"] = hash
        request.session["retorno_pagina"] = 's1202_evtrmnrpps'
        context = {
            's1202_evtrmnrpps_lista': s1202_evtrmnrpps_lista,
            
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            
            'permissao': permissao,
            'dict_fields': dict_fields,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
            'show_fields': show_fields,
            'for_print': for_print,
            'hash': hash,
            'filtrar': filtrar,
       
            'transmissor_lote_esocial_lista': transmissor_lote_esocial_lista,
        }
        #return render(request, 's1202_evtrmnrpps_listar.html', context)
        if for_print in (0,1):
            return render(request, 's1202_evtrmnrpps_listar.html', context)
        elif for_print == 2:
            #return render_to_pdf('tables/s1000_evtinfoempregador_pdf_xls.html', context)
            from wkhtmltopdf.views import PDFTemplateResponse
            response = PDFTemplateResponse(
                request=request,
                template='s1202_evtrmnrpps_listar.html',
                filename="s1202_evtrmnrpps.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={'margin-top': 10,
                             'margin-bottom': 10,
                             'margin-right': 10,
                             'margin-left': 10,
                             'zoom': 1,
                             'dpi': 72,
                             'orientation': 'Landscape',
                             'viewport-size': "1366 x 513",
                             'javascript-delay': 1000,
                             'footer-center': '[page]/[topage]',
                             "no-stop-slow-scripts": True},
            )
            return response
        elif for_print == 3:
            from django.shortcuts import render_to_response
            response = render_to_response('s1202_evtrmnrpps_listar.html', context)
            filename = "s1202_evtrmnrpps.xls"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response
        elif for_print == 4:
            from django.shortcuts import render_to_response
            response = render_to_response('tables/s1202_evtrmnrpps_csv.html', context)
            filename = "s1202_evtrmnrpps.csv"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response
    else:
        context = {
            'usuario': usuario,
            
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
        }
        return render(request, 'permissao_negada.html', context)
示例#26
0
def listar(request, output=None):

    if request.user.has_perm('s5003.can_see_s5003infoTrabFGTS'):
    
        filtrar = False
        
        dict_fields = {}
        show_fields = { 
            'show_s5003_ideestablot': 1,
            'show_matricula': 0,
            'show_codcateg': 1,
            'show_dtadm': 0,
            'show_dtdeslig': 0,
            'show_dtinicio': 0,
            'show_mtvdeslig': 0,
            'show_dtterm': 0,
            'show_mtvdesligtsv': 0, }
            
        post = False
        
        if request.method == 'POST':
        
            post = True
            dict_fields = { 
                's5003_ideestablot__icontains': 's5003_ideestablot__icontains',
                'matricula__icontains': 'matricula__icontains',
                'codcateg__icontains': 'codcateg__icontains',
                'dtadm__range': 'dtadm__range',
                'dtdeslig__range': 'dtdeslig__range',
                'dtinicio__range': 'dtinicio__range',
                'mtvdeslig__icontains': 'mtvdeslig__icontains',
                'dtterm__range': 'dtterm__range',
                'mtvdesligtsv__icontains': 'mtvdesligtsv__icontains', }
                
            for a in dict_fields:
            
                dict_fields[a] = request.POST.get(a or None)
                
            for a in show_fields:
            
                show_fields[a] = request.POST.get(a or None)
                
            if request.method == 'POST':
            
                dict_fields = { 
                    's5003_ideestablot__icontains': 's5003_ideestablot__icontains',
                    'matricula__icontains': 'matricula__icontains',
                    'codcateg__icontains': 'codcateg__icontains',
                    'dtadm__range': 'dtadm__range',
                    'dtdeslig__range': 'dtdeslig__range',
                    'dtinicio__range': 'dtinicio__range',
                    'mtvdeslig__icontains': 'mtvdeslig__icontains',
                    'dtterm__range': 'dtterm__range',
                    'mtvdesligtsv__icontains': 'mtvdesligtsv__icontains', }
                    
                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)
                    
        dict_qs = clear_dict_fields(dict_fields)
        s5003_infotrabfgts_lista = s5003infoTrabFGTS.objects.filter(**dict_qs).filter().exclude(id=0).all()
        
        if not post and len(s5003_infotrabfgts_lista) > 100:
        
            filtrar = True
            s5003_infotrabfgts_lista = None
            messages.warning(request, u'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!')
            
        #[VARIAVEIS_LISTA_FILTRO_RELATORIO]
        #s5003_infotrabfgts_listar_custom
        
        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            's5003_infotrabfgts_lista': s5003_infotrabfgts_lista, 
            'modulos': ['s5003', ],
            'paginas': ['s5003_infotrabfgts', ],
            'dict_fields': dict_fields,
            'data': datetime.datetime.now(),
            'show_fields': show_fields,
            'filtrar': filtrar,
            #[VARIAVEIS_FILTRO_RELATORIO]
        }
            
        if output == 'pdf':
        
            from wkhtmltopdf.views import PDFTemplateResponse
            
            response = PDFTemplateResponse(
                request=request,
                template='s5003_infotrabfgts_listar.html',
                filename="s5003_infotrabfgts.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={'margin-top': 10,
                             'margin-bottom': 10,
                             'margin-right': 10,
                             'margin-left': 10,
                             'zoom': 1,
                             'dpi': 72,
                             'orientation': 'Landscape',
                             "viewport-size": "1366 x 513",
                             'javascript-delay': 1000,
                             'footer-center': '[page]/[topage]',
                             "no-stop-slow-scripts": True}, )
                             
            return response
            
        elif output == 'xls':
        
            from django.shortcuts import render_to_response
            response = render_to_response('s5003_infotrabfgts_listar.html', context)
            filename = "s5003_infotrabfgts.xls"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response
            
        elif output == 'csv':
        
            from django.shortcuts import render_to_response
            response = render_to_response('csv/s5003_infotrabfgts.csv', context)
            filename = "s5003_infotrabfgts.csv"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response
        
        else:
        
            return render(request, 's5003_infotrabfgts_listar.html', context)
            
    else:
    
        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            'data': datetime.datetime.now(),
            'modulos': ['s5003', ],
            'paginas': ['s5003_infotrabfgts', ],
        }
        
        return render(request, 
                      'permissao_negada.html', 
                      context)
示例#27
0
def listar(request, output=None):

    if request.user.has_perm('r1000.can_see_r1000alteracaoinfoEFR'):

        filtrar = False

        dict_fields = {}
        show_fields = {
            'show_r1000_alteracao': 1,
            'show_ideefr': 1,
            'show_cnpjefr': 0,
        }

        post = False

        if request.method == 'POST':

            post = True
            dict_fields = {
                'r1000_alteracao__icontains': 'r1000_alteracao__icontains',
                'ideefr__icontains': 'ideefr__icontains',
                'cnpjefr__icontains': 'cnpjefr__icontains',
            }

            for a in dict_fields:

                dict_fields[a] = request.POST.get(a or None)

            for a in show_fields:

                show_fields[a] = request.POST.get(a or None)

            if request.method == 'POST':

                dict_fields = {
                    'r1000_alteracao__icontains': 'r1000_alteracao__icontains',
                    'ideefr__icontains': 'ideefr__icontains',
                    'cnpjefr__icontains': 'cnpjefr__icontains',
                }

                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)

        dict_qs = clear_dict_fields(dict_fields)
        r1000_alteracao_infoefr_lista = r1000alteracaoinfoEFR.objects.filter(
            **dict_qs).filter().exclude(id=0).all()

        if not post and len(r1000_alteracao_infoefr_lista) > 100:

            filtrar = True
            r1000_alteracao_infoefr_lista = None
            messages.warning(
                request,
                u'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!'
            )

        #[VARIAVEIS_LISTA_FILTRO_RELATORIO]
        #r1000_alteracao_infoefr_listar_custom

        request.session['return'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            'r1000_alteracao_infoefr_lista': r1000_alteracao_infoefr_lista,
            'modulos': [
                'r1000',
            ],
            'paginas': [
                'r1000_alteracao_infoefr',
            ],
            'dict_fields': dict_fields,
            'data': datetime.datetime.now(),
            'show_fields': show_fields,
            'filtrar': filtrar,
            #[VARIAVEIS_FILTRO_RELATORIO]
        }

        if output == 'pdf':

            from wkhtmltopdf.views import PDFTemplateResponse

            response = PDFTemplateResponse(
                request=request,
                template='r1000_alteracao_infoefr_listar.html',
                filename="r1000_alteracao_infoefr.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 10,
                    'zoom': 1,
                    'dpi': 72,
                    'orientation': 'Landscape',
                    "viewport-size": "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )

            return response

        elif output == 'xls':

            from django.shortcuts import render_to_response
            response = render_to_response(
                'r1000_alteracao_infoefr_listar.html', context)
            filename = "r1000_alteracao_infoefr.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response

        elif output == 'csv':

            from django.shortcuts import render_to_response
            response = render_to_response('csv/r1000_alteracao_infoefr.csv',
                                          context)
            filename = "r1000_alteracao_infoefr.csv"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response

        else:

            return render(request, 'r1000_alteracao_infoefr_listar.html',
                          context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            'data': datetime.datetime.now(),
            'modulos': [
                'r1000',
            ],
            'paginas': [
                'r1000_alteracao_infoefr',
            ],
        }

        return render(request, 'permissao_negada.html', context)
示例#28
0
def listar(request, output=None):

    if request.user.has_perm('s2205.can_see_s2205RIC'):

        filtrar = False

        dict_fields = {}
        show_fields = {
            'show_s2205_documentos': 1,
            'show_nrric': 1,
            'show_orgaoemissor': 1,
            'show_dtexped': 0,
        }

        post = False

        if request.method == 'POST':

            post = True
            dict_fields = {
                's2205_documentos__icontains': 's2205_documentos__icontains',
                'nrric__icontains': 'nrric__icontains',
                'orgaoemissor__icontains': 'orgaoemissor__icontains',
                'dtexped__range': 'dtexped__range',
            }

            for a in dict_fields:

                dict_fields[a] = request.POST.get(a or None)

            for a in show_fields:

                show_fields[a] = request.POST.get(a or None)

            if request.method == 'POST':

                dict_fields = {
                    's2205_documentos__icontains':
                    's2205_documentos__icontains',
                    'nrric__icontains': 'nrric__icontains',
                    'orgaoemissor__icontains': 'orgaoemissor__icontains',
                    'dtexped__range': 'dtexped__range',
                }

                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)

        dict_qs = clear_dict_fields(dict_fields)
        s2205_ric_lista = s2205RIC.objects.filter(**dict_qs).filter().exclude(
            id=0).all()

        if not post and len(s2205_ric_lista) > 100:

            filtrar = True
            s2205_ric_lista = None
            messages.warning(
                request,
                u'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!'
            )

        s2205_documentos_lista = s2205documentos.objects.all()
        #s2205_ric_listar_custom

        request.session['return'] = request.META.get('HTTP_REFERER')

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            's2205_ric_lista': s2205_ric_lista,
            'modulos': [
                's2205',
            ],
            'paginas': [
                's2205_ric',
            ],
            'dict_fields': dict_fields,
            'data': datetime.datetime.now(),
            'show_fields': show_fields,
            'filtrar': filtrar,
            's2205_documentos_lista': s2205_documentos_lista,
        }

        if output == 'pdf':

            from wkhtmltopdf.views import PDFTemplateResponse

            response = PDFTemplateResponse(
                request=request,
                template='s2205_ric_listar.html',
                filename="s2205_ric.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 10,
                    'zoom': 1,
                    'dpi': 72,
                    'orientation': 'Landscape',
                    "viewport-size": "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )

            return response

        elif output == 'xls':

            from django.shortcuts import render_to_response
            response = render_to_response('s2205_ric_listar.html', context)
            filename = "s2205_ric.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response

        elif output == 'csv':

            from django.shortcuts import render_to_response
            response = render_to_response('csv/s2205_ric.csv', context)
            filename = "s2205_ric.csv"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response

        else:

            return render(request, 's2205_ric_listar.html', context)

    else:

        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'output': output,
            'data': datetime.datetime.now(),
            'modulos': [
                's2205',
            ],
            'paginas': [
                's2205_ric',
            ],
        }

        return render(request, 'permissao_negada.html', context)
示例#29
0
def listar(request, hash):
    for_print = 0
    db_slug = 'default'
    try:
        usuario_id = request.user.id
        dict_hash = get_hash_url(hash)
        #retorno_pagina = dict_hash['retorno_pagina']
        #retorno_hash = dict_hash['retorno_hash']
        #s2206_observacoes_id = int(dict_hash['id'])
        for_print = int(dict_hash['print'])
    except:
        usuario_id = False
        return redirect('login')
    usuario = get_object_or_404(Usuarios.objects.using(db_slug),
                                excluido=False,
                                id=usuario_id)
    pagina = ConfigPaginas.objects.using(db_slug).get(
        excluido=False, endereco='s2206_observacoes')
    permissao = ConfigPermissoes.objects.using(db_slug).get(
        excluido=False,
        config_paginas=pagina,
        config_perfis=usuario.config_perfis)
    dict_permissoes = json_to_dict(usuario.config_perfis.permissoes)
    paginas_permitidas_lista = usuario.config_perfis.paginas_permitidas
    modulos_permitidos_lista = usuario.config_perfis.modulos_permitidos

    if permissao.permite_listar:
        filtrar = False
        dict_fields = {}
        show_fields = {
            'show_excluido': 0,
            'show_modificado_por': 0,
            'show_modificado_em': 0,
            'show_criado_por': 0,
            'show_criado_em': 0,
            'show_observacao': 1,
            'show_s2206_evtaltcontratual': 1,
        }
        post = False
        if request.method == 'POST':
            post = True
            dict_fields = {
                'observacao__icontains': 'observacao__icontains',
                's2206_evtaltcontratual': 's2206_evtaltcontratual',
            }
            for a in dict_fields:
                dict_fields[a] = request.POST.get(a or None)
            for a in show_fields:
                show_fields[a] = request.POST.get(a or None)
            if request.method == 'POST':
                dict_fields = {
                    'observacao__icontains': 'observacao__icontains',
                    's2206_evtaltcontratual': 's2206_evtaltcontratual',
                }
                for a in dict_fields:
                    dict_fields[a] = request.POST.get(dict_fields[a] or None)
        dict_qs = clear_dict_fields(dict_fields)
        s2206_observacoes_lista = s2206observacoes.objects.using(
            db_slug).filter(**dict_qs).filter(excluido=False).exclude(
                id=0).all()
        if not post and len(s2206_observacoes_lista) > 100:
            filtrar = True
            s2206_observacoes_lista = None
            messages.warning(
                request,
                'Listagem com mais de 100 resultados! Filtre os resultados um melhor desempenho!'
            )

        s2206_evtaltcontratual_lista = s2206evtAltContratual.objects.using(
            db_slug).filter(excluido=False).all()
        #s2206_observacoes_listar_custom
        request.session["retorno_hash"] = hash
        request.session["retorno_pagina"] = 's2206_observacoes'
        context = {
            's2206_observacoes_lista': s2206_observacoes_lista,
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            'permissao': permissao,
            'dict_fields': dict_fields,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
            'show_fields': show_fields,
            'for_print': for_print,
            'hash': hash,
            'filtrar': filtrar,
            's2206_evtaltcontratual_lista': s2206_evtaltcontratual_lista,
        }
        if for_print in (0, 1):
            return render(request, 's2206_observacoes_listar.html', context)
        elif for_print == 2:
            #return render_to_pdf('tables/s1000_evtinfoempregador_pdf_xls.html', context)
            from wkhtmltopdf.views import PDFTemplateResponse
            response = PDFTemplateResponse(
                request=request,
                template='s2206_observacoes_listar.html',
                filename="s2206_observacoes.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 10,
                    'zoom': 1,
                    'dpi': 72,
                    'orientation': 'Landscape',
                    "viewport-size": "1366 x 513",
                    'javascript-delay': 1000,
                    'footer-center': '[page]/[topage]',
                    "no-stop-slow-scripts": True
                },
            )
            return response
        elif for_print == 3:
            from django.shortcuts import render_to_response
            response = render_to_response('s2206_observacoes_listar.html',
                                          context)
            filename = "s2206_observacoes.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            return response
        elif for_print == 4:
            from django.shortcuts import render_to_response
            response = render_to_response('tables/s2206_observacoes_csv.html',
                                          context)
            filename = "s2206_observacoes.csv"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response
    else:
        context = {
            'usuario': usuario,
            'modulos_permitidos_lista': modulos_permitidos_lista,
            'paginas_permitidas_lista': paginas_permitidas_lista,
            'permissao': permissao,
            'data': datetime.datetime.now(),
            'pagina': pagina,
            'dict_permissoes': dict_permissoes,
        }
        return render(request, 'permissao_negada.html', context)
示例#30
0
def verificar(request, pk, output=None):

    if request.user.has_perm('esocial.can_see_s5002evtIrrfBenef'):

        s5002_evtirrfbenef = get_object_or_404(s5002evtIrrfBenef, id=pk)
        s5002_evtirrfbenef_lista = s5002evtIrrfBenef.objects.filter(
            id=pk).all()

        s5002_infodep_lista = s5002infoDep.objects.filter(
            s5002_evtirrfbenef_id__in=listar_ids(
                s5002_evtirrfbenef_lista)).all()
        s5002_infoirrf_lista = s5002infoIrrf.objects.filter(
            s5002_evtirrfbenef_id__in=listar_ids(
                s5002_evtirrfbenef_lista)).all()
        s5002_basesirrf_lista = s5002basesIrrf.objects.filter(
            s5002_infoirrf_id__in=listar_ids(s5002_infoirrf_lista)).all()
        s5002_irrf_lista = s5002irrf.objects.filter(
            s5002_infoirrf_id__in=listar_ids(s5002_infoirrf_lista)).all()
        s5002_idepgtoext_lista = s5002idePgtoExt.objects.filter(
            s5002_infoirrf_id__in=listar_ids(s5002_infoirrf_lista)).all()

        request.session['return_pk'] = pk
        request.session['return_page'] = 's5002_evtirrfbenef'

        context = {
            's5002_evtirrfbenef_lista': s5002_evtirrfbenef_lista,
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            's5002_evtirrfbenef': s5002_evtirrfbenef,
            's5002_infodep_lista': s5002_infodep_lista,
            's5002_infoirrf_lista': s5002_infoirrf_lista,
            's5002_basesirrf_lista': s5002_basesirrf_lista,
            's5002_irrf_lista': s5002_irrf_lista,
            's5002_idepgtoext_lista': s5002_idepgtoext_lista,
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's5002_evtirrfbenef',
            ],
            'data': datetime.now(),
            'output': output,
        }

        if output == 'pdf':

            response = PDFTemplateResponse(
                request=request,
                template='s5002_evtirrfbenef_verificar.html',
                filename="s5002_evtirrfbenef.pdf",
                context=context,
                show_content_in_browser=True,
                cmd_options={
                    'margin-top': 10,
                    'margin-bottom': 10,
                    'margin-right': 10,
                    'margin-left': 20,
                    'zoom': 1,
                    'viewport-size': '1366 x 513',
                    'javascript-delay': 1000,
                    'footer-center': u'Página [page]/[topage]',
                    'footer-font-size': 10,
                    'no-stop-slow-scripts': True
                })

            return response

        elif output == 'xls':

            response = render_to_response('s5002_evtirrfbenef_verificar.html',
                                          context)
            filename = "%s.xls" % s5002_evtirrfbenef.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        elif output == 'csv':

            response = render_to_response('s5002_evtirrfbenef_verificar.html',
                                          context)
            filename = "%s.csv" % s5002_evtirrfbenef.identidade
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'text/csv; charset=UTF-8'
            return response

        else:

            return render(request, 's5002_evtirrfbenef_verificar.html',
                          context)

    else:

        context = {
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's5002_evtirrfbenef',
            ],
            'data': datetime.now(),
        }

        return render(request, 'permissao_negada.html', context)