|
64 | 64 | }
|
65 | 65 |
|
66 | 66 | /** Include PHPExcel */
|
67 |
| - require_once $_SESSION[$guid]["absolutePath"] . '/lib/PHPExcel/Classes/PHPExcel.php'; |
| 67 | + require_once $session->get('absolutePath') . '/lib/PHPExcel/Classes/PHPExcel.php'; |
68 | 68 |
|
69 | 69 | // Create new PHPExcel object
|
70 | 70 | $excel = new PHPExcel();
|
|
76 | 76 | );
|
77 | 77 |
|
78 | 78 | // Set document properties
|
79 |
| - $excel->getProperties()->setCreator(formatName("",$_SESSION[$guid]["preferredName"], $_SESSION[$guid]["surname"], "Staff")) |
80 |
| - ->setLastModifiedBy(formatName("",$_SESSION[$guid]["preferredName"], $_SESSION[$guid]["surname"], "Staff")) |
| 79 | + $excel->getProperties()->setCreator(formatName("",$session->get('preferredName'), $session->get('surname'), "Staff")) |
| 80 | + ->setLastModifiedBy(formatName("",$session->get('preferredName'), $session->get('surname'), "Staff")) |
81 | 81 | ->setTitle( __("Activity Attendance") )
|
82 | 82 | ->setDescription(__('This information is confidential. Generated by Gibbon (https://gibbonedu.org).')) ;
|
83 | 83 |
|
|
91 | 91 |
|
92 | 92 | foreach ($importType->getTableFields() as $fieldName ) {
|
93 | 93 | if ($importType->isFieldHidden($fieldName)) continue; // Skip hidden fields
|
94 |
| - |
| 94 | + |
95 | 95 | $columnFields[] = $fieldName;
|
96 | 96 |
|
97 | 97 | if ($importType->isFieldReadOnly($fieldName) && $dataExport == true) continue; // Skip readonly fields when exporting data
|
98 |
| - |
| 98 | + |
99 | 99 | $queryFields[] = $fieldName;
|
100 | 100 | }
|
101 | 101 |
|
|
107 | 107 | // Create the header row
|
108 | 108 | $count = 0;
|
109 | 109 | foreach ($columnFields as $fieldName ) {
|
110 |
| - |
| 110 | + |
111 | 111 | $excel->getActiveSheet()->setCellValue( num2alpha($count).'1', $importType->getField($fieldName, 'name', $fieldName ) );
|
112 | 112 | $excel->getActiveSheet()->getStyle( num2alpha($count).'1')->applyFromArray($style_head_fill);
|
113 | 113 |
|
|
130 | 130 | $count++;
|
131 | 131 | }
|
132 | 132 |
|
133 |
| - |
| 133 | + |
134 | 134 | if ($dataExport) {
|
135 | 135 | // Get the data
|
136 |
| - $data=array(); |
| 136 | + $data=array(); |
137 | 137 | $sql="SELECT ".implode(', ', $queryFields)." FROM `{$tableName}`" ;
|
138 | 138 |
|
139 | 139 | if ($dataExportAll == false) {
|
140 | 140 | // Optionally limit all exports to the current school year by default, to avoid massive files
|
141 | 141 | $gibbonSchoolYearID = $importType->getField('gibbonSchoolYearID', 'name', null);
|
142 |
| - |
| 142 | + |
143 | 143 | if ($gibbonSchoolYearID != null && $importType->isFieldReadOnly('gibbonSchoolYearID') == false ) {
|
144 |
| - $data['gibbonSchoolYearID'] = $_SESSION[$guid]['gibbonSchoolYearID']; |
| 144 | + $data['gibbonSchoolYearID'] = $session->get('gibbonSchoolYearID'); |
145 | 145 | $sql.= " WHERE gibbonSchoolYearID=:gibbonSchoolYearID ";
|
146 | 146 | }
|
147 | 147 | }
|
|
192 | 192 | // Work backwards, so we can potentially fill in any relational read-only fields
|
193 | 193 | for ($i=count($columnFields)-1; $i >= 0; $i--) {
|
194 | 194 | $fieldName = $columnFields[$i];
|
195 |
| - |
| 195 | + |
196 | 196 | $value = (isset($row[ $fieldName ]))? $row[ $fieldName ] : null;
|
197 | 197 |
|
198 | 198 | // Handle relational fields
|
|
221 | 221 | }
|
222 | 222 | }
|
223 | 223 | }
|
224 |
| - |
| 224 | + |
225 | 225 | // Replace the relational ID value with the actual value
|
226 | 226 | $value = implode(',', $relationalValue);
|
227 | 227 | }
|
|
0 commit comments