-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_timesheetpiscine.php
151 lines (139 loc) · 4.99 KB
/
generate_timesheetpiscine.php
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
<?PHP
// CH?KER LE COMPORTEMENT QU'ON VEUT DONNER
// LES P?RIODES ? venir pour la prochaine semaine?
// Ou bin celle au d?but de la session???
if(isset($_POST['FORMIDPiscine'])){
if(!isset($_POST['MultiVar_From5']))
$Semaine = get_last_sunday();
else
$Semaine = get_last_sunday(0,mktime(0,0,0,$_POST['MultiVar_From4'],$_POST['MultiVar_From5'],$_POST['MultiVar_From3']));
$sql_semaine_statement_for_dls = generate_sql_extended_semaine_query($Semaine);
apply_multiplicateur(array('Semaine1'=>$Semaine,'Semaine2'=>$Semaine));
$VJour = array('0'=>'0','1'=>0,'2'=>0,'3'=>0,'4'=>0,'5'=>0,'6'=>0);
$Req ="SELECT IDPiscine, IDEmploye, Role, sum((End-Start)/3600) as Duree, Jour
FROM
ressource JOIN periode
ON ressource.IDPeriode=periode.IDPeriode
WHERE ".$sql_semaine_statement_for_dls." AND IDPiscine = ".$_POST['FORMIDPiscine']." AND IDEmploye<>0
GROUP BY Jour, IDPiscine, Salaire, IDEmploye, Role, Semaine ASC
ORDER BY IDEmploye ASC, Role ASC, Salaire ASC, IDPiscine ASC, Semaine ASC, Jour ASC";
//ok now this the real shit, premi?re boucle pour les diff?rentes piscines
$SQL->SELECT($Req);
$TimeSheet = array();
$OldIDEmploye="";
$OldRole="";
$OldSalaire="";
//cr?ation du vecteur de timesheet
while($Rep = $SQL->FetchArray()){
if($OldIDEmploye<>$Rep['IDEmploye'] || $OldRole <> $Rep['Role']){
$TimeSheet[$Rep['IDEmploye']][$Rep['Role']]= $VJour;
$OldIDEmploye=$Rep['IDEmploye'];
$OldRole=$Rep['Role'];
}
$TimeSheet[$Rep['IDEmploye']][$Rep['Role']][$Rep['Jour']] = round($Rep['Duree'],2);
}
$PInfo = get_info('piscine',$_POST['FORMIDPiscine']);
$MainOutput->OpenTable('300');
$MainOutput->OpenRow();
$Time = get_end_dates(0,$Semaine);
$MainOutput->OpenCol('',4); // Zone Vide en haut
$MainOutput->AddOutput('<div align=center>',0,0);
$MainOutput->AddTexte('Feuille de temps du '.$Time['Start'].' au '.$Time['End'],'Titre');
$MainOutput->AddOutput('</div>',0,0);
$MainOutput->CloseCol();
$MainOutput->OpenCol('350',7,'top','b');
$MainOutput->AddTexte('<div align=center>'.$PInfo['Nom'].'</div>','Titre');
$MainOutput->CloseCol();
$MainOutput->CloseRow();
$MainOutput->OpenRow();
$MainOutput->OpenCol('20'); // Zone IDEmploye
$MainOutput->AddTexte('ID','Titre');
$MainOutput->CloseCol();
$MainOutput->OpenCol('75'); // Zone Nom
$MainOutput->AddTexte('Nom','Titre');
$MainOutput->CloseCol();
$MainOutput->OpenCol('75'); // Zone Prenom
$MainOutput->AddTexte('Prenom','Titre');
$MainOutput->CloseCol();
$MainOutput->OpenCol('25'); // Zone Prenom
$MainOutput->AddTexte('Role','Titre');
$MainOutput->CloseCol();
$DList = get_day_list("court");
foreach($DList as $k=>$v){
if($k==0)
$MainOutput->OpenCol('25',1,'top','l');
else
$MainOutput->OpenCol('25');
$MainOutput->AddTexte('<div align=center>'.$v.'</div>','Titre');
$MainOutput->CloseCol();
}
$MainOutput->OpenCol('30',1,'top','b'); //
$MainOutput->AddTexte('Total','Titre');
$MainOutput->CloseCol();
$MainOutput->OpenCol('100',1,'top','b'); //
$MainOutput->AddTexte('<img src=carlos width=100 height=1>Ajt','Titre');
$MainOutput->CloseCol();
$c = "two";
foreach($TimeSheet as $IDEmploye =>$v1){
$InfoE = get_info('employe',$IDEmploye);
foreach($v1 as $Role => $v2){
if($c=="two")
$c="one";
else
$c="two";
$MainOutput->OpenRow('',$c);
$MainOutput->OpenCol('20',1,'top','bl'); // Zone IDEmploye
$MainOutput->AddTexte($IDEmploye);
$MainOutput->CloseCol();
$MainOutput->OpenCol('60',1,'top',$c); // Zone Nom
$MainOutput->AddTexte($InfoE['Nom']);
$MainOutput->CloseCol();
$MainOutput->OpenCol('60',1,'top',$c); // Zone Prenom
$MainOutput->AddTexte($InfoE['Prenom']);
$MainOutput->CloseCol();
$MainOutput->OpenCol('25',1,'top',$c); // Zone Prenom
$MainOutput->AddTexte($Role);
$MainOutput->CloseCol();
$Total =0;
foreach($TimeSheet[$IDEmploye][$Role] as $v){
$MainOutput->OpenCol('25',1,'top',$c);
if($v==0)
$v=" ";
$MainOutput->AddTexte($v);
$MainOutput->CloseCol();
}
$STotal = array_sum($TimeSheet[$IDEmploye][$Role]);
$Total = $Total + $STotal;
$MainOutput->OpenCol(30,1,'top','b');
$MainOutput->AddTexte($Total);
$MainOutput->CloseCol();
$MainOutput->OpenCol(100,1,'top','b');
$MainOutput->AddTexte(" ");
$MainOutput->CloseCol();
$MainOutput->CloseRow();
}
}
for($k=0;$k<5;$k++){
if($c=="two")
$c="one";
else
$c="two";
$MainOutput->OpenRow();
for($i=0;$i<13;$i++){
$MainOutput->OpenCol('','','',$c);
$MainOutput->AddTexte('<img src=carlos.gif width=1 height=20>');
}
$MainOutput->CloseRow();
}
$MainOutput->CloseTable();
}else{
$MainOutput->AddForm('Générer la feuille de temps piscine');
$MainOutput->Inputhidden_env('Section','Generate_TimesheetPiscine');
$MainOutput->Inputhidden_env('ToPrint','TRUE');
$Req = "SELECT IDPiscine, Nom FROM piscine WHERE Active ORDER BY Nom ASC";
$MainOutput->inputselect('IDPiscine',$Req,'','Piscine');
$MainOutput->inputtime('From','Finissant',time(),array('Time'=>FALSE,'Date'=>TRUE));
$MainOutput->formsubmit('Générer');
}
echo $MainOutput->Send(1);
?>