Changeset 6cdfd26 in observatorio


Ignore:
Timestamp:
Jul 22, 2014, 3:20:52 PM (10 years ago)
Author:
Ing. Roldan Vargas <rvargas@…>
Branches:
master
Children:
dd2e95b
Parents:
feaffe3
Message:

eliminación de funciones dajax ya no implementadas en el sistema

File:
1 edited

Legend:

Unmodified
Added
Removed
  • procesos/apps/sigesic/ajax.py

    rb010f23 r6cdfd26  
    1717
    1818
    19 def updatecomboM(request):
    20         dajax = Dajax()
    21         cod = str(request.POST['option'])
    22        
    23         options = Municipio.objects.using('sigesic').filter(entidad = cod).order_by("nombre")
    24         optionsp = Parroquia.objects.using('sigesic').filter(codigo__startswith=cod)
    25         out = "<option value='0'>Seleccione...</option>"
    26         outp = "<option value='0'>Seleccione...</option>"
    27         if cod != "0":
    28                 for o in options:
    29                         out = "%s<option value=%s>%s</option>" % (out,o.codigo.encode('utf-8'),o.nombre.encode('utf-8'))
    30                 for o in optionsp:
    31                         outp = "%s<option value=%s>%s</option>" % (outp,o.codigo.encode('utf-8'),o.nombre.encode('utf-8'))
    32                        
    33                 dajax.script("document.getElementById('id_municipiou').disabled = false")
    34                 dajax.script("document.getElementById('id_parroquiau').value = '0'")
    35                 #dajax.script("document.getElementById('id_parroquiau').disabled = true")
    36                 dajax.assign('#id_municipiou','innerHTML',out)
    37                 dajax.assign('#id_parroquiau','innerHTML',outp)
    38                
     19def generarConsulta(request):
     20    dajax = Dajax()
     21    print request
     22
     23    # ciiuSeleccionados = request.POST['ciiuSeleccionados']
     24
     25    rif = str(request.POST['rif'])
     26
     27    narriba = str(request.POST['narriba'])
     28    nabajo = str(request.POST['nabajo'])
     29    """
     30        os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/print_prod_chain") + " --host=" + settings.DATABASES['default']['HOST'] + " --port=" + settings.DATABASES['default']['PORT'] + " --username=" + settings.DATABASES['default']['USER'] + " --password=" + settings.DATABASES['default']['PASSWORD'] + " --dbname=" + settings.DATABASES['default']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --output=" + str(request.user) + " RIF " + rif)
     31        os.system("mv -f " + os.path.join(settings.PATH, "tmp/grafico.html ") + os.path.join(settings.PATH, "templates/cadenas/" + str(request.user) + "_grafico.html") + ";")
     32        os.system("mv -f " + os.path.join(settings.PATH, "tmp/factores.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_factores.xml ") + ";")
     33        os.system("mv -f " + os.path.join(settings.PATH, "tmp/respuestas.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_respuestas.xml ") + ";")
     34        """
     35
     36    ahora = date.today().isoformat()
     37
     38    #dajax.script("window.open('"+settings.BASE_URL+"/SigesicListado?ahora="+ahora+"&ciiuSeleccionados="+ciiuSeleccionados+"')")
     39
     40    dajax.script(
     41        "window.open('" + settings.BASE_URL + "/Grafico?ciiu=" + rif + "&ahora=" + ahora + "&arriba=" + narriba + "&abajo=" + nabajo + "&usuario=" + str(
     42            request.user) + "')")
     43
     44    return dajax
     45
     46
     47def generarGrafo(request):
     48    dajax = Dajax()
     49    print request
     50
     51    # ciiuSeleccionados = request.POST['ciiuSeleccionados']
     52
     53    anyo = str(request.POST['anyo'])
     54    chequeado = str(request.POST['chequeado[]'])
     55    narriba = str(request.POST['narriba'])
     56    nabajo = str(request.POST['nabajo'])
     57    """
     58        os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/print_prod_chain") + " --host=" + settings.DATABASES['default']['HOST'] + " --port=" + settings.DATABASES['default']['PORT'] + " --username=" + settings.DATABASES['default']['USER'] + " --password=" + settings.DATABASES['default']['PASSWORD'] + " --dbname=" + settings.DATABASES['default']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --output=" + str(request.user) + " RIF " + rif)
     59        os.system("mv -f " + os.path.join(settings.PATH, "tmp/grafico.html ") + os.path.join(settings.PATH, "templates/cadenas/" + str(request.user) + "_grafico.html") + ";")
     60        os.system("mv -f " + os.path.join(settings.PATH, "tmp/factores.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_factores.xml ") + ";")
     61        os.system("mv -f " + os.path.join(settings.PATH, "tmp/respuestas.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_respuestas.xml ") + ";")
     62        """
     63
     64    ahora = date.today().isoformat()
     65
     66    #dajax.script("window.open('"+settings.BASE_URL+"/SigesicListado?ahora="+ahora+"&ciiuSeleccionados="+ciiuSeleccionados+"')")
     67    #dajax.script("window.open('"+settings.BASE_URL+"/Grafico?chequeado="+chequeado+"&ahora="+ahora+"&arriba="+narriba+"&abajo="+nabajo+"&usuario="+str(request.user)+"')")
     68
     69    return dajax
     70
     71
     72def generateGraphAdelante(request):
     73    dajax = Dajax()
     74    # print request
     75
     76    anyo = str(request.POST['anyo'])
     77    chequeado = str(request.POST['chequeado[]'])
     78    narriba = str(request.POST['narriba'])
     79    nabajo = str(request.POST['nabajo'])
     80
     81    chequeados = []
     82    productos = []
     83    chequeados = request.POST.getlist('chequeado[]')
     84    usuario = str(request.user)
     85    print chequeados
     86    prod = ""
     87    for e in chequeados:
     88        if anyo == e[0:4]:
     89            print e[0:4]
     90            productos.append(e[5:])
     91            prod = prod + " " + e[5:]
     92    print prod
     93
     94    os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH,
     95                                                                               "extapps/chains/cadenasmivadelante") + " --host=" +
     96              settings.DATABASES['sigesic']['HOST'] + " --port=" + settings.DATABASES['sigesic'][
     97        'PORT'] + " --username=" + settings.DATABASES['sigesic']['USER'] + " --password=" +
     98              settings.DATABASES['sigesic']['PASSWORD'] + " --dbname=" + settings.DATABASES['sigesic'][
     99        'NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --year=" + anyo + " --output=" + str(
     100        request.user) + " PROD" + prod)
     101    """
     102        os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/print_prod_chain") + " --host=" + settings.DATABASES['default']['HOST'] + " --port=" + settings.DATABASES['default']['PORT'] + " --username=" + settings.DATABASES['default']['USER'] + " --password=" + settings.DATABASES['default']['PASSWORD'] + " --dbname=" + settings.DATABASES['default']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --output=" + str(request.user) + " RIF " + rif)
     103        os.system("mv -f " + os.path.join(settings.PATH, "tmp/grafico.html ") + os.path.join(settings.PATH, "templates/cadenas/" + str(request.user) + "_grafico.html") + ";")
     104        os.system("mv -f " + os.path.join(settings.PATH, "tmp/factores.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_factores.xml ") + ";")
     105        os.system("mv -f " + os.path.join(settings.PATH, "tmp/respuestas.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_respuestas.xml ") + ";")
     106        """
     107
     108    ahora = date.today().isoformat()
     109
     110    #dajax.script("window.open('"+settings.BASE_URL+"/SigesicListado?ahora="+ahora+"&ciiuSeleccionados="+ciiuSeleccionados+"')")
     111    dajax.script(
     112        "window.open('" + settings.BASE_URL + "/Graficarv2?prod=" + prod + "&ahora=" + ahora + "&anyo=" + anyo + "&narriba=" + narriba + "&nabajo=" + nabajo + "&usuario=" + str(
     113            request.user) + "')")
     114
     115    return dajax
     116
     117
     118def generateGraphAtras(request):
     119    dajax = Dajax()
     120    # print request
     121
     122    anyo = str(request.POST['anyo'])
     123    chequeado = str(request.POST['chequeado[]'])
     124    narriba = str(request.POST['narriba'])
     125    nabajo = str(request.POST['nabajo'])
     126
     127    chequeados = []
     128    productos = []
     129    chequeados = request.POST.getlist('chequeado[]')
     130    usuario = str(request.user)
     131
     132    print chequeados
     133    prod = ""
     134    for e in chequeados:
     135        if anyo == e[0:4]:
     136            print e[0:4]
     137            productos.append(e[5:])
     138            prod = prod + " " + e[5:]
     139
     140    os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH,
     141                                                                               "extapps/chains/cadenasmivatras") + " --host=" +
     142              settings.DATABASES['sigesic']['HOST'] + " --port=" + settings.DATABASES['sigesic'][
     143        'PORT'] + " --username=" + settings.DATABASES['sigesic']['USER'] + " --password=" +
     144              settings.DATABASES['sigesic']['PASSWORD'] + " --dbname=" + settings.DATABASES['sigesic'][
     145        'NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --year=" + anyo + " --output=" + str(
     146        request.user) + "_adelante" + " PROD" + prod)
     147    """
     148        os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/print_prod_chain") + " --host=" + settings.DATABASES['default']['HOST'] + " --port=" + settings.DATABASES['default']['PORT'] + " --username=" + settings.DATABASES['default']['USER'] + " --password=" + settings.DATABASES['default']['PASSWORD'] + " --dbname=" + settings.DATABASES['default']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --output=" + str(request.user) + " RIF " + rif)
     149        os.system("mv -f " + os.path.join(settings.PATH, "tmp/grafico.html ") + os.path.join(settings.PATH, "templates/cadenas/" + str(request.user) + "_grafico.html") + ";")
     150        os.system("mv -f " + os.path.join(settings.PATH, "tmp/factores.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_factores.xml ") + ";")
     151        os.system("mv -f " + os.path.join(settings.PATH, "tmp/respuestas.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_respuestas.xml ") + ";")
     152        """
     153
     154    ahora = date.today().isoformat()
     155
     156    #dajax.script("window.open('"+settings.BASE_URL+"/SigesicListado?ahora="+ahora+"&ciiuSeleccionados="+ciiuSeleccionados+"')")
     157    dajax.script(
     158        "window.open('" + settings.BASE_URL + "/Graficarv3?prod=" + prod + "&ahora=" + ahora + "&anyo=" + anyo + "&narriba=" + narriba + "&nabajo=" + nabajo + "&usuario=" + str(
     159            request.user) + "')")
     160
     161    return dajax
     162
     163
     164def generateGraphAdelanteParaCanviz(request):
     165    dajax = Dajax()
     166    # print request
     167
     168    anyo = str(request.POST['anyo'])
     169    chequeado = str(request.POST['chequeado[]'])
     170    narriba = str(request.POST['narriba'])
     171    nabajo = str(request.POST['nabajo'])
     172
     173    chequeados = []
     174    productos = []
     175    chequeados = request.POST.getlist('chequeado[]')
     176    usuario = str(request.user)
     177    print chequeados
     178    prod = ""
     179    for e in chequeados:
     180        if anyo == e[0:4]:
     181            print e[0:4]
     182            productos.append(e[5:])
     183            prod = prod + " " + e[5:]
     184    print prod
     185
     186    comando = "cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH,
     187                                                                               "extapps/chains/cadenasmivadelantecanviz") + " --host=" + \
     188              settings.DATABASES['sigesic']['HOST'] + " --port=" + settings.DATABASES['sigesic'][
     189                  'PORT'] + " --username=" + settings.DATABASES['sigesic']['USER'] + " --password=" + \
     190              settings.DATABASES['sigesic']['PASSWORD'] + " --dbname=" + settings.DATABASES['sigesic'][
     191                  'NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --year=" + anyo + " --output=" + str(
     192        request.user) + " PROD" + prod
     193
     194    print comando
     195
     196    os.system(comando)
     197
     198    ahora = date.today().isoformat()
     199
     200    dajax.script(
     201        "window.open('" + settings.BASE_URL + "/GraficarCanviz/adelante?prod=" + prod + "&ahora=" + ahora + "&anyo=" + anyo + "&narriba=" + narriba + "&nabajo=" + nabajo + "&usuario=" + str(
     202            request.user) + "')")
     203
     204    return dajax
     205
     206
     207def generateGraphAtrasParaCanviz(request):
     208    dajax = Dajax()
     209    # print request
     210
     211    anyo = str(request.POST['anyo'])
     212    chequeado = str(request.POST['chequeado[]'])
     213    narriba = str(request.POST['narriba'])
     214    nabajo = str(request.POST['nabajo'])
     215
     216    chequeados = []
     217    productos = []
     218    chequeados = request.POST.getlist('chequeado[]')
     219    usuario = str(request.user)
     220
     221    print chequeados
     222    prod = ""
     223    for e in chequeados:
     224        if anyo == e[0:4]:
     225            print e[0:4]
     226            productos.append(e[5:])
     227            prod = prod + " " + e[5:]
     228
     229    ahora = date.today().isoformat()
     230
     231    args = os.path.join(settings.PATH, "extapps/chains/svg_builder_canviz") + " --host=" + \
     232           settings.DATABASES['sigesic']['HOST'] + " --port=" + settings.DATABASES['sigesic']['PORT'] + " --username=" + \
     233           settings.DATABASES['sigesic']['USER'] + " --password=" + settings.DATABASES['sigesic'][
     234               'PASSWORD'] + " --dbname=" + settings.DATABASES['sigesic'][
     235               'NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --year=" + anyo + " --output=" + os.path.join(
     236        settings.PATH, "tmp/") + str(request.user) + " PROD" + prod
     237
     238    ret = subprocess.call(args, shell=True)
     239
     240    if ret == 0:
     241        dajax.script(
     242            "$('#dialog-modal').dialog('close');window.open('" + settings.BASE_URL + "/GraficarCanviz?prod=" + prod + "&ahora=" + ahora + "&anyo=" + anyo + "&narriba=" + narriba + "&nabajo=" + nabajo + "&usuario=" + str(
     243                request.user) + "')")
     244    else:
     245        dajax.script("$('#dialog-modal').dialog('close');alert('No hubo resultados para la selección')")
     246    return dajax
     247
     248
     249def limpiarConsulta(request):
     250    dajax = Dajax()
     251    # Pestaña CIIU
     252
     253    dajax.script("document.getElementById('id_buscaCiiu').value = ''")
     254    dajax.script("document.getElementById('id_desdeciiu').value = ''")
     255    dajax.script("document.getElementById('id_hastaciiu').value = ''")
     256    dajax.script("document.getElementById('eliminarTodosCIIU').click()")
     257
     258    # Pestaña Unidad Económica
     259    dajax.script("document.getElementById('eliminarTodosEmpresa').click()")
     260
     261    return dajax
     262
     263
     264def exportarCSV(request):
     265    dajax = Dajax()
     266
     267    busca = str(request.POST['busca'])
     268    seleccion = str(request.POST['seleccion_0'])
     269
     270    q = ''
     271    if busca != "":
     272        if seleccion == '1':
     273            q = Q(rif__startswith=busca.upper())
    39274        else:
    40                 dajax.script("document.getElementById('id_municipiou').value = '0'")
    41                 dajax.script("document.getElementById('id_municipiou').disabled = true")
    42                 dajax.script("document.getElementById('id_parroquiau').value = '0'")
    43                 dajax.script("document.getElementById('id_parroquiau').disabled = true")
    44        
    45         return dajax
    46 
    47 def updatecomboP(request):
    48         dajax = Dajax()
    49         cod = str(request.POST['option'])
    50 
    51         options = Parroquia.objects.using('sigesic').filter(municipio = cod).order_by("nombre")
    52         out = "<option value='0'>Seleccione...</option>"
    53         if cod != "0":
    54                 for o in options:
    55                         out = "%s<option value=%s>%s</option>" % (out,o.codigo.encode('utf-8'),o.nombre.encode('utf-8'))
    56                        
    57                 dajax.script("document.getElementById('id_parroquiau').disabled = false")
    58                 dajax.assign('#id_parroquiau','innerHTML',out)
    59                
    60         else:
    61                 dajax.script("document.getElementById('id_parroquiau').value = '0'")
    62                 dajax.script("document.getElementById('id_parroquiau').disabled = true")
    63        
    64         return dajax
    65 
    66 def generarConsulta(request):
    67         dajax = Dajax()
    68         print request
    69 
    70         #ciiuSeleccionados = request.POST['ciiuSeleccionados']
    71        
    72         rif = str(request.POST['rif'])
    73        
    74         narriba = str(request.POST['narriba'])
    75         nabajo = str(request.POST['nabajo'])
    76         """
    77         os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/print_prod_chain") + " --host=" + settings.DATABASES['default']['HOST'] + " --port=" + settings.DATABASES['default']['PORT'] + " --username=" + settings.DATABASES['default']['USER'] + " --password=" + settings.DATABASES['default']['PASSWORD'] + " --dbname=" + settings.DATABASES['default']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --output=" + str(request.user) + " RIF " + rif)
    78         os.system("mv -f " + os.path.join(settings.PATH, "tmp/grafico.html ") + os.path.join(settings.PATH, "templates/cadenas/" + str(request.user) + "_grafico.html") + ";")
    79         os.system("mv -f " + os.path.join(settings.PATH, "tmp/factores.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_factores.xml ") + ";")
    80         os.system("mv -f " + os.path.join(settings.PATH, "tmp/respuestas.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_respuestas.xml ") + ";")
    81         """
    82    
    83         ahora = date.today().isoformat()
    84        
    85         #dajax.script("window.open('"+settings.BASE_URL+"/SigesicListado?ahora="+ahora+"&ciiuSeleccionados="+ciiuSeleccionados+"')")
    86         dajax.script("window.open('"+settings.BASE_URL+"/Grafico?ciiu="+rif+"&ahora="+ahora+"&arriba="+narriba+"&abajo="+nabajo+"&usuario="+str(request.user)+"')")
    87        
    88         return dajax
    89 
    90 def generarGrafo(request):
    91         dajax = Dajax()
    92         print request
    93 
    94         #ciiuSeleccionados = request.POST['ciiuSeleccionados']
    95        
    96         anyo = str(request.POST['anyo'])
    97         chequeado = str(request.POST['chequeado[]'])
    98         narriba = str(request.POST['narriba'])
    99         nabajo = str(request.POST['nabajo'])
    100         """
    101         os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/print_prod_chain") + " --host=" + settings.DATABASES['default']['HOST'] + " --port=" + settings.DATABASES['default']['PORT'] + " --username=" + settings.DATABASES['default']['USER'] + " --password=" + settings.DATABASES['default']['PASSWORD'] + " --dbname=" + settings.DATABASES['default']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --output=" + str(request.user) + " RIF " + rif)
    102         os.system("mv -f " + os.path.join(settings.PATH, "tmp/grafico.html ") + os.path.join(settings.PATH, "templates/cadenas/" + str(request.user) + "_grafico.html") + ";")
    103         os.system("mv -f " + os.path.join(settings.PATH, "tmp/factores.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_factores.xml ") + ";")
    104         os.system("mv -f " + os.path.join(settings.PATH, "tmp/respuestas.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_respuestas.xml ") + ";")
    105         """
    106    
    107         ahora = date.today().isoformat()
    108        
    109         #dajax.script("window.open('"+settings.BASE_URL+"/SigesicListado?ahora="+ahora+"&ciiuSeleccionados="+ciiuSeleccionados+"')")
    110         #dajax.script("window.open('"+settings.BASE_URL+"/Grafico?chequeado="+chequeado+"&ahora="+ahora+"&arriba="+narriba+"&abajo="+nabajo+"&usuario="+str(request.user)+"')")
    111        
    112         return dajax
    113 
    114 
    115 def generateGraphAdelante(request):
    116         dajax = Dajax()
    117         #print request
    118        
    119         anyo = str(request.POST['anyo'])
    120         chequeado = str(request.POST['chequeado[]'])
    121         narriba = str(request.POST['narriba'])
    122         nabajo = str(request.POST['nabajo'])
    123        
    124         chequeados = []
    125         productos = []
    126         chequeados = request.POST.getlist('chequeado[]')
    127         usuario = str(request.user)
    128         print chequeados
    129         prod = ""
    130         for e in chequeados:
    131             if anyo == e[0:4]:
    132                 print e[0:4]
    133                 productos.append(e[5:])
    134                 prod = prod +" "+e[5:]
    135         print prod
    136        
    137         os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/cadenasmivadelante") + " --host=" + settings.DATABASES['sigesic']['HOST'] + " --port=" + settings.DATABASES['sigesic']['PORT'] + " --username=" + settings.DATABASES['sigesic']['USER'] + " --password=" + settings.DATABASES['sigesic']['PASSWORD'] + " --dbname=" + settings.DATABASES['sigesic']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --year="+ anyo +" --output=" + str(request.user) + " PROD" + prod)
    138         """
    139         os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/print_prod_chain") + " --host=" + settings.DATABASES['default']['HOST'] + " --port=" + settings.DATABASES['default']['PORT'] + " --username=" + settings.DATABASES['default']['USER'] + " --password=" + settings.DATABASES['default']['PASSWORD'] + " --dbname=" + settings.DATABASES['default']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --output=" + str(request.user) + " RIF " + rif)
    140         os.system("mv -f " + os.path.join(settings.PATH, "tmp/grafico.html ") + os.path.join(settings.PATH, "templates/cadenas/" + str(request.user) + "_grafico.html") + ";")
    141         os.system("mv -f " + os.path.join(settings.PATH, "tmp/factores.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_factores.xml ") + ";")
    142         os.system("mv -f " + os.path.join(settings.PATH, "tmp/respuestas.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_respuestas.xml ") + ";")
    143         """
    144    
    145         ahora = date.today().isoformat()
    146        
    147         #dajax.script("window.open('"+settings.BASE_URL+"/SigesicListado?ahora="+ahora+"&ciiuSeleccionados="+ciiuSeleccionados+"')")
    148         dajax.script("window.open('"+settings.BASE_URL+"/Graficarv2?prod="+prod+"&ahora="+ahora+"&anyo="+anyo+"&narriba="+narriba+"&nabajo="+nabajo+"&usuario="+str(request.user)+"')")
    149        
    150         return dajax
    151 
    152 
    153 def generateGraphAtras(request):
    154         dajax = Dajax()
    155         #print request
    156 
    157         anyo = str(request.POST['anyo'])
    158         chequeado = str(request.POST['chequeado[]'])
    159         narriba = str(request.POST['narriba'])
    160         nabajo = str(request.POST['nabajo'])
    161        
    162         chequeados = []
    163         productos = []
    164         chequeados = request.POST.getlist('chequeado[]')
    165         usuario = str(request.user)
    166        
    167         print chequeados
    168         prod = ""
    169         for e in chequeados:
    170             if anyo == e[0:4]:
    171                 print e[0:4]
    172                 productos.append(e[5:])
    173                 prod = prod +" "+e[5:]
    174                
    175         os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/cadenasmivatras") + " --host=" + settings.DATABASES['sigesic']['HOST'] + " --port=" + settings.DATABASES['sigesic']['PORT'] + " --username=" + settings.DATABASES['sigesic']['USER'] + " --password=" + settings.DATABASES['sigesic']['PASSWORD'] + " --dbname=" + settings.DATABASES['sigesic']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --year="+ anyo +" --output=" + str(request.user)+"_adelante" + " PROD" + prod)
    176         """
    177         os.system("cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/print_prod_chain") + " --host=" + settings.DATABASES['default']['HOST'] + " --port=" + settings.DATABASES['default']['PORT'] + " --username=" + settings.DATABASES['default']['USER'] + " --password=" + settings.DATABASES['default']['PASSWORD'] + " --dbname=" + settings.DATABASES['default']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --output=" + str(request.user) + " RIF " + rif)
    178         os.system("mv -f " + os.path.join(settings.PATH, "tmp/grafico.html ") + os.path.join(settings.PATH, "templates/cadenas/" + str(request.user) + "_grafico.html") + ";")
    179         os.system("mv -f " + os.path.join(settings.PATH, "tmp/factores.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_factores.xml ") + ";")
    180         os.system("mv -f " + os.path.join(settings.PATH, "tmp/respuestas.xml ") + os.path.join(settings.PATH, "tmp/" + str(request.user) + "_respuestas.xml ") + ";")
    181         """
    182    
    183         ahora = date.today().isoformat()
    184        
    185         #dajax.script("window.open('"+settings.BASE_URL+"/SigesicListado?ahora="+ahora+"&ciiuSeleccionados="+ciiuSeleccionados+"')")
    186         dajax.script("window.open('"+settings.BASE_URL+"/Graficarv3?prod="+prod+"&ahora="+ahora+"&anyo="+anyo+"&narriba="+narriba+"&nabajo="+nabajo+"&usuario="+str(request.user)+"')")
    187        
    188         return dajax
    189 
    190 def generateGraphAdelanteParaCanviz(request):
    191         dajax = Dajax()
    192         #print request
    193        
    194         anyo = str(request.POST['anyo'])
    195         chequeado = str(request.POST['chequeado[]'])
    196         narriba = str(request.POST['narriba'])
    197         nabajo = str(request.POST['nabajo'])
    198        
    199         chequeados = []
    200         productos = []
    201         chequeados = request.POST.getlist('chequeado[]')
    202         usuario = str(request.user)
    203         print chequeados
    204         prod = ""
    205         for e in chequeados:
    206             if anyo == e[0:4]:
    207                 print e[0:4]
    208                 productos.append(e[5:])
    209                 prod = prod +" "+e[5:]
    210         print prod
    211        
    212         comando = "cd " + os.path.join(settings.PATH, "tmp/") + ";" + os.path.join(settings.PATH, "extapps/chains/cadenasmivadelantecanviz") + " --host=" + settings.DATABASES['sigesic']['HOST'] + " --port=" + settings.DATABASES['sigesic']['PORT'] + " --username=" + settings.DATABASES['sigesic']['USER'] + " --password=" + settings.DATABASES['sigesic']['PASSWORD'] + " --dbname=" + settings.DATABASES['sigesic']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --year="+ anyo +" --output=" + str(request.user) + " PROD" + prod
    213        
    214         print comando
    215        
    216         os.system(comando)
    217 
    218         ahora = date.today().isoformat()
    219        
    220         dajax.script("window.open('"+settings.BASE_URL+"/GraficarCanviz/adelante?prod="+prod+"&ahora="+ahora+"&anyo="+anyo+"&narriba="+narriba+"&nabajo="+nabajo+"&usuario="+str(request.user)+"')")
    221        
    222         return dajax
    223 
    224 
    225 def generateGraphAtrasParaCanviz(request):
    226         dajax = Dajax()
    227         #print request
    228 
    229         anyo = str(request.POST['anyo'])
    230         chequeado = str(request.POST['chequeado[]'])
    231         narriba = str(request.POST['narriba'])
    232         nabajo = str(request.POST['nabajo'])
    233        
    234         chequeados = []
    235         productos = []
    236         chequeados = request.POST.getlist('chequeado[]')
    237         usuario = str(request.user)
    238        
    239         print chequeados
    240         prod = ""
    241         for e in chequeados:
    242             if anyo == e[0:4]:
    243                 print e[0:4]
    244                 productos.append(e[5:])
    245                 prod = prod +" "+e[5:]
    246                
    247        
    248         ahora = date.today().isoformat()
    249        
    250         args = os.path.join(settings.PATH, "extapps/chains/svg_builder_canviz") + " --host=" + settings.DATABASES['sigesic']['HOST'] + " --port=" + settings.DATABASES['sigesic']['PORT'] + " --username=" + settings.DATABASES['sigesic']['USER'] + " --password=" + settings.DATABASES['sigesic']['PASSWORD'] + " --dbname=" + settings.DATABASES['sigesic']['NAME'] + " --levelsup=" + narriba + " --levelsdown=" + nabajo + " --year="+ anyo + " --output=" + os.path.join(settings.PATH, "tmp/")+str(request.user) + " PROD" + prod
    251        
    252         ret = subprocess.call(args,shell=True)
    253 
    254         if ret == 0:
    255             dajax.script("$('#dialog-modal').dialog('close');window.open('"+settings.BASE_URL+"/GraficarCanviz?prod="+prod+"&ahora="+ahora+"&anyo="+anyo+"&narriba="+narriba+"&nabajo="+nabajo+"&usuario="+str(request.user)+"')")
    256         else:
    257             dajax.script("$('#dialog-modal').dialog('close');alert('No hubo resultados para la selección')")
    258         return dajax
    259 
    260 def limpiarConsulta(request):
    261         dajax = Dajax()
    262         # Pestaña CIIU
    263        
    264         dajax.script("document.getElementById('id_buscaCiiu').value = ''")
    265         dajax.script("document.getElementById('id_desdeciiu').value = ''")
    266         dajax.script("document.getElementById('id_hastaciiu').value = ''")
    267         dajax.script("document.getElementById('eliminarTodosCIIU').click()")
    268 
    269         # Pestaña Unidad Económica
    270         dajax.script("document.getElementById('eliminarTodosEmpresa').click()")
    271        
    272         return dajax
    273 
    274 
    275 def exportarCSV(request):
    276         dajax = Dajax()
    277        
    278         busca = str(request.POST['busca'])
    279         seleccion = str(request.POST['seleccion_0'])
    280        
    281         q = ''
    282         if busca !="":
    283             if seleccion=='1':
    284                 q = Q(rif__startswith=busca.upper())
    285             else:
    286                 if seleccion=='2':
    287                     q = Q(nombre__contains=busca.upper())
    288                 else:
    289                     q = Q(razon_social__contains=busca.upper())
    290 
    291         if q =='':
    292                 data=Unidad_Economica.objects.using('sigesic').all()
    293         else:
    294                 data=Unidad_Economica.objects.using('sigesic').filter(q)
    295        
    296         response = HttpResponse(content_type='text/csv')
    297         response['Content-Disposition'] = 'attachment; filename="descarga.csv"'
    298 
    299        
    300         writer = csv.writer(response)
    301        
    302         for ue in data:
    303                 writer.writerow([ue.rif, ue.razon_social])
    304 
    305         print response
    306         #dajax.assign(response)
    307        
    308         dajax.script("window.open('"+settings.BASE_URL+"/')")
    309        
    310 
    311         return dajax
     275            if seleccion == '2':
     276                q = Q(nombre__contains=busca.upper())
     277            else:
     278                q = Q(razon_social__contains=busca.upper())
     279
     280    if q == '':
     281        data = Unidad_Economica.objects.using('sigesic').all()
     282    else:
     283        data = Unidad_Economica.objects.using('sigesic').filter(q)
     284
     285    response = HttpResponse(content_type='text/csv')
     286    response['Content-Disposition'] = 'attachment; filename="descarga.csv"'
     287
     288    writer = csv.writer(response)
     289
     290    for ue in data:
     291        writer.writerow([ue.rif, ue.razon_social])
     292
     293    print response
     294    # dajax.assign(response)
     295
     296    dajax.script("window.open('" + settings.BASE_URL + "/')")
     297
     298    return dajax
Note: See TracChangeset for help on using the changeset viewer.