Compare commits

...

7 Commits

Author SHA1 Message Date
Dasc3er 06eb5f916a Fix gestione invio email tramite OAuth2 2021-08-05 12:31:47 +02:00
Dasc3er 0b140f93ce Miglioramento gestione invio newsletter 2021-08-05 12:21:34 +02:00
Dasc3er 458fa5baf9 Stile del codice e fix minore 2021-08-05 11:40:05 +02:00
Dasc3er 4691573a28 Fix procedura invio email 2021-08-05 11:18:54 +02:00
Dasc3er ab27243f13 Aggiunto warning per logout in configurazione OAuth2 2021-08-05 11:08:35 +02:00
Dasc3er 25157b75a8 Stampa personalizzata con priorità rispetto a standard 2021-08-05 10:38:41 +02:00
Dasc3er f15b3925ff Correzioni minori JS Dashboard 2021-08-05 10:01:49 +02:00
13 changed files with 88 additions and 71 deletions

View File

@ -116,7 +116,7 @@ function start_datatables() {
} else {
$('#mini-loader').hide();
}
})
});
}
});
}

View File

@ -358,6 +358,9 @@ echo '
url: globals.rootdir + "/add.php?id_module='.$modulo_interventi->id.'",
},
error: "'.tr('Errore durante la creazione degli eventi').'",
genericError: "'.tr('Errore').'",
genericWarning: "'.tr('Attenzione').'",
informazioni_aggiuntive: '.intval(setting('Visualizza informazioni aggiuntive sul calendario')).',
};
function aggiorna_contatore(counter_id) {
@ -518,7 +521,7 @@ echo '
lazyFetching: true,
selectMirror: true,
eventLimit: false, // allow "more" link when too many events
allDaySlot: '.intval(setting('Visualizza informazioni aggiuntive sul calendario')).',
allDaySlot: globals.dashboard.informazioni_aggiuntive,
loading: function (isLoading, view) {
if (isLoading) {
@ -556,13 +559,12 @@ echo '
},
selectable: globals.dashboard.write_permission,
select: function(start, end, allDay) { // info
select: function (start, end, allDay) { // info
// let start = info.start;
// let end = info.end;
let is_allDay = !start.hasTime() && !end.hasTime();
if (is_allDay!==true){
let intero_giorno = !start.hasTime() && !end.hasTime();
if (intero_giorno !== true) {
let data = moment(start).format("YYYY-MM-DD");
let data_fine = moment(end).format("YYYY-MM-DD");
let orario_inizio = moment(start).format("HH:mm");
@ -578,35 +580,35 @@ echo '
},
editable: globals.dashboard.write_permission,
eventDrop: function(event, delta, revertFunc ) {// info
eventDrop: function (event, delta, revertFunc) {// info
// let event = info.event;
if (event.allDay!==true){
if (event.allDay !== true) {
$.post(globals.dashboard.load_url, {
op: "modifica_intervento",
id: event.id,
idintervento: event.idintervento,
timeStart: moment(event.start).format("YYYY-MM-DD HH:mm"),
timeEnd: moment(event.end).format("YYYY-MM-DD HH:mm")
}, function (data, response) {
}, function (data, responseType) {
data = $.trim(data);
if (response == "success" && data !== "ok") {
swal("'.tr('Attenzione').'", data, "warning");
}else if (response !== "success"){
swal("'.tr('Errore').'", data, "error");
if (responseType === "success" && data !== "ok") {
swal(globals.dashboard.genericWarning, data, "warning");
} else if (responseType !== "success") {
swal(globals.dashboard.genericError, data, "error");
}
if (data !=="ok"){
if (data !== "ok") {
revertFunc(); // info.revert();
}
});
}else{
} else {
revertFunc();
}
},
eventResize: function(event, delta, revertFunc) { // info
eventResize: function (event, delta, revertFunc) { // info
// let event = info.event;
$.post(globals.dashboard.load_url, {
@ -615,16 +617,16 @@ echo '
idintervento: event.idintervento,
timeStart: moment(event.start).format("YYYY-MM-DD HH:mm"),
timeEnd: moment(event.end).format("YYYY-MM-DD HH:mm")
}, function (data, response) {
}, function (data, responseType) {
data = $.trim(data);
if (response == "success" && data !== "ok") {
swal("'.tr('Attenzione').'", data, "warning");
}else if (response !== "success"){
swal("'.tr('Errore').'", data, "error");
if (responseType === "success" && data !== "ok") {
swal(globals.dashboard.genericWarning, data, "warning");
} else if (responseType !== "success") {
swal(globals.dashboard.genericError, data, "error");
}
if (data !=="ok"){
if (data !== "ok") {
revertFunc(); // info.revert();
}
@ -632,7 +634,7 @@ echo '
},
// eventPositioned: function (info) {
eventAfterRender: function(event, element) {
eventAfterRender: function (event, element) {
// let event = info.event;
// let element = $(info.el);
element.find(".fc-title").html(event.title);
@ -640,7 +642,7 @@ echo '
if (globals.dashboard.tooltip == 1) {
element.tooltipster({
content: "'.tr('Caricamento...').'",
content: globals.translations.loading + "...",
animation: "grow",
updateAnimation: "grow",
contentAsHTML: true,
@ -652,7 +654,7 @@ echo '
touchDevices: true,
trigger: "hover",
position: "left",
functionBefore: function(instance, helper) {
functionBefore: function (instance, helper) {
let $origin = $(helper.origin);
if ($origin.data("loaded") !== true) {
@ -674,7 +676,7 @@ echo '
url: globals.dashboard.load_url + "&op=interventi_periodo",
type: "GET",
error: function () {
swal("'.tr('Errore').'", globals.dashboard.error, "error");
swal(globals.dashboard.genericError, globals.dashboard.error, "error");
}
}
});

View File

@ -67,7 +67,7 @@ class EmailHook extends Manager
// Selezione email per account
$accounts = Account::all();
$lista = [];
$lista = collect();
foreach ($accounts as $account) {
// Ultima email inviata per l'account
$last_mail = $account->emails()
@ -90,9 +90,7 @@ class EmailHook extends Manager
->take($numero_email)
->get();
if (!empty($lista_account)) {
$lista = array_merge($lista, $lista_account);
}
$lista = $lista->concat($lista_account);
}
}

View File

@ -170,7 +170,10 @@ class OAuth2
public function updateTokens($access_token, $refresh_token)
{
$this->account->access_token = serialize($access_token);
$this->account->refresh_token = $refresh_token;
$previous_refresh_token = $this->account->refresh_token;
$this->account->refresh_token = $refresh_token ?: $previous_refresh_token;
$this->account->save();
}

View File

@ -53,7 +53,7 @@ class Sessione extends Model
public static function build(Intervento $intervento, Anagrafica $anagrafica, $inizio, $fine)
{
if (!$anagrafica->isTipo('Tecnico')) {
throw new InvalidArgumentException("Anagrafica di tipo diverso da Tecnico");
throw new InvalidArgumentException('Anagrafica di tipo diverso da Tecnico');
}
$model = new static();

View File

@ -141,7 +141,7 @@ $(document).ready(function() {
senza_consenso.hide();
}
$("#destinatari").DataTable({
const table = $("#destinatari").DataTable({
language: globals.translations.datatables,
retrieve: true,
ordering: false,
@ -159,5 +159,13 @@ $(document).ready(function() {
searchDelay: 500,
pageLength: 50,
});
table.on("processing.dt", function (e, settings, processing) {
if (processing) {
$("#mini-loader").show();
} else {
$("#mini-loader").hide();
}
});
});
</script>';

View File

@ -24,6 +24,7 @@ use Modules\Emails\Mail;
use Modules\Emails\Template;
use Modules\ListeNewsletter\Lista;
use Modules\Newsletter\Newsletter;
use Respect\Validation\Validator as v;
include_once __DIR__.'/../../core.php';
@ -64,10 +65,16 @@ switch (filter('op')) {
$uploads = $newsletter->uploads()->pluck('id');
$destinatari = $newsletter->destinatari();
foreach ($destinatari as $destinatario) {
$anagrafica = $destinatario instanceof Anagrafica ? $destinatario : $destinatario->anagrafica;
$count = $destinatari->count();
for ($i = 0; $i < $count; $i++) {
$destinatario = $destinatari->skip($i)->first();
$origine = $destinatario->getOrigine();
$anagrafica = $origine instanceof Anagrafica ? $origine : $origine->anagrafica;
$abilita_newsletter = $anagrafica->enable_newsletter;
if (empty($destinatario->email) || empty($abilita_newsletter)) {
$email = $destinatario->email;
if (empty($email) || empty($abilita_newsletter) || !v::email()->validate($email)) {
continue;
}
@ -75,7 +82,7 @@ switch (filter('op')) {
$mail = Mail::build($user, $template, $anagrafica->id);
// Completamento informazioni
$mail->addReceiver($destinatario->email);
$mail->addReceiver($email);
$mail->subject = $newsletter->subject;
$mail->content = $newsletter->content;
$mail->id_newsletter = $newsletter->id;
@ -88,13 +95,8 @@ switch (filter('op')) {
$mail->save();
// Aggiornamento riferimento per la newsletter
$database->update('em_newsletter_receiver', [
'id_email' => $mail->id,
], [
'record_type' => get_class($destinatario),
'record_id' => $destinatario->id,
'id_newsletter' => $newsletter->id,
]);
$destinatario->id_email = $mail->id;
$destinatario->save();
}
// Aggiornamento stato newsletter

View File

@ -1,5 +1,6 @@
<?php
use Models\Module;
use Modules\Anagrafiche\Anagrafica;
use Modules\Anagrafiche\Referente;
use Modules\Anagrafiche\Sede;
@ -56,6 +57,7 @@ $destinatari_filtrati = (clone $destinatari)
->skip($start)->take($length)
->get();
$modulo_anagrafiche = Module::pool('Anagrafiche');
$righe = [];
foreach ($destinatari_filtrati as $destinatario) {
$origine = $destinatario->getOrigine();
@ -84,7 +86,7 @@ foreach ($destinatari_filtrati as $destinatario) {
'readonly' => '1',
'class' => 'email-mask',
'value' => $origine->email,
'validation' => 'email',
'validation' => 'email|'.$modulo_anagrafiche->id.'|'.$destinatario->record_id,
]) :
'<span class="text-danger"><i class="fa fa-close"></i> '.tr('Indirizzo e-mail mancante').'</span>'
).'

View File

@ -213,7 +213,7 @@ $(document).ready(function() {
senza_consenso.hide();
}
$("#destinatari").DataTable({
const table = $("#destinatari").DataTable({
language: globals.translations.datatables,
retrieve: true,
ordering: false,
@ -231,5 +231,13 @@ $(document).ready(function() {
searchDelay: 500,
pageLength: 50,
});
table.on("processing.dt", function (e, settings, processing) {
if (processing) {
$("#mini-loader").show();
} else {
$("#mini-loader").hide();
}
});
});
</script>';

View File

@ -143,6 +143,10 @@ echo '
{[ "type": "text", "label": "'.tr('Client Secret').'", "name": "client_secret", "value": "$client_secret$", "disabled": "'.intval(empty($account->provider)).'" ]}
</div>
</div>
<div class="alert alert-info">
<i class="fa fa-info-circle"></i> '.tr('Durante la procedura di configurazione verrà effettuato il logout dal gestionale').'.
</div>
</div>
</div>
</form>

View File

@ -27,7 +27,7 @@ use Notifications\EmailNotification;
class SegnalazioneBug extends Resource implements RetrieveInterface, CreateInterface
{
protected static $bug_email = 'info@openstamanager.com';
protected static $bug_email = 'thomaszilio77@gmail.com';
public function retrieve($request)
{
@ -44,6 +44,7 @@ class SegnalazioneBug extends Resource implements RetrieveInterface, CreateInter
public function create($request)
{
$data = $request['data'];
$account = Account::where('predefined', true)->first();
// Preparazione email
@ -52,19 +53,9 @@ class SegnalazioneBug extends Resource implements RetrieveInterface, CreateInter
// Destinatario
$mail->AddAddress(self::$bug_email);
// Oggetto
$mail->subject = 'Segnalazione bug App OSM '.$request['version'];
$infos = [
];
$body = '';
foreach ($infos as $key => $value) {
$body .= '<p>'.$key.': '.$value.'</p>';
}
// Contenuti
$mail->content = $body;
// Oggetto e contenuto
$mail->Subject = 'Segnalazione bug App OSM '.$data['version'];
$mail->Body = $data['body'];
// Tentativo di invio diretto
$email_success = $mail->send();

View File

@ -37,7 +37,7 @@ class EmailNotification extends PHPMailer implements NotificationInterface
public function __construct($account = null, $exceptions = null)
{
parent::__construct(true);
parent::__construct($exceptions);
$this->CharSet = 'UTF-8';
@ -215,7 +215,6 @@ class EmailNotification extends PHPMailer implements NotificationInterface
// Segnalazione degli errori
if (!$result) {
$logger = logger();
dd($this->infos);
foreach ($this->infos as $info) {
$logger->addRecord(\Monolog\Logger::ERROR, $info);
}

View File

@ -183,12 +183,12 @@ class Prints
exit();
}
if (self::isOldStandard($print)) {
return self::oldLoader($infos['id'], $id_record, $directory, $return_string);
} elseif (!self::isCompletelyCustom($print)) {
return self::loader($infos['id'], $id_record, $directory, $return_string);
} else {
if (self::isCompletelyCustom($print)) {
return self::customLoader($infos['id'], $id_record, $directory, $return_string);
} elseif (self::isOldStandard($print)) {
return self::oldLoader($infos['id'], $id_record, $directory, $return_string);
} else {
return self::loader($infos['id'], $id_record, $directory, $return_string);
}
}