mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
email Service merge
This commit is contained in:
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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()
|
||||
|
||||
@ -29,53 +29,16 @@ class Test extends BaseController
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
private function index()
|
||||
{
|
||||
$modelCliente = model('App\Models\Clientes\ClienteModel');
|
||||
var_dump($modelCliente->getPendienteCobro(1284));
|
||||
}
|
||||
|
||||
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');
|
||||
|
||||
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -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');
|
||||
|
||||
Reference in New Issue
Block a user