Пример #1
0
def consulta_depositos_detalhe(request: HttpRequest,
                               upload: int) -> HttpResponse:
    menu = menu_consultas(request)

    q = request.GET.get("q", "")

    form = FormFiltraQ(initial={"q": q}, descricao="nome ou matrícula")

    query = Q(upload__id=upload)

    if q:
        query = Q(query & Q(
            Q(user_to__username__icontains=q)
            | Q(user_to__first_name__icontains=q)
            | Q(user_to__last_name__icontains=q)))

    itens = services.get_upload_data(query)

    paginator = Paginator(itens, 50)
    page_number = request.GET.get("page")
    page_obj = paginator.get_page(page_number)

    context = {
        "page_obj": page_obj,
        "form": form,
        "form_submit_text": 'Filtrar'
    }
    context.update(menu)

    return render(request, "cartao/consultar_uploads_detalhe.html", context)
Пример #2
0
def grupos(request):
    menu = menu_principal(request)

    q = request.GET.get('q', '')

    initial = {'q': q}

    form = FormFiltraQ(initial=initial, descricao='nome')

    query = Q()

    if q != '':
        query = query & Q(name__icontains=q)

    sub_query = User.objects.filter(
        groups__id=OuterRef('pk')).values('groups__id').annotate(
            quantidade=Count('id')).values('quantidade')

    itens = Group.objects.filter(query).values(
        'id',
        'name',
    ).annotate(quantidade=Subquery(sub_query))

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'page_obj': page_obj,
        'form': form,
        'form_submit_text': 'Filtrar',
    }
    context.update(menu)

    return render(request, 'controle_acessos/v2/grupos.html', context)
Пример #3
0
def consulta_patrimonio_status(request):
    menu = menu_consultas(request)

    patrimonio = request.GET.get('q', '')

    form = FormFiltraQ(descricao="patrimônio", initial={
        'q': patrimonio,
    })

    query = Q()

    if patrimonio != '':
        query = query & Q(
            Q(codigo__icontains=patrimonio)
            | Q(patrimonio__nome__icontains=patrimonio))

    itens = PatrimonioId.objects.filter(query).order_by(
        'patrimonio__nome', 'codigo')

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'form': form,
        'form_submit_text': 'Filtrar',
        'page_obj': page_obj,
    }
    context.update(menu)

    return render(request,
                  'patrimonio1/v2/consulta_patrimonio_status.html',
                  context=context)
Пример #4
0
def consulta_ferramenta_estoque(request):
    menu = menu_consultas(request)

    ferramenta = request.GET.get('q', '')

    form = FormFiltraQ(descricao="ferramenta", initial={
        'q': ferramenta,
    })

    query = Q()

    if ferramenta != '':
        query = query & Q(ferramenta__nome__icontains=ferramenta)

    itens = FerramentaQuantidade.objects.filter(query).values(
        'ferramenta__nome',
        'quantidade',
    ).exclude(quantidade__lte=0, ).order_by('ferramenta__nome')

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'form': form,
        'form_submit_text': 'Filtrar',
        'page_obj': page_obj,
    }
    context.update(menu)

    return render(request,
                  'ferramenta/v2/consulta_ferramenta_estoque.html',
                  context=context)
Пример #5
0
def view_consulta_km_time(request: HttpRequest) -> HttpResponse:
  menu = mn.consultas(request)

  q = request.GET.get("q", "")

  form = FormFiltraQ(
    "nome ou matrícula",
    initial={
      "q": q,
    }
  )

  query = Q(user__id=request.user.id)

  if q != "":
    query = query & Q(
      Q(user_to__first_name__icontains=q) |
      Q(user_to__last_name__icontains=q) |
      Q(user_to__username__icontains=q)
    )

  itens = services.query_km_team(query)

  paginator = Paginator(itens, 50)
  page_number = request.GET.get("page")
  page_obj = paginator.get_page(page_number)

  context = {
    "page_obj": page_obj,
    "form": form,
    "form_submit_text": "Filtrar"
  }
  context.update(menu)

  return render(request, "km/consultar_km_time.html", context)
Пример #6
0
def edicao_material(request):
    menu = menu_edicao(request)

    material = request.GET.get('q', '')

    form = FormFiltraQ(descricao='nome ou código', initial={'q': material})

    query = Q()

    if material != '':
        query = query & Q(
            Q(codigo__icontains=material) | Q(material__icontains=material))

    itens = Material.objects.filter(query).values(
        'codigo',
        'material',
        'descricao',
        'data',
        'user__first_name',
        'user__last_name',
        'status',
    ).order_by('material')

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'page_obj': page_obj,
        'form': form,
        'form_submit_text': 'Filtrar',
    }
    context.update(menu)

    return render(request, 'almoxarifado/v2/edicao_material.html', context)
Пример #7
0
def consulta_colaboradores(request: HttpRequest) -> HttpResponse:
    menu = menu_consultas(request)

    q = request.GET.get("q", "")

    form = FormFiltraQ(
        initial={"q": q},
        descricao="nome ou matrícula"
    )

    query = Q()

    if q:
        query = query & Q(
            Q(username__icontains=q) |
            Q(first_name__icontains=q) |
            Q(last_name__icontains=q)
        )

    subquery = FerramentaSaida.objects.filter(
        user_to__id=OuterRef("id")
    ).values(
        "user_to"
    ).annotate(
        total=Count("id")
    ).values(
        "total"
    )

    itens = User.objects.filter(query).values(
        "username",
        "first_name",
        "last_name",
    ).annotate(
        total_p=Count(F("patrimonio_retiradas"), filter=Q(patrimonio_retiradas__patrimonio__status=1), distinct=True),
        total_f=Subquery(subquery)
    ).exclude(
        total_p__lte=0,
        total_f__lte=0,
    ).order_by(
        "first_name",
        "last_name",
    )

    paginator = Paginator(itens, 50)

    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)
    context = {
        'page_obj': page_obj,
        'tipo': 1,
        'form': form,
        'form_submit_text': 'filtar',
    }
    context.update(menu)

    return render(request, 'patrimonio/v2/consulta_colaboradores.html', context)
Пример #8
0
def consulta_meu_talao(request):
    """
    View de exibição dos talões cadastrados no sistema que foram recebido pelo usuário logado
    :param request: informações gerais
    :return: template
    """
    menu = menu_consultas(request)

    q = request.GET.get('q', '')

    form = FormFiltraQ('código do talão ou matrícula', initial={
        'q': q,
    })

    query = Q(talao_entrega__user_to=request.user)

    if q != '':
        query = query & Q(
            Q(talao__icontains=q)
            | Q(talao_cadastro__user__username__icontains=q)
            | Q(talao_entrega__user__username__icontains=q)
            | Q(talao_entrega__user_to__username__icontains=q))

    itens = Talao.objects.filter(query).values(
        'talao',
        'status',
        'talao_cadastro__data',
        'talao_cadastro__user__username',
        'talao_cadastro__user__first_name',
        'talao_cadastro__user__last_name',
        'talao_entrega__data',
        'talao_entrega__user__username',
        'talao_entrega__user__first_name',
        'talao_entrega__user__last_name',
        'talao_entrega__user_to__username',
        'talao_entrega__user_to__first_name',
        'talao_entrega__user_to__last_name',
    ).order_by('talao')

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'page_obj': page_obj,
        'form': form,
        'form_submit_text': 'Filtrar',
    }
    context.update(menu)

    return render(request, 'talao/v2/consulta_talao.html', context)
Пример #9
0
def view_registrar_km_final(request: HttpRequest) -> HttpResponse:
  menu = mn.registros(request)

  q = request.GET.get("q", "")

  form = FormFiltraQ(
    "nome ou matrícula",
    initial={
      "q": q,
    }
  )

  query = Q()

  if q != "":
    query = query & Q(
      Q(user_to__first_name__icontains=q) |
      Q(user_to__last_name__icontains=q) |
      Q(user_to__username__icontains=q)
    )

  itens = services.get_user_team_final_km(request.user, query).values(
    "id",
    "date",
    "user_to__id",
    "user_to__username",
    "user_to__first_name",
    "user_to__last_name",
  ).order_by(
    "user_to__first_name",
    "user_to__last_name",
    "date",
  )

  paginator = Paginator(itens, 50)
  page_number = request.GET.get("page")
  page_obj = paginator.get_page(page_number)

  context = {
    "page_obj": page_obj,
    "form": form,
    "form_submit_text": "Filtrar",
    "details": "patrimonio_combustivel_km_registros_final"
  }
  context.update(menu)

  return render(request, "km/registrar_km_final.html", context)
Пример #10
0
def consulta_funcionarios(request):
    """
    View de exibição dos funcionários cadastrados
    :param request: informações gerais
    :return: template
    """
    menu = menu_consultas(request)

    q = request.GET.get('q', '')

    form = FormFiltraQ('matrícula', initial={
        'q': q,
    })

    query = Q()

    if q != '':
        query = query & Q(
            Q(username__icontains=q) | Q(first_name__icontains=q)
            | Q(last_name__icontains=q))

    itens = User.objects.filter(query).values(
        'username',
        'first_name',
        'last_name',
        'user_type__is_passive',
        'is_superuser',
        'is_active',
        'last_login',
    ).annotate(veiculos_qtde=Count(F('veiculos__id'))).order_by(
        'first_name', 'last_name')

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'page_obj': page_obj,
        'form': form,
        'form_submit_text': 'Filtrar',
    }
    context.update(menu)

    return render(request, 'constel/v2/consulta_funcionarios.html', context)
Пример #11
0
def relatorio_geral_detalhe(request, user):

    menu = menu_relatorios(request)

    q = request.GET.get('q', '')

    form = FormFiltraQ('código do vale ou matrícula', initial={
        'q': q,
    })

    query = Q(vale_entrega__user_to__username=user)

    if q != '':
        query = query & Q(
            Q(vale__icontains=q)
            | Q(vale_entrega__user__username__icontains=q))

    itens = Vale.objects.filter(query).values(
        'vale',
        'talao__talao',
        'status',
        'vale_entrega__data',
        'vale_entrega__user__first_name',
        'vale_entrega__user__last_name',
        'vale_entrega__combustivel__combustivel',
        'vale_entrega__posto__posto',
        'vale_entrega__valor',
        'vale_entrega__observacao',
    ).order_by('vale_entrega__data')

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'page_obj': page_obj,
        'form': form,
        'form_submit_text': 'Filtrar',
    }
    context.update(menu)

    return render(request, 'talao/v2/relatorio_geral_detalhe.html', context)
Пример #12
0
def consulta_saidas(request):
    menu = menu_consultas(request)

    q = request.GET.get('q', '')

    form = FormFiltraQ(initial={'q': q}, descricao='Fucionário ou id da ordem')

    query = Q()

    if q != '':
        query = query & Q(
            Q(user_to_username__icontains=q)
            | Q(user_to_first_name__icontains=q)
            | Q(user_to_last_name__icontains=q) | Q(id__icontains=q))

    itens = Ordem.objects.filter(tipo=1, saida_ordem_ont__id__gte=0).annotate(
        user_to_username=Min('saida_ordem_ont__user_to__first_name'),
        user_to_first_name=Min('saida_ordem_ont__user_to__first_name'),
        user_to_last_name=Min('saida_ordem_ont__user_to__last_name'),
        quantidade=Count('saida_ordem_ont__id')).values(
            'id',
            'data',
            'user__first_name',
            'user__last_name',
            'user_to_first_name',
            'user_to_last_name',
            'quantidade',
        ).filter(query).order_by('-data')

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'page_obj': page_obj,
        'tipo': 1,
        'form_submit_text': 'Filtrar',
        'form': form,
    }
    context.update(menu)

    return render(request, 'cont/v2/consulta_ordem.html', context)
Пример #13
0
def consulta_vales(request: HttpRequest) -> HttpResponse:
    menu = menu_consultas(request)

    q = request.GET.get("q", "")

    form = FormFiltraQ("Código do vale ou matrícula", initial={
        "q": q,
    })

    query = Q()

    if q != "":
        query = query & Q(
            Q(vale__icontains=q) | Q(vale_entrega__user__username__icontains=q)
            | Q(vale_entrega__user_to__username__icontains=q))

    itens = Vale.objects.filter(query).order_by("vale").values(
        "vale",
        "status",
        "talao__talao",
        "vale_entrega__data",
        "vale_entrega__user_to__first_name",
        "vale_entrega__user_to__last_name",
        "vale_entrega__combustivel__combustivel",
        "vale_entrega__valor",
        "vale_entrega__posto__posto",
    )

    paginator = Paginator(itens, 50)
    page_number = request.GET.get("page")
    page_obj = paginator.get_page(page_number)

    context = {
        "page_obj": page_obj,
        "form": form,
        "form_submit_text": 'Filtrar'
    }
    context.update(menu)

    return render(request, "talao/v2/consulta_vale.html", context)
Пример #14
0
def consulta_devolucoes(request):
    menu = menu_consultas(request)

    q = request.GET.get('q', '')

    form = FormFiltraQ(initial={'q': q}, descricao='Fornecedor ou id da ordem')

    query = Q()

    if q != '':
        query = query & Q(
            Q(fornecedor_cnpj__icontains=q) | Q(fornecedor_nome__icontains=q)
            | Q(id__icontains=q))

    itens = Ordem.objects.filter(tipo=1, devolucao_ont__id__gte=0).annotate(
        fornecedor_cnpj=Min('devolucao_ont__forncedor__cnpj'),
        fornecedor_nome=Min('devolucao_ont__fornecedor__nome'),
        quantidade=Count('devolucao_ont__id')).values(
            'id',
            'data',
            'fornecedor_cnpj',
            'fornecedor_nome',
            'quantidade',
        ).filter(query).order_by('-data')

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'page_obj': page_obj,
        'tipo': 1,
        'form_submit_text': 'Filtrar',
        'form': form,
    }
    context.update(menu)

    return render(request, 'cont/v2/consulta_ordem.html', context)
Пример #15
0
def usuarios(request):
    menu = menu_principal(request)

    q = request.GET.get('q', '')

    initial = {'q': q}

    form = FormFiltraQ(initial=initial, descricao='matrícula ou nome')

    query = Q()

    if q != '':
        query = query & Q(
            Q(username__icontains=q) | Q(first_name__icontains=q)
            | Q(last_name__icontains=q))

    itens = User.objects.filter(query).values(
        'username',
        'first_name',
        'last_name',
    ).order_by(
        'first_name',
        'last_name',
    )

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'page_obj': page_obj,
        'form': form,
        'form_submit_text': 'Filtrar',
    }
    context.update(menu)

    return render(request, 'controle_acessos/v2/usuarios.html', context)
Пример #16
0
def consulta_ferramenta(request):
    menu = menu_consultas_modelos(request)

    ferramenta = request.GET.get('q', '')

    form = FormFiltraQ(descricao="ferramenta", initial={
        'q': ferramenta,
    })

    query = Q()

    if ferramenta != '':
        query = query & Q(nome__icontains=ferramenta)

    itens = Ferramenta.objects.filter(query).values(
        'id',
        'nome',
        'descricao',
        'data',
        'user__first_name',
        'user__last_name',
    ).order_by('nome')

    paginator = Paginator(itens, 50)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)

    context = {
        'form': form,
        'form_submit_text': 'Filtrar',
        'page_obj': page_obj,
    }
    context.update(menu)

    return render(request,
                  'ferramenta/v2/consulta_ferramenta.html',
                  context=context)