Skip to content
Snippets Groups Projects
Commit 428624f1 authored by Brett Bieber's avatar Brett Bieber
Browse files

Fix downloading Year2 applications and endorsement CSV

parent 6de14bfa
No related branches found
No related tags found
No related merge requests found
......@@ -26,5 +26,14 @@ class UNL_UCARE_Year2Application extends UNL_UCARE_Year1Application
}
return false;
}
public function getEndorsement()
{
if ($endorsement = UNL_UCARE_Year2Endorsement::getByApplicationID($this->id)) {
return $endorsement;
}
return false;
}
}
?>
\ No newline at end of file
<?php
class UNL_UCARE_Year2CSV extends UNL_UCARE_Year1CSV
{
function __construct($options = array())
{
UNL_UCARE_OutputController::setOutputTemplate('UNL_UCARE_Year2CSV', 'UNL_UCARE_Year1CSV');
parent::__construct($options);
}
}
\ No newline at end of file
<?php
$year = 1;
if (isset($_GET['view']) && $_GET['view'] == 'csv2') {
$year = 2;
}
header("Content-type: application/vnd-msexel");
header("Content-Disposition: attachment; filename=year1.csv");
$columns = array_keys(get_class_vars('UNL_UCARE_Year1Application'));
array_splice($columns, count($columns), 0, array_keys(get_class_vars('UNL_UCARE_Year1Endorsement')));
header("Content-Disposition: attachment; filename=year$year.csv");
$columns = array_keys(get_class_vars('UNL_UCARE_Year'.$year.'Application'));
array_splice($columns, count($columns), 0, array_keys(get_class_vars('UNL_UCARE_Year'.$year.'Endorsement')));
echo implode($columns, ',').PHP_EOL;
foreach ($this->year1apps as $id) :
$app = UNL_UCARE_Year1Application::getById($id);
$app_field = 'year'.$year.'apps';
foreach ($this->$app_field as $id) :
$app = call_user_func(array('UNL_UCARE_Year'.$year.'Application', 'getById'), $id);
$fields = array_values($app->toArray());
if ($endorsement = UNL_UCARE_Year1Endorsement::getByApplicationID($app->id)) {
if ($endorsement = $app->getEndorsement()) {
array_splice($fields, count($fields), 0, $endorsement->toArray());
}
$field_count = count($fields);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment