From 00656efaef7ac8499129d8c94565d71412f82bd3 Mon Sep 17 00:00:00 2001 From: Cris Date: Mon, 22 Mar 2021 12:12:04 +0100 Subject: [PATCH] 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 --- .../anrechnung/ApproveAnrechnungDetail.php | 8 +++-- .../ApproveAnrechnungUebersicht.php | 6 +++- .../anrechnung/ReviewAnrechnungDetail.php | 8 +++-- .../anrechnung/ReviewAnrechnungUebersicht.php | 6 +++- application/libraries/AnrechnungLib.php | 36 +++++++++++++++++++ 5 files changed, 58 insertions(+), 6 deletions(-) diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php index 85fb2812f..a245d783b 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungDetail.php @@ -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); } /** diff --git a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php index b2d09fbe1..21da93df8 100644 --- a/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ApproveAnrechnungUebersicht.php @@ -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); } diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php index 28a3690d0..156c17334 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungDetail.php @@ -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); } diff --git a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php index 005cde97a..e7b7cb56d 100644 --- a/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php +++ b/application/controllers/lehre/anrechnung/ReviewAnrechnungUebersicht.php @@ -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); } diff --git a/application/libraries/AnrechnungLib.php b/application/libraries/AnrechnungLib.php index c32b8a91c..ca97ee95c 100644 --- a/application/libraries/AnrechnungLib.php +++ b/application/libraries/AnrechnungLib.php @@ -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)