示例#1
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(r2050evtComProd, id=pk)
    ident = identidade_evento(obj, 'efdreinf')

    return HttpResponse(ident)
示例#2
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(r2030evtAssocDespRec, id=pk)
    ident = identidade_evento(obj, 'efdreinf')

    return HttpResponse(ident)
示例#3
0
def salvar(request, pk=None, tab='master', output=None):

    from emensageriapro.efdreinf.models import STATUS_EVENTO_CADASTRADO
    from emensageriapro.settings import VERSAO_EMENSAGERIA, VERSAO_LAYOUT_EFDREINF
    TP_AMB = config.EFDREINF_TP_AMB
    
    if pk:
    
        r9012_evtretcons = get_object_or_404(r9012evtRetCons, id=pk)

        if r9012_evtretcons.status != STATUS_EVENTO_CADASTRADO:
        
            dict_permissoes = {}
            dict_permissoes['r9012_evtretcons_apagar'] = 0
            dict_permissoes['r9012_evtretcons_editar'] = 0
            
    if request.user.has_perm('efdreinf.can_see_r9012evtRetCons'):
    
        if pk:
        
            r9012_evtretcons_form = form_r9012_evtretcons(request.POST or None, instance = r9012_evtretcons, 
                                         initial={'ativo': True})
                                         
        else:
        
            r9012_evtretcons_form = form_r9012_evtretcons(request.POST or None, 
                                         initial={'versao': VERSAO_LAYOUT_EFDREINF, 
                                                  'status': STATUS_EVENTO_CADASTRADO, 
                                                  'tpamb': TP_AMB, 
                                                  'procemi': 1, 
                                                  'verproc': VERSAO_EMENSAGERIA, 
                                                  'ativo': True})
                                                  
        if request.method == 'POST':
        
            if r9012_evtretcons_form.is_valid():
            
                obj = r9012_evtretcons_form.save(request=request)
                messages.success(request, u'Salvo com sucesso!')
                
                if not pk:
                
                    from emensageriapro.functions import identidade_evento
                    identidade_evento(obj)
                  
                    gravar_auditoria('{}',
                                 json.dumps(model_to_dict(obj), indent=4, sort_keys=True, default=str), 
                                 'r9012_evtretcons', obj.id, request.user.id, 1)
                else:
                
                    gravar_auditoria(json.dumps(model_to_dict(r9012_evtretcons), indent=4, sort_keys=True, default=str),
                                     json.dumps(model_to_dict(obj), indent=4, sort_keys=True, default=str), 
                                     'r9012_evtretcons', pk, request.user.id, 2)
                                 
                if request.session['return_page'] not in (
                    'r9012_evtretcons_apagar', 
                    'r9012_evtretcons_salvar', 
                    'r9012_evtretcons'):
                    
                    return redirect(
                        request.session['return_page'], 
                        pk=request.session['return_pk'])
                    
                if pk != obj.id:
                
                    return redirect(
                        'r9012_evtretcons_salvar', 
                        pk=obj.id)

            else:
                messages.error(request, u'Erro ao salvar!')
                
        r9012_evtretcons_form = disabled_form_fields(
             r9012_evtretcons_form, 
             request.user.has_perm('efdreinf.change_r9012evtRetCons'))
        
        if pk:
        
            if r9012_evtretcons.status != 0:
            
                r9012_evtretcons_form = disabled_form_fields(r9012_evtretcons_form, False)
                
        #r9012_evtretcons_campos_multiple_passo3

        for field in r9012_evtretcons_form.fields.keys():
        
            r9012_evtretcons_form.fields[field].widget.attrs['ng-model'] = 'r9012_evtretcons_'+field
            
        if output:
        
            r9012_evtretcons_form = disabled_form_for_print(r9012_evtretcons_form)

        
        r1000_evtinfocontri_lista = None 
        r1000_evtinfocontri_form = None 
        r1070_evttabprocesso_lista = None 
        r1070_evttabprocesso_form = None 
        r2010_evtservtom_lista = None 
        r2010_evtservtom_form = None 
        r2020_evtservprest_lista = None 
        r2020_evtservprest_form = None 
        r2030_evtassocdesprec_lista = None 
        r2030_evtassocdesprec_form = None 
        r2040_evtassocdesprep_lista = None 
        r2040_evtassocdesprep_form = None 
        r2050_evtcomprod_lista = None 
        r2050_evtcomprod_form = None 
        r2060_evtcprb_lista = None 
        r2060_evtcprb_form = None 
        r2070_evtpgtosdivs_lista = None 
        r2070_evtpgtosdivs_form = None 
        r2098_evtreabreevper_lista = None 
        r2098_evtreabreevper_form = None 
        r2099_evtfechaevper_lista = None 
        r2099_evtfechaevper_form = None 
        r3010_evtespdesportivo_lista = None 
        r3010_evtespdesportivo_form = None 
        r4010_evtretpf_lista = None 
        r4010_evtretpf_form = None 
        r4020_evtretpj_lista = None 
        r4020_evtretpj_form = None 
        r4040_evtbenefnid_lista = None 
        r4040_evtbenefnid_form = None 
        r4098_evtreab_lista = None 
        r4098_evtreab_form = None 
        r4099_evtfech_lista = None 
        r4099_evtfech_form = None 
        r9000_evtexclusao_lista = None 
        r9000_evtexclusao_form = None 
        r9012_regocorrs_lista = None 
        r9012_regocorrs_form = None 
        r9012_infototalcontrib_lista = None 
        r9012_infototalcontrib_form = None 
        
        if pk:
        
            r9012_evtretcons = get_object_or_404(r9012evtRetCons, id=pk)
            
            r9012_regocorrs_form = form_r9012_regocorrs(
                initial={ 'r9012_evtretcons': r9012_evtretcons })
            r9012_regocorrs_form.fields['r9012_evtretcons'].widget.attrs['readonly'] = True
            r9012_regocorrs_lista = r9012regOcorrs.objects.\
                filter(r9012_evtretcons_id=r9012_evtretcons.id).all()
            r9012_infototalcontrib_form = form_r9012_infototalcontrib(
                initial={ 'r9012_evtretcons': r9012_evtretcons })
            r9012_infototalcontrib_form.fields['r9012_evtretcons'].widget.attrs['readonly'] = True
            r9012_infototalcontrib_lista = r9012infoTotalContrib.objects.\
                filter(r9012_evtretcons_id=r9012_evtretcons.id).all()
            r1000_evtinfocontri_form = form_r1000_evtinfocontri(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r1000_evtinfocontri_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r1000_evtinfocontri_lista = r1000evtInfoContri.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r1070_evttabprocesso_form = form_r1070_evttabprocesso(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r1070_evttabprocesso_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r1070_evttabprocesso_lista = r1070evtTabProcesso.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r2010_evtservtom_form = form_r2010_evtservtom(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r2010_evtservtom_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r2010_evtservtom_lista = r2010evtServTom.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r2020_evtservprest_form = form_r2020_evtservprest(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r2020_evtservprest_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r2020_evtservprest_lista = r2020evtServPrest.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r2030_evtassocdesprec_form = form_r2030_evtassocdesprec(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r2030_evtassocdesprec_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r2030_evtassocdesprec_lista = r2030evtAssocDespRec.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r2040_evtassocdesprep_form = form_r2040_evtassocdesprep(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r2040_evtassocdesprep_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r2040_evtassocdesprep_lista = r2040evtAssocDespRep.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r2050_evtcomprod_form = form_r2050_evtcomprod(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r2050_evtcomprod_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r2050_evtcomprod_lista = r2050evtComProd.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r2060_evtcprb_form = form_r2060_evtcprb(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r2060_evtcprb_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r2060_evtcprb_lista = r2060evtCPRB.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r2070_evtpgtosdivs_form = form_r2070_evtpgtosdivs(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r2070_evtpgtosdivs_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r2070_evtpgtosdivs_lista = r2070evtPgtosDivs.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r2098_evtreabreevper_form = form_r2098_evtreabreevper(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r2098_evtreabreevper_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r2098_evtreabreevper_lista = r2098evtReabreEvPer.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r2099_evtfechaevper_form = form_r2099_evtfechaevper(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r2099_evtfechaevper_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r2099_evtfechaevper_lista = r2099evtFechaEvPer.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r3010_evtespdesportivo_form = form_r3010_evtespdesportivo(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r3010_evtespdesportivo_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r3010_evtespdesportivo_lista = r3010evtEspDesportivo.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r4010_evtretpf_form = form_r4010_evtretpf(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r4010_evtretpf_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r4010_evtretpf_lista = r4010evtRetPF.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r4020_evtretpj_form = form_r4020_evtretpj(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r4020_evtretpj_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r4020_evtretpj_lista = r4020evtRetPJ.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r4040_evtbenefnid_form = form_r4040_evtbenefnid(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r4040_evtbenefnid_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r4040_evtbenefnid_lista = r4040evtBenefNId.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r4098_evtreab_form = form_r4098_evtreab(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r4098_evtreab_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r4098_evtreab_lista = r4098evtReab.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r4099_evtfech_form = form_r4099_evtfech(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r4099_evtfech_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r4099_evtfech_lista = r4099evtFech.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
            r9000_evtexclusao_form = form_r9000_evtexclusao(
                initial={ 'retornos_r9012': r9012_evtretcons })
            r9000_evtexclusao_form.fields['retornos_r9012'].widget.attrs['readonly'] = True
            r9000_evtexclusao_lista = r9000evtExclusao.objects.\
                filter(retornos_r9012_id=r9012_evtretcons.id).all()
                
        else:
        
            r9012_evtretcons = None
            
        #r9012_evtretcons_salvar_custom_variaveis#
        tabelas_secundarias = []
        #[FUNCOES_ESPECIAIS_SALVAR]
        
        if 'r9012_evtretcons'[1] == '5':
            evento_totalizador = True
            
        else:
            evento_totalizador = False
        
        if tab or 'r9012_evtretcons' in request.session['return_page']:
        
            request.session['return_pk'] = pk
            request.session['return_tab'] = tab
            request.session['return_page'] = 'r9012_evtretcons_salvar'
            
        controle_alteracoes = Auditoria.objects.filter(identidade=pk, tabela='r9012_evtretcons').all()
        
        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'output': output,
            'evento_totalizador': evento_totalizador,
            'controle_alteracoes': controle_alteracoes,
            'r9012_evtretcons': r9012_evtretcons, 
            'r9012_evtretcons_form': r9012_evtretcons_form, 
            
            'r1000_evtinfocontri_form': r1000_evtinfocontri_form,
            'r1000_evtinfocontri_lista': r1000_evtinfocontri_lista,
            'r1070_evttabprocesso_form': r1070_evttabprocesso_form,
            'r1070_evttabprocesso_lista': r1070_evttabprocesso_lista,
            'r2010_evtservtom_form': r2010_evtservtom_form,
            'r2010_evtservtom_lista': r2010_evtservtom_lista,
            'r2020_evtservprest_form': r2020_evtservprest_form,
            'r2020_evtservprest_lista': r2020_evtservprest_lista,
            'r2030_evtassocdesprec_form': r2030_evtassocdesprec_form,
            'r2030_evtassocdesprec_lista': r2030_evtassocdesprec_lista,
            'r2040_evtassocdesprep_form': r2040_evtassocdesprep_form,
            'r2040_evtassocdesprep_lista': r2040_evtassocdesprep_lista,
            'r2050_evtcomprod_form': r2050_evtcomprod_form,
            'r2050_evtcomprod_lista': r2050_evtcomprod_lista,
            'r2060_evtcprb_form': r2060_evtcprb_form,
            'r2060_evtcprb_lista': r2060_evtcprb_lista,
            'r2070_evtpgtosdivs_form': r2070_evtpgtosdivs_form,
            'r2070_evtpgtosdivs_lista': r2070_evtpgtosdivs_lista,
            'r2098_evtreabreevper_form': r2098_evtreabreevper_form,
            'r2098_evtreabreevper_lista': r2098_evtreabreevper_lista,
            'r2099_evtfechaevper_form': r2099_evtfechaevper_form,
            'r2099_evtfechaevper_lista': r2099_evtfechaevper_lista,
            'r3010_evtespdesportivo_form': r3010_evtespdesportivo_form,
            'r3010_evtespdesportivo_lista': r3010_evtespdesportivo_lista,
            'r4010_evtretpf_form': r4010_evtretpf_form,
            'r4010_evtretpf_lista': r4010_evtretpf_lista,
            'r4020_evtretpj_form': r4020_evtretpj_form,
            'r4020_evtretpj_lista': r4020_evtretpj_lista,
            'r4040_evtbenefnid_form': r4040_evtbenefnid_form,
            'r4040_evtbenefnid_lista': r4040_evtbenefnid_lista,
            'r4098_evtreab_form': r4098_evtreab_form,
            'r4098_evtreab_lista': r4098_evtreab_lista,
            'r4099_evtfech_form': r4099_evtfech_form,
            'r4099_evtfech_lista': r4099_evtfech_lista,
            'r9000_evtexclusao_form': r9000_evtexclusao_form,
            'r9000_evtexclusao_lista': r9000_evtexclusao_lista,
            'r9012_regocorrs_form': r9012_regocorrs_form,
            'r9012_regocorrs_lista': r9012_regocorrs_lista,
            'r9012_infototalcontrib_form': r9012_infototalcontrib_form,
            'r9012_infototalcontrib_lista': r9012_infototalcontrib_lista,
            'data': datetime.datetime.now(),
            'modulos': ['efdreinf', ],
            'paginas': ['r9012_evtretcons', ],
            'tabelas_secundarias': tabelas_secundarias,
            'tab': tab,
            #r9012_evtretcons_salvar_custom_variaveis_context#
        }
        
            
        if output == 'pdf':
        
            response = PDFTemplateResponse(
                request=request,
                template='r9012_evtretcons_salvar.html',
                filename="r9012_evtretcons.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('r9012_evtretcons_salvar.html', context)
            filename = "r9012_evtretcons.xls"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            
            return response
            
        else:
        
            return render(request, 'r9012_evtretcons_salvar.html', context)
            
    else:
    
        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'tab': tab,
            'output': output,
            'modulos': ['efdreinf', ],
            'paginas': ['r9012_evtretcons', ],
            'data': datetime.datetime.now(),
        }
        
        return render(request, 'permissao_negada.html', context)
示例#4
0
def gerar_xml_assinado(request, pk):

    from emensageriapro.settings import BASE_DIR
    from emensageriapro.mensageiro.functions.funcoes import salvar_arquivo_esocial
    from emensageriapro.mensageiro.functions.funcoes_esocial import assinar_esocial

    s2405_evtcdbenefalt = get_object_or_404(s2405evtCdBenefAlt, id=pk)

    if not s2405_evtcdbenefalt.identidade:
        from emensageriapro.functions import identidade_evento
        ident = identidade_evento(s2405_evtcdbenefalt, 'esocial')
        s2405_evtcdbenefalt = get_object_or_404(s2405evtCdBenefAlt, id=pk)

    if s2405_evtcdbenefalt.arquivo_original:
        xml = ler_arquivo(s2405_evtcdbenefalt.arquivo)

    else:
        xml = gerar_xml_s2405(request, pk)

    STATUS_ANT = [
        STATUS_EVENTO_CADASTRADO, STATUS_EVENTO_IMPORTADO,
        STATUS_EVENTO_DUPLICADO, STATUS_EVENTO_GERADO
    ]

    if 'Signature' in xml and s2405_evtcdbenefalt.status in STATUS_ANT:

        xml_assinado = xml
        s2405evtCdBenefAlt.objects.\
            filter(id=pk).update(status=STATUS_EVENTO_ASSINADO)

    else:

        if not s2405_evtcdbenefalt.transmissor_lote_esocial:

            from emensageriapro.mapa_processamento.views.funcoes_automaticas_esocial \
                import vincular_transmissor_esocial, criar_transmissor_esocial, get_grupo

            grupo = get_grupo(s2405evtCdBenefAlt)

            criar_transmissor_esocial(request, grupo,
                                      s2405_evtcdbenefalt.nrinsc,
                                      s2405_evtcdbenefalt.tpinsc)

            vincular_transmissor_esocial(request, grupo, s2405evtCdBenefAlt,
                                         s2405_evtcdbenefalt)

        s2405_evtcdbenefalt = get_object_or_404(s2405evtCdBenefAlt, id=pk)

        xml_assinado = assinar_esocial(
            request, xml, s2405_evtcdbenefalt.transmissor_lote_esocial_id)

        if 'Signature' in xml_assinado and s2405_evtcdbenefalt.status in STATUS_ANT:

            s2405evtCdBenefAlt.objects.\
                filter(id=pk).update(status=STATUS_EVENTO_ASSINADO)

        elif s1000evtInfoEmpregador.status in STATUS_ANT:

            s2405evtCdBenefAlt.objects.\
                filter(id=pk).update(status=STATUS_EVENTO_GERADO)

    arquivo = '/arquivos/Eventos/s2405_evtcdbenefalt/%s.xml' % (
        s2405_evtcdbenefalt.identidade)
    os.system('mkdir -p %s/arquivos/Eventos/s2405_evtcdbenefalt/' % BASE_DIR)

    if not os.path.exists(BASE_DIR + arquivo):

        salvar_arquivo_esocial(arquivo, xml_assinado, 1)

    xml_assinado = ler_arquivo(arquivo)

    return xml_assinado
示例#5
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:

        s1280_evtinfocomplper = get_object_or_404(s1280evtInfoComplPer, id=pk)

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

        if pk:

            s1280_evtinfocomplper_form = form_s1280_evtinfocomplper(
                request.POST or None,
                instance=s1280_evtinfocomplper,
                initial={'ativo': True})

        else:

            s1280_evtinfocomplper_form = form_s1280_evtinfocomplper(
                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 s1280_evtinfocomplper_form.is_valid():

                obj = s1280_evtinfocomplper_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 's1280-evtinfocomplper' not in request.session[
                            'return_page']:

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

                if pk != obj.id:

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

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

        s1280_evtinfocomplper_form = disabled_form_fields(
            s1280_evtinfocomplper_form,
            request.user.has_perm('esocial.change_s1280evtInfoComplPer'))

        if pk:

            if s1280_evtinfocomplper.status != 0:

                s1280_evtinfocomplper_form = disabled_form_fields(
                    s1280_evtinfocomplper_form, False)

        for field in s1280_evtinfocomplper_form.fields.keys():

            s1280_evtinfocomplper_form.fields[field].widget.attrs[
                'ng-model'] = 's1280_evtinfocomplper_' + field

        if output:

            s1280_evtinfocomplper_form = disabled_form_for_print(
                s1280_evtinfocomplper_form)

        s1280_infosubstpatr_lista = None
        s1280_infosubstpatr_form = None
        s1280_infosubstpatropport_lista = None
        s1280_infosubstpatropport_form = None
        s1280_infoativconcom_lista = None
        s1280_infoativconcom_form = None

        if pk:

            s1280_evtinfocomplper = get_object_or_404(s1280evtInfoComplPer,
                                                      id=pk)

            s1280_infosubstpatr_form = form_s1280_infosubstpatr(
                initial={'s1280_evtinfocomplper': s1280_evtinfocomplper})
            s1280_infosubstpatr_form.fields[
                's1280_evtinfocomplper'].widget.attrs['readonly'] = True
            s1280_infosubstpatr_lista = s1280infoSubstPatr.objects.\
                filter(s1280_evtinfocomplper_id=s1280_evtinfocomplper.id).all()
            s1280_infosubstpatropport_form = form_s1280_infosubstpatropport(
                initial={'s1280_evtinfocomplper': s1280_evtinfocomplper})
            s1280_infosubstpatropport_form.fields[
                's1280_evtinfocomplper'].widget.attrs['readonly'] = True
            s1280_infosubstpatropport_lista = s1280infoSubstPatrOpPort.objects.\
                filter(s1280_evtinfocomplper_id=s1280_evtinfocomplper.id).all()
            s1280_infoativconcom_form = form_s1280_infoativconcom(
                initial={'s1280_evtinfocomplper': s1280_evtinfocomplper})
            s1280_infoativconcom_form.fields[
                's1280_evtinfocomplper'].widget.attrs['readonly'] = True
            s1280_infoativconcom_lista = s1280infoAtivConcom.objects.\
                filter(s1280_evtinfocomplper_id=s1280_evtinfocomplper.id).all()

        else:

            s1280_evtinfocomplper = None

        tabelas_secundarias = []

        controle_alteracoes = Auditoria.objects.filter(
            identidade=pk, tabela='s1280_evtinfocomplper').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,
            's1280_evtinfocomplper': s1280_evtinfocomplper,
            's1280_evtinfocomplper_form': s1280_evtinfocomplper_form,
            's1280_infosubstpatr_form': s1280_infosubstpatr_form,
            's1280_infosubstpatr_lista': s1280_infosubstpatr_lista,
            's1280_infosubstpatropport_form': s1280_infosubstpatropport_form,
            's1280_infosubstpatropport_lista': s1280_infosubstpatropport_lista,
            's1280_infoativconcom_form': s1280_infoativconcom_form,
            's1280_infoativconcom_lista': s1280_infoativconcom_lista,
            'data': datetime.datetime.now(),
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's1280_evtinfocomplper',
            ],
            'tabelas_secundarias': tabelas_secundarias,
            'tab': tab,
        }

        if output == 'pdf':

            response = PDFTemplateResponse(
                request=request,
                template='s1280_evtinfocomplper_salvar.html',
                filename="s1280_evtinfocomplper.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('s1280_evtinfocomplper_salvar.html',
                                          context)
            filename = "s1280_evtinfocomplper.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        else:

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

    else:

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

        return render(request, 'permissao_negada.html', context)
示例#6
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s5012evtIrrf, id=pk)
    ident = identidade_evento(obj)

    return HttpResponse(ident)
示例#7
0
def gerar_xml_assinado(request, pk):

    from emensageriapro.settings import BASE_DIR
    from emensageriapro.mensageiro.functions.funcoes import salvar_arquivo_efdreinf
    from emensageriapro.mensageiro.functions.funcoes_efdreinf import assinar_efdreinf

    r2030_evtassocdesprec = get_object_or_404(r2030evtAssocDespRec, id=pk)

    if not r2030_evtassocdesprec.identidade:
        from emensageriapro.functions import identidade_evento
        ident = identidade_evento(r2030_evtassocdesprec, 'efdreinf')
        r2030_evtassocdesprec = get_object_or_404(r2030evtAssocDespRec, id=pk)

    if r2030_evtassocdesprec.arquivo_original:
        xml = ler_arquivo(r2030_evtassocdesprec.arquivo)

    else:
        xml = gerar_xml_r2030(request, pk)

    STATUS_ANT = [
        STATUS_EVENTO_CADASTRADO, STATUS_EVENTO_IMPORTADO,
        STATUS_EVENTO_DUPLICADO, STATUS_EVENTO_GERADO
    ]

    if 'Signature' in xml and r2030_evtassocdesprec.status in STATUS_ANT:

        xml_assinado = xml
        r2030evtAssocDespRec.objects.\
            filter(id=pk).update(status=STATUS_EVENTO_ASSINADO)

    else:

        if not r2030_evtassocdesprec.transmissor_lote_efdreinf:

            from emensageriapro.mapa_processamento.views.funcoes_automaticas_efdreinf \
                import vincular_transmissor_efdreinf, criar_transmissor_efdreinf, get_grupo

            grupo = get_grupo(r2030evtAssocDespRec)

            criar_transmissor_efdreinf(request, grupo,
                                       r2030_evtassocdesprec.nrinsc,
                                       r2030_evtassocdesprec.tpinsc)

            vincular_transmissor_efdreinf(request, grupo, r2030evtAssocDespRec,
                                          r2030_evtassocdesprec)

        r2030_evtassocdesprec = get_object_or_404(r2030evtAssocDespRec, id=pk)

        xml_assinado = assinar_efdreinf(
            request, xml, r2030_evtassocdesprec.transmissor_lote_efdreinf_id)

        if 'Signature' in xml_assinado and r2030_evtassocdesprec.status in STATUS_ANT:

            r2030evtAssocDespRec.objects.\
                filter(id=pk).update(status=STATUS_EVENTO_ASSINADO)

        elif s1000evtInfoEmpregador.status in STATUS_ANT:

            r2030evtAssocDespRec.objects.\
                filter(id=pk).update(status=STATUS_EVENTO_GERADO)

    arquivo = '/arquivos/Eventos/r2030_evtassocdesprec/%s.xml' % (
        r2030_evtassocdesprec.identidade)
    os.system('mkdir -p %s/arquivos/Eventos/r2030_evtassocdesprec/' % BASE_DIR)

    if not os.path.exists(BASE_DIR + arquivo):

        salvar_arquivo_efdreinf(arquivo, xml_assinado, 1)

    xml_assinado = ler_arquivo(arquivo)

    return xml_assinado
示例#8
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s1295evtTotConting, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)
示例#9
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s2399evtTSVTermino, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)
示例#10
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s1202evtRmnRPPS, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)
示例#11
0
def limpar_base(request, pk):

    from emensageriapro.esocial.views.s1000_evtinfoempregador_importar import read_s1000_evtinfoempregador_string
    from emensageriapro.esocial.views.s1000_evtinfoempregador_gerar_xml import gerar_xml_s1000
    from emensageriapro.s1000.models import s1000inclusao
    from emensageriapro.functions import identidade_evento

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

        if pk:

            s1000_evtinfoempregador = get_object_or_404(s1000evtInfoEmpregador,
                                                        id=pk)

            texto = gerar_xml_s1000(request, pk, versao="|")
            dados = read_s1000_evtinfoempregador_string(
                request, {}, texto.encode('utf-8'), 0)
            nova_identidade = identidade_evento(s1000_evtinfoempregador,
                                                'esocial')

            s1000evtInfoEmpregador.objects.\
                filter(id=dados['id']).\
                update(status=STATUS_EVENTO_CADASTRADO,
                       arquivo_original=0,
                       tpamb=2,
                       arquivo='')

            s1000inclusao.objects.\
                filter(s1000_evtinfoempregador_id=dados['id']).\
                update(nmrazao='RemoverEmpregadorDaBaseDeDadosDaProducaoRestrita',
                       natjurid=None,
                       inivalid='2019-01',
                       classtrib='00')

            gravar_auditoria(
                u'{}',
                u'{"funcao": "Evento de limpeza de base de produção restrita de identidade %s criado a partir da duplicação do evento %s"}'
                % (nova_identidade, s1000_evtinfoempregador.identidade),
                's1000_evtinfoempregador', dados['id'], request.user.id, 1)

            messages.success(
                request, u'''Evento de limpeza de base de produção 
                                          restrita criado com sucesso! 
                                          Valide, envie o evento e verifique o retorno!'''
            )
            return_pk = dados['id']

            return redirect('s1000_evtinfoempregador_salvar', pk=return_pk)

        messages.error(request, 'Erro ao duplicar evento!')

        return redirect('s1000_evtinfoempregador_salvar', pk=pk)

    else:

        messages.error(
            request, u'''Você não possui permissão para duplicar o evento.
                                    Entre em contato com o administrador do sistema!'''
        )

        return redirect('s1000_evtinfoempregador_salvar', pk=pk)
示例#12
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(r3010evtEspDesportivo, id=pk)
    ident = identidade_evento(obj, 'efdreinf')

    return HttpResponse(ident)
示例#13
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s5001evtBasesTrab, id=pk)
    ident = identidade_evento(obj)

    return HttpResponse(ident)
示例#14
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s3000evtExclusao, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)
示例#15
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(r2098evtReabreEvPer, id=pk)
    ident = identidade_evento(obj, 'efdreinf')

    return HttpResponse(ident)
示例#16
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(r1070evtTabProcesso, id=pk)
    ident = identidade_evento(obj, 'efdreinf')

    return HttpResponse(ident)
示例#17
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:
    
        s5011_evtcs = get_object_or_404(s5011evtCS, id=pk)

        if s5011_evtcs.status != STATUS_EVENTO_CADASTRADO:
        
            dict_permissoes = {}
            dict_permissoes['s5011_evtcs_apagar'] = 0
            dict_permissoes['s5011_evtcs_editar'] = 0
            
    if request.user.has_perm('esocial.can_see_s5011evtCS'):
    
        if pk:
        
            s5011_evtcs_form = form_s5011_evtcs(request.POST or None, instance = s5011_evtcs, 
                                         initial={'ativo': True})
                                         
        else:
        
            s5011_evtcs_form = form_s5011_evtcs(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 s5011_evtcs_form.is_valid():
            
                obj = s5011_evtcs_form.save(request=request)
                messages.success(request, u'Salvo com sucesso!')
                
                if not pk:
                
                    from emensageriapro.functions import identidade_evento
                    identidade_evento(obj)
                  
                    gravar_auditoria('{}',
                                 json.dumps(model_to_dict(obj), indent=4, sort_keys=True, default=str), 
                                 's5011_evtcs', obj.id, request.user.id, 1)
                else:
                
                    gravar_auditoria(json.dumps(model_to_dict(s5011_evtcs), indent=4, sort_keys=True, default=str),
                                     json.dumps(model_to_dict(obj), indent=4, sort_keys=True, default=str), 
                                     's5011_evtcs', pk, request.user.id, 2)
                                 
                if request.session['return_page'] not in (
                    's5011_evtcs_apagar', 
                    's5011_evtcs_salvar', 
                    's5011_evtcs'):
                    
                    return redirect(
                        request.session['return_page'], 
                        pk=request.session['return_pk'])
                    
                if pk != obj.id:
                
                    return redirect(
                        's5011_evtcs_salvar', 
                        pk=obj.id)

            else:
                messages.error(request, u'Erro ao salvar!')
                
        s5011_evtcs_form = disabled_form_fields(
             s5011_evtcs_form, 
             request.user.has_perm('esocial.change_s5011evtCS'))
        
        if pk:
        
            if s5011_evtcs.status != 0:
            
                s5011_evtcs_form = disabled_form_fields(s5011_evtcs_form, False)
                
        #s5011_evtcs_campos_multiple_passo3

        for field in s5011_evtcs_form.fields.keys():
        
            s5011_evtcs_form.fields[field].widget.attrs['ng-model'] = 's5011_evtcs_'+field
            
        if output:
        
            s5011_evtcs_form = disabled_form_for_print(s5011_evtcs_form)

        
        s5011_infocpseg_lista = None 
        s5011_infocpseg_form = None 
        s5011_infopj_lista = None 
        s5011_infopj_form = None 
        s5011_ideestab_lista = None 
        s5011_ideestab_form = None 
        s5011_infocrcontrib_lista = None 
        s5011_infocrcontrib_form = None 
        
        if pk:
        
            s5011_evtcs = get_object_or_404(s5011evtCS, id=pk)
            
            s5011_infocpseg_form = form_s5011_infocpseg(
                initial={ 's5011_evtcs': s5011_evtcs })
            s5011_infocpseg_form.fields['s5011_evtcs'].widget.attrs['readonly'] = True
            s5011_infocpseg_lista = s5011infoCPSeg.objects.\
                filter(s5011_evtcs_id=s5011_evtcs.id).all()
            s5011_infopj_form = form_s5011_infopj(
                initial={ 's5011_evtcs': s5011_evtcs })
            s5011_infopj_form.fields['s5011_evtcs'].widget.attrs['readonly'] = True
            s5011_infopj_lista = s5011infoPJ.objects.\
                filter(s5011_evtcs_id=s5011_evtcs.id).all()
            s5011_ideestab_form = form_s5011_ideestab(
                initial={ 's5011_evtcs': s5011_evtcs })
            s5011_ideestab_form.fields['s5011_evtcs'].widget.attrs['readonly'] = True
            s5011_ideestab_lista = s5011ideEstab.objects.\
                filter(s5011_evtcs_id=s5011_evtcs.id).all()
            s5011_infocrcontrib_form = form_s5011_infocrcontrib(
                initial={ 's5011_evtcs': s5011_evtcs })
            s5011_infocrcontrib_form.fields['s5011_evtcs'].widget.attrs['readonly'] = True
            s5011_infocrcontrib_lista = s5011infoCRContrib.objects.\
                filter(s5011_evtcs_id=s5011_evtcs.id).all()
                
        else:
        
            s5011_evtcs = None
            
        #s5011_evtcs_salvar_custom_variaveis#
        tabelas_secundarias = []
        #[FUNCOES_ESPECIAIS_SALVAR]
        
        if 's5011_evtcs'[1] == '5':
            evento_totalizador = True
            
        else:
            evento_totalizador = False
        
        if tab or 's5011_evtcs' in request.session['return_page']:
        
            request.session['return_pk'] = pk
            request.session['return_tab'] = tab
            request.session['return_page'] = 's5011_evtcs_salvar'
            
        controle_alteracoes = Auditoria.objects.filter(identidade=pk, tabela='s5011_evtcs').all()
        
        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'output': output,
            'evento_totalizador': evento_totalizador,
            'controle_alteracoes': controle_alteracoes,
            's5011_evtcs': s5011_evtcs, 
            's5011_evtcs_form': s5011_evtcs_form, 
            
            's5011_infocpseg_form': s5011_infocpseg_form,
            's5011_infocpseg_lista': s5011_infocpseg_lista,
            's5011_infopj_form': s5011_infopj_form,
            's5011_infopj_lista': s5011_infopj_lista,
            's5011_ideestab_form': s5011_ideestab_form,
            's5011_ideestab_lista': s5011_ideestab_lista,
            's5011_infocrcontrib_form': s5011_infocrcontrib_form,
            's5011_infocrcontrib_lista': s5011_infocrcontrib_lista,
            'data': datetime.datetime.now(),
            'modulos': ['esocial', ],
            'paginas': ['s5011_evtcs', ],
            'tabelas_secundarias': tabelas_secundarias,
            'tab': tab,
            #s5011_evtcs_salvar_custom_variaveis_context#
        }
        
            
        if output == 'pdf':
        
            response = PDFTemplateResponse(
                request=request,
                template='s5011_evtcs_salvar.html',
                filename="s5011_evtcs.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('s5011_evtcs_salvar.html', context)
            filename = "s5011_evtcs.xls"
            response['Content-Disposition'] = 'attachment; filename=' + filename
            response['Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'
            
            return response
            
        else:
        
            return render(request, 's5011_evtcs_salvar.html', context)
            
    else:
    
        context = {
            'usuario': Usuarios.objects.get(user_id=request.user.id),
            'pk': pk,
            'tab': tab,
            'output': output,
            'modulos': ['esocial', ],
            'paginas': ['s5011_evtcs', ],
            'data': datetime.datetime.now(),
        }
        
        return render(request, 'permissao_negada.html', context)
示例#18
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s2206evtAltContratual, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)
示例#19
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s1280evtInfoComplPer, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)
示例#20
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s1299evtFechaEvPer, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)
示例#21
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s1030evtTabCargo, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)
示例#22
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s2420evtCdBenTerm, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)
示例#23
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s2241evtInsApo, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)
示例#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:

        s2200_evtadmissao = get_object_or_404(s2200evtAdmissao, id=pk)

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

        if pk:

            s2200_evtadmissao_form = form_s2200_evtadmissao(
                request.POST or None,
                instance=s2200_evtadmissao,
                initial={'ativo': True})

        else:

            s2200_evtadmissao_form = form_s2200_evtadmissao(
                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 s2200_evtadmissao_form.is_valid():

                obj = s2200_evtadmissao_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 's2200-evtadmissao' not in request.session[
                            'return_page']:

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

                if pk != obj.id:

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

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

        s2200_evtadmissao_form = disabled_form_fields(
            s2200_evtadmissao_form,
            request.user.has_perm('esocial.change_s2200evtAdmissao'))

        if pk:

            if s2200_evtadmissao.status != 0:

                s2200_evtadmissao_form = disabled_form_fields(
                    s2200_evtadmissao_form, False)

        for field in s2200_evtadmissao_form.fields.keys():

            s2200_evtadmissao_form.fields[field].widget.attrs[
                'ng-model'] = 's2200_evtadmissao_' + field

        if output:

            s2200_evtadmissao_form = disabled_form_for_print(
                s2200_evtadmissao_form)

        s2200_documentos_lista = None
        s2200_documentos_form = None
        s2200_brasil_lista = None
        s2200_brasil_form = None
        s2200_exterior_lista = None
        s2200_exterior_form = None
        s2200_trabestrangeiro_lista = None
        s2200_trabestrangeiro_form = None
        s2200_infodeficiencia_lista = None
        s2200_infodeficiencia_form = None
        s2200_dependente_lista = None
        s2200_dependente_form = None
        s2200_aposentadoria_lista = None
        s2200_aposentadoria_form = None
        s2200_contato_lista = None
        s2200_contato_form = None
        s2200_infoceletista_lista = None
        s2200_infoceletista_form = None
        s2200_infoestatutario_lista = None
        s2200_infoestatutario_form = None
        s2200_localtrabgeral_lista = None
        s2200_localtrabgeral_form = None
        s2200_localtrabdom_lista = None
        s2200_localtrabdom_form = None
        s2200_horcontratual_lista = None
        s2200_horcontratual_form = None
        s2200_filiacaosindical_lista = None
        s2200_filiacaosindical_form = None
        s2200_alvarajudicial_lista = None
        s2200_alvarajudicial_form = None
        s2200_observacoes_lista = None
        s2200_observacoes_form = None
        s2200_sucessaovinc_lista = None
        s2200_sucessaovinc_form = None
        s2200_transfdom_lista = None
        s2200_transfdom_form = None
        s2200_mudancacpf_lista = None
        s2200_mudancacpf_form = None
        s2200_afastamento_lista = None
        s2200_afastamento_form = None
        s2200_desligamento_lista = None
        s2200_desligamento_form = None
        s2200_cessao_lista = None
        s2200_cessao_form = None

        if pk:

            s2200_evtadmissao = get_object_or_404(s2200evtAdmissao, id=pk)

            s2200_documentos_form = form_s2200_documentos(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_documentos_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_documentos_lista = s2200documentos.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_brasil_form = form_s2200_brasil(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_brasil_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_brasil_lista = s2200brasil.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_exterior_form = form_s2200_exterior(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_exterior_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_exterior_lista = s2200exterior.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_trabestrangeiro_form = form_s2200_trabestrangeiro(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_trabestrangeiro_form.fields[
                's2200_evtadmissao'].widget.attrs['readonly'] = True
            s2200_trabestrangeiro_lista = s2200trabEstrangeiro.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_infodeficiencia_form = form_s2200_infodeficiencia(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_infodeficiencia_form.fields[
                's2200_evtadmissao'].widget.attrs['readonly'] = True
            s2200_infodeficiencia_lista = s2200infoDeficiencia.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_dependente_form = form_s2200_dependente(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_dependente_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_dependente_lista = s2200dependente.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_aposentadoria_form = form_s2200_aposentadoria(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_aposentadoria_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_aposentadoria_lista = s2200aposentadoria.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_contato_form = form_s2200_contato(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_contato_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_contato_lista = s2200contato.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_infoceletista_form = form_s2200_infoceletista(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_infoceletista_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_infoceletista_lista = s2200infoCeletista.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_infoestatutario_form = form_s2200_infoestatutario(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_infoestatutario_form.fields[
                's2200_evtadmissao'].widget.attrs['readonly'] = True
            s2200_infoestatutario_lista = s2200infoEstatutario.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_localtrabgeral_form = form_s2200_localtrabgeral(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_localtrabgeral_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_localtrabgeral_lista = s2200localTrabGeral.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_localtrabdom_form = form_s2200_localtrabdom(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_localtrabdom_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_localtrabdom_lista = s2200localTrabDom.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_horcontratual_form = form_s2200_horcontratual(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_horcontratual_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_horcontratual_lista = s2200horContratual.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_filiacaosindical_form = form_s2200_filiacaosindical(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_filiacaosindical_form.fields[
                's2200_evtadmissao'].widget.attrs['readonly'] = True
            s2200_filiacaosindical_lista = s2200filiacaoSindical.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_alvarajudicial_form = form_s2200_alvarajudicial(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_alvarajudicial_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_alvarajudicial_lista = s2200alvaraJudicial.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_observacoes_form = form_s2200_observacoes(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_observacoes_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_observacoes_lista = s2200observacoes.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_sucessaovinc_form = form_s2200_sucessaovinc(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_sucessaovinc_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_sucessaovinc_lista = s2200sucessaoVinc.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_transfdom_form = form_s2200_transfdom(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_transfdom_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_transfdom_lista = s2200transfDom.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_mudancacpf_form = form_s2200_mudancacpf(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_mudancacpf_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_mudancacpf_lista = s2200mudancaCPF.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_afastamento_form = form_s2200_afastamento(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_afastamento_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_afastamento_lista = s2200afastamento.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_desligamento_form = form_s2200_desligamento(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_desligamento_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_desligamento_lista = s2200desligamento.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()
            s2200_cessao_form = form_s2200_cessao(
                initial={'s2200_evtadmissao': s2200_evtadmissao})
            s2200_cessao_form.fields['s2200_evtadmissao'].widget.attrs[
                'readonly'] = True
            s2200_cessao_lista = s2200cessao.objects.\
                filter(s2200_evtadmissao_id=s2200_evtadmissao.id).all()

        else:

            s2200_evtadmissao = None

        tabelas_secundarias = []

        controle_alteracoes = Auditoria.objects.filter(
            identidade=pk, tabela='s2200_evtadmissao').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,
            's2200_evtadmissao': s2200_evtadmissao,
            's2200_evtadmissao_form': s2200_evtadmissao_form,
            's2200_documentos_form': s2200_documentos_form,
            's2200_documentos_lista': s2200_documentos_lista,
            's2200_brasil_form': s2200_brasil_form,
            's2200_brasil_lista': s2200_brasil_lista,
            's2200_exterior_form': s2200_exterior_form,
            's2200_exterior_lista': s2200_exterior_lista,
            's2200_trabestrangeiro_form': s2200_trabestrangeiro_form,
            's2200_trabestrangeiro_lista': s2200_trabestrangeiro_lista,
            's2200_infodeficiencia_form': s2200_infodeficiencia_form,
            's2200_infodeficiencia_lista': s2200_infodeficiencia_lista,
            's2200_dependente_form': s2200_dependente_form,
            's2200_dependente_lista': s2200_dependente_lista,
            's2200_aposentadoria_form': s2200_aposentadoria_form,
            's2200_aposentadoria_lista': s2200_aposentadoria_lista,
            's2200_contato_form': s2200_contato_form,
            's2200_contato_lista': s2200_contato_lista,
            's2200_infoceletista_form': s2200_infoceletista_form,
            's2200_infoceletista_lista': s2200_infoceletista_lista,
            's2200_infoestatutario_form': s2200_infoestatutario_form,
            's2200_infoestatutario_lista': s2200_infoestatutario_lista,
            's2200_localtrabgeral_form': s2200_localtrabgeral_form,
            's2200_localtrabgeral_lista': s2200_localtrabgeral_lista,
            's2200_localtrabdom_form': s2200_localtrabdom_form,
            's2200_localtrabdom_lista': s2200_localtrabdom_lista,
            's2200_horcontratual_form': s2200_horcontratual_form,
            's2200_horcontratual_lista': s2200_horcontratual_lista,
            's2200_filiacaosindical_form': s2200_filiacaosindical_form,
            's2200_filiacaosindical_lista': s2200_filiacaosindical_lista,
            's2200_alvarajudicial_form': s2200_alvarajudicial_form,
            's2200_alvarajudicial_lista': s2200_alvarajudicial_lista,
            's2200_observacoes_form': s2200_observacoes_form,
            's2200_observacoes_lista': s2200_observacoes_lista,
            's2200_sucessaovinc_form': s2200_sucessaovinc_form,
            's2200_sucessaovinc_lista': s2200_sucessaovinc_lista,
            's2200_transfdom_form': s2200_transfdom_form,
            's2200_transfdom_lista': s2200_transfdom_lista,
            's2200_mudancacpf_form': s2200_mudancacpf_form,
            's2200_mudancacpf_lista': s2200_mudancacpf_lista,
            's2200_afastamento_form': s2200_afastamento_form,
            's2200_afastamento_lista': s2200_afastamento_lista,
            's2200_desligamento_form': s2200_desligamento_form,
            's2200_desligamento_lista': s2200_desligamento_lista,
            's2200_cessao_form': s2200_cessao_form,
            's2200_cessao_lista': s2200_cessao_lista,
            'data': datetime.datetime.now(),
            'modulos': [
                'esocial',
            ],
            'paginas': [
                's2200_evtadmissao',
            ],
            'tabelas_secundarias': tabelas_secundarias,
            'tab': tab,
        }

        if output == 'pdf':

            response = PDFTemplateResponse(
                request=request,
                template='s2200_evtadmissao_salvar.html',
                filename="s2200_evtadmissao.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('s2200_evtadmissao_salvar.html',
                                          context)
            filename = "s2200_evtadmissao.xls"
            response[
                'Content-Disposition'] = 'attachment; filename=' + filename
            response[
                'Content-Type'] = 'application/vnd.ms-excel; charset=UTF-8'

            return response

        else:

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

    else:

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

        return render(request, 'permissao_negada.html', context)
示例#25
0
def validar_evento_funcao(request, pk):

    from emensageriapro.padrao import executar_sql
    from emensageriapro.functions import get_versao_evento
    from emensageriapro.settings import BASE_DIR
    from emensageriapro.mensageiro.functions.funcoes_validacoes_precedencia import validar_precedencia
    from emensageriapro.mensageiro.functions.funcoes_validacoes import get_schema_name, validar_schema
    from emensageriapro.efdreinf.views.r2099_evtfechaevper_gerar_xml import gerar_xml_assinado

    VERIFICAR_PREDECESSAO_ANTES_ENVIO = config.EFDREINF_VERIFICAR_PREDECESSAO_ANTES_ENVIO

    lista_validacoes = []
    r2099_evtfechaevper = get_object_or_404(r2099evtFechaEvPer, id=pk)

    if not r2099_evtfechaevper.identidade:
        from emensageriapro.functions import identidade_evento
        ident = identidade_evento(r2099_evtfechaevper, 'efdreinf')
        r2099_evtfechaevper = get_object_or_404(r2099evtFechaEvPer, id=pk)

    #
    # Validações internas
    #

    arquivo = '/arquivos/Eventos/r2099_evtfechaevper/%s.xml' % (r2099_evtfechaevper.identidade)

    os.system('mkdir -p %s/arquivos/Eventos/r2099_evtfechaevper/' % BASE_DIR)
    lista = []
    tipo = 'efdreinf'

    if not os.path.exists(BASE_DIR + arquivo):

        gerar_xml_assinado(request, pk)

    if os.path.exists(BASE_DIR + arquivo):

        from emensageriapro.efdreinf.views.r2099_evtfechaevper_validar import validacoes_r2099_evtfechaevper

        texto_xml = ler_arquivo(arquivo).replace("s:", "")
        versao = get_versao_evento(texto_xml)
        lista = validacoes_r2099_evtfechaevper(arquivo)

    for a in lista:

        if a:

            lista_validacoes.append(a)

    #
    # validando schema
    #

    schema_filename = 'efdreinf/%s/evtFechaEvPer.xsd' % (r2099_evtfechaevper.versao)
    quant_erros, error_list = validar_schema(request, schema_filename, arquivo, lang='pt')

    for a in error_list:

        if a:

            lista_validacoes.append(a)

    #
    #
    #

    if lista_validacoes:

        validacoes = '<br>'.join(lista_validacoes).replace("'", "''")

        r2099evtFechaEvPer.objects.\
            filter(id=pk).\
            update(validacoes=validacoes,
                   status=STATUS_EVENTO_VALIDADO_ERRO)

        messages.error(request,
            u'Validações foram processadas, porém foram encontrados erros!')

    else:

        from emensageriapro.mensageiro.functions.funcoes_validacoes_precedencia import EVENTOS_SEM_PREDECESSAO, validar_precedencia

        if VERIFICAR_PREDECESSAO_ANTES_ENVIO and 'r2099_evtfechaevper' not in EVENTOS_SEM_PREDECESSAO:

            quant = validar_precedencia('r2099_evtfechaevper', pk)

            if quant <= 0:

                r2099evtFechaEvPer.objects.\
                    filter(id=pk).\
                    update(validacoes=None,
                           status=STATUS_EVENTO_AGUARD_PRECEDENCIA)

                messages.warning(request,
                    u'Validações foram processadas com sucesso, porém o evento está aguardando envio de sua precedência!')

            else:

                r2099evtFechaEvPer.objects.\
                    filter(id=pk).\
                    update(validacoes=None,
                           status=STATUS_EVENTO_AGUARD_ENVIO)

                messages.success(request,
                    u'Validações foram processadas com sucesso, evento está aguardandando envio!')

        else:

            r2099evtFechaEvPer.objects. \
                filter(id=pk).\
                update(validacoes=None,
                       status=STATUS_EVENTO_AGUARD_ENVIO)

            messages.success(request,
                u'Validações foram processadas com sucesso, evento está aguardandando envio!')

    return lista_validacoes
示例#26
0
def gerar_identidade(request, pk):

    obj = get_object_or_404(s2230evtAfastTemp, id=pk)
    ident = identidade_evento(obj, 'esocial')

    return HttpResponse(ident)