This commit is contained in:
MatteoPistorello 2022-10-10 11:23:21 +02:00
commit 7a54da3aa4
10 changed files with 316 additions and 22 deletions

View File

@ -27,6 +27,31 @@ class Referente extends Model
use SimpleModelTrait;
protected $table = 'an_referenti';
/**
* Crea un nuovo referente.
*
* @param string $nome
*
* @return self
*/
public static function build($idanagrafica, $nome, $idmansione, $idsede)
{
$model = new static();
$model->idanagrafica = $idanagrafica;
$model->nome = $nome;
$model->idmansione = $idmansione;
$model->idsede = $idsede;
$model->save();
return $model;
}
/**
* The attributes that aren't mass assignable.

View File

@ -135,7 +135,7 @@ if (!empty($note_accredito)) {
]);
echo '
<br>'.Modules::link('Fatture di vendita', $nota['id'], $text, $text);
<br>'.Modules::link( ($dir == 'entrata' ? 'Fatture di vendita' : 'Fatture di acquisto' ), $nota['id'], $text, $text);
}
echo '
</div>';

View File

@ -446,7 +446,7 @@ $(document).ready(function() {
data: {
labels: months,
datasets: [
'.$dataset.'
'.($dataset? :'{ label: "", backgroundColor: "transparent", data: [ 0,0,0,0,0,0,0,0,0,0,0,0 ] }').'
]
},
options: {
@ -521,7 +521,6 @@ INNER JOIN an_tipianagrafiche_anagrafiche ON an_anagrafiche.idanagrafica=an_tipi
INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica
WHERE an_tipianagrafiche.descrizione = "Cliente" AND co_tipidocumento.dir = "entrata" AND an_anagrafiche.created_at BETWEEN '.prepare($start).' AND '.prepare($end).' GROUP BY YEAR(an_anagrafiche.created_at), MONTH(an_anagrafiche.created_at) ORDER BY YEAR(an_anagrafiche.created_at) ASC, MONTH(an_anagrafiche.created_at) ASC');
$clienti = Stats::monthly($clienti, $start, $end);
//Random color
$background = '#'.dechex(rand(256, 16777215));

View File

@ -267,6 +267,48 @@ switch (filter('op')) {
break;
case 'disabilita-hook':
$id = filter('id');
// Abilitazione del widget indicato
$database->table('zz_hooks')
->where('id', '=', $id)
->update(['enabled' => 0]);
// Messaggio informativo
$hook = $database->table('zz_hooks')
->where('id', '=', $id)
->first();
flash()->info(tr('Hook "_NAME_" disabilitato!', [
'_NAME_' => $hook->name,
]));
echo json_encode([]);
break;
case 'abilita-hook':
$id = filter('id');
// Abilitazione del widget indicato
$database->table('zz_hooks')
->where('id', '=', $id)
->update(['enabled' => 1]);
// Messaggio informativo
$hook = $database->table('zz_hooks')
->where('id', '=', $id)
->first();
flash()->info(tr('Hook "_NAME_" abilitato!', [
'_NAME_' => $hook->name,
]));
echo json_encode([]);
break;
case 'sizes':
$results = [];
@ -279,13 +321,17 @@ switch (filter('op')) {
];
foreach ($dirs as $dir => $description) {
$size = FileSystem::folderSize($dir, ['htaccess','gitkeep','ini','xml']);
$excluded_extensions = ['htaccess','gitkeep'];
//Tutte le cartelle che non prevedono log in zz_files
$excluded_dir = [DOCROOT.'\files\impianti', DOCROOT.'\files\importFE', DOCROOT.'\files\exportFE', DOCROOT.'\files\receiptFE', DOCROOT.'\files\temp'];
$size = FileSystem::folderSize($dir, array_merge($excluded_extensions,$excluded_dir));
$results[] = [
'description' => $description,
'size' => $size,
'formattedSize' => FileSystem::formatBytes($size),
'count' => FileSystem::fileCount($dir, ['htaccess','gitkeep','ini','xml']) ?: 0,
'count' => FileSystem::fileCount($dir, array_merge($excluded_extensions,$excluded_dir)) ?: 0,
'dbSize' => ($description == 'Allegati') ? $dbo->fetchOne('SELECT SUM(`size`) AS dbsize FROM zz_files')['dbsize'] : 0,
'dbCount' => ($description == 'Allegati') ? $dbo->fetchOne('SELECT COUNT(`id`) AS dbcount FROM zz_files')['dbcount'] : 0,
'dbExtensions' => ($description == 'Allegati') ? $dbo->fetchArray("SELECT SUBSTRING_INDEX(filename, '.', -1) AS extension, COUNT(*) AS num FROM zz_files GROUP BY extension ORDER BY num DESC LIMIT 10") : 0,

View File

@ -264,7 +264,7 @@ echo '
</div>
</div>';
// Widgets
// Widgets + Hooks
echo '
<div class="col-md-12 col-lg-6">
<div class="box box-info">
@ -277,6 +277,18 @@ echo '
<div class="box-body" id="widget">
</div>
</div>
<div class="box box-info">
<div class="box-header">
<h3 class="box-title">
'.tr('Hooks disponibili').'
</h3>
</div>
<div class="box-body" id="hook">
</div>
</div>
</div>
</div>
@ -422,9 +434,23 @@ function caricaElencoWidget() {
});
}
function caricaElencoHooks() {
let container = $("#hook");
localLoading(container, true);
return $.get("'.$structure->fileurl('elenco-hooks.php').'?id_module='.$id_module.'", function(data) {
container.html(data);
localLoading(container, false);
init();
});
}
$(document).ready(function() {
caricaElencoModuli();
caricaElencoWidget();
caricaElencoHooks();
init();
});

View File

@ -0,0 +1,193 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
include_once __DIR__.'/../../core.php';
echo '
<table class="table table-hover table-condensed">
<thead>
<tr>
<th>'.tr('Nome').'</th>
<th class="text-center">'.tr('Ultima esecuzione').'</th>
<th class="text-center">'.tr('Stato').'</th>
</tr>
</thead>';
$hooks = $dbo->fetchArray('SELECT zz_hooks.*, zz_modules.name AS modulo
FROM zz_hooks
INNER JOIN zz_modules ON zz_hooks.id_module = zz_modules.id
ORDER BY `id_module` ASC, `zz_hooks`.`id` ASC');
$gruppi = collect($hooks)->groupBy('modulo');
foreach ($gruppi as $modulo => $hooks) {
echo '
<thead>
<tr>
<th colspan="4">'.$modulo.'</th>
</tr>
</thead>
<tbody>';
foreach ($hooks as $hook) {
$class = $hook['enabled'] ? 'success' : 'warning';
$nome_tipo = 'hook';
echo '
<tr class="'.$class.'" data-id="'.$hook['id'].'" data-nome='.json_encode($hook['name']).'>
<td>
'.$hook['name'].(!empty($hook['help']) ? '
<i class="tip fa fa-question-circle-o" title="'.$hook['help'].'"</i>' : '').'
</td>
<td class="text-center">
'.Translator::timestampToLocale($hook['processing_at']).'
</td>
<td class="text-center">';
// Possibilità di disabilitare o abilitare il hook
if ($hook['enabled']) {
echo '
<div class="tip" data-toggle="tooltip" title="'.tr('Questo _TYPE_ è abilitato: clicca qui per disabilitarlo', [
'_TYPE_' => $nome_tipo,
]).'">
<button type="button" class="btn btn-warning btn-xs" onclick="disabilitaHook(this)">
<i class="fa fa-power-off" title="'.tr('Disabilita').'"></i>
</button>
</div>';
} else {
echo '
<div class="tip" data-toggle="tooltip" title="'.tr('Questo _TYPE_ è disabilitato: clicca qui per abilitarlo', [
'_TYPE_' => $nome_tipo,
]).'">
<button type="button" class="btn btn-success btn-xs" onclick="abilitaHook(this)">
<i class="fa fa-plug" title="'.tr('Abilita').'"></i>
</button>
</div>';
}
echo '
</td>
</tr>';
}
echo '
</tbody>';
}
echo '
</table>
<script>
function disabilitaHook(button){
const riga = $(button).closest("tr");
const id = riga.data("id");
const nome = riga.data("nome");
const nome_tipo = "hook";
swal({
title: "'.tr('Disabilitare il _TYPE_?', [
'_TYPE_' => '" + nome_tipo + "',
]).'",
html: "'.tr('Sei sicuro di voler disabilitare il _TYPE_ _NAME_?', [
'_TYPE_' => '" + nome_tipo + "',
'_NAME_' => '" + nome + "',
]).'",
type: "warning",
showCancelButton: true,
confirmButtonText: "'.tr('Continua').'"
}).then(function (result) {
let restore = buttonLoading(button);
$.ajax({
url: globals.rootdir + "/actions.php",
type: "POST",
dataType: "JSON",
data: {
id_module: globals.id_module,
op: "disabilita-hook",
id: id,
},
success: function (response) {
caricaElencoHooks();
renderMessages();
},
error: function() {
buttonRestore(button, restore);
swal({
type: "error",
title: globals.translations.ajax.error.title,
text: globals.translations.ajax.error.text,
});
}
});
})
}
function abilitaHook(button) {
const riga = $(button).closest("tr");
const id = riga.data("id");
const nome = riga.data("nome");
const nome_tipo = "hook";
swal({
title: "'.tr('Abilitare il _TYPE_?', [
'_TYPE_' => '" + nome_tipo + "',
]).'",
html: "'.tr('Sei sicuro di voler abilitare il _TYPE_ _NAME_?', [
'_TYPE_' => '" + nome_tipo + "',
'_NAME_' => '" + nome + "',
]).'",
type: "warning",
showCancelButton: true,
confirmButtonText: "'.tr('Continua').'"
}).then(function (result) {
let restore = buttonLoading(button);
$.ajax({
url: globals.rootdir + "/actions.php",
type: "POST",
dataType: "JSON",
data: {
id_module: globals.id_module,
op: "abilita-hook",
id: id,
},
success: function (response) {
caricaElencoHooks();
renderMessages();
},
error: function() {
buttonRestore(button, restore);
swal({
type: "error",
title: globals.translations.ajax.error.title,
text: globals.translations.ajax.error.text,
});
}
});
})
}
</script>';

View File

@ -24,7 +24,7 @@ echo '
<thead>
<tr>
<th>'.tr('Nome').'</th>
<th>'.tr('Posizione').'</th>
<th>'.tr('Ubicazione').'</th>
<th>'.tr('Stato').'</th>
<th>'.tr('Posizione').'</th>
</tr>

View File

@ -72,7 +72,7 @@ function crea_grafico(values){
if (element.count<element.dbCount){
var diff = (element.dbCount-element.count);
$("#message").append("<div class=\"label label-warning\" ><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+diff+" files non trovati sul disco per allegati.</div><br>");
$("#message").append("<div class=\"label label-warning\" ><i class=\"fa fa-exclamation-triangle\" aria-hidden=\"true\"></i> "+diff+" files non trovati per allegati.</div><br>");
}
}

View File

@ -19,26 +19,30 @@
include_once __DIR__.'/../../core.php';
use Modules\Anagrafiche\Referente;
$operazione = filter('op');
switch ($operazione) {
case 'addreferente':
if (!empty(post('nome'))) {
$opt_out_newsletter = post('disable_newsletter');
$dbo->insert('an_referenti', [
'idanagrafica' => $id_parent,
'nome' => post('nome'),
'idmansione' => post('idmansione'),
'telefono' => post('telefono'),
'email' => post('email'),
'idsede' => post('idsede'),
'enable_newsletter' => empty($opt_out_newsletter),
]);
$id_record = $dbo->lastInsertedID();
$nome = post('nome');
$idmansione = post('idmansione');
$idsede = post('idsede');
$opt_out_newsletter = post('disable_newsletter');
$referente = Referente::build($id_parent, $nome, $idmansione, $idsede);
$id_record = $referente->id;
$referente->telefono = post('telefono');
$referente->email = post('email');
$referente->enable_newsletter = empty($opt_out_newsletter);
$referente->save();
if (isAjaxRequest() && !empty($id_record)) {
echo json_encode(['id' => $id_record, 'text' => post('nome')]);
echo json_encode(['id' => $id_record, 'text' => $referente->nome]);
}
flash()->info(tr('Aggiunto nuovo referente!'));

View File

@ -71,7 +71,7 @@ class FileSystem
if ($path !== false && $path != '' && file_exists($path)) {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object) {
if (!in_array($object->getExtension(), $exclusions)) {
if (!in_array($object->getExtension(), $exclusions) && (!in_array($object->getPath(), $exclusions)) ) {
$total += $object->getSize();
}
}
@ -94,7 +94,8 @@ class FileSystem
if ($path !== false && $path != '' && file_exists($path)) {
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS)) as $object) {
if (!in_array($object->getExtension(), $exclusions)) {
if (!in_array($object->getExtension(), $exclusions) && (!in_array($object->getPath(), $exclusions)) ) {
++$total;
}
}