mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 16:44:28 +00:00
Added logic & GUI adaptations for rejecting Anrechnungen
. Added rejecting-methods in Controller and Library Signed-off-by: cris-technikum <[email protected]>
This commit is contained in:
@@ -18,7 +18,8 @@ class approveAnrechnungUebersicht extends Auth_Controller
|
||||
array(
|
||||
'index' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'download' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'approve' => 'lehre/anrechnung_genehmigen:rw'
|
||||
'approve' => 'lehre/anrechnung_genehmigen:rw',
|
||||
'reject' => 'lehre/anrechnung_genehmigen:rw'
|
||||
)
|
||||
);
|
||||
|
||||
@@ -127,6 +128,45 @@ class approveAnrechnungUebersicht extends Auth_Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function reject()
|
||||
{
|
||||
$data = $this->input->post('data');
|
||||
|
||||
if(isEmptyArray($data))
|
||||
{
|
||||
return $this->outputJsonError('Fehler beim Übertragen der Daten.');
|
||||
}
|
||||
|
||||
// Get statusbezeichnung for 'approved'
|
||||
$this->AnrechnungstatusModel->addSelect('bezeichnung_mehrsprachig');
|
||||
$rejected = getData($this->AnrechnungstatusModel->load('rejected'))[0];
|
||||
$rejected = getUserLanguage() == 'German'
|
||||
? $rejected->bezeichnung_mehrsprachig[0]
|
||||
: $rejected->bezeichnung_mehrsprachig[1];
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
// Approve Anrechnung
|
||||
if(getData($this->anrechnunglib->rejectAnrechnung($item['anrechnung_id'])))
|
||||
{
|
||||
$json[]= array(
|
||||
'anrechnung_id' => $item['anrechnung_id'],
|
||||
'status_bezeichnung' => $rejected
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Output json to ajax
|
||||
if (isset($json) && !isEmptyArray($json))
|
||||
{
|
||||
return $this->outputJsonSuccess($json);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->outputJsonError('Es wurden keine Anrechnungen genehmigt.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Download and open uploaded document (Nachweisdokument).
|
||||
*/
|
||||
|
||||
@@ -202,6 +202,50 @@ class AnrechnungLib
|
||||
return success(true); // has been approved
|
||||
}
|
||||
|
||||
public function rejectAnrechnung($anrechnung_id)
|
||||
{
|
||||
// Check last Anrechnungstatus
|
||||
if (!$result = getData($this->ci->AnrechnungModel->getLastAnrechnungstatus($anrechnung_id))[0])
|
||||
{
|
||||
show_error(getError($result));
|
||||
}
|
||||
|
||||
$status_kurzbz = $result->status_kurzbz;
|
||||
|
||||
// Exit if already approved or rejected
|
||||
if ($status_kurzbz == self::ANRECHNUNGSTATUS_APPROVED || $status_kurzbz == self::ANRECHNUNGSTATUS_REJECTED) // TODO: in js: bereits genehmigte nicht clickable!
|
||||
{
|
||||
return success(false); // dont reject
|
||||
}
|
||||
|
||||
// Start DB transaction
|
||||
$this->ci->db->trans_start(false);
|
||||
|
||||
// Insert new status approved
|
||||
$result = $this->ci->AnrechnungModel->saveAnrechnungstatus($anrechnung_id, self::ANRECHNUNGSTATUS_REJECTED);
|
||||
|
||||
// Update genehmigt von
|
||||
$result = $this->ci->AnrechnungModel->update(
|
||||
$anrechnung_id,
|
||||
array(
|
||||
'genehmigt_von' => getAuthUID(),
|
||||
'updateamum' => (new DateTime())->format('Y-m-d H:m:i'),
|
||||
'updatevon' => getAuthUID()
|
||||
)
|
||||
);
|
||||
|
||||
// Transaction complete!
|
||||
$this->ci->db->trans_complete();
|
||||
|
||||
if ($this->ci->db->trans_status() === false || isError($result))
|
||||
{
|
||||
$this->ci->db->trans_rollback();
|
||||
show_error($result->msg, EXIT_ERROR);
|
||||
}
|
||||
|
||||
return success(true); // rejected
|
||||
}
|
||||
|
||||
private function _setAnrechnungDataObject($anrechnung)
|
||||
{
|
||||
$anrechnung_data = new StdClass();
|
||||
|
||||
Reference in New Issue
Block a user