`oSc@sddlTddlmZddlTddlTddlTddlTddlTddlmZddl Tddl Tddl Tddl m Z ddlmZddlmZddlmZdd lmZdd lmZdd l mZdd lZdd lmZddlmZddlmZddlm Z m!Z!ddl m"Z"ddl m Z dd l Z ddl m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)dd l*Z+dd l,Z,dd l-Z-dZ.dZ/dZ0dZ1e2dddZ3dd lmZedZ4edZ5d Z6d!Z7d"Z8d#Z9d$Z:d%Z;d&Z<d'Z=d(Z>d)Z?d*Z@d+ZAd,ZBd-ZCd.ZDd/ZEd0ZFd S(1i(t*(trender_to_response(tUser(tmessages(tformats(tListViewi(tDatosGenerales(tcsrf(t csrf_exempt(tQN(t serializers(tUserCreationForm(tTemplateResponse(t format_htmltformat_html_join(tdate(tdatetime(t timedelta(thttp(t get_template(tContextcCs t|dS(Ns login.html(R (trequest((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytlogin_,scCs|jd}|jd}td|d|}|dk rn|jr[t||tdStj|dntj|dt|dS(Ntusernametpasswords/indexscuenta desactivadas-Usuario no valido, verifique sus credencialess login.html( tPOSTt authenticatetNonet is_activetlogintHttpResponseRedirectRterrorR (RRRtuser((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pyt validarView0s      cCst|}tdS(Ns/login(tlogoutR(Rtresponse((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pyt logout_user@s cCs,t|didd6dd6dd6dd6S(Ns index.htmltactivet principaltclosedt Dependenciat evaluaciont configuracion(R (R((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytindexDst login_urls/logincCstddt|S(Nsprincipal.htmltcontext_instance(RtRequestContext(R((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pyR&HscCs|jrs|jdkr$d}qs|jdkrs|jd}tjdtjjjd|dd }qsnt |d d S( NtGETseste se envio via getRt id_municipiotjsont municipiotfieldstidtnombretmimetypesapplication/javascript(sidsnombre( tis_ajaxtmethodRR t serializet Localidadtobjectstalltfiltert HttpResponse(RtrespuestR0tpartidas((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytconsultarLocalidadOs   3cCs|jrs|jdkr$d}qs|jdkrs|jd}tjdtjjjd|dd }qsnt |d d S( NR/seste se envio via getRtid_giroR1tgiroR3R4R5R6sapplication/javascript(sidsnombre( R7R8RR R9tActividadEspecificaR;R<R=R>(RR?RBR@((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytconsultarActividadEspecifica[s   3c Csttjj}|dkrt|}t|}|dkrL|d}n|dkrut|d}d|}n|dkr|d}qnd}tjj}|jdkr#t|j}y3|j r|j }t dt|j SWq9t k r}tj||jq9Xntd i|d 6}i|d 6|d 6d d 6dd 6} td| dt|S(Nii ii t0t01Rs /wizard_pdf/tinitialtfoliot formDocumentoR%tabastot desactivos wizard.htmlR-(RR;tcounttinttstrR<R8tDocumentosFormRtis_validtsaveRR4t ExceptionRRtmessageRR.( RRItultimotcadenat consecutivotdatosRJt documentotetcontexto((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytwizardzzs0          "cCs5tjjd|}tdi|d6dt|S(Ntpkspre_view_pdf.htmltpdfR-(RR;tgetRR.(Rt id_documentotdocume((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytpre_viewscCs|}tjj}tjjd|}tjjd|}|jdkrt|j}|jr|jt j |dt d|Sn t}t di|j d6|d6|d6d d 6d t|S( NR4RsEmpresa Validadas /recibo/%s/svalidacion_credito.htmlRXtmostrart formValidaR'R&R-(RR;R<R_R8tValidacionFormRRQRRRtsuccessRRR4R.(Rt id_personatid_validacionEmpresatdatosGeneralesRXtdatosgeneralesRd((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytregistra_validacions   cCstjjd|}|jdkrtdi |jd6|jd6|jd6|jd6|j d6|j d 6|j d 6|j d 6|j d 6|jd 6|jd6|jd6}ni|d6|d6}td|dt|S(NR4R/RHtrfctcurpt nombreNegociotnombreEmpresariotapellidoPaternotapellidoMaternot tipoVialidadtnombreVialidadtnumeroExterior1ttipo_AsentamientoHumanotnombreAsentamientoHumanot codigoPostalRJtpersonasrecibo_pymes.htmlR-(RR;R_R8RPRlRmRnRoRpRqRrRsRtRuRvRwRR.(RRgRxRJR[((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pyt recibo_pymess"            cCstjjd}tjj}|jdkrt|j}y:|jrx|jd}t j ||t dSWqt k r}t j ||jqXn t}i|d6|d6|d6dd6d d6}td |d t|S( NRIRs<El registro domicilio de la empresa se ingreso correctamentes/indexRJRjR%RKRLs consulta.htmlR-(RR;torder_byR<R8RPRRQRRRRfRRSRRTRR.(RRIRjRJtmsjRZR[((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytconsultas   )cCstjjtdttdtB}tjjd|}tjjd|}|jdkrtdi<|j d6|j d6|j d6|j d 6|j d 6|jd 6|jd 6|jd 6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|jd6|j d6|j!d6|j"d6|j#d 6|j$d!6|j%d"6|j&d#6|j'd$6|j(d%6|j)d&6|j*d'6|j+d(6|j,d)6|j-d*6|j.d+6|j/d,6|j0d-6|j1d.6|j2d/6|j3d06|j4d16|j5d26|j6d36|j7d46|j8d56|j9d66|j:d76|j;d86|j<d96|j=d:6|j>d;6|j?d<6|j@d=6|jAd>6|jBd?6|jCd@6|jDdA6}n|jdkrdtEdi |jFd6|jGd6|jHdB6|jIdC6|jJdD6|jKdE6|jLdF6|jMdG6|jNdH6|jOdI6|jPdJ6|jQdK6}n|jdLkrt|jR}tE|jR}ni|dM6|dN6|dO6|dP6}tSdQ|dRtT|S(SNtvalidacionCreditotvalidacionApoyoDirectoR4R/RHtidentificacionttipoIdentificaciontcurPtrfCtcomprobanteDomiciliot tipoPersonaRlRmRntanotmesesRoRpRqtgenerottelefonotcelulartcorreoElectronicoR2t localidadRrRsRttnumeroExterior2tnumeroInteriorRuRvRwt tipoVialidad1tnombreVialidad1t tipoVialidad2tnombreVialidad2t tipoVialidad3tnombreVialidad3tdescripcionUbicaciont tipoSectorRCtactividadEspecificatturismotorganizacionEmpresarialt ventaAnualtnoEmpleadoHombretnoEmpleadoMujert totalEmpleadot tamanoEmpresat tipoLocaltinfraestructurAt maquinaEquipot inventariOt economicotinfraestructurat maquinariat inventariot danoEconomicotsubtotalFisiccottotalMontoEstimadotRequiereCreditoEmpresatbancotmontoRequeridotcreditotfechaValidacionttipoDanot observaciontnombreValidadort montoVentast montoCostostutilidadtnuevoMontoCreditot enOperacionttipoRRJRxRdRjscon.htmlR-(UtvalidacionEmpresaR;R=R tTrueRR_R8RPRRRRRRRlRmRnRRRoRpRqRRRRR2RRrRsRtRRRuRvRwRRRRRRRRRCRRRRRRRRRRRRRRRRRRRRRRRReR~R}RRRRRRRRRRRRR.(RRgRjRxt validadorRJRdR[((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytconsulta_registros(                                                                        "cCsJtjj}tjjd|}i|d6}td|dt|S(Ntvalidacionempresa__intvalidacionempresasvalidacion_Empresa.htmlR-(RR;R<RtexcludeRR.(RtvalidaRR[((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pyt validacionBs cCstjjtdttdtB}|jdkr_t|j}t|j}t dSt}t}i|d6|d6|d6}t d|d t |S( NR}R~Rs /consultaRjRJRdsconsulta_validados.htmlR-( RR;R=R RR8RPRReRRR.(RRjRJRdR[((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pyt validadosMs(   cCstjjd|}t|jd|}|jrV|j}|jtdStd|}tdi|d6dt |S(NR4tinstances /validados/spersona_update.htmltformR-( RR;R_tActualizarFormRRQRRRRR.(RRgRxRtupdate_persona((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytpersona_update^s    cCsf|jjdd}|rEtd|}tjj|j}ng}tdi|d6|d6S(Ntqttfolio__icontainss consulta.htmltresultstquery(R/R_R RR;R=tdistinctR(RRtqsetR((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytsearchjs cCs{tjjd|}t|jd|}|jrL|j}tdStd|}tdi|d6dt |S(NR4Rs /validados/sconsultar_busqueda.htmlRR-( RR;R_RRRQRRRRR.(RRgRxRtbusqueda_consulta((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytconsulta_busquedavs   cCstjjd|}|jdkrTtdi|jd6|jd6|jd6}ni|d6|d6}td i|d 6d t |S( NR4R/RHRoRpRqRPtpsactualizar_recibo.htmltctxR-( RR;R_R8RPRoRpRqRR.(RRgRRR((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytactualizar_recibos   cCst|}t|}|j|}tj}tjtj|jd|}tjtj|jd|}|jstj |j ddStj dt j |S(Ns ISO-8859-1sutf-8R6sapplication/pdfsWe had some errors
%s
( RRtrendertStringIOtpisat pisaDocumenttencodeterrRR>tgetvaluetcgitescape(t template_srct context_dictttemplatetcontextthtmltresultR^((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pyt render_to_pdfs   $$ cCsEtjjd|}tjjd|}tdidd6|d6S(NR4s test_pdf.htmltA4tpagesizettest_pdf(RR;R_R(RRgt contigenpdftreporte((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pyt reporte_pdfs  cCst|}t|}|j|}tj}tjtj|jd|}tjtj|jd|}|jstj |j ddStj dt j |S(Ns ISO-8859-1sutf-8R6sapplication/pdfsWe had some errors
%s
( RRRRRRRRRR>RRR(RRRRRRR^((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pyt pdf_to_pdfs   $$ cCsFtjjd|}tjj}tdidd6|d6|d6S(NR4srecibo_pdf.htmlRRt recibo_pdfthola(RR;R_RRttodayR(RRgRt today_date((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytreportees  cCstjjd|}tjj}d}tjjjd}tjjjd}tdidd6|d6|d 6|d 6S( NR4is%d/%m/%Y %H:%M:%Ss%d/%m/%Ysprueba_pdf.htmlRRt prueba_pdftfechatregistro(RR;R_RtnowtstrftimeR(RRgRRt UTC_OFFSETtlocal_datetimet dia_registro((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytpruebas (Gt django.httptdjango.shortcutsRtdjango.template.responsetdjango.contrib.auth.decoratorstdjango.contrib.authtalmacen.modelstdjango.contrib.auth.modelsRt almacen.formstdjango.db.modelsRtdjango.contribRt django.utilsRtdjango.views.genericRtmodelsRtdjango.core.context_processorsRtdjango.views.decorators.csrfRR R1t django.coreR tdjango.contrib.auth.formsR R tdjango.utils.htmlR RRRtdjangoRtdjango.template.loaderRtdjango.templateRt cStringIORRtosRR!R$R+tlogin_requiredR&RARER\RbRkRyR|RRRRRRRRRRRR(((s:/home/luisalfredo/Documentos/Contingencia/almacen/views.pytsr                    %     ]