You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
260 lines
11 KiB
260 lines
11 KiB
var event_types = (function ($, window, jQuery) {
|
|
var _vars_ = {};
|
|
|
|
return {
|
|
"notify": function(mtype, message){
|
|
var icon = "glyphicon glyphicon-info-sign",
|
|
type = "info";
|
|
if(mtype == "success"){
|
|
icon = "glyphicon glyphicon-ok-sign";
|
|
type = "success";
|
|
}else if(mtype == "warning"){
|
|
icon = "glyphicon glyphicon-warning-sign";
|
|
type = "warning";
|
|
}else if(mtype == "error" || mtype == "session_timeout"){
|
|
icon = "glyphicon glyphicon-exclamation-sign";
|
|
type = "danger";
|
|
}
|
|
$.notifyDefaults({
|
|
type: type,
|
|
allow_dismiss: true,
|
|
z_index: 2031
|
|
});
|
|
$.notify({
|
|
message: '<span class="system-message">'+message+'</span>',
|
|
icon: icon
|
|
});
|
|
}
|
|
|
|
};//end of return
|
|
// Pass in jQuery.
|
|
})(jQuery, this);
|
|
|
|
|
|
$(function() {
|
|
// delete
|
|
$('#natureofbusinesstable' ).on('click', '.delete-naturebtn', function() {
|
|
var qid = this.id; // button ID
|
|
var trid = $(this).closest('tr').attr('id'); // table row ID
|
|
// console.log(qid);
|
|
$.ajax({
|
|
url : app.get_vars().baseurl+"contact/get_nature",
|
|
type : "POST",
|
|
data : {
|
|
nature : qid,
|
|
},
|
|
success : function(result){
|
|
// alert(result.question);
|
|
$('.question-txt').html("<p><b>Nature de l'entreprise : </b>"+result.nature_of_business+"</p>");
|
|
|
|
bootbox.dialog({
|
|
"title": "Confirmer la suppression de la question FAQ",
|
|
"className" : "my-modal-with-sm event-normal-registration-modal table",
|
|
"message": $("#delete-question"),
|
|
"cache":false,
|
|
"show": false, /* We will show it manually later */
|
|
"buttons" : [
|
|
{
|
|
"label": "RETOUR",
|
|
"className": "btn btn-default",
|
|
"callback": function () {
|
|
$('#delete-question').empty();
|
|
window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"contact_email"},500);
|
|
}
|
|
},
|
|
{
|
|
"label": "CONFIRMER",
|
|
"className": "btn btn-primary",
|
|
"callback": function () {
|
|
$.ajax({
|
|
url : app.get_vars().baseurl+"contact/delete_nature",
|
|
type : "POST",
|
|
data : {
|
|
nature : qid,
|
|
},
|
|
success : function(result){
|
|
// console.log(result);
|
|
// // alert(result.question);
|
|
// if(result==true){
|
|
event_types.notify("success", "Suppression réussie");
|
|
// window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"contact_email"},2000); }
|
|
}
|
|
});
|
|
}
|
|
}
|
|
]
|
|
}).on('shown.bs.modal', function() {
|
|
|
|
}).on('hide.bs.modal', function() {
|
|
$('#delete-question').empty();
|
|
window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"contact_email"},2000);
|
|
}).modal('show');
|
|
}
|
|
});
|
|
});
|
|
|
|
// edit
|
|
$('#natureofbusinesstable').on('click', '.edit-naturebtn',function() {
|
|
var nid = this.id; // button ID
|
|
var trid = $(this).closest('tr').attr('id'); // table row ID
|
|
console.log(nid);
|
|
$.ajax({
|
|
url : app.get_vars().baseurl+"contact/get_nature",
|
|
type : "POST",
|
|
data : {
|
|
nature : nid,
|
|
},
|
|
success : function(result){
|
|
// $('#edit-question-subject').val(result.subject_id);
|
|
$('#editnature').val(result.nature_of_business);
|
|
// $('#edit-answer').val(result.reply);
|
|
bootbox.dialog({
|
|
"title": "Modifier la nature de l'entreprise",
|
|
"className" : "my-modal-with-sm event-normal-registration-modal table",
|
|
"message": $("#edit-nature"),
|
|
"cache":false,
|
|
"show": false, /* We will show it manually later */
|
|
"buttons" : [
|
|
{
|
|
"label": "RETOUR",
|
|
"className": "btn btn-default",
|
|
"callback": function () {
|
|
$('#edit-nature').empty();
|
|
window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"contact_email"},500);
|
|
}
|
|
},
|
|
{
|
|
"label": "MODIFIER",
|
|
"className": "btn btn-primary",
|
|
"callback": function () {
|
|
var q;
|
|
q=$('#editnature').val();
|
|
|
|
if($.trim( q )==''){
|
|
event_types.notify("error", "Please complete the required fields.");
|
|
//window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"contact_email"},1000);
|
|
}else{
|
|
$.ajax({
|
|
url : app.get_vars().baseurl+"contact/edit_nature",
|
|
type : "POST",
|
|
data : {
|
|
nid:nid,
|
|
nature : q
|
|
},
|
|
success : function(result){
|
|
console.log(result);
|
|
if(result==true){
|
|
event_types.notify("success", "Mise à jour réussie");
|
|
// window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"contact_email"},2000);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
]
|
|
}).on('shown.bs.modal', function() {
|
|
$('#edit-question').show();
|
|
}).on('hide.bs.modal', function() {
|
|
window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"contact_email"},3000);
|
|
}).modal('show');
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// Onload
|
|
$('#edit_contact_email_btn').hide();
|
|
$('#contact_email_text').prop("disabled", true);
|
|
$('#nature_of_business_text').hide();
|
|
$('#save_nature_of_business').hide();
|
|
$('#hide_add_nature_of_business').hide();
|
|
$('#add_nature_of_business').show();
|
|
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "contact/email",
|
|
type: "POST",
|
|
data: {},
|
|
success: function (result) {
|
|
$('#contact_email_text').val(result);
|
|
}
|
|
});
|
|
|
|
$(document).on("click", '#edit_contact_email_btn', function(){
|
|
var contactemail = $('#contact_email_text').val();
|
|
|
|
if( $.trim( contactemail ) !="" )
|
|
{
|
|
var contactemail = $('#contact_email_text').val();
|
|
|
|
if( $.trim( contactemail ) != "" ){
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "contact/update_email",
|
|
type: "POST",
|
|
data: {
|
|
contact_email_info: contactemail
|
|
},
|
|
success: function (result) {
|
|
if(result == 'true'){
|
|
app._notify('success', 'Mise à jour réussie');
|
|
}
|
|
}
|
|
});
|
|
}else{
|
|
app._notify('warning', 'You need to provide a valid email address');
|
|
}
|
|
|
|
$('#contact_email_text').prop("disabled", true);
|
|
$('#contact_email_btn').show();
|
|
$('#edit_contact_email_btn').hide();
|
|
}else{
|
|
app._notify('warning', 'You need to provide a valid email address');
|
|
}
|
|
});
|
|
|
|
$(document).on("click", '#save_nature_of_business', function(){
|
|
var nature_of_business = $('#nature_of_business_text').val();
|
|
var contactemail = $('#contact_email_text').val();
|
|
|
|
if( $.trim( contactemail ) != "" && $.trim( nature_of_business ) != "" ){
|
|
$.ajax({
|
|
url: app.get_vars().baseurl + "contact/add_nature_of_business",
|
|
type: "POST",
|
|
data: {
|
|
nature_of_business:nature_of_business
|
|
},
|
|
success: function (result) {
|
|
if(result == 'true'){
|
|
app._notify('success', 'Nature Of Business Added Successfully');
|
|
window.setTimeout(function(){window.location.href = app.get_vars().baseurl+"contact_email"},2000);
|
|
}
|
|
}
|
|
});
|
|
}else if( $.trim( nature_of_business ) == "" ){
|
|
app._notify('warning', 'Nature of buisness is required!');
|
|
}else{
|
|
app._notify('warning', 'Nature of buisness requires email address!');
|
|
}
|
|
});
|
|
$(document).on("click", '#hide_add_nature_of_business', function(){
|
|
$('#nature_of_business_text').hide();
|
|
$('#save_nature_of_business').hide();
|
|
$('#hide_add_nature_of_business').hide();
|
|
$('#add_nature_of_business').show();
|
|
});
|
|
$(document).on("click", '#add_nature_of_business', function(){
|
|
$('#nature_of_business_text').show();
|
|
$('#save_nature_of_business').show();
|
|
$('#hide_add_nature_of_business').show();
|
|
$('#add_nature_of_business').hide();
|
|
});
|
|
$(document).on("click", '#contact_email_btn', function(){
|
|
$('#contact_email_btn').hide();
|
|
$('#edit_contact_email_btn').show();
|
|
$('#contact_email_text').prop("disabled", false);
|
|
});
|
|
|
|
});
|