-
Notifications
You must be signed in to change notification settings - Fork 12
/
regleAbsence.php
219 lines (182 loc) · 7.56 KB
/
regleAbsence.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
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
<?php
require('config.php');
require('./class/absence.class.php');
require('./lib/absence.lib.php');
$langs->load('absence@absence');
$ATMdb=new TPDOdb;
$regle=new TRH_RegleAbsence;
if(isset($_REQUEST['action'])) {
switch($_REQUEST['action']) {
case 'add':
case 'new':
//$ATMdb->db->debug=true;
$regle->load($ATMdb, GETPOST('id','integer'));
_fiche($ATMdb,$regle,'edit');
break;
case 'edit' :
//$ATMdb->db->debug=true;
$regle->load($ATMdb, GETPOST('id','integer'));
_fiche($ATMdb, $regle, 'edit');
break;
case 'save':
$ATMdb->db->debug=true;
$regle->load($ATMdb, GETPOST('id','integer'));
$regle->restrictif=0;
$regle->contigue=0;
$regle->contigueNoJNT=0;
$regle->set_values($_REQUEST);
$regle->save($ATMdb);
$mesg = '<div class="ok">' . $langs->trans('ChangesMade') . '</div>';
_fiche($ATMdb, $regle,'view');
break;
case 'view':
$regle->load($ATMdb, GETPOST('id','integer'));
_fiche($ATMdb, $regle,'view');
break;
case 'delete':
$regle->load($ATMdb, GETPOST('id','integer'));
$regle->delete($ATMdb);
$mesg = '<div class="ok">' . $langs->trans('RuleDeleted') . '</div>';
_liste($ATMdb, $regle);
break;
}
}
elseif(isset($_REQUEST['id'])) {
$regle->load($ATMdb, $_REQUEST['id']);
_liste($ATMdb, $regle);
}
else {
_liste($ATMdb, $regle);
}
$ATMdb->close();
function _liste(&$ATMdb, $regle) {
global $langs,$conf, $db, $user;
llxHeader('', $langs->trans('HolidaysRules'));
print dol_get_fiche_head(reglePrepareHead($regle,'regle') , 'regle', $langs->trans('Rules'));
$r = new TSSRenderControler($regle);
$sql="SELECT DISTINCT r.rowid as 'ID',r.periode, CONCAT(u.firstname,' ',u.lastname) as 'Utilisateur', g.nom as 'Groupe',
r.typeAbsence, r.nbJourCumulable , r.restrictif as 'Restrictif', '' as 'Supprimer'
FROM ".MAIN_DB_PREFIX."rh_absence_regle as r
LEFT OUTER JOIN ".MAIN_DB_PREFIX."user as u ON (r.fk_user = u.rowid)
LEFT OUTER JOIN ".MAIN_DB_PREFIX."usergroup as g ON (r.fk_usergroup = g.rowid)
WHERE r.entity IN (0,".$conf->entity.")";
//echo $sql;
$TOrder = array('ID'=>'ASC');
if(isset($_REQUEST['orderDown']))$TOrder = array($_REQUEST['orderDown']=>'DESC');
if(isset($_REQUEST['orderUp']))$TOrder = array($_REQUEST['orderUp']=>'ASC');
$page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
$form=new TFormCore($_SERVER['PHP_SELF'],'formtranslateList','GET');
$r->liste($ATMdb, $sql, array(
'limit'=>array(
'page'=>$page
,'nbLine'=>'30'
)
,'link'=>array(
'ID'=>'<a href=?id=@ID@&action=view&fk_user='.$user->id.'>@val@</a>'
,'typeAbsence'=>'<a href=?id=@ID@&action=view&fk_user='.$user->id.'>@val@</a>'
,'Supprimer'=>"<a onclick=\"if (window.confirm('" . $langs->trans('ConfirmDeleteRule') . "')){href='?id=@ID@&fk_user=".$user->id."&action=delete'};\"><img src='./img/delete.png'></a>"
)
,'translate'=>array(
'typeAbsence'=>array(
'rttcumule' => $langs->trans('CumulatedDayOff'),
'rttnoncumule' => $langs->trans('NonCumulatedDayOff'),
'conges' => $langs->trans('Holidays'),
'maladiemaintenue' => $langs->trans('MaintainedSickness'),
'maladienonmaintenue' => $langs->trans('NoMaintainedSickness'),
'maternite' => $langs->trans('Maternity'),
'paternite' => $langs->trans('Paternity'),
'chomagepartiel' => $langs->trans('PartialUnemployment'),
'nonremuneree' => $langs->trans('UnpaidAbsence'),
'accidentdetravail' => $langs->trans('WorkAccident'),
'maladieprofessionnelle'=> $langs->trans('ProfessionalSickness'),
'congeparental' => $langs->trans('ParentalHoliday'),
'accidentdetrajet' => $langs->trans('TravelAccident'),
'mitempstherapeutique' => $langs->trans('TherapeuticHalftime')
)
,'Restrictif'=>array('1'=> $langs->trans('Yes'), '0'=> $langs->trans('No'))
)
,'hide'=>array('periode')
,'type'=>array()
,'liste'=>array(
'titre'=> $langs->trans('AbsencesPresencesRequestRulesList')
,'image'=>img_picto('','title.png', '', 0)
,'picto_precedent'=>img_picto('','previous.png', '', 0)
,'picto_suivant'=>img_picto('','next.png', '', 0)
,'noheader'=> (int)isset($_REQUEST['ID'])
,'messageNothing'=> $langs->trans('NoRulesToShow')
,'order_down'=>img_picto('','1downarrow.png', '', 0)
,'order_up'=>img_picto('','1uparrow.png', '', 0)
)
,'title'=>array(
'typeAbsence'=> $langs->trans('AbsencePresenceType')
,'nbJourCumulable'=> $langs->trans('NbPossibleContiguousDays')
)
,'eval'=>array(
'Utilisateur'=>'ucwords(strtolower(htmlentities("@val@", ENT_COMPAT , "UTF-8")))'
,'Groupe'=>'ucwords(strtolower(htmlentities("@val@", ENT_COMPAT , "UTF-8")))'
,'nbJourCumulable'=>'_periode("@val@", "@periode@")'
)
,'orderBy'=>$TOrder
));
?><div class="tabsAction" >
<a class="butAction" href="?id=<?php echo $regle->getId(); ?>&action=new"><?php echo $langs->trans('NewRule'); ?></a>
<div style="clear:both"></div></div><?php
$form->end();
llxFooter();
}
function _periode($nbJourCumulable, $periode) {
if($periode=='ONE')return $nbJourCumulable;
else return $nbJourCumulable.' / '.TRH_RegleAbsence::$TPeriode[$periode] ;
}
function _fiche(&$ATMdb, $regle, $mode) {
global $langs;
llxHeader('', $langs->trans('AbsenceRule'), '', '', 0, 0);
global $user,$conf;
$form=new TFormCore($_SERVER['PHP_SELF'],'form1','POST');
$form->Set_typeaff($mode);
echo $form->hidden('id', $regle->getId());
echo $form->hidden('action', 'save');
$regle->load_liste($ATMdb);
$TTypeAbsence = array_merge(TRH_TypeAbsence::getTypeAbsence($ATMdb, 'admin'), TRH_TypeAbsence::getTypeAbsence($ATMdb, 'admin', true));
$TBS=new TTemplateTBS();
$regle->load_liste($ATMdb);
print $TBS->render('./tpl/regleAbsence.tpl.php'
,array()
,array(
'newRule'=>array(
'id'=>$regle->getId()
,'choixApplication'=>$form->radiodiv('','choixApplication',$regle->TChoixApplication, $regle->choixApplication)
,'choixApplicationViewMode'=>$regle->TChoixApplication[$regle->choixApplication]
,'fk_user'=>$form->combo('', 'fk_user',$regle->TUser, $regle->fk_user)
,'fk_group'=>$form->combo('', 'fk_usergroup',$regle->TGroup, $regle->fk_usergroup)
,'nbJourCumulable'=>$form->texte('', 'nbJourCumulable', $regle->nbJourCumulable,30 ,255,'','','')
,'typeAbsence'=>$form->combo('', 'typeAbsence',$TTypeAbsence, $regle->typeAbsence)
,'periode'=>$form->combo('', 'periode',TRH_RegleAbsence::$TPeriode, $regle->periode)
,'restrictif'=>$form->checkbox1('','restrictif','1',$regle->restrictif==1?true:false)
,'contigue'=>$form->checkbox1('','contigue','1',$regle->contigue==1?true:false)
,'contigueNoJNT'=>$form->checkbox1('','contigueNoJNT','1',$regle->contigueNoJNT==1?true:false)
,'titreRegle'=>load_fiche_titre($langs->trans('AbsencePresenceRule'),'', 'title.png', 0, '')
)
,'userCourant'=>array(
'id'=>$user->id
,'lastname'=>htmlentities($user->lastname, ENT_COMPAT , 'ISO8859-1')
,'firstname'=>htmlentities($user->firstname, ENT_COMPAT , 'ISO8859-1')
,'valideurConges'=>($user->rights->absence->myactions->valideurConges && $estValideur)
,'enregistrerPaieAbsences'=>($user->rights->absence->myactions->enregistrerPaieAbsences && $estValideur)
)
,'view'=>array(
'mode'=>$mode
,'head'=>dol_get_fiche_head(reglePrepareHead($regle) , 'regle', $langs->trans('Rules'))
)
,'trad' => array(
'user' => $langs->trans('User'),
'group' => $langs->trans('Group'),
'all' => $langs->trans('AllThis')
)
)
);
echo $form->end_form();
global $mesg, $error;
dol_htmloutput_mesg($mesg, '', ($error ? 'error' : 'ok'));
llxFooter();
}