1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
Option Compare Database
Public Function FDateUs(vDate As Date) As String
FDateUs = "#" & Format(vDate, "mm/dd/yyyy") & "#"
End Function
'
' Retourne le nombre de jour d'un mois donné, en utilisant Day(), DateSerial et DateAdd()
'
Public Function DaysInMonth(ByVal nMonth As Integer, ByVal nYear As Integer) As Integer
DaysInMonth = Day(DateAdd("d", -1, DateAdd("m", 1, DateSerial(nYear, nMonth, 1))))
End Function
' Code de la faq : Auteur MC2.
Function EstFerie(ByVal QuelleDate As Date) As Boolean
Dim anneeDate As Integer
Dim joursFeries(1 To 11) As Date
Dim i As Integer
anneeDate = Year(QuelleDate)
joursFeries(1) = DateSerial(anneeDate, 1, 1)
joursFeries(2) = DateSerial(anneeDate, 5, 1)
joursFeries(3) = DateSerial(anneeDate, 5, 8)
joursFeries(4) = DateSerial(anneeDate, 7, 14)
joursFeries(5) = DateSerial(anneeDate, 8, 15)
joursFeries(6) = DateSerial(anneeDate, 11, 1)
joursFeries(7) = DateSerial(anneeDate, 11, 11)
joursFeries(8) = DateSerial(anneeDate, 12, 25)
joursFeries(9) = fLundiPaques(anneeDate)
joursFeries(10) = joursFeries(9) + 38 ' Ascension = lundi de Paques + 38
joursFeries(11) = joursFeries(9) + 49 ' Lundi Pentecôte = lundi de Paques + 49
For i = 1 To 11
If QuelleDate = joursFeries(i) Then
EstFerie = True
Exit For
End If
Next
End Function
Private Function fLundiPaques(ByVal Iyear As Integer) As Date
'Adapté de +ieurs scripts...
Dim L(6) As Long, Lj As Long, Lm As Long
L(1) = Iyear Mod 19: L(2) = Iyear Mod 4: L(3) = Iyear Mod 7
L(4) = (19 * L(1) + 24) Mod 30
L(5) = ((2 * L(2)) + (4 * L(3)) + (6 * L(4)) + 5) Mod 7
L(6) = 22 + L(4) + L(5)
If L(6) > 31 Then
Lj = L(6) - 31
Lm = 4
Else
Lj = L(6)
Lm = 3
End If
' Lundi de Pâques = Paques + 1 jour
fLundiPaques = DateAdd("d", 1, (Lj & "/" & Lm & "/" & Iyear))
End Function
Public Sub MajPlanning()
Dim ND As Integer, j As Integer
Dim DateJ As Date, S As Double, ST As Double
ND = DaysInMonth(Forms!Frm_Pointage!Mois, Forms!Frm_Pointage!An)
DateJ = DateSerial(Forms!Frm_Pointage!An, Forms!Frm_Pointage!Mois, 1)
ST = 0
'Forms!Frm_Pointage!SFrm_Pointage.Form!controle1.SetFocus
For j = 1 To ND
Forms!Frm_Pointage!SF_Pointage.Form("Col" & j).Caption = UCase(Left(Format(DateJ, "ddd"), 1)) & vbCrLf & j
If (DateJ = Date) Then ' 15852772
Forms!Frm_Pointage!SF_Pointage.Form("Col" & j).BackColor = 15852772
Forms!Frm_Pointage!SF_Pointage.Form("Jour" & j).BackColor = 15852772
ElseIf EstWeekEnd(DateJ) Then
Forms!Frm_Pointage!SF_Pointage.Form("Col" & j).BackColor = 13428479
Forms!Frm_Pointage!SF_Pointage.Form("Jour" & j).BackColor = 13428479
ElseIf EstFerie(DateJ) Then
Forms!Frm_Pointage!SF_Pointage.Form("Col" & j).BackColor = 8963327
Forms!Frm_Pointage!SF_Pointage.Form("Jour" & j).BackColor = 8963327
Else
Forms!Frm_Pointage!SF_Pointage.Form("Col" & j).BackColor = 16761024
Forms!Frm_Pointage!SF_Pointage.Form("Jour" & j).BackColor = vbWhite
End If
S = Nz(DSum("[NbHeuresPointees]", "[T_Pointage]", "[DatePointage] = " & FDateUs(DateJ) & " and ([LoginSalarié]=" & Formulaires!Frm_Pointage!loginSalarie & ")"), 0)
ST = ST + S
Forms!Frm_Pointage!SF_Pointage.Form("Total" & j).Value = S
DateJ = DateJ + 1
Next j
Forms!Frm_Pointage!SF_Pointage.Form("Total").Value = ST
For j = 29 To ND
Forms!Frm_Pointage!SF_Pointage.Form("Col" & j).Visible = True
Forms!Frm_Pointage!SF_Pointage.Form("Jour" & j).Visible = True
Next j
For j = (ND + 1) To 31
Forms!Frm_Pointage!SF_Pointage.Form("Col" & j).Visible = False
Forms!Frm_Pointage!SF_Pointage.Form("Jour" & j).Visible = False
Next j
Forms!Frm_Pointage!SF_Pointage.Requery
End Sub
Public Function EstWeekEnd(dt As Date) As Boolean
EstWeekEnd = (Weekday(dt) = 1) Or (Weekday(dt) = 7)
End Function
Public Sub MajReport()
Dim ND As Integer, j As Integer
Dim DateJ As Date
ND = DaysInMonth(Forms!Frm_Pointage!Mois, Forms!Frm_Pointage!An)
DateJ = DateSerial(Forms!Frm_Pointage!An, Forms!Frm_Pointage!Mois, 1)
Reports!R_Récup_Pointage_par_Affaires_par_Salarié!Titre.Caption = "Planning mensuel des heures pour le mois de " & Format(DateJ, "mmmm yyyy")
For j = 1 To ND
Reports!R_Récup_Pointage_par_Affaires_par_Salarié("Col" & j).Caption = UCase(Left(Format(DateJ, "ddd"), 1)) & vbCrLf & j
If EstWeekEnd(DateJ) Or EstFerie(DateJ) Then
Reports!R_Récup_Pointage_par_Affaires_par_Salarié("Col" & j).BackColor = 13428479
Reports!R_Récup_Pointage_par_Affaires_par_Salarié("Jour" & j).BackColor = 13428479
Else
Reports!R_Récup_Pointage_par_Affaires_par_Salarié("Col" & j).BackColor = 16761024
Reports!R_Récup_Pointage_par_Affaires_par_Salarié("Jour" & j).BackColor = vbWhite
End If
DateJ = DateJ + 1
Next j
For j = 29 To ND
Reports!R_Récup_Pointage_par_Affaires_par_Salarié("Col" & j).Visible = True
Reports!R_Récup_Pointage_par_Affaires_par_Salarié("Jour" & j).Visible = True
Next j
For j = (ND + 1) To 31
Reports!R_Récup_Pointage_par_Affaires_par_Salarié("Col" & j).Visible = False
Reports!R_Récup_Pointage_par_Affaires_par_Salarié("Jour" & j).Visible = False
Next j
End Sub
Public Function OuvrirFormSaisie(j As Integer)
Dim DateJ As Date
DateJ = DateSerial(Forms!Frm_Pointage!An, Forms!Frm_Pointage!Mois, j)
'DoCmd.OpenForm "F_Saisie", , , "[LoginSalarié]=" & Nz(Formulaires!Frm_Pointage!loginSalarie, 0) & " and [Référénce Commande]=" & Nz(Formulaires!Frm_Pointage!SF_Pointage!Référence_Commande, 0) & " and ([DatePointage]=" & FDateUs(DateJ) & ")"
DoCmd.OpenForm "F_Saisie", , , "[Référénce Commande]=" & Nz(Formulaires!Frm_Pointage!SF_Pointage!Référence_Commande, 0) & " and ([DatePointage]=" & FDateUs(DateJ) & ")"
Forms!F_Saisie!loginSalarie.Value = Forms!Frm_Pointage!loginSalarie
Forms!F_Saisie!Jour.Value = DateJ
Forms!F_Saisie!Référence_Commande.Value = Forms!Frm_Pointage!SF_Pointage!Référence_Commande
End Function |
Partager