Rev 16542 | Rev 16822 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
$acl = $this->viewModel()->getRoot()->getVariable('acl');
$currentUser = $this->currentUserHelper();
$roleName = $currentUser->getUserTypeId();
$routeAdd = $this->url('discovery-contacts/add');
$routeDatatable = $this->url('discovery-contacts');
$routeUpload = $this->url('discovery-contacts/upload');
$allowInteractionAdd = $acl->isAllowed($roleName, 'discovery-contacts/interactions/add') ? 1 : 0;
$allowAdd = $acl->isAllowed($roleName, 'discovery-contacts/add') ? 1 : 0;
$allowEdit = $acl->isAllowed($roleName, 'discovery-contacts/edit') ? 1 : 0;
$allowDelete = $acl->isAllowed($roleName, 'discovery-contacts/delete',) ? 1 : 0;
$allowView = $acl->isAllowed($roleName, 'discovery-contacts/view',) ? 1 : 0;
$allowUpload = $acl->isAllowed($roleName, 'discovery-contacts/upload') ? 1 : 0;
$this->headLink()->appendStylesheet($this->basePath('plugins/nprogress/nprogress.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/nprogress/nprogress.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/jquery.validate.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/additional-methods.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/jquery-validation/localization/messages_es.js'));
$this->headLink()->appendStylesheet($this->basePath('plugins/datatables-bs4/css/dataTables.bootstrap4.min.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/datatables/jquery.dataTables.min.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/datatables-bs4/js/dataTables.bootstrap4.min.js'));
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap4-toggle/css/bootstrap4-toggle.min.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap4-toggle/js/bootstrap4-toggle.min.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-confirmation/dist/bootstrap-confirmation.js'));
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-checkbox/awesome-bootstrap-checkbox.css'));
$this->headLink()->appendStylesheet($this->basePath('plugins/intl-tel-input/build/css/intlTelInput.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/intl-tel-input/build/js/intlTelInput-jquery.js'));
$utilsScript = $this->basePath('plugins/intl-tel-input/build/js/utils.js');
$this->inlineScript()->appendFile($this->basePath('plugins/jsrender/jsrender.min.js'));
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/css/fileinput.min.css'));
$this->headLink()->appendStylesheet($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fas/theme.css'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/piexif.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/plugins/sortable.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/fileinput.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/js/locales/es.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/fa/theme.js'));
$this->inlineScript()->appendFile($this->basePath('plugins/bootstrap-fileinput/themes/explorer-fa/theme.js'));
$this->headStyle()->captureStart();
echo <<<CSS
#table-wrapper {
width: 100%;
height: 300px;
overflow: auto;
}
#table-wrapper table {
border-collapse: separate;
border-spacing: 0;
}
#table-wrapper table thead {
flex: 0 0 auto;
}
#table-wrapper table thead th,
#table-wrapper table tbody td {
}
/*
style=""
#gridTableUploadContacts {
display: flex;
flex-flow: column;
width: 100%;
}
#gridTableUploadContacts thead {
flex: 0 0 auto;
}
#gridTableUploadContacts tbody {
flex: 1 1 auto;
display: block;
overflow-y: auto;
overflow-x: auto;
}
#gridTableUploadContacts tr {
width: 100%;
display: table;
table-layout: fixed;
*/
}
CSS;
$this->headStyle()->captureEnd();
$this->inlineScript()->captureStart();
echo <<<JS
jQuery( document ).ready(function( $ ) {
$.validator.addMethod("isIntlPhoneNumber", function(value, element) {
if(!value || value.length == '') {
return true;
} else {
return $(element).intlTelInput('isValidNumber');
}
}, 'ERROR_INTERNATIONAL_PHONE_FORMAT_IS_INVALID');
$.validator.setDefaults({
debug: true,
highlight: function(element) {
$(element).addClass('is-invalid');
},
unhighlight: function(element) {
$(element).removeClass('is-invalid');
},
errorElement: 'span',
errorClass: 'error invalid-feedback',
errorPlacement: function(error, element) {
if(element.parent('.form-group').length) {
error.insertAfter(element);
} else if(element.parent('.toggle').length) {
error.insertAfter(element.parent().parent());
} else {
error.insertAfter(element.parent());
}
}
});
$.fn.showFormErrorValidator = function(fieldname, errors) {
var field = $(fieldname);
if(field) {
$(field).addClass('is-invalid');
var error = $('<span id="' + fieldname +'-error" class="error invalid-feedback">' + errors + '</div>');
if(field.parent('.form-group').length) {
error.insertAfter(field);
} else if(field.parent('.toggle').length) {
error.insertAfter(field.parent().parent());
} else {
error.insertAfter(field.parent());
}
}
};
var allowEdit = $allowEdit;
var allowDelete = $allowDelete;
var allowView = $allowView;
var linkInteractions = '';
var linkInteractionsAdd = '';
var linkLogs = '';
var pageInteractions = 0;
var pageLogs = 0;
$.fn.loadLogs = function() {
NProgress.start();
var action = $(this).data('href');
$.ajax({
'dataType' : 'json',
'method' : 'get',
'url' : linkLogs,
'data' : {
'page' : pageLogs
}
}).done(function(response) {
if(response['success']) {
pagination = {
has_previous_page : response['data']['current']['page'] > 1,
has_next_page : response['data']['current']['page'] < response['data']['total']['page'],
}
if(pageLogs > response['data']['total']['page']) {
pageLogs = response['data']['total']['page'];
}
$('#discovery-contacts-pagination-logs').empty();
$('#discovery-contacts-pagination-logs').append($('#logPaginationTemplate').render(pagination));
$('#grid-discovery-contacts-tabs-logs').empty();
$('#grid-discovery-contacts-tabs-logs').append(
$('#logTemplate').render(response['data']['current'])
);
} else {
$.fn.showError(response['data']);
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
};
$.fn.loadInteractions = function() {
NProgress.start();
$.ajax({
'dataType' : 'json',
'method' : 'get',
'url' : linkInteractions,
'data' : {
'page' : pageInteractions
}
}).done(function(response) {
if(response['success']) {
pagination = {
has_previous_page : response['data']['current']['page'] > 1,
has_next_page : response['data']['current']['page'] < response['data']['total']['page'],
}
if(pageInteractions > response['data']['total']['page']) {
pageInteractions = response['data']['total']['page'];
}
$('#discovery-contacts-pagination-interactions').empty();
$('#discovery-contacts-pagination-interactions').append($('#interactionPaginationTemplate').render(pagination));
$('#grid-discovery-contacts-tabs-interactions').empty();
$('#grid-discovery-contacts-tabs-interactions').append(
$('#interactionTemplate').render(response['data']['current'])
);
} else {
$.fn.showError(response['data']);
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
};
var gridTable = $('#gridTable').dataTable( {
'processing': true,
'serverSide': true,
'searching': true,
'order': [[ 0, 'asc' ]],
'ordering': true,
'ordenable' : true,
'responsive': true,
'select' : false,
'paging': true,
'pagingType': 'simple_numbers',
'ajax': {
'url' : '$routeDatatable',
'type' : 'get',
'beforeSend': function (request) {
NProgress.start();
},
'dataFilter': function(response) {
var response = jQuery.parseJSON( response );
var json = {};
json.recordsTotal = 0;
json.recordsFiltered = 0;
json.data = [];
if(response.success) {
json.recordsTotal = response.data.total;
json.recordsFiltered = response.data.total;
json.data = response.data.items;
} else {
$.fn.showError(response.data)
}
return JSON.stringify( json );
}
},
'language' : {
'sProcessing': 'LABEL_DATATABLE_SPROCESSING',
'sLengthMenu': 'LABEL_DATATABLE_SLENGTHMENU',
'sZeroRecords': 'LABEL_DATATABLE_SZERORECORDS',
'sEmptyTable': 'LABEL_DATATABLE_SEMPTYTABLE',
'sInfo': 'LABEL_DATATABLE_SINFO',
'sInfoEmpty': 'LABEL_DATATABLE_SINFOEMPTY',
'sInfoFiltered': 'LABEL_DATATABLE_SINFOFILTERED',
'sInfoPostFix': '',
'sSearch': 'LABEL_DATATABLE_SSEARCH',
'sUrl': '',
'sInfoThousands': ',',
'sLoadingRecords': 'LABEL_DATATABLE_SLOADINGRECORDS',
'oPaginate': {
'sFirst': 'LABEL_DATATABLE_SFIRST',
'sLast': 'LABEL_DATATABLE_SLAST',
'sNext': 'LABEL_DATATABLE_SNEXT',
'sPrevious': 'LABEL_DATATABLE_SPREVIOUS'
},
'oAria': {
'sSortAscending': ': LABEL_DATATABLE_SSORTASCENDING',
'sSortDescending': ':LABEL_DATATABLE_SSORTDESCENDING'
},
},
'drawCallback': function( settings ) {
NProgress.done();
$('button.btn-delete').confirmation({
rootSelector: 'button.btn-delete',
title : 'LABEL_ARE_YOU_SURE',
singleton : true,
btnOkLabel: 'LABEL_YES',
btnCancelLabel: 'LABEL_NO',
onConfirm: function(value) {
action = $(this).data('href');
NProgress.start();
$.ajax({
'dataType' : 'json',
'accept' : 'application/json',
'method' : 'post',
'url' : action,
}).done(function(response) {
if(response['success']) {
$.fn.showSuccess(response['data']);
gridTable.api().ajax.reload(null, false);
} else {
$.fn.showError(response['data']);
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
},
});
},
'aoColumns': [
{ 'mDataProp': 'first_name' },
{ 'mDataProp': 'last_name' },
{ 'mDataProp': 'corporate_email' },
{ 'mDataProp': 'company' },
{ 'mDataProp': 'country' },
{ 'mDataProp': 'sector' },
{ 'mDataProp': 'scholarship' },
{ 'mDataProp': 'actions' },
],
'columnDefs': [
{
'targets': -1,
'orderable': false,
'render' : function ( data, type, row ) {
s = '';
if(allowEdit && data['link_edit']) {
s = s + '<button class="btn btn-primary btn-edit" data-href="' + data['link_edit']+ '" data-toggle="tooltip" title="LABEL_EDIT"><i class="fa fa-pencil"></i> LABEL_EDIT </button> ';
}
if(allowDelete && data['link_delete']) {
s = s + '<button class="btn btn-danger btn-delete" data-href="' + data['link_delete']+ '" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button> ';
}
if(allowView && data['link_view']) {
s = s + '<button class="btn btn-default btn-view" data-href="' + data['link_view']+ '" data-toggle="tooltip" title="LABEL_VIEW"><i class="fa fa-external-link"></i> LABEL_VIEW </button> ';
}
return s;
}
}
],
});
var validator = $('#form').validate({
debug: true,
onclick: false,
onkeyup: false,
ignore: [],
rules: {
'first_name': {
required: false,
maxlength: 128,
},
'last_name': {
required: false,
maxlength: 128,
},
'corporate_email': {
required: true,
maxlength: 250,
email: true,
},
'company': {
required: true,
maxlength: 128,
},
'position': {
required: true,
maxlength: 128,
},
'country': {
required: true,
maxlength: 128,
},
'state': {
required: false,
maxlength: 128,
},
'city': {
required: false,
maxlength: 128,
},
'personal_email': {
required: false,
maxlength: 128,
email: true,
},
'phone': {
required: false,
maxlength: 25,
isIntlPhoneNumber: true,
},
'phone_extension': {
required: false,
maxlength: 5,
},
'celular': {
required: false,
maxlength: 25,
isIntlPhoneNumber: true,
},
'whatsapp': {
required: false,
maxlength: 25,
isIntlPhoneNumber: true,
},
'linkedin': {
required: false,
maxlength: 250,
url: true,
},
'sector': {
required: false,
maxlength: 250,
},
'scholarship': {
required: false,
},
},
submitHandler: function(form)
{
data = {
first_name : $('#form #first_name').val(),
last_name : $('#form #last_name').val(),
corporate_email : $('#form #corporate_email').val(),
company : $('#form #company').val(),
position : $('#form #position').val(),
country : $('#form #country').val(),
state : $('#form #state').val(),
city : $('#form #city').val(),
personal_email : $('#form #personal_email').val(),
phone : $('#form #phone').intlTelInput('getNumber'),
phone_extension : $('#form #phone_extension').val(),
celular : $('#form #celular').intlTelInput('getNumber'),
whatsapp : $('#form #whatsapp').intlTelInput('getNumber'),
linkedin : $('#form #linkedin').val(),
sector : $('#form #sector').val(),
scholarship: $('#form #scholarship').val(),
};
$('#modal .btn-primary').attr('disabled', true)
$.ajax({
'dataType' : 'json',
'accept' : 'application/json',
'method' : 'post',
'url' : $('#form').attr('action'),
'data' : data
}).done(function(response) {
NProgress.start();
if(response['success']) {
$.fn.showSuccess(response['data']);
$('#form-row').hide();
$('#listing-row').show();
gridTable.api().ajax.reload(null, false);
} else {
validator.resetForm();
if(jQuery.type(response['data']) == 'string') {
$.fn.showError(response['data']);
} else {
$.each(response['data'], function( fieldname, errors ) {
$.fn.showFormErrorValidator('#form #' + fieldname, errors);
});
}
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
$('#modal .btn-primary').removeAttr('disabled')
});
return false;
},
invalidHandler: function(form, validator) {
}
});
var validatorInteraction = $('#form-interaction').validate({
debug: true,
onclick: false,
onkeyup: false,
ignore: [],
rules: {
'notes': {
required: true,
},
'interaction_type_id': {
required: true,
},
},
submitHandler: function(form)
{
$.ajax({
'dataType' : 'json',
'accept' : 'application/json',
'method' : 'post',
'url' : $('#form-interaction').attr('action'),
'data' : $('#form-interaction').serialize()
}).done(function(response) {
NProgress.start();
if(response['success']) {
$.fn.showSuccess(response['data']);
$('#modal-interaction').modal('hide');
$.fn.loadInteractions();
$.fn.loadLogs();
} else {
validator.resetForm();
if(jQuery.type(response['data']) == 'string') {
$.fn.showError(response['data']);
} else {
$.each(response['data'], function( fieldname, errors ) {
$.fn.showFormErrorValidator('#form-interaction #' + fieldname, errors);
});
}
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
return false;
},
invalidHandler: function(form, validator) {
}
});
$('body').on('click', 'button.btn-add-interaction', function(e) {
e.preventDefault();
$('#form-interaction').attr('action', linkInteractionsAdd);
$('#form-interaction #notes').val('');
$('#form-interaction #status').val('');
validator.resetForm();
$('#modal-interaction').modal('show');
});
$('body').on('click', 'button.btn-cancel-interaction', function(e) {
e.preventDefault();
$('#modal-interaction').modal('hide');
});
$('body').on('click', 'button.btn-delete-interaction', function(e) {
e.preventDefault();
var action = $(this).data('href');
NProgress.start();
$.ajax({
'dataType' : 'json',
'accept' : 'application/json',
'method' : 'post',
'url' : action,
}).done(function(response) {
if(response['success']) {
$.fn.showSuccess(response['data']);
$.fn.loadLogs();
$.fn.loadInteractions();
} else {
$.fn.showError(response['data']);
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
});
$('body').on('click', 'button.btn-add', function(e) {
e.preventDefault();
$('span[id="form-title"]').html('LABEL_ADD');
$('#form').attr('action', '$routeAdd');
$('#form #first_name').val('');
$('#form #last_name').val('');
$('#form #corporate_email').val('');
$('#form #company').val('');
$('#form #position').val('');
$('#form #country').val('');
$('#form #state').val('');
$('#form #city').val('');
$('#form #personal_email').val('');
$('#form #phone').intlTelInput('setNumber', '');
$('#form #phone_extension').val('');
$('#form #celular').intlTelInput('setNumber', '');
$('#form #whatsapp').intlTelInput('setNumber', '');
$('#form #linkedin').val('');
$('#form #sector').val('');
$('#form #scholarship').val('');
validator.resetForm();
$('#listing-row').hide();
$('#form-row').show();
});
$('body').on('click', 'button.btn-edit', function(e) {
e.preventDefault();
NProgress.start();
var action = $(this).data('href');
$.ajax({
'dataType' : 'json',
'method' : 'get',
'url' : action,
}).done(function(response) {
if(response['success']) {
$('span[id="form-title"]').html('LABEL_EDIT');
$('#form').attr('action', action);
$('#form #first_name').val(response['data']['first_name']);
$('#form #last_name').val(response['data']['last_name']);
$('#form #corporate_email').val(response['data']['corporate_email']);
$('#form #company').val(response['data']['company']);
$('#form #position').val(response['data']['position']);
$('#form #country').val(response['data']['country']);
$('#form #state').val(response['data']['state']);
$('#form #city').val(response['data']['city']);
$('#form #personal_email').val(response['data']['personal_email']);
$('#form #phone').intlTelInput('setNumber', response['data']['phone']);
$('#form #phone_extension').val(response['data']['phone_extension']);
$('#form #celular').intlTelInput('setNumber', response['data']['celular']);
$('#form #whatsapp').intlTelInput('setNumber', response['data']['whatsapp']);
$('#form #linkedin').val(response['data']['linkedin']);
$('#form #sector').val(response['data']['sector']);
$('#form #scholarship').val(response['data']['scholarship']);
validator.resetForm();
$('#listing-row').hide();
$('#form-row').show();
} else {
$.fn.showError(response['data']);
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
});
$('body').on('click', 'a.class-btn-log-previous', function(e) {
e.preventDefault();
if( pageLogs > 1) {
pageLogs = pageLogs - 1;
$.fn.loadLogs();
}
});
$('body').on('click', 'a.class-btn-log-next', function(e) {
e.preventDefault();
pageLogs = pageLogs + 1;
$.fn.loadLogs();
});
$('body').on('click', 'a.class-btn-interaction-previous', function(e) {
e.preventDefault();
if( pageInteractions > 1) {
pageInteractions = v - 1;
$.fn.loadInteractions();
}
});
$('body').on('click', 'a.class-btn-interaction-next', function(e) {
e.preventDefault();
pageInteractions = pageInteractions + 1;
$.fn.loadInteractions();
});
$('body').on('click', 'button.btn-view', function(e) {
e.preventDefault();
NProgress.start();
var action = $(this).data('href');
$.ajax({
'dataType' : 'json',
'method' : 'get',
'url' : action,
}).done(function(response) {
if(response['success']) {
$('#interactions-first_name').val(response['data']['first_name']);
$('#interactions-last_name').val(response['data']['last_name']);
$('#interactions-corporate_email').val(response['data']['corporate_email']);
$('#interactions-company').val(response['data']['company']);
$('#interactions-position').val(response['data']['position']);
$('#interactions-country').val(response['data']['country']);
$('#interactions-state').val(response['data']['state']);
$('#interactions-city').val(response['data']['city']);
$('#interactions-personal_email').val(response['data']['personal_email']);
$('#interactions-phone').val(response['data']['phone']);
$('#interactions-phone_extension').val(response['data']['phone_extension']);
$('#interactions-celular').val(response['data']['celular']);
$('#interactions-whatsapp').val(response['data']['whatsapp']);
$('#interactions-linkedin').val(response['data']['linkedin']);
$('#interactions-sector').val(response['data']['sector']);
$('#interactions-scholarship').val(response['data']['scholarship']);
linkInteractions = response['data']['link_interactions'];
linkInteractionsAdd = response['data']['link_interactions_add'];
linkLogs = response['data']['link_logs'];
pageInteractions = 0;
pageLogs = 0;
$.fn.loadLogs();
$.fn.loadInteractions();
$('#listing-row').hide();
$('#interactions-row').show();
} else {
$.fn.showError(response['data']);
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
});
$('body').on('click', 'button.btn-refresh', function(e) {
e.preventDefault();
gridTable.api().ajax.reload(null, false);
});
$('body').on('click', 'button.btn-cancel', function(e) {
e.preventDefault();
$('#form-row').hide();
$('#listing-row').show();
});
$('body').on('click', 'button.btn-close-view', function(e) {
e.preventDefault();
$('#interactions-row').hide();
$('#listing-row').show();
});
$('#form #phone').intlTelInput({
utilsScript: "$utilsScript",
formatOnDisplay: true,
separateDialCode: false,
});
$('#form #celular').intlTelInput({
utilsScript: "$utilsScript",
formatOnDisplay: true,
separateDialCode: false,
});
$('#form #whatsapp').intlTelInput({
utilsScript: "$utilsScript",
formatOnDisplay: true,
separateDialCode: false,
});
var validatorContactUpload = $('#form-contact-upload').validate({
debug: true,
onclick: false,
onkeyup: false,
onfocusout: false,
ignore: [],
rules: {
'file' : {
required: true,
extension: 'xls|xlsx',
accept: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel'
},
},
submitHandler: function(form)
{
NProgress.start();
var formdata = false;
if (window.FormData){
formdata = new FormData(form);
}
formdata.append('step','validation');
$.ajax({
'dataType' : 'json',
'accept' : 'application/json',
'method' : 'post',
'url' : '$routeUpload',
'data' : formdata,
'processData': false,
'contentType': false,
}).done(function(response) {
if(response['success']) {
$('#table-upload-contacts-key').val(response['data']['key']);
$('#table-upload-contacts-topic').val(response['data']['topic']);
$('#table-upload-contacts-capsule').val(response['data']['capsule']);
$('#gridTableUploadContacts tbody').html($('#uploadContactTemplate').render(response['data']))
$('#modalContactUpload').modal('hide');
$('#modalContactUploadTable').modal('show');
} else {
validatorContactUpload.resetForm();
if(jQuery.type(response['data']) == 'string') {
$.fn.showError(response['data']);
} else {
$.each(response['data'], function( fieldname, errors ) {
$.fn.showFormErrorValidator('#form-contact-upload #' + fieldname, errors);
});
}
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
return false;
},
invalidHandler: function(form, validator) {
}
});
$('body').on('click', 'button.btn-upload', function(e) {
e.preventDefault();
$('#form-contact-upload #file').fileinput('reset');
$('#form-contact-upload #file').val('');
$('#modalContactUpload').modal('show');
});
$('#form-contact-upload #file').fileinput({
theme: 'fa',
language: 'es',
showUpload: false,
dropZoneEnabled: false,
maxFileCount: 1,
allowedFileExtensions: ['xls', 'xlsx'],
});
$('body').on('click', 'button.btn-upload', function(e) {
e.preventDefault();
$('#form-contact-upload #file').fileinput('reset');
$('#form-contact-upload #file').val('');
$('#modalContactUpload').modal('show');
});
$('body').on('click', 'button.btn-upload-contacts-step2', function(e) {
e.preventDefault();
NProgress.start();
$.ajax({
'dataType' : 'json',
'accept' : 'application/json',
'method' : 'post',
'url' : '$routeUpload',
'data' : {
'step' : 'process',
'key' : $('#table-upload-contacts-key').val(),
}
}).done(function(response) {
if(response['success']) {
var s = response['data']['new_contacts'] + ' LABEL_NEW_CONTACTS <br>' +
response['data']['error_contacts'] + ' LABEL_ERROR_CONTACTS <br>' +
response['data']['duplicate_contacts'] + ' LABEL_DUPLICATE_CONTACTS <br>';
$.fn.showSuccess(s);
gridTable.api().ajax.reload(null, false);
$('#modalContactUploadTable').modal('hide');
} else {
$.fn.showError(response['data']);
}
}).fail(function( jqXHR, textStatus, errorThrown) {
$.fn.showError(textStatus);
}).always(function() {
NProgress.done();
});
return false;
});
});
JS;
$this->inlineScript()->captureEnd();
?>
<section class="content" id="listing-row">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h2>LABEL_CONTACTS</h2>
</div>
<div class="card-body">
<table id="gridTable" class="table table-striped table-hover">
<thead>
<tr>
<th>LABEL_FIRST_NAME</th>
<th>LABEL_LAST_NAME</th>
<th>LABEL_CORPORATE_EMAIL</th>
<th>LABEL_COMPANY</th>
<th>LABEL_COUNTRY</th>
<th>LABEL_SECTOR</th>
<th>LABEL_SCHOLARSHIP</th>
<th>LABEL_ACTIONS</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<div class="card-footer clearfix">
<div style="float:right;">
<button type="button" class="btn btn-info btn-refresh"><i class="fa fa-refresh"></i> LABEL_REFRESH </button>
<?php if ($allowUpload) : ?>
<button type="button" class="btn btn-primary btn-upload"><i class="fa fa-upload"></i> LABEL_UPLOAD </button>
<?php endif; ?>
<?php if ($allowAdd) : ?>
<button type="button" class="btn btn-primary btn-add"><i class="fa fa-plus"></i> LABEL_ADD </button>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<section class="content" id="form-row" style="display: none">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h2>LABEL_CONTACT - <span id="form-title"></span></h2>
</div>
<div class="card-body">
<?php
$form = $this->form;
$form->setAttributes([
'method' => 'post',
'action' => $routeAdd,
'name' => 'form',
'id' => 'form',
]);
$form->prepare();
echo $this->form()->openTag($form);
?>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_FIRST_NAME';
$field = 'first_name';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_LAST_NAME';
$field = 'last_name';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_CORPORATE_EMAIL';
$field = 'corporate_email';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_COMPANY';
$field = 'company';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_POSITION';
$field = 'position';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_SECTOR';
$field = 'sector';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo '<br>';
echo $this->formText($element);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_COUNTRY';
$field = 'country';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_STATE';
$field = 'state';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_CITY';
$field = 'city';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_PHONE';
$field = 'phone';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo '<br>';
echo $this->formText($element);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_PHONE_EXTENSION';
$field = 'phone_extension';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_PERSONAL_EMAIL';
$field = 'personal_email';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_CELULAR';
$field = 'celular';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo '<br>';
echo $this->formText($element);
?>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_WHATSAPP';
$field = 'whatsapp';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo '<br>';
echo $this->formText($element);
?>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_LINKEDIN';
$field = 'linkedin';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formText($element);
?>
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<?php
$label = 'LABEL_SCHOLARSHIP';
$field = 'scholarship';
$element = $form->get($field);
$element->setAttributes(['id' => $field, 'class' => 'form-control']);
$element->setOptions(['label' => $label]);
echo $this->formLabel($element);
echo $this->formSelect($element);
?>
</div>
</div>
</div>
</div>
<div class="card-footer clearfix">
<div style="float:right;">
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
</div>
</div>
<?php echo $this->form()->closeTag($form); ?>
</div>
</div>
</div>
</div>
</section>
<section class="content" id="interactions-row" style="display: none">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<h2>LABEL_CONTACT</h2>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card card-primary card-outline card-tabs">
<div class="card-body p-0 pt-2">
<div class="row mx-0">
<?php
$fields = [
'LABEL_FIRST_NAME' => 'interactions-first_name',
'LABEL_LAST_NAME' => 'interactions-last_name',
'LABEL_CORPORATE_EMAIL' => 'interactions-corporate_email',
'LABEL_COMPANY' => 'interactions-company',
'LABEL_POSITION' => 'interactions-position',
'LABEL_COUNTRY' => 'interactions-country',
'LABEL_STATE' => 'interactions-state',
'LABEL_CITY' => 'interactions-city',
'LABEL_PHONE' => 'interactions-phone',
'LABEL_PHONE_EXTENSION' => 'interactions-phone_extension',
'LABEL_PERSONAL_EMAIL' => 'interactions-personal_email',
'LABEL_CELULAR' => 'interactions-celular',
'LABEL_WHATSAPP' => 'interactions-whatsapp',
'LABEL_LINKEDIN' => 'interactions-linkedin',
'LABEL_SCHOLARSHIP' => 'interactions-scholarship',
];
foreach ($fields as $label => $field) :
?>
<div class="col-sm-6">
<div class="form-group">
<label for="<?php echo $field ?>"><?php echo $label ?></label>
<input type="text" id="<?php echo $field ?>" class="form-control" value="" readonly="readonly" />
</div>
</div>
<?php endforeach; ?>
</div>
<ul class="nav nav-tabs border-bottom-0" id="custom-tabs-three-tab" role="tablist">
<li class="nav-item">
<a class="nav-link px-2 active" id="discovery-contacts-tabs-interactions-tab" data-toggle="pill" href="#discovery-contacts-tabs-interactions" role="tab" aria-controls="discovery-contacts-tabs-interactions" aria-selected="false">LABEL_INTERACTIONS</a>
</li>
<li class="nav-item">
<a class="nav-link px-2" id="discovery-contacts-tabs-logs-tab" data-toggle="pill" href="#discovery-contacts-tabs-logs" role="tab" aria-controls="discovery-contacts-tabs-logs" aria-selected="false">LABEL_LOGS</a>
</li>
</ul>
</div>
<div class="card-body p-0">
<div class="tab-content" id="custom-tabs-three-tabContent">
<div class="tab-pane fade show active" id="discovery-contacts-tabs-interactions" role="tabpanel" aria-labelledby="discovery-contacts-tabs-interactions-tab">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>LABEL_FIRST_NAME</th>
<th>LABEL_LAST_NAME</th>
<th>LABEL_EMAIL</th>
<th>LABEL_DATE</th>
<th>LABEL_ACTIONS</th>
</tr>
</thead>
<tbody id="grid-discovery-contacts-tabs-interactions">
</tbody>
</table>
<br>
<ul id="discovery-contacts-pagination-interactions" class="pagination pagination-sm m-0 float-right">
</ul>
</div>
<div class="tab-pane fade" id="discovery-contacts-tabs-logs" role="tabpanel" aria-labelledby="discovery-contacts-tabs-logs-tab">
<table class="table table-striped table-hover">
<thead>
<tr>
<th>LABEL_FIRST_NAME</th>
<th>LABEL_LAST_NAME</th>
<th>LABEL_EMAIL</th>
<th>LABEL_ACTIVITY</th>
</tr>
</thead>
<tbody id="grid-discovery-contacts-tabs-logs">
</tbody>
</table>
<br>
<ul id="discovery-contacts-pagination-logs" class="pagination pagination-sm m-0 float-right">
</ul>
</div>
</div>
</div>
<div class="card-footer clearfix">
<div style="float:right;">
<button type="button" class="btn btn-primary btn-close-view"><i class="fa fa-chevron-left"></i> LABEL_BACK </button>
<?php if ($allowInteractionAdd) : ?>
<button type="button" class="btn btn-primary btn-add-interaction"><i class="fa fa-plus"></i> LABEL_ADD </button>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- The Modal -->
<div class="modal" id="modal-interaction">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">LABEL_INTERACTION</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<?php
$form = $this->formInteraction;
$form->setAttributes([
'method' => 'post',
'name' => 'form-interaction',
'id' => 'form-interaction'
]);
$form->prepare();
echo $this->form()->openTag($form);
?>
<div class="form-group">
<?php
$element = $form->get('interaction_type_id');
$element->setOptions(['label' => 'LABEL_INTERACTION_TYPE']);
$element->setAttributes(['class' => 'form-control']);
echo $this->formLabel($element);
echo $this->formSelect($element);
?>
</div>
<div class="form-group">
<?php
$element = $form->get('notes');
$element->setOptions(['label' => 'LABEL_NOTES']);
$element->setAttributes(['class' => 'form-control']);
echo $this->formLabel($element);
echo $this->formTextArea($element);
?>
</div>
<div class="text-right">
<button type="submit" class="btn btn-primary">LABEL_SAVE</button>
<button type="button" class="btn btn-light btn-cancel-interaction">LABEL_CANCEL</button>
</div>
<?php echo $this->form()->closeTag($form); ?>
</div>
</div>
</div>
</div>
<!-- The Modal -->
<div class="modal" id="modalContactUpload">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">LABEL_UPLOAD</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<?php
$form = $this->contactUploadForm;
$form->setAttributes([
'method' => 'post',
'name' => 'form-contact-upload',
'id' => 'form-contact-upload'
]);
$form->prepare();
echo $this->form()->openTag($form);
?>
<div class="form-group">
<?php
$element = $form->get('file');
$element->setOptions(['label' => 'LABEL_EXCEL']);
echo $this->formLabel($element);
?>
<div class="file-loading">
<?php
$element->setAttributes(['class' => 'form-control', 'accept' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel']);
echo $this->formFile($element);
?>
</div>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">LABEL_UPLOAD</button>
<button type="button" class="btn btn-light btn-cancel">LABEL_CANCEL</button>
</div>
<?php echo $this->form()->closeTag($form); ?>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
</div>
</div>
</div>
</div>
<!-- The Modal -->
<div class="modal" id="modalContactUploadTable">
<div class="modal-dialog modal-xl">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">LABEL_CONTACTS</h4>
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<!-- Modal body -->
<div class="modal-body">
<form>
<input type="hidden" name="table-upload-contacts-key" id="table-upload-contacts-key">
</form>
<div id="table-wrapper">
<table id="gridTableUploadContacts" class="table table-bordered table-hover">
<thead>
<tr>
<th>LABEL_FIRST_NAME</th>
<th>LABEL_LAST_NAME</th>
<th>LABEL_PERSONAL_EMAIL</th>
<th>LABEL_CORPORATE_EMAIL</th>
<th>LABEL_COMPANY</th>
<th>LABEL_POSITION</th>
<th>LABEL_SECTOR</th>
<th>LABEL_COUNTRY</th>
<th>LABEL_STATE</th>
<th>LABEL_CITY</th>
<th>LABEL_PHONE</th>
<th>LABEL_PHONE_EXTENSION</th>
<th>LABEL_CELULAR</th>
<th>LABEL_WHATSAPP</th>
<th>LABEL_LINKEDIN</th>
<th>LABEL_SECTOR</th>
<th>LABEL_SCHOLARSHIP</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="submit" class="btn btn-primary btn-upload-contacts-step2">LABEL_SAVE</button>
<button type="button" class="btn btn-danger" data-dismiss="modal">LABEL_CLOSE</button>
</div>
</div>
</div>
</div>
<script id="interactionTemplate" type="text/x-jsrender">
{{for items}}
<tr>
<td>{{>first_name}}</td>
<td>{{>last_name}}</td>
<td>{{>email}}</td>
<td> {{>added_on}}</td>
<td>
<button class="btn btn-danger btn-delete-interaction" data-href="{{>link_delete}}" data-toggle="tooltip" title="LABEL_DELETE"><i class="fa fa-trash"></i> LABEL_DELETE </button>
</td>
</tr>
<tr>
<td colspan="2">
{{>name}}
</td>
<td colspan="3">
{{>notes}}
</td>
</tr>
{{/for}}
</script>
<script id="logTemplate" type="text/x-jsrender">
{{for items}}
<tr>
<td>{{>first_name}}</td>
<td>{{>last_name}}</td>
<td>{{>email}}</td>
<td>
{{>activity}} -
{{>added_on}}
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
{{>details}}
</td>
</tr>
{{/for}}
</script>
<script id="uploadContactTemplate" type="text/x-jsrender">
{{for items}}
<tr>
<td>{{>first_name}}</td>
<td>{{>last_name}}</td>
<td>{{>email_personal}}</td>
<td>{{>email_company}}</td>
<td>{{>company}}</td>
<td>{{>position}}</td>
<td>{{>sector}}</td>
<td>{{>country}}</td>
<td>{{>state}}</td>
<td>{{>city}}</td>
<td>{{>phone}}</td>
<td>{{>extension}}</td>
<td>{{>movil}}</td>
<td>{{>whatsapp}}</td>
<td>{{>linkedin}}</td>
<td>{{>sector}}</td>
<td>{{>scholarship}}</td>
</tr>
{{/for}}
</script>
<script id="logPaginationTemplate" type="text/x-jsrender">
{{if has_previous_page}}
<li class="page-item"><a class="page-link class-btn-log-previous" href="#"> <i class="fa fa-chevron-left" aria-hidden="true"></i> LABEL_PREVIOUS </a></li>
{{/if}}
{{if has_next_page}}
<li class="page-item"><a class="page-link class-btn-log-next" href="#"> LABEL_NEXT <i class="fa fa-chevron-right" aria-hidden="true"></i> </a></li>
{{/if}}
</script>
<script id="interactionPaginationTemplate" type="text/x-jsrender">
{{if has_previous_page}}
<li class="page-item"><a class="page-link class-btn-interaction-previous" href="#"> <i class="fa fa-chevron-left" aria-hidden="true"></i> LABEL_PREVIOUS </a></li>
{{/if}}
{{if has_next_page}}
<li class="page-item"><a class="page-link class-btn-interaction-next" href="#"> LABEL_NEXT <i class="fa fa-chevron-right" aria-hidden="true"></i> </a></li>
{{/if}}
</script>