|
|
@@ -96,7 +96,7 @@ $(document).ready(function() {
|
|
|
}
|
|
|
|
|
|
function addSpinner(element) {
|
|
|
- element.append("<div class=\"spinner\"><div class=\"bounce1\"></div><div class=\"bounce2\"></div><div class=\"bounce3\"></div></div>");
|
|
|
+ $(element).append("<div class=\"spinner\"><div class=\"bounce1\"></div><div class=\"bounce2\"></div><div class=\"bounce3\"></div></div>");
|
|
|
}
|
|
|
|
|
|
function removeSpinner(element) {
|
|
|
@@ -395,14 +395,14 @@ $(document).ready(function() {
|
|
|
});
|
|
|
|
|
|
var calendar = $("#calendar").calendar({
|
|
|
- tmpl_path: "/tmpls/",
|
|
|
- events_source: "ajax.php?action=getCalendarEvents",
|
|
|
- first_day: 1, // Monday
|
|
|
- onAfterViewLoad: function(view) {
|
|
|
- $('.btn-group button').removeClass('active');
|
|
|
- $('button[data-calendar-view="' + view + '"]').addClass('active');
|
|
|
- }
|
|
|
- });
|
|
|
+ tmpl_path: "/tmpls/",
|
|
|
+ events_source: "ajax.php?action=getCalendarEvents",
|
|
|
+ first_day: 1, // Monday
|
|
|
+ onAfterViewLoad: function(view) {
|
|
|
+ $('.btn-group button').removeClass('active');
|
|
|
+ $('button[data-calendar-view="' + view + '"]').addClass('active');
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
$('.btn-group button[data-calendar-view]').each(function() {
|
|
|
var $this = $(this);
|
|
|
@@ -410,6 +410,277 @@ $(document).ready(function() {
|
|
|
calendar.view($this.data('calendar-view'));
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ $(document).on("click", "a[data-action='loadContact']", function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+
|
|
|
+ $("#contact-list .contact-selected").removeClass("contact-selected");
|
|
|
+ loadContact($(this).attr("data-contact-id"));
|
|
|
+ $($(this).children()[0]).addClass("contact-selected");
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ reloadContactList(true);
|
|
|
+
|
|
|
+ $(document).on("click", "a[data-action='save-contact']", function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+
|
|
|
+ var communications = [];
|
|
|
+
|
|
|
+ $("a[data-action='save-contact']").remove();
|
|
|
+ addSpinner("#save-contact-wrapper > div");
|
|
|
+
|
|
|
+ $("#contact-communication > div").each(function(e) {
|
|
|
+
|
|
|
+ switch($(this).attr("data-contact-input-type")) {
|
|
|
+ case 'tel':
|
|
|
+ communications.push({
|
|
|
+ type: 0,
|
|
|
+ id: $(this).attr("data-id"),
|
|
|
+ name: $(this).children(".col-xs-4").children("input").val(),
|
|
|
+ value: $(this).children(".col-xs-7").children("input").val()
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 'email':
|
|
|
+ communications.push({
|
|
|
+ type: 1,
|
|
|
+ id: $(this).attr("data-id"),
|
|
|
+ name: '',
|
|
|
+ value: $(this).children(".col-xs-11").children("input").val()
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ case 'web':
|
|
|
+ communications.push({
|
|
|
+ type: 2,
|
|
|
+ id: $(this).attr("data-id"),
|
|
|
+ name: '',
|
|
|
+ value: $(this).children(".col-xs-11").children("input").val()
|
|
|
+ });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ data = {
|
|
|
+ contactID: $("#contact-tab").attr("data-contact-id"),
|
|
|
+ organization: $("#contact-organization").val(),
|
|
|
+ department: $("#contact-department").val(),
|
|
|
+ title: $("#contact-title").val(),
|
|
|
+ degree: $("#contact-degree").val(),
|
|
|
+ forename: $("#contact-forename").val(),
|
|
|
+ surname: $("#contact-surname").val(),
|
|
|
+ street: $("#contact-street").val(),
|
|
|
+ streetNumber: $("#contact-street-nr").val(),
|
|
|
+ postalCode: $("#contact-postal-code").val(),
|
|
|
+ city: $("#contact-city").val(),
|
|
|
+ communications: communications
|
|
|
+ };
|
|
|
+
|
|
|
+ $.getJSON("ajax.php?action=updateContact", data, function(r) {
|
|
|
+ if(r['status'] != "OK") {
|
|
|
+ noty_error_retry();
|
|
|
+ removeSpinner($("#save-contact-wrapper > div"));
|
|
|
+ } else {
|
|
|
+ removeSpinner($("#save-contact-wrapper > div"));
|
|
|
+ $("#save-contact-wrapper > div").append("<a href=\"#\" data-action=\"save-contact\"><i class=\"fa fa-floppy-o pull-right\"></i></a>");
|
|
|
+ reloadContactList(false, function() {
|
|
|
+ $("a[data-action='loadContact'][data-contact-id='" + $("#contact-tab").attr("data-contact-id") + "'] > div").addClass("contact-selected");
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("click", "a[data-action='add-contact']", function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+
|
|
|
+ data = {
|
|
|
+ userID: $("body").attr("data-user-id")
|
|
|
+ };
|
|
|
+
|
|
|
+ $.getJSON("ajax.php?action=addContact", data, function(r) {
|
|
|
+ if(r['status'] == "OK") {
|
|
|
+ reloadContactList(false);
|
|
|
+ } else {
|
|
|
+ noty_error_retry();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("click", "a[data-action='add-phone-input']", function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+
|
|
|
+ var html = "<div class=\"row\" data-contact-input-type=\"tel\" data-id=\"-1\"> <div class=\"col-xs-4\"> <input type=\"text\" class=\"form-control\" list=\"tel_kategorie\" placeholder=\"\" /> <datalist id=\"tel_kategorie\"> <option>Geschäftlich</option> <option>Privat</option> <option>Mobil</option> </datalist> </div> <div class=\"col-xs-7\"> <input type=\"tel\" class=\"form-control\" placeholder=\"Telefon\"> </div> <div class=\"col-xs-1\"> <div style=\"padding: 15%; margin-left: -15%;\"> <a href=\"#\" data-action=\"add-phone-input\"><i class=\"fa fa-plus-circle\"></i></a><a href=\"#\" data-action=\"remove-communication\"><i class=\"fa fa-minus-circle\"></i></a> </div> </div> </div> <br>";
|
|
|
+
|
|
|
+ if($($(this).parent()).attr("id") == "communication-buttons") {
|
|
|
+ var telInputs = $("[data-contact-input-type='tel']");
|
|
|
+ if(telInputs.length > 0) {
|
|
|
+ $(html).insertAfter($(telInputs[telInputs.length - 1]).next());
|
|
|
+ } else {
|
|
|
+ $("#contact-communication").prepend(html);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $(html).insertAfter($(this).closest("[data-contact-input-type='tel']").next());
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("click", "a[data-action='add-email-input']", function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+
|
|
|
+ var html = "<div class=\"row\" data-contact-input-type=\"email\" data-id=\"-1\"> <div class=\"col-xs-11\"> <input type=\"email\" class=\"form-control\" placeholder=\"Email\"> </div> <div class=\"col-xs-1\"> <div style=\"padding: 15%; margin-left: -15%;\"> <a href=\"#\" data-action=\"add-email-input\"><i class=\"fa fa-plus-circle\"></i></a><a href=\"#\" data-action=\"remove-communication\"><i class=\"fa fa-minus-circle\"></i></a> </div> </div> </div> <br>";
|
|
|
+
|
|
|
+ if($($(this).parent()).attr("id") == "communication-buttons") {
|
|
|
+ var mailInputs = $("[data-contact-input-type='email']");
|
|
|
+ if(mailInputs.length > 0) {
|
|
|
+ $(html).insertAfter($(mailInputs[mailInputs.length - 1]).next());
|
|
|
+ } else {
|
|
|
+ var telInputs = $("[data-contact-input-type='tel']");
|
|
|
+ if(telInputs.length > 0) {
|
|
|
+ $(html).insertAfter($(telInputs[telInputs.length - 1]).next());
|
|
|
+ } else {
|
|
|
+ $("#contact-communication").prepend(html);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $(html).insertAfter($(this).closest("[data-contact-input-type='email']").next());
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("click", "a[data-action='add-web-input']", function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+
|
|
|
+ var html = "<div class=\"row\" data-contact-input-type=\"web\" data-id=\"-1\"> <div class=\"col-xs-11\"> <input type=\"url\" class=\"form-control\" placeholder=\"Webseite\"> </div> <div class=\"col-xs-1\"> <div style=\"padding: 15%; margin-left: -15%;\"> <a href=\"#\" data-action=\"add-web-input\"><i class=\"fa fa-plus-circle\"></i></a><a href=\"#\" data-action=\"remove-communication\"><i class=\"fa fa-minus-circle\"></i></a> </div> </div> </div> <br>";
|
|
|
+
|
|
|
+ if($($(this).parent()).attr("id") == "communication-buttons") {
|
|
|
+ var urlInputs = $("[data-contact-input-type='web']");
|
|
|
+ if(urlInputs.length > 0) {
|
|
|
+ $(html).insertAfter($(urlInputs[urlInputs.length - 1]).next());
|
|
|
+ } else {
|
|
|
+ $("#contact-communication").append(html);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $(html).insertAfter($(this).closest("[data-contact-input-type='web']").next());
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("click", "a[data-action='remove-contact']", function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+
|
|
|
+ data = {
|
|
|
+ contactID: $("#contact-tab").attr("data-contact-id")
|
|
|
+ };
|
|
|
+
|
|
|
+ $.getJSON("ajax.php?action=removeContact", data, function(r) {
|
|
|
+ if(r['status'] == "OK") {
|
|
|
+ reloadContactList(true);
|
|
|
+ } else {
|
|
|
+ noty_error_retry();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ $(document).on("click", "a[data-action='remove-communication']", function(e) {
|
|
|
+ e.preventDefault();
|
|
|
+
|
|
|
+ var communicationID = $(this).closest(".row").attr("data-id");
|
|
|
+
|
|
|
+ if(communicationID == -1) { // just remove from DOM, not saved yet
|
|
|
+ $(this).closest(".row").next().remove();
|
|
|
+ $(this).closest(".row").remove();
|
|
|
+ } else { // also remove from DB
|
|
|
+
|
|
|
+ var row = $(this).closest(".row");
|
|
|
+
|
|
|
+ data = {
|
|
|
+ communicationID: communicationID
|
|
|
+ };
|
|
|
+
|
|
|
+ $.getJSON("ajax.php?action=removeCommunication", data, function(r) {
|
|
|
+ if(r['status'] == "OK") {
|
|
|
+ $(row).next().remove();
|
|
|
+ $(row).remove();
|
|
|
+ } else {
|
|
|
+ noty_error_retry();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function loadContact(contactID) {
|
|
|
+ data = {
|
|
|
+ contactID: contactID
|
|
|
+ };
|
|
|
+
|
|
|
+ $.getJSON("ajax.php?action=getContactByID", data, function(r) {
|
|
|
+ if(r['status'] != "OK") {
|
|
|
+ noty_error_retry();
|
|
|
+ }
|
|
|
+
|
|
|
+ $("#contact-tab").attr("data-contact-id", r['contact'][0]['id']);
|
|
|
+ $("#contact-organization").val(r['contact'][0]['organization']);
|
|
|
+ $("#contact-department").val(r['contact'][0]['department']);
|
|
|
+ $("#contact-title").val(r['contact'][0]['title']);
|
|
|
+ $("#contact-degree").val(r['contact'][0]['degree']);
|
|
|
+ $("#contact-forename").val(r['contact'][0]['forename']);
|
|
|
+ $("#contact-surname").val(r['contact'][0]['surname']);
|
|
|
+ $("#contact-street").val(r['contact'][0]['street']);
|
|
|
+ $("#contact-street-nr").val(r['contact'][0]['streetNumber']);
|
|
|
+ $("#contact-postal-code").val(r['contact'][0]['postalCode']);
|
|
|
+ $("#contact-city").val(r['contact'][0]['city']);
|
|
|
+
|
|
|
+ $("#contact-communication").empty();
|
|
|
+
|
|
|
+ if(r['communications']) {
|
|
|
+ $.each(r['communications'], function(i) {
|
|
|
+ var html;
|
|
|
+
|
|
|
+ switch(this['type']) {
|
|
|
+ case "0":
|
|
|
+ html = "<div class=\"row\" data-contact-input-type=\"tel\" data-id=\"" + this['id'] + "\"> <div class=\"col-xs-4\"> <input type=\"text\" class=\"form-control\" list=\"tel_kategorie\" placeholder=\"\" value=\"" + this['name'] + "\" /> <datalist id=\"tel_kategorie\"> <option>Geschäftlich</option> <option>Privat</option> <option>Mobil</option> </datalist> </div> <div class=\"col-xs-7\"> <input type=\"tel\" class=\"form-control\" placeholder=\"Telefon\" value=\"" + this['value'] + "\"> </div> <div class=\"col-xs-1\"> <div style=\"padding: 15%; margin-left: -15%;\"> <a href=\"#\" data-action=\"add-phone-input\"><i class=\"fa fa-plus-circle\"></i></a><a href=\"#\" data-action=\"remove-communication\"><i class=\"fa fa-minus-circle\"></i></a> </div> </div> </div> <br>";
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ html = "<div class=\"row\" data-contact-input-type=\"email\" data-id=\"" + this['id'] + "\"> <div class=\"col-xs-11\"> <input type=\"email\" class=\"form-control\" placeholder=\"Email\" value=\"" + this['value'] + "\"> </div> <div class=\"col-xs-1\"> <div style=\"padding: 15%; margin-left: -15%;\"> <a href=\"#\" data-action=\"add-email-input\"><i class=\"fa fa-plus-circle\"></i></a><a href=\"#\" data-action=\"remove-communication\"><i class=\"fa fa-minus-circle\"></i></a> </div> </div> </div> <br>";
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ html = "<div class=\"row\" data-contact-input-type=\"web\" data-id=\"" + this['id'] + "\"> <div class=\"col-xs-11\"> <input type=\"url\" class=\"form-control\" placeholder=\"Webseite\" value=\"" + this['value'] + "\"> </div> <div class=\"col-xs-1\"> <div style=\"padding: 15%; margin-left: -15%;\"> <a href=\"#\" data-action=\"add-web-input\"><i class=\"fa fa-plus-circle\"></i></a><a href=\"#\" data-action=\"remove-communication\"><i class=\"fa fa-minus-circle\"></i></a> </div> </div> </div> <br>";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ $("#contact-communication").append(html);
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ function reloadContactList(firstRun, callBack) {
|
|
|
+
|
|
|
+ data = {
|
|
|
+ userID: $("body").attr("data-user-id")
|
|
|
+ };
|
|
|
+
|
|
|
+ $.getJSON("ajax.php?action=getContacts", data, function(r) {
|
|
|
+ if(r['status'] != "OK") {
|
|
|
+ noty_error_retry();
|
|
|
+ } else {
|
|
|
+ $("#contact-list > div").empty();
|
|
|
+ $.each(r['contacts'], function(i) {
|
|
|
+ $("#contact-list > div").append("<a href=\"#\" data-action=\"loadContact\" data-contact-id=\"" + this['id'] + "\"><div class=\"col-md-12\">" + this['forename'] + " " + this['surname'] + "</div></a>");
|
|
|
+ });
|
|
|
+
|
|
|
+ if(firstRun) {
|
|
|
+ loadContact($($("a[data-action='loadContact']")[0]).attr("data-contact-id"));
|
|
|
+ $($($("a[data-action='loadContact']")[0]).children()[0]).addClass("contact-selected");
|
|
|
+ }
|
|
|
+
|
|
|
+ callBack = typeof callBack !== 'undefined' ? callBack : function() {};
|
|
|
+ callBack();
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
function reloadDraftVars() {
|
|
|
@@ -418,7 +689,6 @@ $(document).ready(function() {
|
|
|
draftVarsContainer = $("#draft-vars");
|
|
|
|
|
|
if(draftVarsContainer.length > 0) {
|
|
|
- console.log(draftVarsContainer);
|
|
|
draftVarsContainer.remove();
|
|
|
}
|
|
|
|
|
|
@@ -443,7 +713,6 @@ $(document).ready(function() {
|
|
|
$('.editable-element-text').editable({
|
|
|
escape: false,
|
|
|
success: function(response, newValue) {
|
|
|
- console.log(response); // Debug output from ajax.php
|
|
|
if(response.status == 'error') return response.msg; //msg will be shown in editable form
|
|
|
},
|
|
|
error: function (xhr, status, error) {
|
|
|
@@ -463,7 +732,6 @@ $(document).ready(function() {
|
|
|
{value: 'pop3', text: 'POP3'}
|
|
|
],
|
|
|
success: function(response, newValue) {
|
|
|
- console.log(response); // Debug output from ajax.php
|
|
|
if(response.status == 'error') return response.msg; //msg will be shown in editable form
|
|
|
},
|
|
|
error: function (xhr, status, error) {
|
|
|
@@ -484,7 +752,6 @@ $(document).ready(function() {
|
|
|
{value: '0', text: 'Off'}
|
|
|
],
|
|
|
success: function(response, newValue) {
|
|
|
- console.log(response); // Debug output from ajax.php
|
|
|
if(response.status == 'error') return response.msg; //msg will be shown in editable form
|
|
|
},
|
|
|
error: function (xhr, status, error) {
|
|
|
@@ -505,7 +772,6 @@ $(document).ready(function() {
|
|
|
{value: '1', text: 'Off'}
|
|
|
],
|
|
|
success: function(response, newValue) {
|
|
|
- console.log(response); // Debug output from ajax.php
|
|
|
if(response.status == 'error') return response.msg; //msg will be shown in editable form
|
|
|
},
|
|
|
error: function (xhr, status, error) {
|
|
|
@@ -527,7 +793,6 @@ $(document).ready(function() {
|
|
|
type: 'POST',
|
|
|
data: {'action': 'addDefaultMailaccount', 'user-id': uID},
|
|
|
success: function (result) {
|
|
|
- console.log(result);
|
|
|
location.reload();
|
|
|
}
|
|
|
});
|
|
|
@@ -548,7 +813,6 @@ $(document).ready(function() {
|
|
|
//defaultValue: '0',
|
|
|
source: result,
|
|
|
success: function(response, newValue) {
|
|
|
- console.log(response); // Debug output from ajax.php
|
|
|
if(response.status == 'error') return response.msg; //msg will be shown in editable form
|
|
|
},
|
|
|
error: function (xhr, status, error) {
|
|
|
@@ -566,7 +830,6 @@ $(document).ready(function() {
|
|
|
$('.editable-element-text').editable({
|
|
|
escape: false,
|
|
|
success: function(response, newValue) {
|
|
|
- console.log(response); // Debug output from ajax.php
|
|
|
if(response.status == 'error') return response.msg; //msg will be shown in editable form
|
|
|
},
|
|
|
error: function (xhr, status, error) {
|
|
|
@@ -589,7 +852,6 @@ $(document).ready(function() {
|
|
|
type: 'POST',
|
|
|
data: {'action': 'removeMailaccount', 'id': id},
|
|
|
success: function (result) {
|
|
|
- console.log(result);
|
|
|
location.reload();
|
|
|
}
|
|
|
});
|
|
|
@@ -603,7 +865,6 @@ $(document).ready(function() {
|
|
|
type: 'POST',
|
|
|
data: {'action': 'removeMailboxFolder', 'id': id},
|
|
|
success: function (result) {
|
|
|
- console.log(result);
|
|
|
location.reload();
|
|
|
}
|
|
|
});
|
|
|
@@ -618,11 +879,10 @@ $(document).ready(function() {
|
|
|
type: 'POST',
|
|
|
data: {'action': 'addDefaultMailfolder', 'user-id': uID, 'label-id': lID},
|
|
|
success: function (result) {
|
|
|
- console.log(result);
|
|
|
location.reload();
|
|
|
},
|
|
|
error: function(result) {
|
|
|
- console.log(result);
|
|
|
+ noty_error_retry();
|
|
|
}
|
|
|
});
|
|
|
});
|