Filter year index view
This commit is contained in:
@@ -40,13 +40,13 @@ class Clientes(models.Model):
|
||||
fecha_baja = models.DateField(blank=True,null=True)
|
||||
email = models.EmailField(max_length=254, blank=True)
|
||||
conteo_mes = models.IntegerField(blank=True,null=True,default=0)
|
||||
def timbres_X_MES(self, mes=None, year=None):
|
||||
def timbres_X_MES(self, mes=None, year=None, PAC=None):
|
||||
today = datetime.date.today()
|
||||
if year is None:
|
||||
year = today.year
|
||||
if mes==None:
|
||||
mes = today.month
|
||||
|
||||
|
||||
dat = datetime.datetime(int(year),int(mes),1)
|
||||
if dat.month in (1,3,5,7,8,10,12):#31
|
||||
findate = dat + datetime.timedelta(days=30)
|
||||
@@ -56,8 +56,11 @@ class Clientes(models.Model):
|
||||
|
||||
else:#28 or 29
|
||||
findate = dat + datetime.timedelta(days=28)
|
||||
findate += datetime.timedelta(days=1)
|
||||
cou = Timbres.objects.filter(rfcc=self.RFC, created_at__range=[dat,findate]).count()
|
||||
findate += datetime.timedelta(days=1)
|
||||
if PAC:
|
||||
cou = Timbres.objects.filter(rfcc=self.RFC, created_at__range=[dat,findate], rfcp=PAC).count()
|
||||
else:
|
||||
cou = Timbres.objects.filter(rfcc=self.RFC, created_at__range=[dat,findate]).count()
|
||||
self.conteo_mes =cou
|
||||
self.save()
|
||||
|
||||
|
||||
@@ -32,6 +32,4 @@ urlpatterns = [
|
||||
path('check_host/',check_host.as_view(),name='check_host'),
|
||||
path('emails_cliente/',Retrive_Cliente_Email, name='Retrive_Cliente_Email'),
|
||||
path('pacs/list/',PACS_Retrive_RFCS,name='PACS_Retrive_RFCS'),
|
||||
|
||||
|
||||
]
|
||||
@@ -162,9 +162,10 @@ def send_timbres_Email(request):
|
||||
def index(request):
|
||||
#read_env_file()
|
||||
clientes_list = Clientes.objects.all()
|
||||
PAC = request.GET.get('PAC',None)
|
||||
mes = request.GET.get('mes', None)
|
||||
today = datetime.date.today()
|
||||
|
||||
|
||||
year = request.GET.get('year',None)
|
||||
if year is None or year =='None':
|
||||
year= today.year
|
||||
@@ -173,28 +174,29 @@ def index(request):
|
||||
page = request.GET.get('page', 1)
|
||||
search = request.GET.get('search',None)
|
||||
rfcc = request.GET.get('rfcc', None)
|
||||
filters = {key:value[0] for (key,value) in dict(request.GET).items() if value !=[""]}
|
||||
filters = {key:value[0] for (key,value) in dict(request.GET).items() if value !=[""] or value!=None}
|
||||
filters.pop('page', '')
|
||||
filters.pop('datepicker','')
|
||||
filters.pop('datepickerFin','')
|
||||
filters.pop('mes','')
|
||||
filters.pop('year','')
|
||||
|
||||
if PAC=='00':
|
||||
filters.pop('PAC')
|
||||
PAC=None
|
||||
|
||||
if rfcc and search:
|
||||
clientes_list = Clientes.objects.filter(Q(RFC__icontains=search))
|
||||
|
||||
# for i,ii in enumerate(clientes_list):
|
||||
# ii.timbres_X_MES(mes=mes)
|
||||
|
||||
met = iter(clientes_list)
|
||||
while met:
|
||||
try:
|
||||
c = next(met)
|
||||
c.timbres_X_MES(mes=mes,year=year)
|
||||
c.timbres_X_MES(mes=mes,year=year, PAC=PAC)
|
||||
except StopIteration:
|
||||
break
|
||||
|
||||
clientes_list =pageFunc(page,clientes_list,20)
|
||||
|
||||
|
||||
context = {
|
||||
'lista':clientes_list,
|
||||
'mes':mes,
|
||||
|
||||
@@ -1 +1,35 @@
|
||||
no hay
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<!-- Required meta tags -->
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.2.1/dist/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
|
||||
|
||||
<title>AS Admin Pagina No Encontrada</title>
|
||||
</head>
|
||||
<body >
|
||||
<div>
|
||||
{% include 'partials/messages.html' %}
|
||||
<img class="rounded mx-auto d-block" src="https://static.doofinder.com/main-files/uploads/2019/08/110655-404-not-found-Doofinder.jpg" alt="Forbidden">
|
||||
<a href="/" class="btn btn-info btn-lg rounded mx-auto d-block mt-3">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-arrow-return-left" viewBox="0 0 16 16">
|
||||
<path fill-rule="evenodd" d="M14.5 1.5a.5.5 0 0 1 .5.5v4.8a2.5 2.5 0 0 1-2.5 2.5H2.707l3.347 3.346a.5.5 0 0 1-.708.708l-4.2-4.2a.5.5 0 0 1 0-.708l4-4a.5.5 0 1 1 .708.708L2.707 8.3H12.5A1.5 1.5 0 0 0 14 6.8V2a.5.5 0 0 1 .5-.5z"/>
|
||||
</svg>
|
||||
Regresar al Inicio
|
||||
</a>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Optional JavaScript -->
|
||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.6/dist/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.2.1/dist/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -18,38 +18,56 @@ Timbres disponibles Comercio Digital: {{saldo}}
|
||||
</th>
|
||||
<th>Nombre</th>
|
||||
<th>
|
||||
<div class="d-flex align-items-center">
|
||||
Total x mes
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="">
|
||||
<a data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
|
||||
Total x mes
|
||||
</a>
|
||||
<strong>
|
||||
<small>Filtrado: Mes:{{mes}}, Año:{{year}}, PAC:<label id="lbl_pac"></label></small>
|
||||
</strong>
|
||||
</div>
|
||||
<div style="display:none;" id="spinner_id" class="spinner-border ml-auto spinner-border-sm" role="status" aria-hidden="true"></div>
|
||||
</div>
|
||||
<select style="display:inline" id="table_select_anio" class="form-control form-control-sm">
|
||||
<!--option value="0"></option-->
|
||||
</select>
|
||||
<select id="table_select" class="form-control form-control-sm">
|
||||
<option value="01">Enero</option>
|
||||
<option value="02">Febrero</option>
|
||||
<option value="03">Marzo
|
||||
</option>
|
||||
<option value="04">Abril
|
||||
</option>
|
||||
<option value="05">Mayo
|
||||
</option>
|
||||
<option value="06">Junio
|
||||
</option>
|
||||
<option value="07">Julio
|
||||
</option>
|
||||
<option value="08">Agosto
|
||||
</option>
|
||||
<option value="09">Septiembre
|
||||
</option>
|
||||
<option value="10">Octubre
|
||||
</option>
|
||||
<option value="11">Noviembre
|
||||
</option>
|
||||
<option value="12">Diciembre
|
||||
</option>
|
||||
</select>
|
||||
|
||||
<div class="collapse" id="collapseExample">
|
||||
<div class="card card-body">
|
||||
<!--PACS-->
|
||||
<select id="table_select_PAC" class="form-control form-control-sm my_event_cls">
|
||||
<option value="00">Todos</option>
|
||||
<!--option value="01">EDICOM</option-->
|
||||
</select>
|
||||
<!--ANIOS-->
|
||||
<select style="display:inline" id="table_select_anio" class="form-control form-control-sm">
|
||||
<!--option value="0"></option-->
|
||||
</select>
|
||||
|
||||
<!--MESES-->
|
||||
<select id="table_select" class="form-control form-control-sm">
|
||||
<option value="01">Enero</option>
|
||||
<option value="02">Febrero</option>
|
||||
<option value="03">Marzo
|
||||
</option>
|
||||
<option value="04">Abril
|
||||
</option>
|
||||
<option value="05">Mayo
|
||||
</option>
|
||||
<option value="06">Junio
|
||||
</option>
|
||||
<option value="07">Julio
|
||||
</option>
|
||||
<option value="08">Agosto
|
||||
</option>
|
||||
<option value="09">Septiembre
|
||||
</option>
|
||||
<option value="10">Octubre
|
||||
</option>
|
||||
<option value="11">Noviembre
|
||||
</option>
|
||||
<option value="12">Diciembre
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</th>
|
||||
<th>Estado</th>
|
||||
<th scope="col">
|
||||
@@ -139,7 +157,7 @@ Timbres disponibles Comercio Digital: {{saldo}}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id='id_filters' style="display: inline;">{% for i,v in filters.items %}&{{i}}={{v}}{% endfor%}</div>
|
||||
<div id='id_filters' style="display: none;">{% for i,v in filters.items %}&{{i}}={{v}}{% endfor%}</div>
|
||||
|
||||
|
||||
<!-- Modal EMAIL-->
|
||||
@@ -289,8 +307,47 @@ Timbres disponibles Comercio Digital: {{saldo}}
|
||||
let filters = document.getElementById('id_filters').textContent
|
||||
let mes ='{{mes}}'
|
||||
let year = parseInt('{{year}}')
|
||||
let anc = document.getElementById('home_id')
|
||||
let PAC = Object.values(filters.split('&'))
|
||||
PAC.filter(val=>{
|
||||
lbl_pac.innerHTML="Todos"
|
||||
if(val.length >0){
|
||||
lbl_pac.innerHTML= val.split('=')[1]=="" ? "Todos" :val.split('=')[1]
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
/*-------------------------Carga los pacs*/
|
||||
fetch("{% url 'PACS_Retrive_RFCS' %}",{
|
||||
method:'GET',
|
||||
headers:{
|
||||
'Content-Type':'application/json',
|
||||
'X-Requested-With':'XMLHttpRequest',
|
||||
},
|
||||
credentials:"same-origin"
|
||||
})
|
||||
.then(res=>{
|
||||
return res.json()
|
||||
})
|
||||
.then(data=>{
|
||||
let pacs = [...new Set(data['PACS'].map((arr)=>arr.rfcp) )]
|
||||
|
||||
pacs.forEach((val,index)=>{
|
||||
let option = document.createElement('option')
|
||||
option.value=val
|
||||
option.text=val
|
||||
table_select_PAC.add(option)
|
||||
PAC.filter(val=>val.includes('PAC'))
|
||||
.forEach((val,index)=>{
|
||||
table_select_PAC.value = val.split('=')[1]
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(error=>{
|
||||
console.log(error)
|
||||
})
|
||||
/*----------------------fin carga pacs*/
|
||||
|
||||
function aclick(event,RFC ,cuantos){
|
||||
|
||||
@@ -338,7 +395,7 @@ Timbres disponibles Comercio Digital: {{saldo}}
|
||||
document.getElementById('table_select').addEventListener('change',(event)=>{
|
||||
spinner_id.setAttribute('style','display:inline;')
|
||||
|
||||
let anc = document.getElementById('home_id')
|
||||
|
||||
anc.href=''
|
||||
|
||||
let url = `?mes=${event.target.value}&year=${year}${filters}`
|
||||
@@ -353,7 +410,7 @@ Timbres disponibles Comercio Digital: {{saldo}}
|
||||
table_select_anio.addEventListener('change',(event)=>{
|
||||
spinner_id.setAttribute('style','display:inline;')
|
||||
|
||||
let anc = document.getElementById('home_id')
|
||||
|
||||
anc.href=''
|
||||
|
||||
let url = `?mes=${mes}&year=${event.target.value}${filters}`
|
||||
@@ -364,6 +421,17 @@ Timbres disponibles Comercio Digital: {{saldo}}
|
||||
},1000)
|
||||
})
|
||||
|
||||
table_select_PAC.addEventListener('change',(event)=>{
|
||||
spinner_id.setAttribute('style','display:inline;');
|
||||
anc.href='';
|
||||
let url =`?mes=${mes}&year=${year}&PAC=${event.target.value}`
|
||||
setTimeout(()=>{
|
||||
anc.href=url
|
||||
anc.click()
|
||||
},1000)
|
||||
|
||||
})
|
||||
|
||||
enviar_btn.addEventListener('click',(e)=>{
|
||||
|
||||
if(id_form.checkValidity()){
|
||||
|
||||
Reference in New Issue
Block a user