-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvfp
230 lines (192 loc) · 11.1 KB
/
vfp
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
220
221
222
223
224
225
226
227
228
229
230
<apex:page controller="SchoolConsultsController_SC" sidebar="false" docType="html-5.0" showHeader="false" standardStylesheets="false">
<c:PageSchoolHeader />
<apex:stylesheet value="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/css/bootstrap-datepicker3.css" />
<apex:includeScript value="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.1/js/bootstrap-datepicker.min.js" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<apex:form id="theForm">
<apex:actionFunction name="getTableRecords" action="{!queryDB}" rerender="tables, scripts">
<apex:param name="startDate" assignTo="{!startDate}" value="" />
<apex:param name="endDate" assignTo="{!endDate}" value="" />
</apex:actionFunction>
<apex:actionFunction name="filterTableRecords" action="{!filterSchoolRecords}" rerender="tables, scripts">
<apex:param name="startDate" assignTo="{!startDate}" value="" />
<apex:param name="endDate" assignTo="{!endDate}" value="" />
</apex:actionFunction>
<apex:actionFunction name="pageNumberchanged" action="{!onPageNumberChanged}" rerender="tables, scripts"/>
<apex:actionFunction name="clearFilterFields" action="{!clearFilterField}" rerender="tables, scripts"/>
<div class='pt-4 pl-3 pr-3'>
<apex:pageBlock title="Data from School">
<apex:outputPanel id="tables">
<div class='pl-5 pr-5 ml-3 mr-3 pt-4 pb-4'>
<div class="border p-4">
<h3 class="mb-3">Filtros</h3>
<div class="d-flex justify-content-between">
<div class="form-group">
<label class='d-block'>Tipo de registros</label>
<apex:selectlist required="true" value="{!selectedRecordType}" size="1" styleClass="mb-3">
<apex:selectOptions value="{!recordTypeOptions}" />
</apex:selectlist>
</div>
<div class="form-group">
<label class='d-block'>Nombre</label>
<apex:inputText value="{!searchName}"/>
</div>
<div class="form-group">
<label class='d-block'>Last Name</label>
<apex:inputText value="{!searchLastName}"/>
</div>
</div>
<div class="d-flex">
<div class="form-group ">
<label class='d-block'>Initial Date</label>
<input class="form-control" id="startDate" name="startDate" value="{!startDate}" placeholder="DD/MM/YY" type="text"/>
</div>
<div class="form-group ">
<label class='d-block'>End Date</label>
<input class="form-control" id="endDate" name="endDate" value="{!endDate}" placeholder="DD/MM/YY" type="text"/>
</div>
</div>
<button onclick="clearFilters(event)" class="btn btn-danger mt-3">Clear</button>
<button onclick="filterRecords(event)" class="btn btn-primary mt-3">Filter</button>
</div>
<apex:outputPanel rendered="{! selectedRecordType == 'Students' && ( schoolSecurity.isAdmin || schoolSecurity.isStudent ) }">
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>User name</th>
<th>Last name</th>
<th>User</th>
<th>Age</th>
<th>Registered Day</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!stdSchool}" var="Sc">
<tr>
<td>
<apex:outputLink value="PageSchoolDetails_SC?id={!Sc.id}" >
<apex:outputText value="{!Sc.Id}" />
</apex:outputLink>
</td>
<td><apex:outputText value="{!Sc.User_Name__c}" /></td>
<td><apex:outputText value="{!Sc.Last_Name__c}" /></td>
<td><apex:outputText value="{!Sc.User__c}" /></td>
<td><apex:outputText value="{!Sc.Age__c}" /></td>
<td>
<apex:outputText value="{0, date, MMMM d',' yyyy}">
<apex:param value="{!Sc.Registered_Date__c}" />
</apex:outputText></td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:outputPanel>
<apex:outputPanel rendered="{!selectedRecordType == 'Teachers' && ( schoolSecurity.isAdmin || schoolSecurity.isTeacher )}">
<table class="table table-striped">
<thead>
<tr>
<th>Id</th>
<th>User name</th>
<th>Last name</th>
<th>User</th>
<th>Age</th>
<th>Departamento</th>
<th>Subject</th>
<th>Registered Day</th>
</tr>
</thead>
<tbody>
<apex:repeat value="{!stdSchool}" var="Sc" id="theRepeat">
<tr>
<td>
<apex:outputLink value="PageSchoolDetails_SC?id={!Sc.id}" >
<apex:outputText value="{!Sc.Id}" />
</apex:outputLink>
</td>
<td><apex:outputText value="{!Sc.User_Name__c}" /></td>
<td><apex:outputText value="{!Sc.Last_Name__c}" /></td>
<td><apex:outputText value="{!Sc.User__c}" /></td>
<td><apex:outputText value="{!Sc.Age__c}" /></td>
<td><apex:outputText value="{!Sc.Department__c}" /></td>
<td><apex:outputText value="{!Sc.Subject__c}" /></td>
<td><apex:outputText value="{0, date, MMMM d',' yyyy}">
<apex:param value="{!Sc.Registered_Date__c}" />
</apex:outputText></td>
</tr>
</apex:repeat>
</tbody>
</table>
</apex:outputPanel>
<div class="d-flex justify-content-between pt-3 pb-3">
<div>
<p>Page <apex:inputText value="{!PageNumber}" styleClass="ml-2 w-25" onkeypress="return handlePageKeyPress(event)"/> /<apex:outputText value="{!TotalPages}" /></p>
</div>
<div>
<apex:commandButton value="Start" action="{!Firstbtn}" disabled="{!DisablePrevious}" reRender="tables, scripts" styleClass="btn btn-link"/>
<apex:commandButton value="<" action="{!previousbtn}" disabled="{!DisablePrevious}" reRender="tables, scripts" styleClass="btn btn-link"/>
<apex:commandButton value=">" action="{!Nextbtn}" disabled="{!DisableNext}" reRender="tables, scripts" styleClass="btn btn-link"/>
<apex:commandButton value="End" action="{!Lastbtn}" disabled="{!DisableNext}" reRender="tables, scripts" styleClass="btn btn-link"/>
</div>
<div>
<p>Showing <apex:selectlist required="true" value="{!selectedRecordsToShow}" size="1" styleClass="ml-3" >
<apex:actionSupport event="onchange" reRender="tables, scripts" action="{!onRecordsToShowChange}" />
<apex:selectOptions value="{!recordsToShowOptions}" />
</apex:selectlist></p>
</div>
</div>
</div>
</apex:outputPanel>
</apex:pageBlock>
</div>
</apex:form>
<script>
function handlePageKeyPress (event){
if (event.keyCode === 13) {
event.preventDefault();
pageNumberchanged();
return false;
}
return true;
}
function getRecords (event){
event.preventDefault();
var startDate = document.getElementById('startDate').value;
var endDate = document.getElementById('endDate').value;
getTableRecords(startDate,endDate );
}
function filterRecords (event){
event.preventDefault();
var startDate = document.getElementById('startDate').value;
var endDate = document.getElementById('endDate').value;
filterTableRecords(startDate,endDate );
}
function clearFilters (event){
event.preventDefault();
clearFilterFields();
}
window.onload = function () {
getTableRecords();
}
</script>
<apex:outputPanel id="scripts">
<script>
$(document).ready(function(){
$('#startDate').datepicker({ clearBtn:true })
.on('changeDate', function(e){
const endDate = document.getElementById('endDate').value;
if(endDate && moment(e.date).isAfter(endDate) ){
document.getElementById('endDate').value = moment(e.date).format('MM/DD/YYYY');
}
});
$('#endDate').datepicker({ clearBtn:true })
.on('changeDate', function(e){
const startDate = document.getElementById('startDate').value;
if(startDate && moment(e.date).isBefore(startDate) ){
document.getElementById('startDate').value = moment(e.date).format('MM/DD/YYYY');
}
});;
});
</script>
</apex:outputPanel>
</apex:page>