replaced php requests with ajax requests

This commit is contained in:
alex
2018-02-28 12:56:14 +01:00
parent b8e7599888
commit 7581ac05dd
7 changed files with 254 additions and 93 deletions
@@ -156,12 +156,12 @@ class InfoCenter extends VileSci_Controller
/**
* Saves if a document has been formal geprueft. saves current timestamp if checked as geprueft, or null if not.
* @param $person_id
*/
public function saveFormalGeprueft()
public function saveFormalGeprueft($person_id)
{
$akte_id = $this->input->get('akte_id');
$formalgeprueft = $this->input->get('formal_geprueft');
$person_id = $this->input->get('person_id');
$akte_id = $this->input->post('akte_id');
$formalgeprueft = $this->input->post('formal_geprueft');
if (!isset($akte_id) || !isset($formalgeprueft) || !isset($person_id))
show_error('Parameters not set!');
@@ -191,7 +191,9 @@ class InfoCenter extends VileSci_Controller
)
);
redirect(self::URL_PREFIX.'/showDetails/'.$person_id.'#DokPruef');
$this->output
->set_content_type('application/json')
->set_output(json_encode($timestamp));
}
/**
@@ -260,7 +262,9 @@ class InfoCenter extends VileSci_Controller
$this->_log($logdata['person_id'], 'savezgv', array($logdata['studiengang_kurzbz'], $prestudent_id));
$this->_redirectToStart($prestudent_id, 'ZgvPruef');
$this->output
->set_content_type('application/json')
->set_output(json_encode($result->retval));
}
/**
@@ -385,7 +389,35 @@ class InfoCenter extends VileSci_Controller
$this->_log($person_id, 'savenotiz', array($titel));
redirect(self::URL_PREFIX.'/showDetails/'.$person_id.'#NotizAkt');
$this->output
->set_content_type('application/json')
->set_output(json_encode($result->retval));
}
/**
* Loads Notizen view for a person, helper for reloading after ajax request
* @param $person_id
*/
public function reloadNotizen($person_id)
{
$notizen = $this->NotizModel->getNotiz($person_id);
if (isError($notizen))
{
show_error($notizen->retval);
}
$this->load->view('system/infocenter/notizen.php', array('notizen' => $notizen->retval));
}
/**
* Loads Logs view for a person, helper for reloading after ajax request
* @param $person_id
*/
public function reloadLogs($person_id)
{
$logs = $this->personloglib->getLogs($person_id);
$this->load->view('system/infocenter/logs.php', array('logs' => $logs));
}
/**
@@ -675,7 +707,7 @@ class InfoCenter extends VileSci_Controller
// Interessenten come first, otherwise by bewerbungsdatum desc, then by prestudent_id desc
usort($zgvpruefungen, function ($a, $b) {
$bewdatesort = strcmp($b->prestudentstatus->bewerbung_abgeschicktamum, $a->prestudentstatus->bewerbung_abgeschicktamum);
$bewdatesort = isset($a->prestudentstatus) && isset($b->prestudentstatus) ? strcmp($b->prestudentstatus->bewerbung_abgeschicktamum, $a->prestudentstatus->bewerbung_abgeschicktamum) : 0;
$defaultsort = $bewdatesort === 0 ? (int)$b->prestudent_id - (int)$a->prestudent_id : $bewdatesort;
if (!isset($a->prestudentstatus->status_kurzbz) || !isset($b->prestudentstatus->status_kurzbz))
return $defaultsort;
@@ -1,4 +1,4 @@
<form method="post" action="../saveNotiz/<?php echo $stammdaten->person_id ?>">
<form method="post" action="#" id="notizform">
<div class="form-group">
<div class="text-center">
<label>Notiz hinzuf&uuml;gen</label>
@@ -22,9 +22,11 @@
<td><?php echo date_format(date_create($dokument->erstelltam), 'd.m.Y') ?></td>
<td><?php echo $dokument->langtext ?></td>
<td>
<input type="checkbox" class="form-check-input"
id="prchkbx<?php echo $dokument->akte_id ?>" <?php echo $geprueft ?> />
<input type="checkbox" class="form-check-input prchbox"
id="prchkbx_<?php echo $dokument->akte_id ?>" <?php echo $geprueft ?>>
<span id="formalgeprueftam_<?php echo $dokument->akte_id ?>">
<?php echo isset($dokument->formal_geprueft_amum) ? date_format(date_create($dokument->formal_geprueft_amum), 'd.m.Y') : ''; ?>
</span>
</td>
</tr>
<?php endforeach ?>
@@ -129,10 +129,14 @@
<div class="panel-body">
<div class="row">
<div class="col-lg-6">
<div id="addnotiz">
<?php $this->load->view('system/infocenter/addNotiz.php'); ?>
</div>
<div id="notizen">
<?php $this->load->view('system/infocenter/notizen.php'); ?>
</div>
</div>
<div class="col-lg-6">
<div class="col-lg-6" id="logs">
<?php $this->load->view('system/infocenter/logs.php'); ?>
</div> <!-- ./column -->
</div> <!-- ./row -->
@@ -144,26 +148,6 @@
</div> <!-- ./container-fluid-->
</div> <!-- ./page-wrapper-->
</div> <!-- ./wrapper -->
<script>
$(document).ready(
function ()
{
//add click events to "formal geprüft" checkboxes
<?php foreach($dokumente as $dokument): ?>
if ($("#prchkbx<?php echo $dokument->akte_id; ?>"))
{
$("#prchkbx<?php echo $dokument->akte_id; ?>").click(function ()
{
window.location = "../saveFormalGeprueft?akte_id=<?php echo $dokument->akte_id; ?>&formal_geprueft=" + this.checked + "&person_id=<?php echo $stammdaten->person_id ?>";
});
}
<?php endforeach ?>
}
);
</script>
</body>
<?php $this->load->view('templates/FHC-Footer'); ?>
@@ -27,7 +27,8 @@
class="panel-collapse collapse<?php echo $infoonly ? '' : ' in' ?>">
<div class="panel-body">
<form method="post"
action="../saveZgvPruefung/<?php echo $zgvpruefung->prestudent_id ?>">
action="#" class="zgvform">
<input type="hidden" name="prestudentid" value="<?php echo $zgvpruefung->prestudent_id ?>">
<div class="row">
<div class="col-lg-<?php echo $columns[0] ?>">
<div class="form-group">
@@ -193,7 +194,7 @@
</button>
</div>
<div class="col-lg-6 text-right">
<button type="submit" class="btn btn-default">
<button type="submit" class="btn btn-default saveZgv" id="zgvSpeichern_<?php echo $zgvpruefung->prestudent_id ?>">
Speichern
</button>
</div>
+1 -1
View File
@@ -7,6 +7,6 @@ $(document).ready(
{
$("input[type=text], select").addClass("form-control");
$("button, input[type=button]").addClass("btn btn-default");
$("table").addClass('table-condensed');
$("table").addClass("table-condensed");
}
);
+200 -58
View File
@@ -23,12 +23,10 @@ $(document).ready(
addTablesorter("doctable", [[2, 1], [1, 0]], ["zebra"]);
addTablesorter("nachgdoctable", [[2, 0], [1, 1]], ["zebra"]);
addTablesorter("msgtable", [[0, 1], [2, 0]], ["zebra", "filter"], 2);
addTablesorter("logtable", [[0, 1]], ["filter"], 2);
addTablesorter("notiztable", [[0, 1]], ["filter"], 2);
tablesortAddPager("msgtable", "msgpager", 10);
//add pager
tablesortAddPager("logtable", "logpager", 23);
tablesortAddPager("notiztable", "notizpager", 10);
formatNotizTable();
formatLogTable();
//initialise datepicker
$.datepicker.setDefaults($.datepicker.regional['de']);
@@ -36,16 +34,6 @@ $(document).ready(
"dateFormat": "dd.mm.yy"
});
//add click events to "formal geprüft" checkboxes
/* $(".prchbox input[type=checkbox]").click(
function()
{
var akteid = this.;
var personid = ;
window.location = "../saveFormalGeprueft?akte_id="+akteid+"&formal_geprueft=" + this.checked + "&person_id="+personid;
}
);*/
//add submit event to message send link
$("#sendmsglink").click(
function ()
@@ -54,14 +42,43 @@ $(document).ready(
}
);
//add click events to "formal geprüft" checkboxes
$(".prchbox").click(function ()
{
var boxid = this.id;
var personid = $("#hiddenpersonid").val();
var akteid = boxid.substr(boxid.indexOf("_") + 1);
var checked = this.checked;
saveFormalGeprueft(personid, akteid, checked)
});
//zgv übernehmen
$(".zgvUebernehmen").click(function ()
{
var btn = $(this);
var personid = $("#hiddenpersonid").val();
var prestudentid = this.id.substr(this.id.indexOf("_") + 1);
$('#zgvUebernehmenNotice').remove();
zgvUebernehmen(personid, prestudentid, btn)
});
//zgv speichern
$(".zgvform").on('submit', function (e)
{
e.preventDefault();
var data = $(this).serializeArray();
saveZgv(data);
}
);
//prevent opening modal when Statusgrund not chosen
$(".absageModal").on('show.bs.modal', function (e)
{
var id = this.id.substr(this.id.indexOf("_") + 1);
var statusgrvalue = $("#statusgrselect_"+id+" select[name=statusgrund]").val();
var statusgrvalue = $("#statusgrselect_" + id + " select[name=statusgrund]").val();
if (statusgrvalue === "null")
{
$("#statusgrselect_"+id).addClass("has-error");
$("#statusgrselect_" + id).addClass("has-error");
return e.preventDefault();
}
}
@@ -75,47 +92,172 @@ $(document).ready(
}
);
//zgv uebernehmen ajax
if ($(".zgvUebernehmen"))
{
$(".zgvUebernehmen").click(function() {
var btn = $(this);
//save notiz
$("#notizform").on("submit", function (e)
{
e.preventDefault();
var personid = $("#hiddenpersonid").val();
var prestudentid = this.id.substr(this.id.indexOf("_") + 1);
$('#nearzgv').remove();
var data = $(this).serializeArray();
saveNotiz(personid, data);
}
)
});
$.ajax({
type: "POST",
dataType: "json",
url: "../getLastPrestudentWithZgvJson/"+personid,
success: function(data, textStatus, jqXHR) {
if(data !== null)
{
var zgvcode = data.zgv_code !== null ? data.zgv_code : "null";
var zgvort = data.zgvort !== null ? data.zgvort : "";
var zgvdatum = data.zgvdatum;
var gerzgvdatum = "";
if(zgvdatum !== null)
{
zgvdatum = $.datepicker.parseDate("yy-mm-dd", data.zgvdatum);
gerzgvdatum = $.datepicker.formatDate("dd.mm.yy", zgvdatum);
}
var zgvnation = data.zgvnation !== null ? data.zgvnation : "null";
$("#zgv_" + prestudentid).val(zgvcode);
$("#zgvort_" + prestudentid).val(zgvort);
$("#zgvdatum_" + prestudentid).val(gerzgvdatum);
$("#zgvnation_" + prestudentid).val(zgvnation);
}
else
{
btn.after("&nbsp;&nbsp;<span id='nearzgv' class='text-warning'>keine ZGV vorhanden</span>");
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert(textStatus + " - " + errorThrown + " - " + jqXHR.responseText);
}
});
});
// -----------------------------------------------------------------------------------------------------------------
// ajax calls
function saveFormalGeprueft(personid, akteid, checked)
{
$.ajax({
type: "POST",
dataType: "json",
url: "../saveFormalGeprueft/" + personid,
data: {"akte_id": akteid, "formal_geprueft": checked},
success: function (data, textStatus, jqXHR)
{
if (data === null)
{
$("#formalgeprueftam_" + akteid).text("");
}
else
{
fgdatum = $.datepicker.parseDate("yy-mm-dd", data);
gerfgdatum = $.datepicker.formatDate("dd.mm.yy", fgdatum);
$("#formalgeprueftam_" + akteid).text(gerfgdatum);
}
//refresh doctable tablesorter, formal geprueft changed!
$("#doctable").trigger("update");
refreshLog();
},
error: function (jqXHR, textStatus, errorThrown)
{
alert(textStatus + " - " + errorThrown + " - " + jqXHR.responseText);
}
}
);
});
}
function zgvUebernehmen(personid, prestudentid, btn)
{
$.ajax({
type: "POST",
dataType: "json",
url: "../getLastPrestudentWithZgvJson/" + personid,
success: function (data, textStatus, jqXHR)
{
if (data !== null)
{
var zgvcode = data.zgv_code !== null ? data.zgv_code : "null";
var zgvort = data.zgvort !== null ? data.zgvort : "";
var zgvdatum = data.zgvdatum;
var gerzgvdatum = "";
if (zgvdatum !== null)
{
zgvdatum = $.datepicker.parseDate("yy-mm-dd", data.zgvdatum);
gerzgvdatum = $.datepicker.formatDate("dd.mm.yy", zgvdatum);
}
var zgvnation = data.zgvnation !== null ? data.zgvnation : "null";
$("#zgv_" + prestudentid).val(zgvcode);
$("#zgvort_" + prestudentid).val(zgvort);
$("#zgvdatum_" + prestudentid).val(gerzgvdatum);
$("#zgvnation_" + prestudentid).val(zgvnation);
}
else
{
btn.after("&nbsp;&nbsp;<span id='zgvUebernehmenNotice' class='text-warning'>keine ZGV vorhanden</span>");
}
},
error: function (jqXHR, textStatus, errorThrown)
{
alert(textStatus + " - " + errorThrown + " - " + jqXHR.responseText);
}
});
}
function saveZgv(data)
{
var prestudentid = data[0].value;
$("#zgvSpeichernNotice").remove();
$.ajax({
type: "POST",
dataType: "json",
data: data,
url: "../saveZgvPruefung/" + prestudentid,
success: function (data, textStatus, jqXHR)
{
if (data === prestudentid)
{
refreshLog();
$("#zgvSpeichern_" + prestudentid).before("<span id='zgvSpeichernNotice' class='text-success'>ZGV erfolgreich gespeichert!</span>&nbsp;&nbsp;");
}
else
{
$("#zgvSpeichern_" + prestudentid).before("<span id='zgvSpeichernNotice' class='text-danger'>Fehler beim Speichern der ZGV!</span>&nbsp;&nbsp;");
}
},
error: function (jqXHR, textStatus, errorThrown)
{
alert(textStatus + " - " + errorThrown + " - " + jqXHR.responseText);
}
});
}
function saveNotiz(personid, data)
{
$.ajax({
type: "POST",
dataType: "json",
data: data,
url: "../saveNotiz/" + personid,
success: function (data, textStatus, jqXHR)
{
refreshNotizen();
refreshLog();
},
error: function (jqXHR, textStatus, errorThrown)
{
alert(textStatus + " - " + errorThrown + " - " + jqXHR.responseText);
}
});
}
// -----------------------------------------------------------------------------------------------------------------
// methods executed after ajax (refreshers)
function refreshLog()
{
var personid = $("#hiddenpersonid").val();
$("#logs").load('../reloadLogs/' + personid,
function ()
{
//readd tablesorter
formatLogTable()
}
);
}
function formatLogTable()
{
addTablesorter("logtable", [[0, 1]], ["filter"], 2);
tablesortAddPager("logtable", "logpager", 23);
$("#logtable").addClass("table-condensed");
}
function refreshNotizen()
{
$("#notizform").find("input[type=text], textarea").val("");
var personid = $("#hiddenpersonid").val();
$("#notizen").load('../reloadNotizen/' + personid,
function ()
{
//readd tablesorter
formatNotizTable()
}
);
}
function formatNotizTable()
{
addTablesorter("notiztable", [[0, 1]], ["filter"], 2);
tablesortAddPager("notiztable", "notizpager", 10);
$("#notiztable").addClass("table-condensed");
}