Skip to content
Snippets Groups Projects
Commit 966ed1ed authored by TimRepke's avatar TimRepke Committed by GitHub
Browse files

Merge pull request #61 from TimRepke/fix-admin-list

Fix admin list
parents c420dd48 2d4e949a
No related branches found
No related tags found
No related merge requests found
......@@ -7,9 +7,12 @@ class AdminListPage extends AdminPage {
if (isset($_REQUEST['change'])) {
try {
$b = Bachelor::makeFromForm(false, $this->fahrt, true, true);
$b->set(['bachelor_id' => $_REQUEST['change']]);
$saveResult = $b->save();
$bNew = Bachelor::makeFromForm(false, $this->fahrt, true, true);
$bNew->set(['bachelor_id' => $_REQUEST['change']]);
$bOld = Bachelor::makeFromDB($this->fahrt, $_REQUEST['change']);
$bOld->updateBachelor($bNew);
$saveResult = $bOld->save();
if ($saveResult !== Bachelor::SAVE_SUCCESS)
throw new Exception('Fehler beim Speichern mit code ' . $saveResult.'<br />'.implode('<br />', $b->getValidationErrors()));
else
......@@ -179,8 +182,15 @@ class AdminListPage extends AdminPage {
$(document).ready(function(){
ltab = $("#mlist").DataTable({
"rowCallback": function (row, data, index) {
if (data['.$buttoncol.'].split(",")[2] != 0) {
var spl = data['.$buttoncol.'].split(",");
if (spl[2] != 0) {
$("td", row).addClass("list-backstepped");
} else if (spl[0] != 0 && spl[1] != 0) {
$("td", row).addClass("list-repaid");
} else if (spl[0] != 0) {
$("td", row).addClass("list-paid");
} else if (spl[0] == 0) {
$("td", row).addClass("list-unpaid");
}
},
"columnDefs": [
......@@ -239,15 +249,35 @@ class AdminListPage extends AdminPage {
var newstate = (((state-1)<0) ? 1 : 0);
$.get("index.php?page=list&ajax=ajax&update="+type+"&hash="+hash+"&nstate="+newstate ,"",
function(){
if(newstate === 1 && type === "backstepped") {
$("td", $(that).parent().parent()).addClass("list-backstepped");
} else {
$("td", $(that).parent().parent()).removeClass("list-backstepped");
}
that.className="btn btn-"+type+"-"+newstate;
that.setAttribute("onclick", "btnclick(this, \'"+type+"\', \'"+hash+"\', "+newstate+")");
var p = $("div", $(that).parent())[0].className;
var r = $("div", $(that).parent())[1].className;
var b = $("div", $(that).parent())[2].className;
if (b == "btn btn-backstepped-1") {
updateClass(that, "list-backstepped");
} else if (p == "btn btn-paid-1" && r == "btn btn-repaid-1") {
updateClass(that, "list-repaid");
} else if (p == "btn btn-paid-1") {
updateClass(that, "list-paid");
} else if (p == "btn btn-paid-0") {
updateClass(that, "list-unpaid");
} else {
updateClass(that);
}
});
}
function updateClass(that, nClass = null) {
$("td", $(that).parent().parent()).removeClass("list-backstepped")
.removeClass("list-repaid")
.removeClass("list-paid")
.removeClass("list-unpaid");
if(nClass != null)
$("td", $(that).parent().parent()).addClass(nClass);
}
</script>';
}
......
......@@ -459,4 +459,15 @@ class Bachelor {
}
}
/**
* @param $newBachelor Bachelor
*/
public function updateBachelor($newBachelor) {
$nBdata = $newBachelor->getData();
foreach ($this->data as $key => $val) {
if (isset($nBdata[$key]) and !empty($nBdata[$key]))
$this->data[$key] = $nBdata[$key];
}
}
}
\ No newline at end of file
......@@ -63,11 +63,21 @@ form table tr td{
padding: 0 5px;
}
.list-backstepped{
.list-backstepped, .list-backstepped a {
color: #d3d3d3 !important;
}
.list-backstepped a{
color: #d3d3d3 !important;
.list-unpaid, .list-unpaid a {
background-color: #ffc6c1;
}
.list-paid, .list-paid a {
background-color: #e5ffc7;
}
.list-repaid, .list-repaid a {
background-color: #1bffbe;
color: grey !important;
}
.cost-table{
padding: 5px;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment