Ajout export pdf des heures supplémetnaires

This commit is contained in:
Ambulance Clerc
2022-05-02 14:40:10 +02:00
parent f410e3c5da
commit 5bd350aece
12 changed files with 193 additions and 11 deletions

View File

@@ -10,6 +10,11 @@ from django.contrib import admin
#test
BASES_CHOICES = [
('1', 'Monthey'),
('2', 'Uvrier'),
]
class Collabs_hour_types(models.Model):
@@ -27,10 +32,7 @@ class Collabs_hour_types(models.Model):
class Collabs_hour(models.Model):
BASES_CHOICES = [
('1', 'Monthey'),
('2', 'Uvrier'),
]
userName = models.CharField("Auteur", max_length=100)
user = models.ForeignKey(settings.AUTH_USER_MODEL, limit_choices_to={'groups__name': "Intervenants"}, verbose_name="Collaborateur", on_delete=models.DO_NOTHING)
@@ -50,18 +52,17 @@ class Collabs_hour(models.Model):
def get_total_hour_by_user(self):
#objs = Collabs_hour.objects.filter(user_id=self.user_id,dtCreated__year=self.dtCreated.year, dtCreated__month=self.dtCreated.month)
objs = Collabs_hour.objects.filter(user_id=self.user_id, dtDate__year=self.dtDate.year , dtDate__month=self.dtDate.month)
print(f"user {self.user} dtCreated__year {self.dtDate.year} dtCreated__month {self.dtDate.month}")
# print(f"user {self.user} dtCreated__year {self.dtDate.year} dtCreated__month {self.dtDate.month}")
#print( Collabs_hour.objects.all())
total = 0.0
for object in objs:
total += object.nHour + object.nMinutes/60
print(f"hour = {object.nHour} minutes = {object.nMinutes} = {object.nMinutes/60}")
# print(f"hour = {object.nHour} minutes = {object.nMinutes} = {object.nMinutes/60}")
print(total)
print(objs)
if total > 0.0:
hours = int(total)
minutes = (total*60) % 60
@@ -74,6 +75,9 @@ class Collabs_hour(models.Model):
return ret_string
def get_bases_name(self):
return BASES_CHOICES[int(self.sBases)-1][1]
@admin.display(description='Présence de remarques', boolean=True)
def has_remarques(self):
ret = False