mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-16 11:39:31 +00:00
Fixed AkteLib->_remove
This commit is contained in:
@@ -261,7 +261,6 @@ class Dokumente extends FHCAPI_Controller
|
||||
$logdata_dms = "Logdata: " . var_export($logdata_dms, true);
|
||||
|
||||
//delete from dmsLib
|
||||
$this->load->library('DmsLib');
|
||||
$person_id = current($dataAkte)->person_id;
|
||||
$result = $this->aktelib->removeByPersonIdAndDmsId($person_id, $dms_id);
|
||||
$this->getDataOrTerminateWithError($result);
|
||||
@@ -321,7 +320,6 @@ class Dokumente extends FHCAPI_Controller
|
||||
|
||||
public function uploadDokument()
|
||||
{
|
||||
$this->load->library('DmsLib');
|
||||
$prestudent_id = $this->input->post('prestudent_id');
|
||||
$anmerkung_intern = $this->input->post('anmerkung_intern');
|
||||
$titel_intern = $this->input->post('titel_intern');
|
||||
|
||||
@@ -332,6 +332,7 @@ class AkteLib
|
||||
private function _remove($akte_id = null, $person_id = null, $dms_id = null)
|
||||
{
|
||||
// Get dms_id for akte
|
||||
$this->_ci->AkteModel->addSelect('akte_id');
|
||||
$this->_ci->AkteModel->addSelect('dms_id');
|
||||
|
||||
$paramArray = array();
|
||||
@@ -344,50 +345,17 @@ class AkteLib
|
||||
|
||||
if (isError($akteResult)) return $akteResult;
|
||||
|
||||
if (!hasData($akteResult)) return error("Akte not found");
|
||||
if (!hasData($akteResult)) return error('Akte not found');
|
||||
|
||||
$dms_id = getData($akteResult)[0]->dms_id;
|
||||
$error = null;
|
||||
// Delete Akte
|
||||
$deleteResult = $this->_ci->AkteModel->delete(getData($akteResult)[0]->akte_id);
|
||||
|
||||
// Start DB transaction to avoid deleting only part of the data
|
||||
$this->_ci->db->trans_begin();
|
||||
if (isError($deleteResult)) return $deleteResult;
|
||||
|
||||
// delete Akte
|
||||
$deleteResult = $this->_ci->AkteModel->delete($akte_id);
|
||||
// Remove all dms entry for dms of the akte
|
||||
$removeAllResult = $this->_ci->dmslib->removeAll(getData($akteResult)[0]->dms_id);
|
||||
|
||||
if (isError($deleteResult))
|
||||
{
|
||||
$error = $deleteResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove all dms entry for dms of the akte
|
||||
$removeAllResult = $this->_ci->dmslib->removeAll($dms_id);
|
||||
|
||||
if (isError($removeAllResult)) $error = $removeAllResult;
|
||||
}
|
||||
|
||||
// Transaction complete!
|
||||
$this->_ci->db->trans_complete();
|
||||
|
||||
// Check if everything went ok during the transaction
|
||||
if ($this->_ci->db->trans_status() === false || isset($error))
|
||||
{
|
||||
$this->_ci->db->trans_rollback();
|
||||
|
||||
// return occured error
|
||||
if (isset($error))
|
||||
return $error;
|
||||
else
|
||||
return error("Error occured when deleting, rolled back");
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_ci->db->trans_commit();
|
||||
|
||||
// return removed dms entry data
|
||||
return $removeAllResult;
|
||||
}
|
||||
return $removeAllResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user