Added 'Zurücknehmen'-button for recommendation in STGL Detail View

Requested recommendations can now be withdrawn.
Now a button 'Zurücknehmen' is displayed as long as the Anrechnung
is processed by the lector and only as long the lector has not provided
a recommendation.

Signed-off-by: cris-technikum <hainberg@technikum-wien.at>
This commit is contained in:
Cris
2021-03-18 10:55:58 +01:00
committed by cris-technikum
parent 616cfaaf41
commit d345cbb43b
4 changed files with 143 additions and 2 deletions
@@ -26,7 +26,8 @@ class approveAnrechnungDetail extends Auth_Controller
'approve' => 'lehre/anrechnung_genehmigen:rw',
'reject' => 'lehre/anrechnung_genehmigen:rw',
'requestRecommendation' => 'lehre/anrechnung_genehmigen:rw',
'withdraw' => 'lehre/anrechnung_genehmigen:rw'
'withdraw' => 'lehre/anrechnung_genehmigen:rw',
'withdrawRequestRecommendation' => 'lehre/anrechnung_genehmigen:rw'
)
);
@@ -317,6 +318,56 @@ class approveAnrechnungDetail extends Auth_Controller
'status_bezeichnung' => $this->anrechnunglib->getLastAnrechnungstatus($anrechnung_id))
);
}
/**
* Withdraw request for reommendation and reset to 'inProgressDP'.
* This is only possible if the lector has not provided a recommendation yet.
*/
public function withdrawRequestRecommendation()
{
$anrechnung_id = $this->input->post('anrechnung_id');
if (!is_numeric($anrechnung_id))
{
show_error('Wrong parameter.');
}
// Get boolean empfehlung of given Anrechnung
if (!$result = getData($this->AnrechnungModel->load($anrechnung_id))[0])
{
show_error('Failed loading Anrechnung');
}
$empfehlung = $result->empfehlung_anrechnung;
// Get last Anrechnungstatus
if (!$result = getData($this->AnrechnungModel->getLastAnrechnungstatus($anrechnung_id))[0])
{
show_error('Failed loading last Anrechnungstatus');
}
$last_status = $result->status_kurzbz;
$anrechnungstatus_id = $result->anrechnungstatus_id;
// Return if Anrechnung was not waiting for recommendation or if Anrechnung has already been recommended
if ($last_status != self::ANRECHNUNGSTATUS_PROGRESSED_BY_LEKTOR && !is_null($empfehlung))
{
return $this->outputJsonError('No recommendation to withdraw.');
}
// Reset status to 'inProgressDP'
$result = $this->AnrechnungModel->deleteAnrechnungstatus($anrechnungstatus_id);
if (isError($result))
{
return $this->outputJsonError('Could not withdraw this application.');
}
// Success output to AJAX
return $this->outputJsonSuccess(array(
'status_bezeichnung' => $this->anrechnunglib->getLastAnrechnungstatus($anrechnung_id))
);
}
/**
* Download and open uploaded document (Nachweisdokument).
@@ -39,6 +39,7 @@ $this->load->view(
),
'anrechnung' => array(
'genehmigungAblehnungWirklichZuruecknehmen',
'empfehlungsanforderungWirklichZuruecknehmen',
'erfolgreichZurueckgenommen'
)
),
@@ -199,6 +200,12 @@ $this->load->view(
</div>
</form>
<div class="pull-right">
<button id="approveAnrechnungDetail-withdraw-request-recommedation"
class="btn btn-default btn-w200 <?php echo (is_null($empfehlungData->empfehlung) &&
$anrechnungData->status_kurzbz == 'inProgressLektor') ? '' : 'hidden' ?>"
type="button">
<?php echo ucfirst($this->p->t('global', 'zuruecknehmen')); ?>
</button>
<button id="approveAnrechnungDetail-request-recommendation" class="btn btn-primary btn-w200"
<?php echo is_null($empfehlungData->empfehlung) && $anrechnungData->status_kurzbz == 'inProgressDP' ? '' : 'disabled' ?>>
<?php echo ucfirst($this->p->t('anrechnung', 'empfehlungAnfordern')); ?>
@@ -202,7 +202,7 @@ $(function(){
);
});
// Request Recommendation for Anrechnungen
// Withdraw approvement or rejection
$("#approveAnrechnungDetail-withdraw-anrechnung-approvement").click(function(){
if(!confirm(FHC_PhrasesLib.t("anrechnung", "genehmigungAblehnungWirklichZuruecknehmen")))
@@ -251,6 +251,55 @@ $(function(){
);
});
// Withdraw request for recommendation
$("#approveAnrechnungDetail-withdraw-request-recommedation").click(function(){
if(!confirm(FHC_PhrasesLib.t("anrechnung", "empfehlungsanforderungWirklichZuruecknehmen")))
{
return;
}
// Get form data
let form_data = $('form').serializeArray();
// Prepare data object for ajax call
let data = {
'anrechnung_id' : form_data[0].value
};
FHC_AjaxClient.ajaxCallPost(
FHC_JS_DATA_STORAGE_OBJECT.called_path + "/withdrawRequestRecommendation",
data,
{
successCallback: function (data, textStatus, jqXHR)
{
console.log(data);
if (data.error && data.retval != null)
{
// Print error message
FHC_DialogLib.alertWarning(data.retval);
}
if (!data.error && data.retval != null)
{
approveAnrechnungDetail.formatEmpfehlungIsWithdrawed(
data.retval.status_bezeichnung
);
FHC_DialogLib.alertSuccess(
FHC_PhrasesLib.t("anrechnung", "erfolgreichZurueckgenommen")
);
}
},
errorCallback: function (jqXHR, textStatus, errorThrown)
{
FHC_DialogLib.alertError(FHC_PhrasesLib.t("ui", "systemfehler"));
}
}
);
});
// Copy Begruendung into textarea
$(".btn-copyIntoTextarea").click(function(){
approveAnrechnungDetail.copyIntoTextarea(this);
@@ -313,6 +362,7 @@ var approveAnrechnungDetail = {
$('#approveAnrechnungDetail-request-recommendation').prop('disabled', true);
$('#approveAnrechnungDetail-approve-anrechnung-ask').prop('disabled', true);
$('#approveAnrechnungDetail-reject-anrechnung-ask').prop('disabled', true);
$('#approveAnrechnungDetail-withdraw-request-recommedation').removeClass('hidden');
},
formatGenehmigungIsPositiv: function(abgeschlossenAm, abgeschlossenVon, statusBezeichnung){
$('#approveAnrechnungDetail-genehmigungDetail').children().addClass('hidden');
@@ -355,9 +405,22 @@ var approveAnrechnungDetail = {
$('#approveAnrechnungDetail-abgeschlossenAm').text('-');
$('#approveAnrechnungDetail-abgeschlossenVon').text('-');
$('#approveAnrechnungDetail-request-recommendation').prop('disabled', false);
$('#approveAnrechnungDetail-approve-anrechnung-ask').prop('disabled', false);
$('#approveAnrechnungDetail-reject-anrechnung-ask').prop('disabled', false);
// Hide button to withdraw approval
$('#approveAnrechnungDetail-withdraw-anrechnung-approvement').addClass('hidden');
},
formatEmpfehlungIsWithdrawed: function (statusBezeichnung){
$('#approveAnrechnungDetail-status_kurzbz').text(statusBezeichnung);
$('#approveAnrechnungDetail-empfehlungDetail-empfehlungIsAngefordert').addClass('hidden');
$('#approveAnrechnungDetail-empfehlungDetail-empfehlungIsNull').removeClass('hidden');
$('#approveAnrechnungDetail-request-recommendation').prop('disabled', false);
$('#approveAnrechnungDetail-approve-anrechnung-ask').prop('disabled', false);
$('#approveAnrechnungDetail-reject-anrechnung-ask').prop('disabled', false);
// Hide button to withdraw approval
$('#approveAnrechnungDetail-withdraw-request-recommedation').addClass('hidden');
}
}
+20
View File
@@ -10290,6 +10290,26 @@ array(
)
)
),
array(
'app' => 'core',
'category' => 'anrechnung',
'phrase' => 'empfehlungsanforderungWirklichZuruecknehmen',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => "Empfehlungsanforderung wirklich zurücknehmen?",
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => "Do you really want to withdraw your request for recommendation?",
'description' => '',
'insertvon' => 'system'
)
)
),
);