InfoCenter Details AjaxLib calls update:

- using outputJson... methods instead of output type and json_encode
- added errorcallbacks for blocking errors
- called IC controller methods return success or error objects
- fitstudiengang is checked when sending freigabe stg message
This commit is contained in:
alex
2019-04-16 13:58:21 +02:00
parent 255516c8fd
commit d23357c331
2 changed files with 112 additions and 88 deletions
@@ -234,7 +234,7 @@ class InfoCenter extends Auth_Controller
$akte_id = $this->input->post('akte_id');
$formalgeprueft = $this->input->post('formal_geprueft');
$json = false;
$json = null;
if (isset($akte_id) && isset($formalgeprueft) && isset($person_id))
{
@@ -247,7 +247,7 @@ class InfoCenter extends Auth_Controller
if (isSuccess($result))
{
$json = $timestamp;
$json = is_null($timestamp) ? '' : $timestamp;
$this->_log(
$person_id,
@@ -261,7 +261,7 @@ class InfoCenter extends Auth_Controller
}
}
$this->output->set_content_type('application/json')->set_output(json_encode($json));
$this->outputJsonSuccess(array($json));
}
/**
@@ -272,7 +272,7 @@ class InfoCenter extends Auth_Controller
{
$prestudentdata = $this->_loadPrestudentData($person_id);
$this->output->set_content_type('application/json')->set_output(json_encode($prestudentdata['zgvpruefungen']));
$this->outputJsonSuccess($prestudentdata['zgvpruefungen']);
}
/**
@@ -283,7 +283,7 @@ class InfoCenter extends Auth_Controller
{
$prestudent = $this->PrestudentModel->getLastPrestudent($person_id, true);
$this->output->set_content_type('application/json')->set_output(json_encode($prestudent));
$this->outputJson($prestudent);
}
/**
@@ -299,10 +299,10 @@ class InfoCenter extends Auth_Controller
$studiengangbezeichnung = $prestudentdata['studiengang_bezeichnung'];
$data = array(
'studiengang_bezeichnung' => $studiengangbezeichnung,
'studiengang_kurzbz' => $studiengangkurzbz,
'data' => null
);
'studiengang_bezeichnung' => $studiengangbezeichnung,
'studiengang_kurzbz' => $studiengangkurzbz,
'data' => null
);
if (hasData($studienordnung))
{
@@ -319,13 +319,14 @@ class InfoCenter extends Auth_Controller
{
$prestudent_id = $this->input->post('prestudentid');
$change = $this->input->post('change');
$json = false;
if (!is_numeric($change) || !is_numeric($prestudent_id))
$result = error('Parameteres missing');
else
$result = $this->PrestudentModel->changePrio($prestudent_id, intval($change));
if (is_numeric($change) || is_numeric($prestudent_id))
{
$json = $this->PrestudentModel->changePrio($prestudent_id, intval($change));
}
$this->output->set_content_type('application/json')->set_output(json_encode($result));
$this->outputJsonSuccess(array($json));
}
/**
@@ -403,7 +404,8 @@ class InfoCenter extends Auth_Controller
$this->_log($logdata['person_id'], 'savezgv', array($logdata['studiengang_kurzbz'], $prestudent_id));
}
}
$this->output->set_content_type('application/json')->set_output(json_encode($json));
$this->outputJson($json);
}
/**
@@ -454,7 +456,8 @@ class InfoCenter extends Auth_Controller
}
}
}
$this->output->set_content_type('application/json')->set_output(json_encode($json));
$this->outputJson($json);
}
/**
@@ -521,9 +524,7 @@ class InfoCenter extends Auth_Controller
// acceptresult returns null if no documents to accept
if ($acceptresult !== null && isError($acceptresult))
{
$json->error = 2;
}
$json->retval['nonCriticalErrors'] = 'error when accepting documents in FAS';
$logparams = array($prestudent_id, $logdata['studiengang_kurzbz'], '');
@@ -543,7 +544,7 @@ class InfoCenter extends Auth_Controller
}
}
$this->output->set_content_type('application/json')->set_output(json_encode($json));
$this->outputJson($json);
}
/**
@@ -557,7 +558,7 @@ class InfoCenter extends Auth_Controller
$notiz_id
);
$this->output->set_content_type('application/json')->set_output(json_encode($result));
$this->outputJson($result);
}
/**
@@ -577,7 +578,7 @@ class InfoCenter extends Auth_Controller
$this->_log($person_id, 'savenotiz', array($titel));
}
$this->output->set_content_type('application/json')->set_output(json_encode($result));
$this->outputJson($result);
}
/**
@@ -608,7 +609,7 @@ class InfoCenter extends Auth_Controller
$this->_log($person_id, 'updatenotiz', array($titel));
}
$this->output->set_content_type('application/json')->set_output(json_encode($result));
$this->outputJson($result);
}
/**
@@ -696,9 +697,9 @@ class InfoCenter extends Auth_Controller
*/
public function getParkedDate($person_id)
{
$result = $this->personloglib->getParkedDate($person_id);
$parkedDate = $this->personloglib->getParkedDate($person_id);
$this->output->set_content_type('application/json')->set_output(json_encode($result));
$this->outputJsonSuccess(array($parkedDate));
}
/**
@@ -711,7 +712,7 @@ class InfoCenter extends Auth_Controller
$result = $this->personloglib->park($person_id, date_format(date_create($date), 'Y-m-d'), self::TAETIGKEIT, self::APP, null, $this->_uid);
$this->output->set_content_type('application/json')->set_output(json_encode($result));
$this->outputJson($result);
}
/**
@@ -722,14 +723,8 @@ class InfoCenter extends Auth_Controller
$person_id = $this->input->post('person_id');
$result = $this->personloglib->unPark($person_id);
if (isError($result))
{
$this->outputJsonError($result);
}
else
{
$this->output->set_content_type('application/json')->set_output(json_encode(getData($result)));
}
$this->outputJson($result);
}
/**
@@ -741,14 +736,14 @@ class InfoCenter extends Auth_Controller
$result = $this->StudienjahrModel->getCurrStudienjahr();
$json = false;
$json = null;
if (hasData($result))
{
$json = $result->retval[0]->ende;
}
$this->output->set_content_type('application/json')->set_output(json_encode($json));
$this->outputJsonSuccess(array($json));
}
/**
@@ -1254,7 +1249,6 @@ class InfoCenter extends Auth_Controller
$data = array (
'zgvpruefungen' => $zgvpruefungen,
'numberinteressenten' => $interessentenCount,
'abwstatusgruende' => $abwstatusgruende,
'intstatusgruende' => $intstatusgruende
);
+81 -51
View File
@@ -118,9 +118,6 @@ $(document).ready(function ()
var InfocenterDetails = {
genericSaveError: function() {
FHC_DialogLib.alertError("error when saving");
},
openZgvInfoForPrestudent: function(prestudent_id)
{
var screenwidth = screen.width;
@@ -141,15 +138,16 @@ var InfocenterDetails = {
},
{
successCallback: function(data, textStatus, jqXHR) {
if (data !== false)
if (FHC_AjaxClient.hasData(data))
{
if (data === null)
var timestamp = data.retval[0];
if (timestamp === "")
{
$("#formalgeprueftam_" + akteid).text("");
}
else
{
var fgdatum = $.datepicker.parseDate("yy-mm-dd", data);
var fgdatum = $.datepicker.parseDate("yy-mm-dd", timestamp);
var gerfgdatum = $.datepicker.formatDate("dd.mm.yy", fgdatum);
$("#formalgeprueftam_" + akteid).text(gerfgdatum);
}
@@ -159,10 +157,10 @@ var InfocenterDetails = {
}
else
{
InfocenterDetails.genericSaveError();
InfocenterDetails._genericSaveError();
}
},
errorCallback: InfocenterDetails.genericSaveError,
errorCallback: InfocenterDetails._genericSaveError,
veilTimeout: 0
}
);
@@ -174,12 +172,13 @@ var InfocenterDetails = {
data,
{
successCallback: function(data, textStatus, jqXHR) {
if (data !== true)
if (!FHC_AjaxClient.hasData(data) || data.retval[0] !== true)
{
FHC_DialogLib.alertError("error when saving ZGV prio");
InfocenterDetails._genericSaveError();
}
InfocenterDetails._refreshZgv(true);
}
},
errorCallback: InfocenterDetails._genericSaveError
}
);
},
@@ -213,6 +212,10 @@ var InfocenterDetails = {
btn.after("&nbsp;&nbsp;<span id='zgvUebernehmenNotice' class='text-warning'>keine ZGV vorhanden</span>");
}
},
errorCallback: function()
{
FHC_DialogLib.alertError('Error when getting last ZGV');
},
veilTimeout: 0
}
);
@@ -261,9 +264,10 @@ var InfocenterDetails = {
}
else
{
FHC_DialogLib.alertError("error when saving Absage");
InfocenterDetails._genericSaveError();
}
}
},
errorCallback: InfocenterDetails._genericSaveError
}
);
},
@@ -273,27 +277,29 @@ var InfocenterDetails = {
CALLED_PATH + '/saveFreigabe',
{"prestudent_id": freigabeData.prestudent_id, "statusgrund_id": freigabeData.statusgrund_id},
{
successCallback: function(freigabeResponseData, textStatus, jqXHR) {
successCallback: function(data, textStatus, jqXHR) {
if (FHC_AjaxClient.hasData(freigabeResponseData))
if (FHC_AjaxClient.hasData(data))
{
var freigabeResponseData = FHC_AjaxClient.getData(data);
if (freigabeResponseData.nonCriticalErrors && freigabeResponseData.nonCriticalErrors.length > 0
&& typeof freigabeResponseData.nonCriticalErrors == "string")
{
FHC_DialogLib.alertWarning(freigabeResponseData.nonCriticalErrors);
}
FHC_AjaxClient.showVeil();
InfocenterDetails.initFrgMessageSend(freigabeData);
InfocenterDetails._refreshZgv();
FHC_AjaxClient.hideVeil();
InfocenterDetails._refreshLog();
}
else if (freigabeResponseData.error === 2 && parseInt(freigabeResponseData.retval.prestudent_id, 10))
{
FHC_DialogLib.alertError("error when setting accepted documents");
InfocenterDetails._refreshZgv();
InfocenterDetails._refreshLog();
}
else
{
FHC_DialogLib.alertError("error when saving Freigabe");
InfocenterDetails._genericSaveError();
}
}
},
errorCallback: InfocenterDetails._genericSaveError
}
);
},
@@ -388,13 +394,17 @@ var InfocenterDetails = {
null,
{
successCallback: function(data, textStatus, jqXHR) {
if (data)
if (FHC_AjaxClient.hasData(data))
{
var engdate = $.datepicker.parseDate("yy-mm-dd", data);
var engdate = $.datepicker.parseDate("yy-mm-dd", FHC_AjaxClient.getData(data)[0]);
var gerdate = $.datepicker.formatDate("dd.mm.yy", engdate);
$("#parkdate").val(gerdate);
}
},
errorCallback: function()
{
FHC_DialogLib.alertError("error when getting Studienjahr end");
},
veilTimeout: 0
}
);
@@ -406,10 +416,18 @@ var InfocenterDetails = {
null,
{
successCallback: function(data, textStatus, jqXHR) {
InfocenterDetails._refreshParking(data);
InfocenterDetails._refreshLog();
if (data === null)
InfocenterDetails.getStudienjahrEnd();
if (FHC_AjaxClient.hasData(data))
{
var parkedDate = FHC_AjaxClient.getData(data)[0];
InfocenterDetails._refreshParking(parkedDate);
InfocenterDetails._refreshLog();
if (parkedDate === null)
InfocenterDetails.getStudienjahrEnd();
}
},
errorCallback: function()
{
FHC_DialogLib.alertError("error when getting parked status");
},
veilTimeout: 0
}
@@ -450,13 +468,12 @@ var InfocenterDetails = {
},
{
successCallback: function(data, textStatus, jqXHR) {
if (Array.isArray(data))
if (FHC_AjaxClient.hasData(data))
{
if (data.length > 0)
InfocenterDetails.getParkedDate(personid);
else
$("#unparkmsg").removeClass().addClass("text-warning").text(FHC_PhrasesLib.t('infocenter', 'nichtsZumAusparken'));
InfocenterDetails.getParkedDate(personid);
}
else
$("#unparkmsg").removeClass().addClass("text-warning").text(FHC_PhrasesLib.t('infocenter', 'nichtsZumAusparken'));
},
errorCallback: function(){
$("#unparkmsg").removeClass().addClass("text-danger").text(FHC_PhrasesLib.t('infocenter', 'fehlerBeimAusparken'));
@@ -472,32 +489,39 @@ var InfocenterDetails = {
null,
{
successCallback: callback,
errorCallback: function()
{
FHC_DialogLib.alertError("error when getting prestudent data")
},
veilTimeout: 0
}
);
},
initFrgMessageSend: function(freigabedata)
{
var callback = function (data)
var personid = $("#hiddenpersonid").val();
var callback = function (prestudentresponse)
{
if (data == null)
if (!FHC_AjaxClient.hasData(prestudentresponse))
return;
var prestudentdata = prestudentresponse.retval;
var prestudent_id = freigabedata.prestudent_id;
var statusgrund_id = freigabedata.statusgrund_id;
var rtfreigabe = !$.isNumeric(statusgrund_id);
// check if a prestudent in same semester is already freigegeben - then not send message again
var rtFreigegeben = false;
var stgFreigegeben = false;
var receiverPrestudentstatus = null;
//get prestudentstatus of message receiver
for(var i = 0; i < data.length; i++)
for(var i = 0; i < prestudentdata.length; i++)
{
if (data[i].prestudentstatus.prestudent_id === prestudent_id)
if (prestudentdata[i].prestudentstatus.prestudent_id === prestudent_id)
{
receiverPrestudentstatus = data[i].prestudentstatus;
receiverPrestudentstatus = prestudentdata[i].prestudentstatus;
break;
}
}
@@ -506,19 +530,20 @@ var InfocenterDetails = {
return;
//check other prestudentstati wether already freigegeben
for(var j = 0; j < data.length; j++)
for(var j = 0; j < prestudentdata.length; j++)
{
var prestudent = data[j];
var prestudent = prestudentdata[j];
var prestudentstatus = prestudent.prestudentstatus;
var id = prestudentstatus.prestudent_id;
if (id !== prestudent_id)
{
var fitfreigegeben = $.inArray(prestudentstatus.bezeichnung_statusgrund[0], STGFREIGABE_MESSAGESEND_EXCEPTIONS) >= 0;
var fitstg = $.inArray(parseInt(prestudent.studiengang_kz), FIT_PROGRAMM_STUDIENGAENGE) >= 0;
if (receiverPrestudentstatus.studiensemester_kurzbz === prestudentstatus.studiensemester_kurzbz
&& prestudentstatus.bestaetigtam !== null && prestudentstatus.status_kurzbz === "Interessent"
&& (prestudent.studiengangtyp === "b"))
&& (prestudent.studiengangtyp === "b" || fitstg))
{
if (prestudentstatus.statusgrund_id === null)
{
@@ -579,7 +604,7 @@ var InfocenterDetails = {
{
var statusgrundbez = freigabedata.statusgrundbezeichnung ? freigabedata.statusgrundbezeichnung : "";
// if Freigabe to Studiengang, send StgFreigabe Message if not already sent
//if Freigabe to Studiengang, send StgFreigabe Message if not already sent
if (!stgFreigegeben && $.inArray(statusgrundbez, STGFREIGABE_MESSAGESEND_EXCEPTIONS) < 0)
{
InfocenterDetails.sendFreigabeMessage(prestudent_id, STGFREIGABE_MESSAGE_VORLAGE, msgvars);
@@ -587,11 +612,9 @@ var InfocenterDetails = {
}
};
var personid = $("#hiddenpersonid").val();
InfocenterDetails.getPrestudentData(
personid, callback
)
);
},
sendFreigabeMessage: function(prestudentid, vorlage_kurzbz, msgvars)
{
@@ -607,6 +630,9 @@ var InfocenterDetails = {
successCallback: function(data, textStatus, jqXHR) {
InfocenterDetails._refreshMessages();
InfocenterDetails._refreshLog();
},
errorCallback: function() {
FHC_DialogLib.alertWarning("Freigabe message could not be sent");
}
}
);
@@ -684,7 +710,8 @@ var InfocenterDetails = {
$(".freigabebtn").click(function()
{
var prestudentid = this.id.substr(this.id.indexOf("_") + 1);
InfocenterDetails._toggleFreigabeDialog(prestudentid, true);//true - Reihungstestfreigabe
//true - Reihungstestfreigabe
InfocenterDetails._toggleFreigabeDialog(prestudentid, true);
}
);
@@ -695,14 +722,14 @@ var InfocenterDetails = {
var statusgrund_id = statusgrel.val();
var statusgrund = statusgrel.find("option:selected").text();
if (statusgrund_id === 'null')
if (!$.isNumeric(statusgrund_id))
{
$("#frgstatusgrselect_" + prestudentid).addClass("has-error");
}
else
{
var rtfreigabe = false;//no Reihungstestfreigabe
InfocenterDetails._toggleFreigabeDialog(prestudentid, rtfreigabe, statusgrund);
//false - no Reihungstestfreigabe
InfocenterDetails._toggleFreigabeDialog(prestudentid, false, statusgrund);
}
}
);
@@ -923,5 +950,8 @@ var InfocenterDetails = {
_notizError: function(phrasename)
{
$("#notizmsg").text(FHC_PhrasesLib.t('ui', phrasename));
},
_genericSaveError: function() {
FHC_DialogLib.alertError("error when saving!");
}
};