added lines with actions for multiple persons in infocenter uebersicht (send message, select all, number of rows), message with no sender sends from logged user, layout tweaks writemessage page

This commit is contained in:
alex
2018-02-09 17:00:16 +01:00
parent d23e44643d
commit fe5e5cc313
8 changed files with 174 additions and 58 deletions
+44 -10
View File
@@ -27,8 +27,19 @@ class Messages extends VileSci_Controller
/**
* write
*/
public function write($sender_id, $msg_id = null, $receiver_id = null)
public function write($sender_id = null, $msg_id = null, $receiver_id = null)
{
if ($sender_id === null)
{
$user_person = $this->PersonModel->getByUid($this->uid);
if (isError($user_person))
{
show_error($user_person->retval);
}
$sender_id = $user_person->retval[0]->person_id;
}
$prestudent_id = $this->input->post('prestudent_id');
$person_id = $this->input->post('person_id');
$personOnly = false;
@@ -68,7 +79,7 @@ class Messages extends VileSci_Controller
$benutzerResult = $this->BenutzerfunktionModel->getByPersonId($sender_id);
if (hasData($benutzerResult))
{
foreach($benutzerResult->retval as $val)
foreach ($benutzerResult->retval as $val)
{
$oe_kurzbz[] = $val->oe_kurzbz;
}
@@ -95,6 +106,12 @@ class Messages extends VileSci_Controller
$v = $this->load->view('system/messageWrite', $data);
}
/**
* gets Message Variables and their data for Prestudent
* @param $prestudent_id
* @param $variablesArray to be filled with variable names
* @param $msgVarsData to be filled with variable data
*/
private function getPrestudentMsgData($prestudent_id, &$variablesArray, &$msgVarsData)
{
$msgVarsData = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudent_id);
@@ -111,7 +128,7 @@ class Messages extends VileSci_Controller
{
$variablesArray = array();
// Skip person_id and prestudent_id
for($i = 2; $i < count($variables->retval); $i++)
for ($i = 2; $i < count($variables->retval); $i++)
{
$variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i];
}
@@ -121,6 +138,12 @@ class Messages extends VileSci_Controller
array_shift($variables->retval); // Remove prestudent_id
}
/**
* gets Message Variables and their data for Person
* @param $person_id
* @param $variablesArray to be filled with variable names
* @param $msgVarsData to be filled with variable data
*/
private function getPersonMsgData($person_id, &$variablesArray, &$msgVarsData)
{
$msgVarsData = $this->MessageModel->getMsgVarsDataByPersonId($person_id);
@@ -137,7 +160,7 @@ class Messages extends VileSci_Controller
{
$variablesArray = array();
// Skip person_id
for($i = 1; $i < count($variables->retval); $i++)
for ($i = 1; $i < count($variables->retval); $i++)
{
$variablesArray['{'.str_replace(" ", "_", strtolower($variables->retval[$i])).'}'] = $variables->retval[$i];
}
@@ -148,8 +171,19 @@ class Messages extends VileSci_Controller
/**
* send
*/
public function send($sender_id)
public function send($sender_id = null)
{
if ($sender_id === null)
{
$user_person = $this->PersonModel->getByUid($this->uid);
if (isError($user_person))
{
show_error($user_person->retval);
}
$sender_id = $user_person->retval[0]->person_id;
}
$error = false;
$subject = $this->input->post('subject');
@@ -165,7 +199,7 @@ class Messages extends VileSci_Controller
// get message data of prestudents or persons
$prestudentsData = array();
if($prestudents !== null)
if ($prestudents !== null)
{
$data = $this->MessageModel->getMsgVarsDataByPrestudentId($prestudents);
//
@@ -182,7 +216,7 @@ class Messages extends VileSci_Controller
{
$parsedText = "";
$dataArray = (array)$data->retval[$i];
foreach($dataArray as $key => $val)
foreach ($dataArray as $key => $val)
{
$newKey = str_replace(" ", "_", strtolower($key));
$dataArray[$newKey] = $dataArray[$key];
@@ -191,7 +225,7 @@ class Messages extends VileSci_Controller
$parsedText = $this->messagelib->parseMessageText($body, $dataArray);
$oe_kurzbz = null;
if(hasData($prestudentsData))
if (hasData($prestudentsData))
{
for ($p = 0; $p < count($prestudentsData->retval); $p++)
{
@@ -247,7 +281,7 @@ class Messages extends VileSci_Controller
{
$person_id = $this->input->get('person_id');
}
else if ($this->input->post('person_id') !== null)
elseif ($this->input->post('person_id') !== null)
{
$person_id = $this->input->get('person_id');
}
@@ -310,7 +344,7 @@ class Messages extends VileSci_Controller
if (hasData($data))
{
$dataArray = (array)$data->retval[0];
foreach($dataArray as $key => $val)
foreach ($dataArray as $key => $val)
{
$newKey = str_replace(" ", "_", strtolower($key));
$dataArray[$newKey] = $dataArray[$key];
@@ -8,7 +8,8 @@
'fontawesome' => true,
'sbadmintemplate' => true,
'tablesorter' => true,
'customCSSs' => 'skin/tablesort_bootstrap.css'
'customCSSs' => 'skin/tablesort_bootstrap.css',
'customJSs' => array('include/js/infocenterPersonDataset.js', 'include/js/bootstrapper.js')
)
);
?>
@@ -40,11 +41,7 @@
</div>
</div>
<script>
//javascript hacks for bootstrap
$("select").addClass("form-control");
$("input[type=text]").addClass("form-control");
$("input[type=button]").addClass("btn btn-default");
$("#tableDataset").addClass('table table-bordered table-responsive table-condensed');
$("#tableDataset").addClass('table table-bordered table-responsive');
</script>
</body>
@@ -10,7 +10,8 @@ $this->load->view(
'tablesorter' => true,
'tinymce' => true,
'sbadmintemplate' => true,
'customCSSs' => array('skin/admintemplate.css', 'skin/tablesort_bootstrap.css')
'customCSSs' => array('skin/admintemplate.css', 'skin/tablesort_bootstrap.css'),
'customJSs' => 'include/js/bootstrapper.js'
)
);
?>
@@ -127,10 +128,6 @@ $this->load->view(
$(document).ready(
function ()
{
//javascript bootstrap hack - not nice!
$("select").addClass('form-control');
$("table").addClass('table-condensed');
//initialise table sorter
addTablesorter("doctable", [[2, 1], [1, 0]], ["zebra"]);
addTablesorter("nachgdoctable", [[2, 0], [1, 1]], ["zebra"]);
@@ -148,14 +145,6 @@ $this->load->view(
"dateFormat": "dd.mm.yy"
});
//add submit event to message send link
$("#sendmsglink").click(
function()
{
$("#sendmsgform").submit();
}
);
//add click events to "formal geprüft" checkboxes
<?php foreach($dokumente as $dokument): ?>
@@ -98,12 +98,18 @@
</div>
<?php if (isset($stammdaten->zugangscode)): ?>
<div class="col-lg-6 text-right">
<a
href="<?php echo base_url('addons/bewerbung/cis/registration.php?code='.html_escape($stammdaten->zugangscode)) ?>"
target='_blank'><i
class="glyphicon glyphicon-new-window"></i>&nbsp;Zugang
Bewerbung</a>
<a href="<?php echo base_url('addons/bewerbung/cis/registration.php?code='.html_escape($stammdaten->zugangscode)) ?>"
target='_blank'><i class="glyphicon glyphicon-new-window"></i>&nbsp;Zugang Bewerbung</a>
</div>
<?php endif; ?>
</div>
</div>
</div>
<script>
//add submit event to message send link
$("#sendmsglink").click(
function ()
{
$("#sendmsgform").submit();
}
);
</script>
+23 -12
View File
@@ -16,7 +16,12 @@ $this->load->view(
<body>
<style>
input[type=text] {
height: 30px;
height: 28px;
padding: 0px;
}
.msgfield label {
margin-bottom: 0px !important;
margin-top: 3px;
}
</style>
<?php
@@ -33,8 +38,9 @@ $href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER[
<form id="sendForm" method="post" action="<?php echo $href; ?>">
<div class="row">
<div class="form-group">
<label class="col-lg-1">To:</label>
<div class="col-lg-1">
<label>To:</label>
</div>
<div class="col-lg-11">
<?php
for ($i = 0; $i < count($receivers); $i++)
@@ -53,7 +59,9 @@ $href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER[
</div>
<div class="row">
<div class="form-group form-inline">
<label class="col-lg-1">Subject:</label>&nbsp;
<div class="col-lg-1 msgfield">
<label>Subject:</label>
</div>&nbsp;
<?php
$subject = '';
if (isset($message))
@@ -67,9 +75,9 @@ $href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER[
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-lg-10">
<br>
<label>Message:</label>
<?php
$body = '';
@@ -84,9 +92,9 @@ $href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER[
if (isset($variables)):
?>
<div class="col-lg-2">
<div class="form-group text-center">
<div class="form-group">
<label>Variables:</label>
<select id="variables" class="form-control" size="13" multiple="multiple">
<select id="variables" class="form-control" size="14" multiple="multiple">
<?php
foreach ($variables as $key => $val)
{
@@ -100,6 +108,7 @@ $href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER[
</div>
<?php endif; ?>
</div>
<br>
<div class="row">
<div class="col-lg-3 text-right">
<?php
@@ -118,7 +127,7 @@ $href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER[
<hr>
<div class="row">
<div class="col-lg-12">
Preview:
<label>Preview:</label>
</div>
</div>
<div class="well">
@@ -186,7 +195,8 @@ $href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER[
</div>
<script>
tinymce.init({
selector: "#bodyTextArea"
selector: "#bodyTextArea",
height: 155
});
tinymce.init({
@@ -206,7 +216,7 @@ $href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER[
if ($("#bodyTextArea"))
{
//if editor active add at cursor position, otherwise at end
if(tinymce.activeEditor.id === "bodyTextArea")
if (tinymce.activeEditor.id === "bodyTextArea")
tinymce.activeEditor.execCommand('mceInsertContent', false, $(this).children(":selected").val());
else
tinyMCE.get("bodyTextArea").setContent(tinyMCE.get("bodyTextArea").getContent() + $(this).children(":selected").val());
@@ -286,8 +296,9 @@ $href = str_replace("/system/Messages/write", "/system/Messages/send", $_SERVER[
function parseMessageText(receiver_id, text)
{
<?php
$url = str_replace("/system/Messages/write", "/system/Messages/parseMessageText", $_SERVER["REQUEST_URI"]);
$url = substr($url, 0, strrpos($url, '/'));
//replacing url (can have sender id at end)
$url = preg_replace("/\/system\/Messages\/write(\/.*)?/", "/system/Messages/parseMessageText", $_SERVER["REQUEST_URI"]);
$idtype = $personOnly === true ? 'person_id' : 'prestudent_id';
?>
+6 -10
View File
@@ -1,16 +1,6 @@
<script language="Javascript" type="text/javascript">
$(document).ready(function() {
// Checks if the table contains data (rows)
if ($('#tableDataset').find('tbody:empty').length == 0
&& $('#tableDataset').find('tr:empty').length == 0)
{
$("#tableDataset").tablesorter(
{
widgets: ["zebra", "filter"]
});
}
$("#addField").change(function() {
$("#filterForm").submit();
});
@@ -72,9 +62,15 @@
<br>
<div id="datasetActionsTop">
</div>
<div>
<?php FilterWidget::loadViewTableDataset($dataset); ?>
</div>
<div id="datasetActionsBottom">
</div>
</form>
</div>
</div>
+2 -1
View File
@@ -6,6 +6,7 @@ $(document).ready(
function()
{
$("input[type=text], select").addClass("form-control");
$("button").addClass("btn btn-default");
$("button, input[type=button]").addClass("btn btn-default");
$("table").addClass('table-condensed');
}
);
+82
View File
@@ -0,0 +1,82 @@
/**
*/
$(document).ready(
function()
{
// Checks if the table contains data (rows)
if ($('#tableDataset').find('tbody:empty').length == 0
&& $('#tableDataset').find('tr:empty').length == 0)
{
$("#tableDataset").tablesorter(
{
widgets: ["zebra", "filter"]
});
}
appendTableActionsHtml();
setTableActions();
}
);
function appendTableActionsHtml()
{
var currurl = window.location.href;
var url = currurl.replace(/infocenter\/InfoCenter(.*)/, "Messages/write");
var formHtml = '<form id="sendMsgsForm" method="post" action="'+ url +'" target="_blank"></form>';
$("#filterForm").before(formHtml);
var selectAllHtml =
'<a href="javascript:void(0)" class="selectAll">' +
'<i class="fa fa-check"></i>&nbsp;Alle</a>&nbsp;&nbsp;' +
'<a href="javascript:void(0)" class="unselectAll">' +
'<i class="fa fa-times"></i>&nbsp;Keinen</a>&nbsp;&nbsp;&nbsp;&nbsp;';
var messageHtml = 'Mit Ausgew&auml;hlten:&nbsp;&nbsp;' +
'<a href="javascript:void(0)" class="sendMsgsLink">' +
'<i class="fa fa-envelope"></i>&nbsp;Nachricht senden</a>';
var personcount = $("#tableDataset tbody tr").length;
var persontext = personcount === 1 ? "Person" : "Personen";
var countHtml = $("#tableDataset tbody tr").length +" "+persontext;
$("#datasetActionsTop, #datasetActionsBottom").append(
"<div class='pull-left'>"+selectAllHtml+"&nbsp;&nbsp;"+ messageHtml+"</div>"+
"<div class='pull-right'>"+countHtml+"</div>"+
"<div class='clearfix'></div>"
);
$("#datasetActionsBottom").append("<br><br>");
}
function setTableActions()
{
$(".sendMsgsLink").click(function() {
var idsel = $("#tableDataset input:checked[name=PersonId\\[\\]]");
if(idsel.length > 0)
{
var form = $("#sendMsgsForm");
form.find("input[type=hidden]").remove();
for (var i = 0; i < idsel.length; i++)
{
var id = $(idsel[i]).val();
form.append("<input type='hidden' name='person_id[]' value='" + id + "'>");
}
form.submit();
}
});
$(".selectAll").click(function()
{
//trs only if not filtered by tablesorter
var trs = $("#tableDataset tbody tr").not(".filtered");
trs.find("input[name=PersonId\\[\\]]").prop("checked", true);
}
);
$(".unselectAll").click(function()
{
var trs = $("#tableDataset tbody tr").not(".filtered");
trs.find("input[name=PersonId\\[\\]]").prop("checked", false);
}
);
}