Skip to content

Commit 94e5bc2

Browse files
committed
Attendance: #add option to show official code in attendance table, pdf and xls export - refs BT#22320
1 parent 324be33 commit 94e5bc2

File tree

4 files changed

+36
-2
lines changed

4 files changed

+36
-2
lines changed

main/attendance/attendance_controller.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,12 @@ public function attendance_sheet_export_to_pdf(
649649

650650
// Get data table
651651
$data_table = [];
652-
$head_table = ['#', get_lang('Name')];
652+
$addOfficialCode = api_get_configuration_value('attendance_add_official_code');
653+
if ($addOfficialCode) {
654+
$head_table = ['#', get_lang('OfficialCode'), get_lang('Name')];
655+
} else {
656+
$head_table = ['#', get_lang('Name')];
657+
}
653658
foreach ($data_array['attendant_calendar'] as $class_day) {
654659
$labelDuration = !empty($class_day['duration']) ? get_lang('Duration').' : '.$class_day['duration'] : '';
655660
$head_table[] =
@@ -667,6 +672,9 @@ public function attendance_sheet_export_to_pdf(
667672
$cols = 1;
668673
$result = [];
669674
$result['count'] = $count;
675+
if ($addOfficialCode) {
676+
$result['official_code'] = $user['official_code'];
677+
}
670678
$result['full_name'] = api_get_person_name($user['firstname'], $user['lastname']);
671679
foreach ($data_array['attendant_calendar'] as $class_day) {
672680
if ($class_day['done_attendance'] == 1) {

main/attendance/attendance_sheet.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,12 @@ function UpdateTableHeaders() {
210210
});
211211
</script>
212212

213+
<?php $addOfficialCode = api_get_configuration_value('attendance_add_official_code');
214+
$headerOfficialCode = '';
215+
if ($addOfficialCode) {
216+
$headerOfficialCode = '<th width="100px">'. get_lang('OfficialCode') . '</th>';
217+
}
218+
?>
213219
<form method="post" action="index.php?action=attendance_sheet_add&<?php echo api_get_cidreq().$param_filter; ?>&attendance_id=<?php echo $attendance_id; ?>" >
214220
<div class="attendance-sheet-content" style="width:100%;background-color:#E1E1E1;margin-top:20px;">
215221
<div class="divTableWithFloatingHeader attendance-users-table" style="width:45%;float:left;margin:0px;padding:0px;">
@@ -218,13 +224,15 @@ function UpdateTableHeaders() {
218224
<tr class="tableFloatingHeader" style="position: absolute; top: 0px; left: 0px; visibility: hidden; margin:0px;padding:0px" >
219225
<th width="10px"><?php echo '#'; ?></th>
220226
<th width="10px"><?php echo get_lang('Photo'); ?></th>
227+
<?php echo $headerOfficialCode ?>
221228
<th width="100px"><?php echo get_lang('LastName'); ?></th>
222229
<th width="100px"><?php echo get_lang('FirstName'); ?></th>
223230
<th width="100px"><?php echo get_lang('AttendancesFaults'); ?></th>
224231
</tr>
225232
<tr class="tableFloatingHeaderOriginal" >
226233
<th width="10px"><?php echo '#'; ?></th>
227234
<th width="10px"><?php echo get_lang('Photo'); ?></th>
235+
<?php echo $headerOfficialCode ?>
228236
<th width="150px"><?php echo get_lang('LastName'); ?></th>
229237
<th width="140px"><?php echo get_lang('FirstName'); ?></th>
230238
<th width="100px"><?php echo get_lang('AttendancesFaults'); ?></th>
@@ -248,6 +256,9 @@ function UpdateTableHeaders() {
248256
<tr class="<?php echo $class; ?>">
249257
<td><center><?php echo $i; ?></center></td>
250258
<td><?php echo $data['photo']; ?></td>
259+
<?php if ($addOfficialCode) {
260+
echo '<td>' . $data['official_code'] . '</td>';
261+
} ?>
251262
<td><span title="<?php echo $username; ?>"><?php echo $data['lastname']; ?></span></td>
252263
<td><?php echo $data['firstname']; ?></td>
253264
<td>

main/inc/lib/attendance.lib.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,10 @@ public function get_users_rel_course($attendanceId = 0, $groupId = 0)
776776
);
777777

778778
$value['photo'] = $photo;
779+
$addOfficialCode = api_get_configuration_value('attendance_add_official_code');
780+
if ($addOfficialCode) {
781+
$value['official_code'] = $user_data['official_code'];
782+
}
779783
$value['firstname'] = $user_data['firstname'];
780784
$value['lastname'] = $user_data['lastname'];
781785
$value['username'] = $user_data['username'];
@@ -2723,7 +2727,12 @@ public function exportAttendanceSheetToXls(
27232727

27242728
// Get data table
27252729
$dataTable = [];
2726-
$headTable = ['#', get_lang('Name')];
2730+
$addOfficialCode = api_get_configuration_value('attendance_add_official_code');
2731+
if ($addOfficialCode) {
2732+
$headTable = ['#', get_lang('OfficialCode'), get_lang('Name')];
2733+
} else {
2734+
$headTable = ['#', get_lang('Name')];
2735+
}
27272736
foreach ($calendar as $classDay) {
27282737
$labelDuration = !empty($classDay['duration']) ? get_lang('Duration').' : '.$classDay['duration'] : '';
27292738
$headTable[] =
@@ -2740,6 +2749,9 @@ public function exportAttendanceSheetToXls(
27402749
$cols = 1;
27412750
$result = [];
27422751
$result['count'] = $count;
2752+
if ($addOfficialCode) {
2753+
$result['official_code'] = $user['official_code'];
2754+
}
27432755
$result['full_name'] = api_get_person_name($user['firstname'], $user['lastname']);
27442756
foreach ($calendar as $classDay) {
27452757
$commentInfo = $this->getComment($user['user_id'], $classDay['id']);

main/install/configuration.dist.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,6 +2507,9 @@
25072507
// Then add the "@" symbol to CAttendanceResultComment class in the ORM\Entity() line.
25082508
//$_configuration['attendance_allow_comments'] = false;
25092509

2510+
// Add the official code of students in the attendance table, pdf and xls export
2511+
//$_configuration['attendance_add_official_code'] = false;
2512+
25102513
// Enable categories in Wiki tool.
25112514
// 1. Run the following DB changes:
25122515
/*

0 commit comments

Comments
 (0)