Redesign manager UI, close #4
parent
d2a048e5e8
commit
21f39a326f
@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once __DIR__ . '/../required.php';
|
|
||||||
|
|
||||||
redirectifnotloggedin();
|
|
||||||
?>
|
|
||||||
|
|
||||||
<form role="form" action="action.php" method="POST">
|
|
||||||
<div class="panel panel-blue">
|
|
||||||
<div class="panel-heading">
|
|
||||||
<h3 class="panel-title">
|
|
||||||
<i class="fa fa-plus"></i> <?php lang("adding relationship"); ?>
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
<div class="panel-body">
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xs-12 col-md-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="manager"><i class="fa fa-id-card-o"></i> <?php lang("manager"); ?></label>
|
|
||||||
<input type="text" class="form-control" name="manager" id="manager" required="required" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-xs-12 col-md-6">
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="employee"><i class="fa fa-user"></i> <?php lang("employee"); ?></label>
|
|
||||||
<input type="text" class="form-control" name="employee" id="employee" required="required" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<input type="hidden" name="action" value="addmanager" />
|
|
||||||
<input type="hidden" name="source" value="managers" />
|
|
||||||
|
|
||||||
<div class="panel-footer">
|
|
||||||
<button type="submit" class="btn btn-success"><i class="fa fa-floppy-o"></i> <?php lang("save"); ?></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
@ -1,58 +0,0 @@
|
|||||||
<?php
|
|
||||||
require_once __DIR__ . "/../required.php";
|
|
||||||
|
|
||||||
redirectifnotloggedin();
|
|
||||||
|
|
||||||
if (is_empty($VARS['mid']) || is_empty($VARS['eid'])) {
|
|
||||||
header('Location: app.php?page=managers&msg=user_not_exists');
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
if (!$database->has('managers', ['managerid' => $VARS['mid']])) {
|
|
||||||
header('Location: app.php?page=managers&msg=user_not_exists');
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
if (!$database->has('managers', ['employeeid' => $VARS['eid']])) {
|
|
||||||
header('Location: app.php?page=managers&msg=user_not_exists');
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xs-12 col-sm-6 col-sm-offset-3">
|
|
||||||
<div class="panel panel-danger">
|
|
||||||
<div class="panel-heading">
|
|
||||||
<h3 class="panel-title">
|
|
||||||
<?php lang("delete relationship") ?>
|
|
||||||
</h3>
|
|
||||||
</div>
|
|
||||||
<div class="panel-body">
|
|
||||||
<div style="text-align: center;">
|
|
||||||
<p><i class="fa fa-exclamation-triangle fa-5x"></i></p>
|
|
||||||
<h4><?php lang("really delete relationship") ?></h4>
|
|
||||||
<?php
|
|
||||||
$data = $database->select('managers', [
|
|
||||||
"[>]accounts (manager)" => ['managerid' => 'uid'],
|
|
||||||
"[>]accounts (employee)" => ['employeeid' => 'uid']
|
|
||||||
], [
|
|
||||||
'manager.username (manageruser)',
|
|
||||||
'employee.username (employeeuser)',
|
|
||||||
'manager.realname (managername)',
|
|
||||||
'employee.realname (employeename)'
|
|
||||||
], ['AND' => ['managerid' => $VARS['mid'], 'employeeid' => $VARS['eid']]])[0];
|
|
||||||
?>
|
|
||||||
<div class="list-group">
|
|
||||||
<div class="list-group-item">
|
|
||||||
<i class="fa fa-fw fa-id-card-o"></i> <?php echo $data['managername']; ?> (<?php echo $data['manageruser']; ?>)
|
|
||||||
</div>
|
|
||||||
<div class="list-group-item">
|
|
||||||
<i class="fa fa-fw fa-user"></i> <?php echo $data['employeename']; ?> (<?php echo $data['employeeuser']; ?>)
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="panel-footer">
|
|
||||||
<a href="action.php?action=delmanager&source=managers&mid=<?php echo htmlspecialchars($VARS['mid']); ?>&eid=<?php echo htmlspecialchars($VARS['eid']); ?>" class="btn btn-danger"><i class="fa fa-times"></i> <?php lang('delete'); ?></a>
|
|
||||||
<a href="app.php?page=authlog" class="btn btn-primary pull-right"><i class="fa fa-arrow-left"></i> <?php lang('cancel'); ?></a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -1,47 +0,0 @@
|
|||||||
$("#manager").easyAutocomplete({
|
|
||||||
url: "action.php",
|
|
||||||
ajaxSettings: {
|
|
||||||
dataType: "json",
|
|
||||||
method: "GET",
|
|
||||||
data: {
|
|
||||||
action: "autocomplete_user"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
preparePostData: function (data) {
|
|
||||||
data.q = $("#manager").val();
|
|
||||||
return data;
|
|
||||||
},
|
|
||||||
getValue: function (element) {
|
|
||||||
return element.username;
|
|
||||||
},
|
|
||||||
template: {
|
|
||||||
type: "custom",
|
|
||||||
method: function (value, item) {
|
|
||||||
return item.name + " <i class=\"small\">" + item.username + "</i>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#employee").easyAutocomplete({
|
|
||||||
url: "action.php",
|
|
||||||
ajaxSettings: {
|
|
||||||
dataType: "json",
|
|
||||||
method: "GET",
|
|
||||||
data: {
|
|
||||||
action: "autocomplete_user"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
preparePostData: function (data) {
|
|
||||||
data.q = $("#employee").val();
|
|
||||||
return data;
|
|
||||||
},
|
|
||||||
getValue: function (element) {
|
|
||||||
return element.username;
|
|
||||||
},
|
|
||||||
template: {
|
|
||||||
type: "custom",
|
|
||||||
method: function (value, item) {
|
|
||||||
return item.name + " <i class=\"small\">" + item.username + "</i>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
@ -1,47 +1,104 @@
|
|||||||
$('#managertable').DataTable({
|
var empoptions = {
|
||||||
responsive: {
|
url: "action.php",
|
||||||
details: {
|
ajaxSettings: {
|
||||||
display: $.fn.dataTable.Responsive.display.modal({
|
dataType: "json",
|
||||||
header: function (row) {
|
method: "GET",
|
||||||
var data = row.data();
|
data: {
|
||||||
return "<i class=\"fa fa-id-card-o fa-fw\"></i> " + data[2];
|
action: "autocomplete_user"
|
||||||
}
|
|
||||||
}),
|
|
||||||
renderer: $.fn.dataTable.Responsive.renderer.tableAll({
|
|
||||||
tableClass: 'table'
|
|
||||||
}),
|
|
||||||
type: "column"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
columnDefs: [
|
preparePostData: function (data) {
|
||||||
{
|
data.q = $("#people-box").val();
|
||||||
targets: 0,
|
return data;
|
||||||
className: 'control',
|
},
|
||||||
orderable: false
|
getValue: function (element) {
|
||||||
},
|
return element.username;
|
||||||
{
|
},
|
||||||
targets: 1,
|
template: {
|
||||||
orderable: false
|
type: "custom",
|
||||||
|
method: function (value, item) {
|
||||||
|
return item.name + " <i class=\"small\">" + item.username + "</i>";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
list: {
|
||||||
|
onClickEvent: function () {
|
||||||
|
var value = $("#people-box").getSelectedItemData().username;
|
||||||
|
addPerson(value);
|
||||||
}
|
}
|
||||||
],
|
}
|
||||||
order: [
|
};
|
||||||
[2, 'asc']
|
|
||||||
],
|
$("#people-box").easyAutocomplete(empoptions);
|
||||||
serverSide: true,
|
|
||||||
ajax: {
|
var manoptions = {
|
||||||
url: "lib/getmanagetable.php",
|
url: "action.php",
|
||||||
dataFilter: function (data) {
|
ajaxSettings: {
|
||||||
var json = jQuery.parseJSON(data);
|
dataType: "json",
|
||||||
json.data = [];
|
method: "GET",
|
||||||
json.managers.forEach(function (row) {
|
data: {
|
||||||
json.data.push([
|
action: "autocomplete_user"
|
||||||
"",
|
|
||||||
row.delbtn,
|
|
||||||
row.managername + " (" + row.manageruser + ")",
|
|
||||||
row.employeename + " (" + row.employeeuser + ")"
|
|
||||||
]);
|
|
||||||
});
|
|
||||||
return JSON.stringify(json);
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
preparePostData: function (data) {
|
||||||
|
data.q = $("#manager-box").val();
|
||||||
|
return data;
|
||||||
|
},
|
||||||
|
getValue: function (element) {
|
||||||
|
return element.username;
|
||||||
|
},
|
||||||
|
template: {
|
||||||
|
type: "custom",
|
||||||
|
method: function (value, item) {
|
||||||
|
return item.name + " <i class=\"small\">" + item.username + "</i>";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
list: {
|
||||||
|
onClickEvent: function () {
|
||||||
|
var value = $("#manager-box").getSelectedItemData().username;
|
||||||
|
document.location.href = "app.php?page=managers&man=" + value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$("#manager-box").easyAutocomplete(manoptions);
|
||||||
|
|
||||||
|
$("#people-box").keyup(function (event) {
|
||||||
|
if (event.keyCode == 13) {
|
||||||
|
$("#addpersonbtn").click();
|
||||||
|
event.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$("#people-box").keydown(function (event) {
|
||||||
|
if (event.keyCode == 13) {
|
||||||
|
event.preventDefault();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#addpersonbtn").click(function () {
|
||||||
|
addPerson($("#people-box").val());
|
||||||
|
});
|
||||||
|
|
||||||
|
function addPerson(p) {
|
||||||
|
p = String.trim(p);
|
||||||
|
if (p == "") {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($("#peoplelist div[data-user=" + p + "]").length) {
|
||||||
|
$("#peoplelist .list-group-item[data-user=" + p + "]").animate({
|
||||||
|
backgroundColor: "#ff0000",
|
||||||
|
}, 500, "linear", function () {
|
||||||
|
$("#peoplelist .list-group-item[data-user=" + p + "]").animate({
|
||||||
|
backgroundColor: "#ffffff",
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
});
|
$('#peoplelist').append("<div class=\"list-group-item\" data-user=\"" + p + "\">" + p + "<div onclick=\"removePerson('" + p + "')\" class=\"btn btn-danger btn-sm pull-right\"><i class=\"fa fa-trash-o\"></i></div><input type=\"hidden\" name=\"employees[]\" value=\"" + p + "\" /></div>");
|
||||||
|
$("#people-box").val("");
|
||||||
|
}
|
||||||
|
|
||||||
|
function removePerson(p) {
|
||||||
|
$("#peoplelist div[data-user=" + p + "]").remove();
|
||||||
|
}
|
Loading…
Reference in New Issue