mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-18 23:42:17 +00:00
Added Notice-Update functionality
. added notice updates functionality by clicking on a row in the notice-table . log "Notice updated" is set into log-table when note was updated successfully
This commit is contained in:
@@ -42,6 +42,11 @@ class InfoCenter extends VileSci_Controller
|
||||
'logtype' => 'Action',
|
||||
'name' => 'Note added',
|
||||
'message' => 'Note with title %s was added'
|
||||
),
|
||||
'updatenotiz' => array(
|
||||
'logtype' => 'Action',
|
||||
'name' => 'Note updated',
|
||||
'message' => 'Note with title %s was updated'
|
||||
)
|
||||
);
|
||||
private $uid; // contains the UID of the logged user
|
||||
@@ -381,6 +386,44 @@ class InfoCenter extends VileSci_Controller
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode($result->retval));
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a new Notiz for a person
|
||||
* @param int $notiz_id
|
||||
* @param int $person_id
|
||||
* @return bool true if success
|
||||
*/
|
||||
public function updateNotiz($notiz_id, $person_id)
|
||||
{
|
||||
$titel = $this->input->post('notiztitel');
|
||||
$text = $this->input->post('notiz');
|
||||
|
||||
$result = $this->NotizModel->update(
|
||||
$notiz_id,
|
||||
array(
|
||||
'titel' => $titel,
|
||||
'text' => $text,
|
||||
'verfasser_uid' => $this->uid,
|
||||
"updateamum" => 'NOW()',
|
||||
"updatevon" => $this->uid
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$json = FALSE;
|
||||
|
||||
if (isSuccess($result))
|
||||
{
|
||||
$json = TRUE;
|
||||
|
||||
//set log "Notiz updated"
|
||||
$this->_log($person_id, 'updatenotiz', array($titel));
|
||||
}
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode($json));
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads Notizen view for a person, helper for reloading after ajax request
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<form method="post" action="#" id="notizform">
|
||||
<input type="hidden" name="hiddenNotizId" value="">
|
||||
<div class="form-group">
|
||||
<div class="text-center">
|
||||
<label>Notiz hinzufügen</label>
|
||||
@@ -19,6 +20,8 @@
|
||||
<textarea name="notiz" class="form-control" rows="10" cols="32"></textarea>
|
||||
</div>
|
||||
<div class="text-right">
|
||||
<!--abbrechen-button only shown when notice is clicked to be changed-->
|
||||
<button type="reset" class="btn btn-default" style="display: none">Abbrechen</button>
|
||||
<button type="submit" class="btn btn-default">Speichern</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
<table id="notiztable" class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Datum</th>
|
||||
<th>Notiz</th>
|
||||
<th>User</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($notizen as $notiz): ?>
|
||||
<tr data-toggle="tooltip"
|
||||
title="<?php echo isset($notiz->text) ? strip_tags($notiz->text) : '' ?>">
|
||||
<td><?php echo date_format(date_create($notiz->insertamum), 'd.m.Y H:i:s') ?></td>
|
||||
<td><?php echo html_escape($notiz->titel) ?></td>
|
||||
<td><?php echo $notiz->verfasser_uid ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
<table id="notiztable" class="table table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Datum</th>
|
||||
<th>Notiz</th>
|
||||
<th>User</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($notizen as $notiz): ?>
|
||||
<tr data-toggle="tooltip"
|
||||
title="<?php echo isset($notiz->text) ? strip_tags($notiz->text) : '' ?>">
|
||||
<td><?php echo date_format(date_create($notiz->insertamum), 'd.m.Y H:i:s') ?></td>
|
||||
<td><?php echo html_escape($notiz->titel) ?></td>
|
||||
<td><?php echo $notiz->verfasser_uid ?></td>
|
||||
<td style="display: none"><?php echo $notiz->notiz_id ?></td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -96,11 +96,45 @@ $(document).ready(
|
||||
$("#notizform").on("submit", function (e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var personid = $("#hiddenpersonid").val();
|
||||
var personId = $("#hiddenpersonid").val();
|
||||
var notizId = $("#notizform :input[name='hiddenNotizId']").val();
|
||||
var data = $(this).serializeArray();
|
||||
saveNotiz(personid, data);
|
||||
|
||||
if (notizId !== '')
|
||||
{
|
||||
updateNotiz(notizId, personId, data);
|
||||
}
|
||||
else
|
||||
{
|
||||
saveNotiz(personId, data);
|
||||
}
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
//update notiz - autofill notizform
|
||||
$(document).on("click", "#notiztable tbody tr", function ()
|
||||
{
|
||||
var notizId = $(this).find("td:eq(3)").html();
|
||||
var notizTitle = $(this).find("td:eq(1)").text();
|
||||
var notizContent = this.title;
|
||||
|
||||
$("#notizform label:first").text("Notiz ändern").css("color", "red");
|
||||
$("#notizform :input[type='reset']").css("display", "inline-block");
|
||||
|
||||
$("#notizform :input[name='hiddenNotizId']").val(notizId);
|
||||
$("#notizform :input[name='notiztitel']").val(notizTitle);
|
||||
$("#notizform :input[name='notiz']").val(notizContent);
|
||||
}
|
||||
);
|
||||
|
||||
//update notiz - abbrechen-button: reset styles
|
||||
$("#notizform :input[type='reset']").click(function ()
|
||||
{
|
||||
resetNotizFields();
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
@@ -220,6 +254,29 @@ function saveNotiz(personid, data)
|
||||
});
|
||||
}
|
||||
|
||||
function updateNotiz(notizId, personId, data)
|
||||
{
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
data: data,
|
||||
url: "../updateNotiz/" + notizId + "/" + personId,
|
||||
success: function (data, textStatus, jqXHR)
|
||||
{
|
||||
if (data)
|
||||
{
|
||||
refreshNotizen();
|
||||
refreshLog();
|
||||
resetNotizFields();
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown)
|
||||
{
|
||||
alert(textStatus + " - " + errorThrown + " - " + jqXHR.responseText);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// methods executed after ajax (refreshers)
|
||||
|
||||
@@ -252,7 +309,7 @@ function refreshNotizen()
|
||||
//readd tablesorter
|
||||
formatNotizTable()
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
function formatNotizTable()
|
||||
@@ -261,3 +318,10 @@ function formatNotizTable()
|
||||
tablesortAddPager("notiztable", "notizpager", 10);
|
||||
$("#notiztable").addClass("table-condensed");
|
||||
}
|
||||
|
||||
function resetNotizFields()
|
||||
{
|
||||
$("#notizform :input[name='hiddenNotizId']").val("");
|
||||
$("#notizform label:first").text("Notiz hinzufügen").css("color", "black");
|
||||
$("#notizform :input[type='reset']").css("display", "none");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user