Changed filename on download to 'Anrechnungsantrag_OrgForm_LVID_VornameNachname'

Adapted STGL and lectors views to change the filename on download event.
All download functions moved from view to library.

Signed-off-by: cris-technikum <hainberg@technikum-wien.at>
This commit is contained in:
Cris
2021-03-22 12:12:04 +01:00
committed by cris-technikum
parent 050eef120c
commit 00656efaef
5 changed files with 58 additions and 6 deletions
@@ -383,8 +383,12 @@ class approveAnrechnungDetail extends Auth_Controller
// Check if user is entitled to read dms doc
self::_checkIfEntitledToReadDMSDoc($dms_id);
$this->dmslib->download($dms_id);
// Set filename to be used on downlaod
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
// Download file
$this->dmslib->download($dms_id, $filename);
}
/**
@@ -256,7 +256,11 @@ class approveAnrechnungUebersicht extends Auth_Controller
// Check if user is entitled to read dms doc
self::_checkIfEntitledToReadDMSDoc($dms_id);
$this->dmslib->download($dms_id);
// Set filename to be used on downlaod
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
// Download file
$this->dmslib->download($dms_id, $filename);
}
@@ -233,8 +233,12 @@ class reviewAnrechnungDetail extends Auth_Controller
// Check if user is entitled to read dms doc
self::_checkIfEntitledToReadDMSDoc($dms_id);
$this->dmslib->download($dms_id);
// Set filename to be used on downlaod
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
// Download file
$this->dmslib->download($dms_id, $filename);
}
@@ -203,7 +203,11 @@ class reviewAnrechnungUebersicht extends Auth_Controller
// Check if user is entitled to read dms doc
self::_checkIfEntitledToReadDMSDoc($dms_id);
$this->dmslib->download($dms_id);
// Set filename to be used on downlaod
$filename = $this->anrechnunglib->setFilenameOnDownload($dms_id);
// Download file
$this->dmslib->download($dms_id, $filename);
}
+36
View File
@@ -601,6 +601,42 @@ class AnrechnungLib
return success(true); // recommended
}
/**
* Set Filename that should be used on download
* @param $dms_id
* @return string|null
*/
public function setFilenameOnDownload($dms_id)
{
// Load Anrechnung
$result = $this->ci->AnrechnungModel->loadWhere(array('dms_id' => $dms_id));
// Return null if no data found
if (!hasData($result))
{
return null;
}
$prestudent_id = $result->retval[0]->prestudent_id;
$lehrveranstaltung_id = $result->retval[0]->lehrveranstaltung_id;
// Get LV OrgForm
$this->ci->LehrveranstaltungModel->addSelect('stg.orgform_kurzbz');
$this->ci->LehrveranstaltungModel->addJoin('public.tbl_studiengang AS stg', 'studiengang_kz');
$result = $this->ci->LehrveranstaltungModel->load($lehrveranstaltung_id);
$orgform_kurzbz = hasData($result) ? '_'. $result->retval[0]->orgform_kurzbz : '';
// Get full name of student
$this->ci->load->model('crm/Prestudent_model', 'PrestudentModel');
$this->ci->PrestudentModel->addSelect('vorname, nachname');
$this->ci->PrestudentModel->addJoin('public.tbl_person', 'person_id');
$result = $this->ci->PrestudentModel->load($prestudent_id);
$fullname = hasData($result) ? $result->retval[0]->vorname. $result->retval[0]->nachname : '';
// Return filename
return 'Anrechnungsantrag'. $orgform_kurzbz .'_LV-'. $lehrveranstaltung_id. '_'. $fullname;
}
// Return an object with Anrechnungdata
private function _setAnrechnungDataObject($anrechnung)