From ee7c161ef2069b52639387340b51499d48019db2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Jim=C3=A9nez?= Date: Wed, 26 Mar 2025 19:36:50 +0100 Subject: [PATCH 1/2] arreglado --- .../safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js index 5ba716e9..4ba517a9 100644 --- a/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js +++ b/httpdocs/assets/js/safekat/pages/presupuestoAdmin/presupuestoAdminEdit.js @@ -507,11 +507,12 @@ class PresupuestoAdminEdit { if (mano > 0) { 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 { - 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) { $('#solapas_ancho').attr('max', maxSolapas); $('#solapas_ancho').trigger('change'); From f37805d310ebbb8f0a45856c98722a0002c69e69 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 27 Mar 2025 12:08:09 +0100 Subject: [PATCH 2/2] Implementado servicio de envio de emails y funcion de envio a correo unico en etorno de desarrollo --- ci4/app/Config/Services.php | 10 ++++ .../Controllers/Soporte/Ticketcontroller.php | 39 ++------------- ci4/app/Controllers/Test.php | 50 +++---------------- ci4/app/Services/ChatService.php | 17 ++++--- 4 files changed, 31 insertions(+), 85 deletions(-) diff --git a/ci4/app/Config/Services.php b/ci4/app/Config/Services.php index 02632cdf..cb9b038f 100755 --- a/ci4/app/Config/Services.php +++ b/ci4/app/Config/Services.php @@ -60,4 +60,14 @@ class Services extends BaseService { return new ChatService(); } + + public static function emailService($getShared = true) + { + if ($getShared) { + return static::getSharedInstance('emailService'); + } + + return new \App\Services\EmailService(); + } + } diff --git a/ci4/app/Controllers/Soporte/Ticketcontroller.php b/ci4/app/Controllers/Soporte/Ticketcontroller.php index a50c7889..51ed1a70 100644 --- a/ci4/app/Controllers/Soporte/Ticketcontroller.php +++ b/ci4/app/Controllers/Soporte/Ticketcontroller.php @@ -60,43 +60,10 @@ class Ticketcontroller extends \App\Controllers\BaseResourceController private function sendMail($subject, $body, $recipient) { - $settings_model = new SettingsModel(); - $config = $settings_model->first()->toArray(); - $gateway = $config['email_gateway']; - $body = html_entity_decode($body); + // Funcion wrapper para el servicio de envio de correos dentro de la fucionalidad previa + $emailService = service('emailService'); - 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; + return $emailService->send($subject, $body, $recipient); } public function add() diff --git a/ci4/app/Controllers/Test.php b/ci4/app/Controllers/Test.php index 9ee22475..dfb723d3 100755 --- a/ci4/app/Controllers/Test.php +++ b/ci4/app/Controllers/Test.php @@ -29,52 +29,16 @@ class Test extends BaseController } - public function index() + private function index() { - $this->sendMail('prueba', 'Esto es una prueba', ['jaimejimenezortega@gmail.com','jaime0jimenez0ortega@gmail.com']); - } - - 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; + $this->emailService = service('emailService'); + + $a= $this->emailService->send('prueba', 'Esto es una prueba', ['imnavajas@coit.es','imnavajas@gmail.com']); + + echo var_dump($a); } + private function clonar_tarifa_encuadernacion($teOrigen, $teDestino){ $tet_model = model('App\Models\Tarifas\TarifaEncuadernacionTiradaModel'); diff --git a/ci4/app/Services/ChatService.php b/ci4/app/Services/ChatService.php index d5d8f9fb..97d88a65 100644 --- a/ci4/app/Services/ChatService.php +++ b/ci4/app/Services/ChatService.php @@ -40,7 +40,7 @@ class ChatService extends BaseService protected array $modelClassMap; 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->chatModel = model(ChatModel::class); $this->chatMessageModel = model(ChatMessageModel::class); @@ -186,10 +186,15 @@ class ChatService extends BaseService { $users = auth()->getProvider(); $toEmail = $users->find($user->id)->getEmail(); - $this->emailService->setTo($toEmail); - $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()])); - return $this->emailService->send(); + + $subject = '[Safekat]' . lang('Chat.mail.mail_subject') . ' - ' . $chatMessageEntity->chat()->title; + + $message = view('themes/vuexy/mail/messageNotification', [ + "header" => lang('Chat.mail.mail_subject'), + "data" => $chatMessageEntity->withUser(), + ]); + + return $this->emailService->send($subject, $message, $toEmail); + } }