Merge branch 'main' into 'add/calculo_credito_cliente'

Main

See merge request jjimenez/safekat!614
This commit is contained in:
2025-03-27 11:24:03 +00:00
7 changed files with 34 additions and 52 deletions

View File

@ -60,4 +60,14 @@ class Services extends BaseService
{ {
return new ChatService(); return new ChatService();
} }
public static function emailService($getShared = true)
{
if ($getShared) {
return static::getSharedInstance('emailService');
}
return new \App\Services\EmailService();
}
} }

View File

@ -399,6 +399,8 @@ class Presupuestoadmin extends \App\Controllers\BaseResourceController
$this->viewData['formAction'] = route_to('updatePresupuestoAdmin', $id); $this->viewData['formAction'] = route_to('updatePresupuestoAdmin', $id);
$this->viewData['cliente_id'] = $presupuestoEntity->cliente_id;
// Si se ha llamado a esta funcion porque se ha duplicado el presupuesto // Si se ha llamado a esta funcion porque se ha duplicado el presupuesto
// se actualiza la bbdd para que sólo ejecute algunas funciones una vez // se actualiza la bbdd para que sólo ejecute algunas funciones una vez
if ($presupuestoEntity->is_duplicado) { if ($presupuestoEntity->is_duplicado) {

View File

@ -60,43 +60,10 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController
private function sendMail($subject, $body, $recipient) private function sendMail($subject, $body, $recipient)
{ {
$settings_model = new SettingsModel(); // Funcion wrapper para el servicio de envio de correos dentro de la fucionalidad previa
$config = $settings_model->first()->toArray(); $emailService = service('emailService');
$gateway = $config['email_gateway'];
$body = html_entity_decode($body);
if ($gateway == 'smtp') { return $emailService->send($subject, $body, $recipient);
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() public function add()

View File

@ -40,7 +40,7 @@ class ChatService extends BaseService
protected array $modelClassMap; protected array $modelClassMap;
public function __construct() public function __construct()
{ {
$this->emailService = service('email'); $this->emailService = service('emailService'); // Usar el servicio de email de Safekat y no el de CI4
$this->userModel = model(UserModel::class); $this->userModel = model(UserModel::class);
$this->chatModel = model(ChatModel::class); $this->chatModel = model(ChatModel::class);
$this->chatMessageModel = model(ChatMessageModel::class); $this->chatMessageModel = model(ChatMessageModel::class);
@ -186,10 +186,15 @@ class ChatService extends BaseService
{ {
$users = auth()->getProvider(); $users = auth()->getProvider();
$toEmail = $users->find($user->id)->getEmail(); $toEmail = $users->find($user->id)->getEmail();
$this->emailService->setTo($toEmail);
$subject = '[Safekat]' . lang('Chat.mail.mail_subject') . '-' . $chatMessageEntity->chat()->title; $subject = '[Safekat]' . lang('Chat.mail.mail_subject') . ' - ' . $chatMessageEntity->chat()->title;
$this->emailService->setSubject($subject);
$this->emailService->setMessage(view('themes/vuexy/mail/messageNotification', ["header" => lang('Chat.mail.mail_subject'), "data" => $chatMessageEntity->withUser()])); $message = view('themes/vuexy/mail/messageNotification', [
return $this->emailService->send(); "header" => lang('Chat.mail.mail_subject'),
"data" => $chatMessageEntity->withUser(),
]);
return $this->emailService->send($subject, $message, $toEmail);
} }
} }

View File

@ -143,7 +143,9 @@
<div class="mb-3"> <div class="mb-3">
<label for="clienteId" class="form-label"> <label for="clienteId" class="form-label">
<?= lang('Presupuestos.clienteId') ?>* <?= lang('Presupuestos.clienteId') ?>*
<a id="openCliente" href="javascript(void)" target="_blank" ><i class="ti ti-file-search ti-sm btn-edit mx-2" data-id="${data.id}"></i></a> <?php if(isset($cliente_id)):?>
<a href="<?= route_to('editarCliente', $cliente_id); ?>" target="_blank" ><i class="ti ti-file-search ti-sm mx-2""></i></a>
<?php endif; ?>
</label> </label>
<select id="clienteId" name="cliente_id" class="form-control select2bs2" style="width: 100%;"> <select id="clienteId" name="cliente_id" class="form-control select2bs2" style="width: 100%;">
</select> </select>

View File

@ -507,11 +507,12 @@ class PresupuestoAdminEdit {
if (mano > 0) { if (mano > 0) {
anchoTotal += 6 + 5; // dobleces + sangre anchoTotal += 6 + 5; // dobleces + sangre
maxSolapas = Math.min(Math.floor((865 - anchoTotal) / 2), 0.75 * this.getDimensionLibro().ancho); maxSolapas = Math.min(Math.floor((865 - anchoTotal) / 2), 0.95 * this.getDimensionLibro().ancho);
} }
else { else {
maxSolapas = 0.75 * this.getDimensionLibro().ancho; maxSolapas = 0.95 * this.getDimensionLibro().ancho;
} }
maxSolapas = Math.floor(maxSolapas, 0);
if ($('#solapas_ancho').length > 0 && $('#solapas_ancho').attr('max') != maxSolapas) { if ($('#solapas_ancho').length > 0 && $('#solapas_ancho').attr('max') != maxSolapas) {
$('#solapas_ancho').attr('max', maxSolapas); $('#solapas_ancho').attr('max', maxSolapas);
$('#solapas_ancho').trigger('change'); $('#solapas_ancho').trigger('change');

View File

@ -16,9 +16,7 @@ class DatosGenerales{
this.numeroEdicion = this.domItem.find('#numeroEdicion'); this.numeroEdicion = this.domItem.find('#numeroEdicion');
this.isbn = this.domItem.find('#isbn'); this.isbn = this.domItem.find('#isbn');
this.openCliente = this.domItem.find('#openCliente');
this.cliente = new ClassSelect($('#clienteId'), '/clientes/cliente/getSelect2', 'Seleccione cliente'); this.cliente = new ClassSelect($('#clienteId'), '/clientes/cliente/getSelect2', 'Seleccione cliente');
this.pais = new ClassSelect($('#paisId'), '/paises/menuitems2', 'Seleccione País'); this.pais = new ClassSelect($('#paisId'), '/paises/menuitems2', 'Seleccione País');
this.referenciaCliente = this.domItem.find('#referenciaCliente'); this.referenciaCliente = this.domItem.find('#referenciaCliente');
@ -34,10 +32,7 @@ class DatosGenerales{
allowClear: false, allowClear: false,
}); });
this.openCliente.click(()=>{
const urlObj = new URL(window.location.href);
window.open(`${urlObj.origin}` + '/clientes/cliente/edit/' + this.cliente.getVal());
});
} }
cargarDatos(datos){ cargarDatos(datos){