Bonjour,
Je viens vers vous car j'ai quelques petits problèmes sans solutions.
Contexte : J'appuie sur un bouton qui m'ouvre une page visualforce. Dans celle-ci, j'ai un calendar pour choisir le mois et l'année. Ensuite, je clique sur un bouton Ok qui me redirige vers une autre page visualforce qui contient des informations pour le paiement des astreintes qui récupère la date rentrée dans le calendar.
J'ai un seul controlleur pour mes deux pages visualforce.
Page visualforce qui contient les informations pour le paiement des astreintes :
Ainsi que son controller :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203 <apex:page standardController="Astreinte__c" extensions="CCE_PDF_SuiviInterventions" showHeader="false" sidebar="false" renderAs="PDF"> <head> <!-- FEUILLE DE STYLE CSS --> <apex:stylesheet value="{!URLFOR($Resource.RS_CSS_PDF, 'CSS_PDF.css')}"/> <style type="text/css"> @page { <!--size: A4 landscape;--> @bottom-left { font-family: Arial,sans-serif; color:#404040; font-size: 0.75em; content: "<apex:outputText value="{!$Organization.Name} - {!$User.FirstName} {!$User.LastName} - {!NOW()}" />" } } </style> </head> <body> <!-- VARIABLES STATIQUES GLOBALES --> <!-- Variable pour avoir le mois en lettres --> <apex:variable var="Mois_en_Analyse" value="{!IF((MONTH(DateMoisAstreinte) == 1), "Janvier", IF((MONTH(DateMoisAstreinte) == 2), "Février", IF((MONTH(DateMoisAstreinte) == 3), "Mars", IF((MONTH(DateMoisAstreinte) == 4), "Avril", IF((MONTH(DateMoisAstreinte) == 5), "Mai", IF((MONTH(DateMoisAstreinte) == 6), "Juin", IF((MONTH(DateMoisAstreinte) == 7), "Juillet", IF((MONTH(DateMoisAstreinte) == 8), "Août", IF((MONTH(DateMoisAstreinte) == 9), "Septembre", IF((MONTH(DateMoisAstreinte) == 10), "Octobre", IF((MONTH(DateMoisAstreinte) == 11), "Novembre", IF((MONTH(DateMoisAstreinte) == 12), "Decembre", "ERREUR"))))))))))))}" /> <!-- DEBUT DE LA BOUCLE POUR CHAQUE RESSOURCES D ASTREINTE pour l astreinte concernée --> <apex:repeat value="{!RessourcesAstreinte}" var="RessourceAstreinte"> <div style="page-break-inside: avoid;"> <h3 class="Grey"> <apex:outputText value="Tableau de suivi paiement des astreintes" escape="false"/> </h3> <!-- Détail de l'astreinte et de l'intervenant --> <!-- Variable qui détermine le premier jour du mois sélectionné à l étape 1--> <apex:variable var="PremierJourDateMoisAstreinte" value="{!DateMoisAstreinte - DAY(DateMoisAstreinte) + 1}"/> <!-- Variable qui détermine le dernier jour du mois sélectionné à l étape 1 --> <apex:variable var="DernierJourDateMoisAstreinte" value="{!DateMoisAstreinte + IF(MONTH(DateMoisAstreinte)=12, DATE(YEAR(DateMoisAstreinte),12,31) - DateMoisAstreinte, DATE(YEAR(DateMoisAstreinte),MONTH(DateMoisAstreinte)+1,1) - DateMoisAstreinte-1 ) }"/> <apex:repeat value="{!Imputations}" var="Imput"> <br/><br/><br/> <!-- Creation d'un nouveau tableau, ce n'est pas très esthetique, mais pas trouvé d'autre solution --> <!-- pour eviter un tableau vide quand il n'y a pas de ticket ... --> <table border="0" cellpadding="2" cellspacing="0" width="100%"> <tr> <td> <b>No AFFAIRE : </b> <apex:outputField value="{!Imput.No_affaire__r.Name}" /> </td> <td></td> <td> <b>Libelle AFFAIRE : </b> <apex:outputText value="{!Imput.Libelle_Affaire__c}" escape="false"/> </td> </tr> <br/> <tr> <td> <b>Nom SALARIE : </b> <apex:outputText value="{!RessourceAstreinte.Ressource_INEO__r.Name} {!RessourceAstreinte.Ressource_INEO__r.Prenom__c}"/> </td> </tr> </table> <br/><br/> <apex:variable var="TOTALPrime" value="{!0}"/> <table border="1" cellpadding="7" cellspacing="2" width="100%" style="border-collapse:collapse;"> <tr> <th class="c20"><center>N° Semaine</center></th> <th class="c20"><center>Nombre jours semaines</center></th> <th class="c20"><center>Nombre jours week-end</center></th> <th class="c20"><center>Nombre jours <br/> fériés / RTTE</center></th> <th class="c20"><center><apex:outputText value="{!If((RessourceAstreinte.Ressource_INEO__r.Est_prestataire__c == false), "Montant", "Montant Facture " + RessourceAstreinte.Ressource_INEO__r.SS2I__c)}"/></center></th> </tr> </table> <apex:repeat value="{!Planif}" var="Planif1"> <apex:variable var="TOTALPrime" value="{!IF((Planif1.Ressource_INEO__c == RessourceAstreinte.Ressource_INEO__c) && (Planif1.Date_fin__c <= DernierJourDateMoisAstreinte) && (Planif1.Date_fin__c >= PremierJourDateMoisAstreinte), TOTALPrime + Planif1.Prime_euro__c, TOTALPrime )}" /> <apex:pageBlock rendered="{!((Planif1.Ressource_INEO__c == RessourceAstreinte.Ressource_INEO__c) && ((Planif1.Date_fin__c<= DernierJourDateMoisAstreinte) && (Planif1.Date_fin__c>= PremierJourDateMoisAstreinte)))}"> <table border="1" cellpadding="5" cellspacing="2" width="100%" style="border-collapse:collapse;"> <tr> <td class="c20"><apex:outputText value="{!CEILING(((Planif1.Date_debut__c - DATE(YEAR(Planif1.Date_debut__c), 1, 1) + 1) + MOD(DATE(YEAR(Planif1.Date_debut__c), 1, 1) - DATE(1900, 1, 7), 7)) / 7)}"/> </td> <td class="c20"><apex:outputText value="{!CASE(MOD( Planif1.Date_debut__c - DATE(1985,6,24),7), 0 , CASE( MOD( Planif1.Date_fin__c - Planif1.Date_debut__c ,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 1 , CASE( MOD( Planif1.Date_fin__c - Planif1.Date_debut__c ,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 2 , CASE( MOD( Planif1.Date_fin__c - Planif1.Date_debut__c ,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 3 , CASE( MOD( Planif1.Date_fin__c - Planif1.Date_debut__c ,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 4 , CASE( MOD( Planif1.Date_fin__c - Planif1.Date_debut__c ,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 5 , CASE( MOD( Planif1.Date_fin__c - Planif1.Date_debut__c ,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 6 , CASE( MOD( Planif1.Date_fin__c - Planif1.Date_debut__c ,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 999) + (FLOOR(( Planif1.Date_fin__c - Planif1.Date_debut__c )/7)*5)}"></apex:outputText> </td> <td class="c20"><apex:outputText value="{!CASE(MOD(Planif1.Date_debut__c - DATE (1985,6,24), 7), 0, CASE (MOD (Planif1.Date_fin__c - Planif1.Date_debut__c, 7), 1,0,2,0,3,0,4, 0,5,1,6,2,0), 1, CASE (MOD (Planif1.Date_fin__c - Planif1.Date_debut__c, 7), 0,0,1,0,2,0,3,0,4,0,5,2, 2), 2, CASE (MOD (Planif1.Date_fin__c - Planif1.Date_debut__c, 7), 0,0,1,0,2,0,3,1,2), 3, CASE (MOD (Planif1.Date_fin__c - Planif1.Date_debut__c, 7), 0, 0,1,0,2,1,2), 4, CASE (MOD (Planif1.Date_fin__c - Planif1.Date_debut__c, 7), 0,0,1,1,2), 5, CASE (MOD (Planif1.Date_fin__c - Planif1.Date_debut__c, 7), 0,1,2), 6, CASE (MOD (Planif1.Date_fin__c - Planif1.Date_debut__c, 7), 6,2,1), 999) + (FLOOR ((Planif1.Date_fin__c - Planif1.Date_debut__c) / 7) * 2)}"/> </td> <td class="c20"><apex:outputText value="{!JourVacances}"> <apex:param value="{!Planif1.Date_debut__c}"/> <apex:param value="{!Planif1.Date_fin__c}"/></apex:outputText></td> <td class="c20"><apex:outputText value="{!Planif1.Prime_Euro__c}"/></td> </tr> </table> </apex:pageBlock> </apex:repeat> <br/> <p style="float:right;color:#1c2691;font-size:1.3em"><b><u>Total :</u> <apex:outputText value="{!TOTALPrime} " style="font-style:bold;float:right;"></apex:outputText></b></p> <br/><br/><br/><br/> <table border="0.5" cellpadding="2" cellspacing="0" width="100%"> <tr> <th><center>VISAS</center></th> <th><center>RA</center></th> <th><center>RCP</center></th> <th><center><apex:outputText value="{!If((RessourceAstreinte.Ressource_INEO__r.Est_prestataire__c == false), "SALARIE", "PRESTATAIRE")}"/></center></th> </tr> <tr> <th class="c10">NOM</th> <td class="c10"><apex:outputText value="{!Imput.No_Affaire__r.Responsable__r.Name} {!Imput.No_Affaire__r.Responsable__r.Prenom__c}" style="text-decoration:none;" /></td> <td class="c10"><apex:outputText value="{!IF(BEGINS(Imput.Site_INEO__r.Direction__c, "DOS"), "Thierry LECLAIR", "?" & IF(BEGINS(Imput.Site_INEO__r.Direction__c, "DR"),"Patrick RODIGUE", "?"))}" escape="false"/></td> <td class="c10"><apex:outputText value="{!RessourceAstreinte.Ressource_INEO__r.Name} {!RessourceAstreinte.Ressource_INEO__r.Prenom__c}"/></td> </tr> <tr> <th class="c10">DATE</th> <td class="c10"><apex:outputText value="{0,date, dd/MM/yyyy}"> <apex:param value="{!TODAY()}" /> </apex:outputText></td> <td></td> <td></td> </tr> <tr> <th class="c10">SIGNATURE</th> <td><br/><br/><br/></td> <td><br/><br/><br/></td> <td><br/><br/><br/></td> </tr> </table> <!-- Et il faut y ajouter les temps à récupérer sur les planifications d'astreinte --> </apex:repeat> <!-- . --> </div> </apex:repeat> </body> </apex:page>
Voici un morceau du rendu de ma page :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198 public class CCE_PDF_SuiviInterventions { public Integer JourVacances{get;set;} public Integer JourTravaille{get;set;} public String myLabel{get;set;} // Pour le wizard ! public PageReference step1() { return Page.PV_PDF_SuiviInterventions_Step1; } public PageReference step2() { Date currentDate = Date.today(); if( currentDate.month() == DateMoisAstreinte.Month()) { return Page.PV_PDF_SuiviInterventions_Step1; } return Page.PV_PDF_SuiviInterventions_Step2; } public PageReference step3() { Date currentDate = Date.today(); if( currentDate.month() == DateMoisAstreinte.Month()) { return Page.PV_PDF_SuiviInterventions_Step1; } //if(DateMoisAstreinte.Year() < 2015 || DateMoisAstreinte.month() <1) // { // ApexPages.Message Alerte = new ApexPages.Message(ApexPages.Severity.FATAL, 'L\'édition des feuilles de paiement par Salesforce n\'est autorisée qu\'à partir des données de Novembre 2015'); // ApexPages.addMessage(Alerte); // return null; //} return Page.PV_DOS_PaiementAstreinte; } // DATES POUR LES RECHERCHES (année en cours, année précédente, date du jour, - 90, - 120 et - 365 jours) public Integer ThisYear = Date.Today().year(); public Integer getThisYear(){return ThisYear;} public Integer LastYear = Date.Today().year() - 1; public Integer getLastYear(){return LastYear;} public Date Today = Date.today(); public Date getToday(){return Today;} public Date Today_90 = Date.today() - 90; public Date getToday_90(){return Today_90;} public Date Today_120 = Date.today() - 120; public Date getToday_120(){return Today_120;} public Date Today_365 = Date.today() - 365; public Date getToday_365(){return Today_365;} // DATE QUI SERA SELECTIONNEE A LA PREMIERE ETAPE DU WIZARD public Date DateMoisAstreinte {get; set;} // DEFINITION DU CONTROLEUR CCE_PDF_SuiviInterventions private final Astreinte__c Astreinte; public CCE_PDF_SuiviInterventions(ApexPages.StandardController controller) { this.Astreinte = (Astreinte__c)controller.getRecord(); } // LES RESSOURCES ASSOCIEES A CETTE ASTREINTE public Ressource_Astreinte__c[] getRessourcesAstreinte() { Ressource_Astreinte__c[] RessourcesAstreinte = [SELECT Astreinte__c, Id, Ressource_INEO__c, Ressource_INEO__r.Est_prestataire__c, Ressource_INEO__r.SS2I__c, Ressource_INEO__r.Name, Ressource_INEO__r.Prenom__c, Ressource_INEO__r.Total_a_recuperer__c, Ressource_INEO__r.Cumul_recuperations__c, Ressource_INEO__r.Reste_a_recuperer__c, Ressource_INEO__r.Reliquat_mn__c FROM Ressource_Astreinte__c WHERE Astreinte__c = :Astreinte.Id ORDER BY Name ASC]; return RessourcesAstreinte; } // LES TICKETS ASSOCIES A CETTE ASTREINTE public Ticket__c[] getTickets() { Ticket__c[] Tickets = [SELECT Astreinte__c, Date_appel__c, Heure_appel__c, Heure_fin_intervention__c, Ressource_INEO__r.Name, Id, Ressource_INEO__c, Intervention__c, Name, Requete_de_suivi__c, Signalement__c, Lien_Site_INEO__c, IsDeleted, Temps_deplacement__c, Temps_intervention__c, Temps_total__c, Temps_total_mn__c, Temps_a_recuperer__c, Temps_a_recuperer_mn__c FROM Ticket__c WHERE Astreinte__c = :Astreinte.Id ORDER BY Date_appel__c, Heure_appel__c ASC]; return Tickets; } // L'ENSEMBLE DES TICKETS (Tous sites, toutes astreintes, toutes ressources) public Ticket__c[] getAllTickets() { Ticket__c[] AllTickets = [SELECT Astreinte__c, Date_appel__c, Heure_appel__c, Heure_fin_intervention__c, Ressource_INEO__r.Name, Id, Ressource_INEO__c, Intervention__c, Name, Requete_de_suivi__c, Signalement__c, Lien_Site_INEO__c, IsDeleted, Temps_deplacement__c, Temps_intervention__c, Temps_total__c, Temps_total_mn__c, Temps_a_recuperer__c, Temps_a_recuperer_mn__c FROM Ticket__c ORDER BY Name ASC]; return AllTickets; } // L'ENSEMBLE DES RECUPERATIONS (Tous sites, toutes astreintes, toutes ressources) public Recuperation__c[] getAllRecup() { Recuperation__c[] AllRecup = [SELECT Date_demande__c, Ressource_INEO__c, Dernier_jour__c, Duree__c, Duree_mn__c, Id, Name, Premier_jour__c FROM Recuperation__c ORDER BY Name ASC]; return AllRecup; } // LES PLANIFICATION ASSOCIEES A CETTE ASTREINTE public Planification_Astreinte__c[] getPlanif() { Planification_Astreinte__c[] Planif = [SELECT Astreinte__c, Date_debut__c, Date_fin__c, Id, Ressource_INEO__c, Niveau__c, Name, Prime_Euro__c, Temps_recuperer__c, Temps_recuperer_mn__c FROM Planification_Astreinte__c WHERE Astreinte__c = :Astreinte.Id ORDER BY Name ASC]; return Planif; } // L'ENSEMBLE DES PLANIFICATION_ASTREINTE (Tous sites, toutes astreintes, toutes ressources) public Planification_Astreinte__c[] getAllPlanif() { Planification_Astreinte__c[] AllPlanif = [SELECT Astreinte__c, Date_debut__c, Date_fin__c, Id, Ressource_INEO__c, Niveau__c, Name, Prime_Euro__c, Temps_recuperer__c, Temps_recuperer_mn__c FROM Planification_Astreinte__c ORDER BY Name ASC]; return AllPlanif; } public Imputation__c[] getImputations() { Imputation__c[] Imputations = [SELECT Site_INEO__r.Name, Site_INEO__r.Direction__c, No_affaire__r.Name, Libelle_affaire__c, Responsable__c, No_Affaire__r.Responsable__r.Name, No_Affaire__r.Responsable__r.Prenom__c FROM Imputation__c WHERE Site_INEO__c in (Select Site_INEO__c FROM Astreinte__c WHERE Id = :Astreinte.Id)]; return Imputations; } //Calcul des Jours travaillés, Jours non travaillés, Jours de Vacances public Integer getCalculateWorkingDays() { Set<Date> holidaysSet = new Set<Date>(); for(Holiday currHoliday : [Select ActivityDate from holiday]) { holidaysSet.add(currHoliday.ActivityDate); } //SELECT Ressource_INEO__r.Name, Date_debut__c, Date_fin__c FROM Planification_Astreinte__c WHERE Ressource_INEO__c in (SELECT Ressource_INEO__c FROM Ressource_Astreinte__c WHERE Astreinte__c = 'a0VD00000078z8oMAA') for(Planification_Astreinte__c Planif : [SELECT Date_debut__c, Date_fin__c FROM Planification_Astreinte__c]) { Date startDate =Planif.Date_debut__c; Date endDate = Planif.Date_fin__c; for(integer i=0; i <= startDate.daysBetween(endDate); i++) { Date dt = startDate + i; DateTime currDate = DateTime.newInstance(dt.year(), dt.month(), dt.day()); String todayDay = currDate.format('EEEE'); if((holidaysSet.contains(dt))) { JourVacances = JourVacances + 1; } else if(todayDay != 'Saturday' && todayDay !='Sunday' && (!holidaysSet.contains(dt))) { JourTravaille = JourTravaille + 1; } system.debug('Jours Vacances ===========================' + JourVacances); system.debug('Jours Travaillés ===========================' + JourTravaille); } } return JourVacances; return JourTravaille; } }
Dans ce tableau, je calcul le n° semaine, nombre jours semaines, nombre jours week-end grâce à des formules et aux champs Date_debut__c et Date_fin__c (on peut voir ça dans le code de la page). Il faut que je calcule aussi le nombre jours fériés/RTTE.
Le montant des astreintes est calculé grâce à un champ de mon objet.
Dans mon tableau, le nombre de jours week-end est bon.
Le n° semaine n'est pas bon puisque, dans l'exemple, j'ai 14 jours semaines et n° semaine 42. Est-il possible d'avoir chaque numéro de semaine ? C'est-à-dire que 14 jours ça fait trois semaines de travail (5+5+4) donc je devrais avoir 3 n° de semaine dans la case.
Le nombre jours semaines est bon pour l'exemple mais si je viens à avoir un jour férié dans la semaine, il le comptera comme un jour de travail.
Pour avoir un bon calcul de Nombre jours semaines et Nombre jours fériés/RTTE, j'ai fais getCalculateWorkingDays (tout en bas du controlleur, en bleu).
Le problème est que je n'arrive pas à appeler ce calcul dans ma page visualforce... J'aimerai avoir mon nombre dans la colonne Nombre jours fériés/RTTE...
J'espère avoir été assez clair dans mes idées ainsi que dans mes questions.
Je vous remercie par avance.
Bonne journée !
Dedex
Partager