Fixed Document Archive und Signature

This commit is contained in:
Andreas Österreicher
2025-08-05 09:25:34 +02:00
parent ecc7e4672f
commit 72bb465ecf
2 changed files with 22 additions and 17 deletions
@@ -152,7 +152,7 @@ class Documents extends FHCAPI_Controller
* @param string $xml
* @param string $xsl
* @param string $sign_user (optional)
*
*
* @return array with Akte data and export data
*/
private function _getAkteExportData($xml, $xsl, $sign_user = null)
@@ -235,7 +235,7 @@ class Documents extends FHCAPI_Controller
$student = current($this->getDataOrTerminateWithError($result));
$ss = $this->input->post_get('ss');
if ($ss !== null) {
$this->load->model('crm/prestudentstatus_model', 'PrestudentstatusModel');
$result = $this->PrestudentstatusModel->getLastStatus($student->prestudent_id, $ss);
@@ -334,7 +334,7 @@ class Documents extends FHCAPI_Controller
$this->PrestudentModel->addJoin('public.tbl_studiengang', 'studiengang_kz', 'LEFT');
$result = $this->PrestudentModel->load($prestudent_id);
$prestudent = current($this->getDataOrTerminateWithError($result));
$studiengang_kz = $prestudent->studiengang_kz;
$akteData['person_id'] = $prestudent->person_id;
$akteData['titel'] = mb_substr($xsl . "_" . $prestudent->kuerzel, 0, 64);
@@ -380,7 +380,7 @@ class Documents extends FHCAPI_Controller
// TODO: was bedeutet wenn keine berechtigung?
if (!$access_rights || !$access_rights->berechtigung)
return show_404();
$allowed = false;
foreach ($access_rights->berechtigung as $access_right) {
if ($this->permissionlib->isBerechtigt($access_right)) {
@@ -454,11 +454,11 @@ class Documents extends FHCAPI_Controller
if (!$vorlage->archivierbar)
$this->terminateWithError($this->p->t("stv", "grades_error_archive"));
if ($sign_user && !$vorlage->signierbar)
$this->terminateWithError($this->p->t("stv", "grades_error_sign"));
$this->load->library('DocumentExportLib');
// XML Data
+16 -11
View File
@@ -55,7 +55,7 @@ use SimpleXMLElement as SimpleXMLElement;
* $doc->create($outputformat);
* $doc->output(true);
* $doc->close();
*
*
* New:
* $xml_data = $this->documentexportlib->getDataXML($data);
* $images = [[
@@ -397,20 +397,24 @@ class DocumentExportLib
$vorlage_stg = current(getData($result));
foreach ($vorlage_stg as $k => $v)
$vorlage->$k = $v;
if ($sign_user)
{
$this->addSignToData($xml_data);
}
$result = $this->create($temp_folder, $outputformat, $vorlage, $xml_data, $images);
if (isError($result))
return $result;
$temp_filename = getData($result);
if ($sign_user) {
$this->addSignToData($xml_data);
if ($sign_user)
{
$result = $this->sign($temp_folder, $temp_filename, $outputformat, $sign_user, $sign_profile);
if (isError($result))
return $result;
$temp_filename = getData($result);
}
@@ -445,6 +449,7 @@ class DocumentExportLib
if ($xml_data->firstChild->tagName == 'error')
return error($xml_data->firstChild->textContent);
$styles_xsl = null;
// styles.xml erstellen
if ($vorlage->style) {
$styles_xsl = new DOMDocument();
@@ -461,7 +466,7 @@ class DocumentExportLib
// Template holen
$vorlage_found = false;
$vorlage_filename = $vorlage->vorlage_kurzbz . ($vorlage->mimetype == 'application/vnd.oasis.opendocument.spreadsheet' ? '.ods' : '.odt');
$aktive_addons = array_filter(array_map('trim', explode(";", ACTIVE_ADDONS)));
foreach($aktive_addons as $addon) {
$zipfile = DOC_ROOT . 'addons/' . $addon . '/system/vorlage_zip/' . $vorlage_filename;
@@ -652,7 +657,7 @@ class DocumentExportLib
foreach ($files as $file)
if (is_file($file))
unlink($file);
chdir($source_folder);
rmdir($temp_folder);
}
@@ -703,12 +708,12 @@ class DocumentExportLib
{
if ($outputformat)
return $outputformat;
if ($mimetype == 'application/vnd.oasis.opendocument.spreadsheet')
return 'ods';
if ($mimetype == 'application/vnd.oasis.opendocument.text')
return 'odt';
return 'pdf';
}
}