mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
haciendo el buscador
This commit is contained in:
@ -6,7 +6,7 @@ use CodeIgniter\Config\BaseConfig;
|
||||
|
||||
class Email extends BaseConfig
|
||||
{
|
||||
public string $fromEmail = 'safekat@imnavajas.es';
|
||||
public string $fromEmail = 'soporte_erp@safekat.es';
|
||||
public string $fromName = 'Safekat ERP';
|
||||
public string $recipients = '';
|
||||
|
||||
@ -28,22 +28,22 @@ class Email extends BaseConfig
|
||||
/**
|
||||
* SMTP Server Hostname
|
||||
*/
|
||||
public string $SMTPHost = 'imnavajas.es';
|
||||
public string $SMTPHost = 'smtp.ionos.es';
|
||||
|
||||
/**
|
||||
* SMTP Username
|
||||
*/
|
||||
public string $SMTPUser = 'safekat@imnavajas.es';
|
||||
public string $SMTPUser = 'soporte_erp@safekat.es';
|
||||
|
||||
/**
|
||||
* SMTP Password
|
||||
*/
|
||||
public string $SMTPPass = 'Etkd9~448';
|
||||
public string $SMTPPass = 'H%5&qDkDkWnfLTGN';
|
||||
|
||||
/**
|
||||
* SMTP Port
|
||||
*/
|
||||
public int $SMTPPort = 25;
|
||||
public int $SMTPPort = 465;
|
||||
|
||||
/**
|
||||
* SMTP Timeout (in seconds)
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Controllers\Soporte;
|
||||
|
||||
use App\Models\Sistema\SettingsModel;
|
||||
use App\Models\Soporte\TicketModel;
|
||||
use App\Models\CategoriaModel;
|
||||
use App\Models\EstadoModel;
|
||||
@ -25,7 +26,7 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
||||
|
||||
protected static $viewPath = 'themes/vuexy/form/soporte/';
|
||||
|
||||
protected $indexRoute = 'ticketList';
|
||||
protected $indexRoute = 'TicketIndex';
|
||||
|
||||
|
||||
public function initController(\CodeIgniter\HTTP\RequestInterface $request, \CodeIgniter\HTTP\ResponseInterface $response, \Psr\Log\LoggerInterface $logger)
|
||||
@ -57,6 +58,48 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
||||
return view(static::$viewPath . 'viewTicketList', $viewData);
|
||||
}
|
||||
|
||||
private function sendMail($subject,$body,$recipient)
|
||||
{
|
||||
$settings_model = new SettingsModel();
|
||||
$config = $settings_model->first()->toArray();
|
||||
$gateway = $config['email_gateway'];
|
||||
$body = html_entity_decode($body);
|
||||
|
||||
if($gateway == 'smtp'){
|
||||
try {
|
||||
//https://codeigniter.com/user_guide/libraries/email.html
|
||||
$email = \Config\Services::email();
|
||||
$config['protocol'] = $config['email_gateway'];
|
||||
$config['SMTPHost'] = $config['email_smtp'];
|
||||
$config['SMTPUser'] = $config['email_address'];
|
||||
$config['SMTPPass'] = $config['email_pass'];
|
||||
$config['SMTPPort'] = intval($config['email_port']);
|
||||
$config['SMTPCrypto'] = $config['email_cert']=='none'?'':$config['email_cert'];
|
||||
$config['SMTPTimeout'] = 15;
|
||||
$config['mailType'] = 'html';
|
||||
$config['wordWrap'] = true;
|
||||
|
||||
$email->initialize($config);
|
||||
|
||||
$email->setFrom($config['email_address'], $config['email_name']);
|
||||
$email->setTo($recipient);
|
||||
|
||||
$email->setSubject($subject);
|
||||
$email->setMessage($body);
|
||||
|
||||
if (!$email->send())
|
||||
{
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
@ -100,6 +143,10 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
|
||||
|
||||
$message = lang('Basic.global.saveSuccess', [lang('Basic.global.record')]) . '.';
|
||||
|
||||
$userModel = new \App\Models\UserModel();
|
||||
|
||||
$this->sendMail(lang('Tickets.newTicket'), lang('Tickets.newTicketBody') . base_url(route_to('editTicket', $id)), $userModel->find($sanitizedData['supportUser'])->email);
|
||||
|
||||
if ($thenRedirect) :
|
||||
if (!empty($this->indexRoute)) :
|
||||
return redirect()->to(route_to($this->indexRoute))->with('successMessage', $message);
|
||||
|
||||
@ -93,5 +93,7 @@ class CreateTicketsSystem extends Migration
|
||||
$this->forge->dropTable('tickets_categorias');
|
||||
$this->forge->dropTable('tickets_estados');
|
||||
$this->forge->dropTable('tickets_secciones');
|
||||
|
||||
$this->db->table('config_variables_app')->where('name', 'default_soporte_user_id')->delete();
|
||||
}
|
||||
}
|
||||
|
||||
@ -47,4 +47,7 @@ return [
|
||||
'adjuntos' => 'Adjuntar imágenes',
|
||||
'adjuntos_ticket' => 'Imágenes adjuntas',
|
||||
|
||||
// Mail
|
||||
'newTicket' => 'Nuevo Ticket en ERP Safekat',
|
||||
'newTicketBody' => '<p>Se ha creado un nuevo ticket en el sistema de soporte de Safekat ERP. <br><br>Puede verlo en el siguiente enlace:</p>',
|
||||
];
|
||||
|
||||
@ -15,14 +15,15 @@ class TicketModel extends \App\Models\BaseModel
|
||||
protected $returnType = "App\Entities\Soporte\TicketEntity";
|
||||
|
||||
const SORTABLE = [
|
||||
0 => "t1.categoria_id",
|
||||
1 => "t1.seccion_id",
|
||||
2 => "t1.estado_id",
|
||||
3 => "t1.prioridad",
|
||||
4 => "t1.titulo",
|
||||
5 => "t1.usuario_id",
|
||||
6 => "t1.usuario_soporte_id",
|
||||
7 => "t1.created_at",
|
||||
0 => "t1.id",
|
||||
1 => "t1.categoria_id",
|
||||
2 => "t1.seccion_id",
|
||||
3 => "t1.estado_id",
|
||||
4 => "t1.prioridad",
|
||||
5 => "t1.titulo",
|
||||
6 => "t1.usuario_id",
|
||||
7 => "t1.usuario_soporte_id",
|
||||
8 => "t1.created_at",
|
||||
];
|
||||
|
||||
public function getEstados()
|
||||
|
||||
@ -8,75 +8,83 @@ class Ticket {
|
||||
constructor() {
|
||||
|
||||
// check if url includes "add"
|
||||
this.action = 'list';
|
||||
if(window.location.href.includes("add"))
|
||||
this.action = 'list';
|
||||
if (window.location.href.includes("add"))
|
||||
this.action = "add";
|
||||
else if(window.location.href.includes("edit"))
|
||||
else if (window.location.href.includes("edit"))
|
||||
this.action = "edit";
|
||||
|
||||
this.table = null;
|
||||
|
||||
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
||||
init() {
|
||||
|
||||
if(this.action == "edit") {
|
||||
if (this.action == "edit") {
|
||||
|
||||
$('.gallery-img').on('click', function() {
|
||||
$('.gallery-img').on('click', function () {
|
||||
let imageUrl = $(this).data('src'); // Obtiene la URL de la imagen
|
||||
$('#modalImage').attr('src', imageUrl); // Cambia la imagen en el modal
|
||||
$('#imageModal').modal('show'); // Muestra el modal
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
else if (this.action == "list") {
|
||||
this.#initDatatable();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#initDatatable() {
|
||||
|
||||
this.#headerSearcher();
|
||||
|
||||
const self = this;
|
||||
|
||||
const actions = ['view'];
|
||||
const columns = [
|
||||
{ 'data': 'id' },
|
||||
{ 'data': 'categoria_id',
|
||||
{
|
||||
'data': 'categoria_id',
|
||||
render: function (data, type, row) {
|
||||
return window.language.Tickets[row.categoria];
|
||||
}
|
||||
},
|
||||
{ 'data': 'seccion_id' ,
|
||||
},
|
||||
{
|
||||
'data': 'seccion_id',
|
||||
render: function (data, type, row) {
|
||||
return window.language.Tickets[row.seccion];
|
||||
}
|
||||
},
|
||||
{ 'data': 'estado_id' ,
|
||||
{
|
||||
'data': 'estado_id',
|
||||
render: function (data, type, row) {
|
||||
return window.language.Tickets[row.estado];
|
||||
}
|
||||
},
|
||||
{ 'data': 'prioridad' ,
|
||||
{
|
||||
'data': 'prioridad',
|
||||
render: function (data, type, row) {
|
||||
return window.language.Tickets[data];
|
||||
},
|
||||
visible: false,
|
||||
},
|
||||
{ 'data': 'titulo' },
|
||||
{ 'data': 'usuario_id' ,
|
||||
{
|
||||
'data': 'usuario_id',
|
||||
render: function (data, type, row) {
|
||||
return row.usuario;
|
||||
},
|
||||
visible: false,
|
||||
},
|
||||
{ 'data': 'user_soporte_id',
|
||||
{
|
||||
'data': 'user_soporte_id',
|
||||
render: function (data, type, row) {
|
||||
return row.user_soporte;
|
||||
},
|
||||
visible: false,
|
||||
},
|
||||
},
|
||||
{ 'data': 'created_at' },
|
||||
];
|
||||
|
||||
@ -88,7 +96,7 @@ class Ticket {
|
||||
columns,
|
||||
);
|
||||
|
||||
|
||||
|
||||
this.table.init({
|
||||
actions: actions,
|
||||
buttonsExport: true,
|
||||
@ -96,7 +104,7 @@ class Ticket {
|
||||
|
||||
this.table.table.on('init.dt', function () {
|
||||
self.table.table.page.len(50).draw();
|
||||
if(window.userType==1){
|
||||
if (window.userType == 1) {
|
||||
|
||||
self.table.table.column(4).visible(true);
|
||||
self.table.table.column(6).visible(true);
|
||||
@ -108,25 +116,172 @@ class Ticket {
|
||||
}
|
||||
});
|
||||
|
||||
this.table.setEditCallback(function(id){
|
||||
this.table.setEditCallback(function (id) {
|
||||
window.location.href = '/soporte/edit/' + id;
|
||||
})
|
||||
}
|
||||
|
||||
#headerSearcher() {
|
||||
const self = this;
|
||||
|
||||
$('#tableOfTickets thead tr').clone(true).appendTo('#tableOfTickets thead');
|
||||
$('#tableOfTickets thead tr:eq(1) th').each(function (i) {
|
||||
if (!$(this).hasClass("noFilter")) {
|
||||
var title = $(this).text();
|
||||
if (i == 8) {
|
||||
|
||||
$(this).html('<input id="bs-rangepicker-range" type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
|
||||
var bsRangePickerRange = $('#bs-rangepicker-range')
|
||||
bsRangePickerRange.daterangepicker({
|
||||
ranges: {
|
||||
[window.language.datePicker.hoy]: [moment(), moment()],
|
||||
[window.language.datePicker.ayer]: [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
||||
[window.language.datePicker.ultimos7]: [moment().subtract(6, 'days'), moment()],
|
||||
[window.language.datePicker.ultimos30]: [moment().subtract(29, 'days'), moment()],
|
||||
[window.language.datePicker.esteMes]: [moment().startOf('month'), moment().endOf('month')],
|
||||
[window.language.datePicker.ultimoMes]: [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
||||
},
|
||||
opens: 'right',
|
||||
language: '<?= config('Basics')->i18n ?>',
|
||||
"locale": {
|
||||
"customRangeLabel": "<?= lang('datePicker.personalizar') ?>",
|
||||
"format": "YYYY-MM-DD",
|
||||
"separator": " ",
|
||||
"applyLabel": "<?= lang('datePicker.aplicar') ?>",
|
||||
"cancelLabel": "<?= lang('datePicker.limpiar') ?>",
|
||||
|
||||
},
|
||||
"alwaysShowCalendars": true,
|
||||
autoUpdateInput: false,
|
||||
|
||||
});
|
||||
|
||||
bsRangePickerRange.on('apply.daterangepicker', function (ev, picker) {
|
||||
$(this).val(picker.startDate.format('YYYY-MM-DD') + ' ' + picker.endDate.format('YYYY-MM-DD'));
|
||||
self.table
|
||||
.column(i)
|
||||
.search(this.value)
|
||||
.draw();
|
||||
});
|
||||
|
||||
bsRangePickerRange.on('cancel.daterangepicker', function (ev, picker) {
|
||||
$(this).val('');
|
||||
self.table
|
||||
.column(i)
|
||||
.search(this.value)
|
||||
.draw();
|
||||
});
|
||||
|
||||
}
|
||||
else if (i == 1) {
|
||||
// Agregar un selector en la tercera columna
|
||||
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
|
||||
|
||||
// Agregar opciones al selector
|
||||
var selectorTipo = $('select', this);
|
||||
selectorTipo.append('<option value="">Todos</option>'); // Opción vacía
|
||||
selectorTipo.append('<option value="errores">' + window.language.Tickets.errores + '</option>');
|
||||
selectorTipo.append('<option value="consultas">' + window.language.Tickets.consultas + '</option>');
|
||||
selectorTipo.append('<option value="sugerencias">' + window.language.Tickets.sugerencias + '</option>');
|
||||
|
||||
selectorTipo.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
self.table.column(i).search(val).draw();
|
||||
});
|
||||
}
|
||||
|
||||
else if (i == 2) {
|
||||
// Agregar un selector en la tercera columna
|
||||
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
|
||||
|
||||
// Agregar opciones al selector
|
||||
var selectorSeccion = $('select', this);
|
||||
selectorSeccion.append('<option value="">Todos</option>'); // Opción vacía
|
||||
selectorSeccion.append('<option value="presupuestos">' + window.language.Tickets.presupuestos + '</option>');
|
||||
selectorSeccion.append('<option value="pedidos">' + window.language.Tickets.pedidos + '</option>');
|
||||
selectorSeccion.append('<option value="facturacion">' + window.language.Tickets.facturacion + '</option>');
|
||||
selectorSeccion.append('<option value="logistica">' + window.language.Tickets.logistica + '</option>');
|
||||
selectorSeccion.append('<option value="configuracion">' + window.language.Tickets.configuracion + '</option>');
|
||||
selectorSeccion.append('<option value="general">' + window.language.Tickets.general + '</option>');
|
||||
|
||||
selectorSeccion.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
self.table.column(i).search(val).draw();
|
||||
});
|
||||
}
|
||||
else if (i == 2) {
|
||||
// Agregar un selector en la tercera columna
|
||||
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
|
||||
|
||||
// Agregar opciones al selector
|
||||
var selectorEstado = $('select', this);
|
||||
selectorEstado.append('<option value="">Todos</option>'); // Opción vacía
|
||||
selectorEstado.append('<option value="abierto">' + window.language.Tickets.abierto + '</option>');
|
||||
selectorEstado.append('<option value="en_proceso">' + window.language.Tickets.en_proceso + '</option>');
|
||||
selectorEstado.append('<option value="resuelto">' + window.language.Tickets.resuelto + '</option>');
|
||||
|
||||
selectorEstado.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
self.table.column(i).search(val).draw();
|
||||
});
|
||||
}
|
||||
else if (i == 8) {
|
||||
// Agregar un selector en la tercera columna
|
||||
$(this).html('<select class="form-control" style="min-width:100px;max-width:120px;font-size:0.8rem !important;"></select>');
|
||||
|
||||
// Agregar opciones al selector
|
||||
var selectorPrioridad = $('select', this);
|
||||
selectorPrioridad.append('<option value="">Todos</option>'); // Opción vacía
|
||||
selectorPrioridad.append('<option value="baja">' + window.language.Tickets.baja + '</option>');
|
||||
selectorPrioridad.append('<option value="media">' + window.language.Tickets.media + '</option>');
|
||||
selectorPrioridad.append('<option value="baja">' + window.language.Tickets.alta + '</option>');
|
||||
|
||||
selectorPrioridad.on('change', function () {
|
||||
var val = $.fn.dataTable.util.escapeRegex(
|
||||
$(this).val()
|
||||
);
|
||||
self.table.column(i).search(val).draw();
|
||||
});
|
||||
}
|
||||
else {
|
||||
$(this).html('<input type="text" class="form-control " style="min-width:100px;max-width:120px;font-size:0.8rem !important;" />');
|
||||
|
||||
$('input', this).on('change clear', function () {
|
||||
if (self.table.column(i).search() !== this.value) {
|
||||
self.table
|
||||
.column(i)
|
||||
.search(this.value)
|
||||
.draw();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
$(this).html('<span></span>');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
|
||||
|
||||
const locale = document.querySelector('meta[name="locale"]').getAttribute('content');
|
||||
|
||||
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Tickets'] }, {},
|
||||
function(translations) {
|
||||
new Ajax('/translate/getTranslation', { locale: locale, translationFile: ['Tickets, datePicker'] }, {},
|
||||
function (translations) {
|
||||
window.language = JSON.parse(translations);
|
||||
new Ticket();
|
||||
},
|
||||
function (error) {
|
||||
console.log("Error getting translations:", error);
|
||||
}
|
||||
).post();
|
||||
});
|
||||
).post();
|
||||
});
|
||||
|
||||
export default Ticket;
|
||||
Reference in New Issue
Block a user