1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2025-02-20 21:40:48 +01:00

Fix minori

This commit is contained in:
Pek5892 2024-03-01 12:10:39 +01:00
parent c894c20c12
commit 685a1b7dcb
17 changed files with 79 additions and 28 deletions

View File

@ -61,13 +61,13 @@ $handler->setFormatter($formatter);
$logger->pushHandler($handler);
// Lettura della cache
$ultima_esecuzione = Cache::pool('Ultima esecuzione del cron');
$ultima_esecuzione = (new Cache())->getByName('Ultima esecuzione del cron');
$data = $ultima_esecuzione->content;
$in_esecuzione = Cache::pool('Cron in esecuzione');
$cron_id = Cache::pool('ID del cron');
$in_esecuzione = (new Cache())->getByName('Cron in esecuzione');
$cron_id = (new Cache())->getByName('ID del cron');
$disattiva = Cache::pool('Disabilita cron');
$disattiva = (new Cache())->getByName('Disabilita cron');
if ($disattiva->content || (in_array($_SERVER['HTTP_HOST'], ['localhost', '127.0.0.1']) && !$forza_cron_localhost)) {
return;
}

View File

@ -39,7 +39,7 @@ switch (filter('op')) {
}
// Salvataggio della versione nella cache
Cache::pool('Ultima versione di OpenSTAManager disponibile')->set($versione);
(new Cache())->getByName('Ultima versione di OpenSTAManager disponibile')->set($versione);
echo $versione;

View File

@ -93,7 +93,7 @@ switch (post('op')) {
if (!in_array($tecnico_presente['id_tecnico'], $tecnici_assegnati)) {
$tecnico = Anagrafica::find($tecnico_presente['id_tecnico']);
if (!empty($tecnico['email'])) {
$template = Template::pool('Notifica rimozione intervento');
$template = (new Template())->getByName('Notifica rimozione intervento');
if (!empty($template)) {
$mail = Mail::build(auth()->getUser(), $template, $intervento->id);
@ -112,7 +112,7 @@ switch (post('op')) {
$tecnico = Anagrafica::find($tecnico_assegnato);
if (!empty($tecnico['email'])) {
$template = Template::pool('Notifica intervento');
$template = (new Template())->getByName('Notifica intervento');
if (!empty($template)) {
$mail = Mail::build(auth()->getUser(), $template, $intervento->id);
@ -294,7 +294,7 @@ switch (post('op')) {
// Notifica al tecnico
if (setting('Notifica al tecnico l\'assegnazione all\'attività')) {
if (!empty($tecnico['email'])) {
$template = Template::pool('Notifica intervento');
$template = (new Template())->getByName('Notifica intervento');
if (!empty($template)) {
$mail = Mail::build(auth()->getUser(), $template, $intervento->id);
@ -917,7 +917,7 @@ switch (post('op')) {
// Notifica rimozione dell' intervento al tecnico
if (setting('Notifica al tecnico la rimozione della sessione dall\'attività')) {
if (!empty($tecnico['email'])) {
$template = Template::pool('Notifica rimozione intervento');
$template = (new Template())->getByName('Notifica rimozione intervento');
if (!empty($template)) {
$mail = Mail::build(auth()->getUser(), $template, $id_record);

View File

@ -107,7 +107,7 @@ if (!function_exists('add_tecnico')) {
// Notifica nuovo intervento al tecnico
if (setting('Notifica al tecnico l\'aggiunta della sessione nell\'attività')) {
if (!empty($anagrafica['email'])) {
$template = Template::pool('Notifica intervento');
$template = (new Template())->getByName('Notifica intervento');
if (!empty($template)) {
$mail = Mail::build(auth()->getUser(), $template, $id_intervento);

View File

@ -72,7 +72,7 @@ switch (post('op')) {
break;
case 'send-sollecito':
$template = Template::pool('Sollecito di pagamento raggruppato per anagrafica');
$template = (new Template())->getByName('Sollecito di pagamento raggruppato per anagrafica');
$list = [];
$anagrafiche = [];

View File

@ -372,7 +372,7 @@ switch (filter('op')) {
break;
case 'informazioni-fe':
$info = Cache::pool('Informazioni su spazio FE');
$info = (new Cache())->getByName('Informazioni su spazio FE');
if (!$info->isValid()) {
$response = Services::request('POST', 'informazioni_fe');
$response = Services::responseBody($response);

View File

@ -42,7 +42,7 @@ class Interaction extends Services
$result = self::getFileList($list);
// Aggiornamento cache hook
Cache::pool('Fatture Elettroniche')->set($result);
(new Cache())->getByName('Fatture Elettroniche')->set($result);
return $result;
}

View File

@ -42,7 +42,7 @@ class Interaction extends Services
$result = self::getFileList($list);
// Aggiornamento cache hook
Cache::pool('Ricevute Elettroniche')->set($result);
(new Cache())->getByName('Ricevute Elettroniche')->set($result);
return $result;
}

View File

@ -41,7 +41,7 @@ class ReceiptHook extends Manager
}
// Lettura cache
$todo_cache = Cache::pool('Ricevute Elettroniche');
$todo_cache = (new Cache())->getByName('Ricevute Elettroniche');
return !$todo_cache->isValid() || !empty($todo_cache->content);
}
@ -49,8 +49,8 @@ class ReceiptHook extends Manager
public function execute()
{
// Lettura cache
$todo_cache = Cache::pool('Ricevute Elettroniche');
$completed_cache = Cache::pool('Ricevute Elettroniche importate');
$todo_cache = (new Cache())->getByName('Ricevute Elettroniche');
$completed_cache = (new Cache())->getByName('Ricevute Elettroniche importate');
// Refresh cache
if (!$todo_cache->isValid()) {
@ -94,8 +94,8 @@ class ReceiptHook extends Manager
public function response()
{
// Lettura cache
$todo_cache = Cache::pool('Ricevute Elettroniche');
$completed_cache = Cache::pool('Ricevute Elettroniche importate');
$todo_cache = (new Cache())->getByName('Ricevute Elettroniche');
$completed_cache = (new Cache())->getByName('Ricevute Elettroniche importate');
$completed_number = (is_array($completed_cache->content) ? count($completed_cache->content) : 0);
$total_number = $completed_number + (is_array($todo_cache->content) ? count($todo_cache->content) : 0);

View File

@ -44,7 +44,7 @@ switch (post('op')) {
$utente->reset_token = secure_random_string();
$utente->save();
$template = Template::pool('Reset password');
$template = (new Template())->getByName('Reset password');
$mail = Mail::build($utente, $template, $utente->id);
$mail->addReceiver($utente->email);

View File

@ -44,22 +44,22 @@ class Task extends Resource implements RetrieveInterface, CreateInterface
$database = database();
// Rimozione della registrazione del cron attuale
$ultima_esecuzione = Cache::pool('Ultima esecuzione del cron');
$ultima_esecuzione = (new Cache())->getByName('Ultima esecuzione del cron');
$ultima_esecuzione->set(null);
// Segnalazione della chiusura al cron attuale
$cron_id = Cache::pool('ID del cron');
$cron_id = (new Cache())->getByName('ID del cron');
$cron_id->set(null);
// Rimozione dell'eventuale blocco sul cron
$disattiva = Cache::pool('Disabilita cron');
$disattiva = (new Cache())->getByName('Disabilita cron');
$disattiva->set(null);
// Salvataggio delle modifiche
$database->commitTransaction();
// Attesa della conclusione per il cron precedente
$in_esecuzione = Cache::pool('Cron in esecuzione');
$in_esecuzione = (new Cache())->getByName('Cron in esecuzione');
while ($in_esecuzione->content) {
$timestamp = (new Carbon())->addMinutes(1)->getTimestamp();
time_sleep_until($timestamp);

View File

@ -49,7 +49,7 @@ class Services
*/
public static function getInformazioni($force = false)
{
$cache = Cache::pool('Informazioni su Services');
$cache = (new Cache())->getByName('Informazioni su Services');
// Aggiornamento dei contenuti della cache
if (!$cache->isValid() || $force) {

View File

@ -30,7 +30,7 @@ abstract class CachedManager extends Manager
{
parent::__construct($hook);
$this->cache = Cache::pool($this->getCacheName());
$this->cache = (new Cache())->getByName($this->getCacheName());
}
abstract public function cacheData();

View File

@ -105,4 +105,34 @@ class Cache extends Model
{
return $query->where('expire_at', '<=', Carbon::now());
}
/**
* Ritorna l'attributo name della cache.
*
* @return string
*/
public function getNameAttribute()
{
return database()->table($this->table.'_lang')
->select('name')
->where('id_record', '=', $this->id)
->where('id_lang', '=', setting('Lingua'))
->first()->name;
}
/**
* Ritorna l'id della cache a partire dal nome.
*
* @param string $name il nome da ricercare
*
* @return \Illuminate\Support\Collection
*/
public function getByName($name)
{
return database()->table($this->table.'_lang')
->select('id_record')
->where('name', '=', $name)
->where('id_lang', '=', setting('Lingua'))
->first();
}
}

View File

@ -208,7 +208,7 @@ class Update
self::normalizeDatabase($database->getDatabaseName());
if (class_exists('\Models\Cache')) {
Models\Cache::pool('Ultima versione di OpenSTAManager disponibile')->set(null);
(new Models\Cache())->getByName('Ultima versione di OpenSTAManager disponibile')->set(null);
}
// Correzione permessi per le cartelle backup e files

View File

@ -1724,4 +1724,24 @@ ALTER TABLE `or_tipiordine`
ALTER TABLE `or_tipiordine` CHANGE `id` `id` INT NOT NULL AUTO_INCREMENT;
ALTER TABLE `or_tipiordine_lang` ADD CONSTRAINT `or_tipiordine_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `or_tipiordine`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `or_tipiordine_lang` ADD CONSTRAINT `or_tipiordine_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `or_tipiordine`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
-- Aggiunta tabella zz_cache_lang
CREATE TABLE IF NOT EXISTS `zz_cache_lang` (
`id` int NOT NULL,
`id_lang` int NOT NULL,
`id_record` int NOT NULL,
`name` VARCHAR(255) NOT NULL
);
ALTER TABLE `zz_cache_lang`
ADD PRIMARY KEY (`id`);
ALTER TABLE `zz_cache_lang`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
INSERT INTO `zz_cache_lang` (`id`, `id_lang`, `id_record`, `name`) SELECT NULL, (SELECT `id` FROM `zz_langs` WHERE `iso_code` = 'it'), `id`, `name` FROM `zz_cache`;
ALTER TABLE `zz_cache`
DROP `name`;
ALTER TABLE `zz_cache_lang` ADD CONSTRAINT `zz_cache_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `zz_cache`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;

View File

@ -154,6 +154,7 @@ return [
'or_tipiordine_lang'
'zz_api_resources',
'zz_cache',
'zz_cache_lang',
'zz_currencies',
'zz_checks',
'zz_check_user',