mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-09 08:08:39 +01:00
Merge branch 'master' of https://github.com/devcode-it/openstamanager
This commit is contained in:
commit
061c0ce46f
@ -25,6 +25,10 @@
|
||||
|
||||
use HTMLBuilder\HTMLBuilder;
|
||||
use Models\OperationLog;
|
||||
use Symfony\Component\Filesystem\Exception\IOException;
|
||||
use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
use Util\FileSystem;
|
||||
|
||||
/**
|
||||
* Esegue il redirect.
|
||||
@ -71,12 +75,12 @@ function sanitizeFilename($filename)
|
||||
function delete($files)
|
||||
{
|
||||
// Filesystem Symfony
|
||||
$fs = new Symfony\Component\Filesystem\Filesystem();
|
||||
$fs = new SymfonyFilesystem();
|
||||
|
||||
// Eliminazione
|
||||
try {
|
||||
$fs->remove($files);
|
||||
} catch (Symfony\Component\Filesystem\Exception\IOException $e) {
|
||||
} catch (IOException $e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -110,7 +114,7 @@ function copyr($source, $destination, $ignores = [])
|
||||
return false;
|
||||
}
|
||||
|
||||
$files = Symfony\Component\Finder\Finder::create()
|
||||
$files = Finder::create()
|
||||
->files()
|
||||
->exclude((array) $ignores['dirs'])
|
||||
->ignoreDotFiles(false)
|
||||
@ -124,14 +128,17 @@ function copyr($source, $destination, $ignores = [])
|
||||
$result = true;
|
||||
|
||||
// Filesystem Symfony
|
||||
$fs = new Symfony\Component\Filesystem\Filesystem();
|
||||
$fs = new SymfonyFilesystem();
|
||||
|
||||
$fs->chmod($destination, 0777, 0000, true);
|
||||
|
||||
foreach ($files as $file) {
|
||||
$filename = rtrim($destination, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$file->getRelativePathname();
|
||||
|
||||
// Copia
|
||||
// Copia effettiva del file
|
||||
try {
|
||||
$fs->copy($file, $filename);
|
||||
} catch (Symfony\Component\Filesystem\Exception\IOException $e) {
|
||||
$fs->copy($file, $filename, true);
|
||||
} catch (IOException $e) {
|
||||
$result = false;
|
||||
}
|
||||
}
|
||||
|
@ -21,12 +21,15 @@ namespace Modules\Articoli\Import;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Importer\CSVImporter;
|
||||
use Models\Upload;
|
||||
use Modules;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Anagrafiche\Sede;
|
||||
use Modules\Articoli\Articolo;
|
||||
use Modules\Articoli\Categoria;
|
||||
use Modules\Iva\Aliquota;
|
||||
use Plugins\ListinoClienti\DettaglioPrezzo;
|
||||
use Uploads;
|
||||
|
||||
/**
|
||||
* Struttura per la gestione delle operazioni di importazione (da CSV) degli Articoli.
|
||||
@ -43,6 +46,14 @@ class CSV extends CSVImporter
|
||||
'label' => 'Codice',
|
||||
'primary_key' => true,
|
||||
],
|
||||
[
|
||||
'field' => 'immagine',
|
||||
'label' => 'Immagine',
|
||||
'names' => [
|
||||
'Immagine',
|
||||
'Foto',
|
||||
],
|
||||
],
|
||||
[
|
||||
'field' => 'descrizione',
|
||||
'label' => 'Descrizione',
|
||||
@ -210,6 +221,8 @@ class CSV extends CSVImporter
|
||||
{
|
||||
$database = database();
|
||||
$primary_key = $this->getPrimaryKey();
|
||||
$url = $record['immagine'];
|
||||
unset($record['immagine']);
|
||||
|
||||
// Fix per campi con contenuti derivati da query implicite
|
||||
if (!empty($record['id_fornitore'])) {
|
||||
@ -316,6 +329,34 @@ class CSV extends CSVImporter
|
||||
$articolo->movimenta($qta_movimento, tr('Movimento da importazione'), new Carbon(), false, [
|
||||
'idsede' => $id_sede,
|
||||
]);
|
||||
|
||||
//Gestione immagine
|
||||
if (!empty($url)) {
|
||||
$file_content = file_get_contents($url);
|
||||
|
||||
if (!empty($file_content)) {
|
||||
$name = 'immagine_'.$articolo->id.'.'.Upload::getExtensionFromMimeType($file_content);
|
||||
|
||||
$upload = Uploads::upload($file_content, [
|
||||
'name' => 'Immagine',
|
||||
'category' => 'Immagini',
|
||||
'original_name' => $name,
|
||||
'id_module' => Modules::get('Articoli')['id'],
|
||||
'id_record' => $articolo->id,
|
||||
], [
|
||||
'thumbnails' => true,
|
||||
]);
|
||||
$filename = $upload->filename;
|
||||
|
||||
if (!empty($filename)) {
|
||||
$database->update('mg_articoli', [
|
||||
'immagine' => $filename,
|
||||
], [
|
||||
'id' => $articolo->id,
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getExample()
|
||||
|
@ -317,7 +317,6 @@ switch (filter('op')) {
|
||||
$max_number = $informazioni['maxNumber'];
|
||||
$avviso_numero = !empty($max_number) && floatval($history[0]['number']) > 0.9 * $max_number;
|
||||
|
||||
|
||||
// Formattazione dei contenuti dello storico
|
||||
foreach ($history as $key => $value) {
|
||||
$history[$key]['size'] = (($history[$key]['size']) ? Filesystem::formatBytes($value['size']) : '-');
|
||||
|
@ -25,16 +25,16 @@ include_once __DIR__.'/../../core.php';
|
||||
// Informazioni sui servizi attivi
|
||||
echo '
|
||||
<div class="row">';
|
||||
|
||||
$limite_scadenze = (new Carbon())->addDays(60);
|
||||
$days = 60;
|
||||
$limite_scadenze = (new Carbon())->addDays($days);
|
||||
if (Services::isEnabled()) {
|
||||
echo '
|
||||
<!-- Informazioni sui Servizi attivi -->
|
||||
<div class="col-md-12 col-lg-6">
|
||||
<div class="box box-success">
|
||||
<div class="box box-primary">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">
|
||||
'.tr('Servizi attivi').'
|
||||
'.tr('Servizi').'
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
@ -43,12 +43,12 @@ if (Services::isEnabled()) {
|
||||
$servizi = Services::getServiziAttivi()->flatten(1);
|
||||
if (!$servizi->isEmpty()) {
|
||||
echo '
|
||||
<table class="table table-striped table-hover">
|
||||
<table class="box-body table table-striped table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="50%">'.tr('Nome').'</th>
|
||||
<th>'.tr('Tipo').'</th>
|
||||
<th>'.tr('Nome').'</th>
|
||||
<th>'.tr('Scadenza').'</th>
|
||||
<th width="30%">'.tr('Scadenza').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -57,9 +57,9 @@ if (Services::isEnabled()) {
|
||||
$scadenza = Carbon::parse($servizio['data_conclusione']);
|
||||
|
||||
echo '
|
||||
<tr class="'.($scadenza->lessThan($limite_scadenze) ? 'info' : '').'">
|
||||
<td>'.$servizio['sottocategoria'].'</td>
|
||||
<tr class="'.($scadenza->lessThan(Carbon::now()) ? 'danger' : ($scadenza->lessThan($limite_scadenze) ? 'warning' : '')).'">
|
||||
<td>'.$servizio['codice'].' - '.$servizio['nome'].'</td>
|
||||
<td>'.$servizio['sottocategoria'].'</td>
|
||||
<td>'.dateFormat($scadenza).' ('.$scadenza->diffForHumans().')</td>
|
||||
</tr>';
|
||||
}
|
||||
@ -84,7 +84,7 @@ if (Services::isEnabled()) {
|
||||
<div class="box box-primary">
|
||||
<div class="box-header">
|
||||
<h3 class="box-title">
|
||||
'.tr('Risorse Services').'
|
||||
'.tr('Risorse').'
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
@ -94,31 +94,39 @@ if (Services::isEnabled()) {
|
||||
$risorse_attive = Services::getRisorseAttive();
|
||||
if (!$risorse_attive->isEmpty()) {
|
||||
$risorse_in_scadenza = Services::getRisorseInScadenza($limite_scadenze);
|
||||
$risorse_scadute = Services::getRisorseScadute();
|
||||
|
||||
if (!$risorse_in_scadenza->isEmpty() || !$risorse_scadute->isEmpty() ) {
|
||||
|
||||
if (!$risorse_in_scadenza->isEmpty()){
|
||||
echo '
|
||||
<div class="alert alert-warning" role="alert"> <i class="fa fa-warning"></i> '.tr('Attenzione, _NUM_ risorse sono in scadenza:', [
|
||||
|
||||
'_NUM_' => $risorse_in_scadenza->count()
|
||||
|
||||
]).'</div>';
|
||||
|
||||
}else{
|
||||
|
||||
echo '
|
||||
<div class="alert alert-success" role="alert"> <i class="fa fa-check"></i> '.tr('Bene, tutte le risorse sono attive e non presentano avvisi:', [
|
||||
'_NUM_' => $risorse_attive->count()
|
||||
<div class="alert alert-warning" role="alert"> <i class="fa fa-clock-o"></i> '.tr('Attenzione, _NUM_ risorse sono in scadenza o stanno per esaurire i crediti:', [
|
||||
'_NUM_' => $risorse_in_scadenza->count(),
|
||||
]).'</div>';
|
||||
|
||||
}
|
||||
|
||||
if (!$risorse_scadute->isEmpty()){
|
||||
echo '
|
||||
<table class="table table-striped table-hover">
|
||||
<div class="alert alert-danger" role="alert"> <i class="fa fa-exclamation-triangle"></i> '.tr('Attenzione, _NUM_ risorse sono scadute o hanno esaurito i crediti:', [
|
||||
'_NUM_' => $risorse_scadute->count(),
|
||||
]).'</div>';
|
||||
}
|
||||
|
||||
} else {
|
||||
echo '
|
||||
<div class="alert alert-success" role="alert"> <i class="fa fa-check-circle"></i> '.tr('Bene, tutte le risorse sono attive e non presentano avvisi:', [
|
||||
'_NUM_' => $risorse_attive->count(),
|
||||
]).'</div>';
|
||||
}
|
||||
|
||||
echo '
|
||||
<table class="box-body table table-striped table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="50%">'.tr('Nome').'</th>
|
||||
<th>'.tr('Crediti').'</th>
|
||||
<th>'.tr('Scadenza').'</th>
|
||||
<th width="30%">'.tr('Scadenza').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@ -127,26 +135,23 @@ if (Services::isEnabled()) {
|
||||
foreach ($risorse_attive as $servizio) {
|
||||
$scadenza = Carbon::parse($servizio['expiration_at']);
|
||||
echo '
|
||||
<tr>
|
||||
<tr class="'.($scadenza->lessThan(Carbon::now()) ? 'danger' : ($scadenza->lessThan($limite_scadenze) ? 'warning' : '')).'">
|
||||
<td>'.$servizio['name'].'</td>
|
||||
<td>'.(($servizio['credits'] < 100 && $servizio['credits']) ? '<b><i class="fa fa-icon fa-warning" ></i>' : '').(($servizio['credits']) ? $servizio['credits'] : '-').(($servizio['credits'] < 100 && $servizio['credits']) ? '</b>' : '').'</td>
|
||||
<td>'.((Carbon::now()->diffInDays($scadenza, false)<60 && $scadenza)? '<b><i class="fa fa-icon fa-warning" ></i>': '' ).dateFormat($scadenza).' ('.$scadenza->diffForHumans().')'.((Carbon::now()->diffInDays($scadenza, false)<60 && $scadenza)? '</b>': '' ).'</td>
|
||||
<td>'.((Carbon::now()->diffInDays($scadenza, false) < $days && $scadenza) ? '<b><i class="fa fa-icon fa-warning" ></i>' : '').dateFormat($scadenza).' ('.$scadenza->diffForHumans().')'.((Carbon::now()->diffInDays($scadenza, false) < $days && $scadenza) ? '</b>' : '').'</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</tbody>
|
||||
</table><hr>';
|
||||
|
||||
|
||||
</table></div></div>';
|
||||
|
||||
//Il servizio Fatturazione Elettronica deve essere presente per visualizzare le Statistiche su Fatture Elettroniche
|
||||
if (Services::getRisorseAttive()->where('name', 'Fatturazione Elettronica')->count()) {
|
||||
echo '
|
||||
|
||||
<div class="panel panel-info">
|
||||
|
||||
<div class="panel-heading" > <i class="fa fa-file"></i> '.tr('Statistiche su Fatture Elettroniche').'</div>
|
||||
<div class="panel-heading" > <i class="fa fa-bar-chart"></i> '.tr('Statistiche su Fatture Elettroniche').'</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
@ -168,7 +173,7 @@ if (Services::isEnabled()) {
|
||||
</div>
|
||||
|
||||
|
||||
<table class="table table-striped">
|
||||
<table class="box-body table table-striped table-hover table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>'.tr('Anno').'</th>
|
||||
@ -189,7 +194,7 @@ if (Services::isEnabled()) {
|
||||
</thead>
|
||||
|
||||
<tbody id="elenco-fe">
|
||||
<tr class="info">
|
||||
<tr style="background-color:#CCCCCC;" >
|
||||
<td>'.tr('Totale').'</td>
|
||||
<td id="fe_numero"></td>
|
||||
<td id="fe_spazio"></td>
|
||||
@ -203,7 +208,6 @@ if (Services::isEnabled()) {
|
||||
aggiornaStatisticheFE();
|
||||
});
|
||||
</script>';
|
||||
|
||||
}
|
||||
} else {
|
||||
echo '
|
||||
@ -213,9 +217,6 @@ if (Services::isEnabled()) {
|
||||
}
|
||||
|
||||
echo '
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>';
|
||||
} else {
|
||||
/*
|
||||
@ -311,7 +312,7 @@ function aggiornaStatisticheFE(){
|
||||
const data = response.history[i];
|
||||
if (data["year"] == '.date('Y').'){
|
||||
|
||||
var highlight = "<tr style=\"background-color:#FFFEEE;\" >";
|
||||
var highlight = "<tr class=\"info\" >";
|
||||
var number = data["number"];
|
||||
|
||||
if (response.maxNumber>0 && response.maxNumber)
|
||||
|
@ -34,23 +34,46 @@ class ServicesHook extends Manager
|
||||
// Elaborazione dei servizi in scadenza
|
||||
$servizi_in_scadenza = Services::getServiziInScadenza($limite_scadenze);
|
||||
if (!$servizi_in_scadenza->isEmpty()) {
|
||||
$message .= tr('I seguenti servizi sono in scadenza: _LIST_', [
|
||||
'_LIST_' => implode(', ', $servizi_in_scadenza->pluck('nome')->all()),
|
||||
]).'. ';
|
||||
$message .= '<i class="fa fa-clock-o text-warning"> </i> ';
|
||||
$message .= tr('I seguenti servizi sono in scadenza:<ul><li> _LIST_', [
|
||||
'_LIST_' => implode('</li><li>', $servizi_in_scadenza->pluck('nome')->all()),
|
||||
]).'</ul>';
|
||||
}
|
||||
|
||||
|
||||
// Elaborazione delle risorse Services scadute
|
||||
$risorse_scadute = Services::getRisorseScadute();
|
||||
if (!$risorse_scadute->isEmpty()) {
|
||||
$message .= '<i class="fa fa-exclamation-triangle text-danger"> </i> ';
|
||||
$message .= tr('Le seguenti risorse sono scadute:<ul><li> _LIST_', [
|
||||
'_LIST_' => implode('</li><li>', $risorse_scadute->pluck('name')->all()),
|
||||
]).'</ul>';
|
||||
}
|
||||
|
||||
// Elaborazione dei servizi scaduti
|
||||
$servizi_scaduti = Services::getServiziScaduti();
|
||||
if (!$servizi_scaduti->isEmpty()) {
|
||||
$message .= '<i class="fa fa-exclamation-triangle text-danger"> </i> ';
|
||||
$message .= tr('I seguenti servizi sono scaduti:<ul><li> _LIST_', [
|
||||
'_LIST_' => implode('</li><li>', $servizi_scaduti->pluck('nome')->all()),
|
||||
]).'</ul>';
|
||||
}
|
||||
|
||||
|
||||
// Elaborazione delle risorse Services in scadenza
|
||||
$risorse_in_scadenza = Services::getRisorseInScadenza($limite_scadenze);
|
||||
if (!$risorse_in_scadenza->isEmpty()) {
|
||||
$message .= tr('Le seguenti risorse Services sono in scadenza: _LIST_', [
|
||||
'_LIST_' => implode(', ', $risorse_in_scadenza->pluck('name')->all()),
|
||||
]);
|
||||
$message .= '<i class="fa fa-clock-o text-warning"> </i> ';
|
||||
$message .= tr('Le seguenti risorse sono in scadenza:<ul><li> _LIST_', [
|
||||
'_LIST_' => implode('</li><li>', $risorse_in_scadenza->pluck('name')->all()),
|
||||
]).'</ul>';
|
||||
}
|
||||
|
||||
|
||||
$module = Module::pool('Stato dei servizi');
|
||||
|
||||
return [
|
||||
'icon' => 'fa fa-refresh text-warning',
|
||||
'icon' => null,
|
||||
'message' => $message,
|
||||
'link' => base_path().'/controller.php?id_module='.$module->id,
|
||||
'show' => Services::isEnabled() && !empty($message),
|
||||
|
@ -21,9 +21,9 @@ namespace Plugins\ImportFE;
|
||||
|
||||
use Modules;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Banche\Banca;
|
||||
use Modules\Anagrafiche\Nazione;
|
||||
use Modules\Anagrafiche\Tipo as TipoAnagrafica;
|
||||
use Modules\Banche\Banca;
|
||||
use Modules\Fatture\Fattura;
|
||||
use Modules\Fatture\Stato as StatoFattura;
|
||||
use Modules\Fatture\Tipo as TipoFattura;
|
||||
|
@ -300,7 +300,6 @@ class FatturaOrdinaria extends FatturaElettronica
|
||||
$tipo = null;
|
||||
$sconto_unitario = null;
|
||||
$obj->save();
|
||||
|
||||
}
|
||||
|
||||
// Ricaricamento della fattura
|
||||
|
@ -86,7 +86,21 @@ class Services
|
||||
return self::getServiziAttivi()
|
||||
->flatten(1)
|
||||
->filter(function ($item) use ($limite_scadenze) {
|
||||
return (isset($item['data_conclusione']) && Carbon::parse($item['data_conclusione'])->lessThan($limite_scadenze));
|
||||
return isset($item['data_conclusione']) && Carbon::parse($item['expiration_at'])->greaterThan(Carbon::now()) && Carbon::parse($item['data_conclusione'])->lessThan($limite_scadenze);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce i servizi scaduti.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public static function getServiziScaduti()
|
||||
{
|
||||
return self::getServiziAttivi()
|
||||
->flatten(1)
|
||||
->filter(function ($item) use ($limite_scadenze) {
|
||||
return isset($item['data_conclusione']) && Carbon::parse($item['data_conclusione'])->lessThan(Carbon::now());
|
||||
});
|
||||
}
|
||||
|
||||
@ -123,11 +137,27 @@ class Services
|
||||
{
|
||||
return self::getRisorseAttive()
|
||||
->filter(function ($item) use ($limite_scadenze) {
|
||||
return (isset($item['expiration_at']) && Carbon::parse($item['expiration_at'])->lessThan($limite_scadenze))
|
||||
return (isset($item['expiration_at']) && Carbon::parse($item['expiration_at'])->greaterThan(Carbon::now()) && Carbon::parse($item['expiration_at'])->lessThan($limite_scadenze))
|
||||
|| (isset($item['credits']) && $item['credits'] < 100);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restituisce le risorse scadute per assenza di crediti oppure per data di fine prossima.
|
||||
*
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public static function getRisorseScadute()
|
||||
{
|
||||
return self::getRisorseAttive()
|
||||
->filter(function ($item) use ($limite_scadenze) {
|
||||
return (isset($item['expiration_at']) && Carbon::parse($item['expiration_at'])->lessThan(Carbon::now()))
|
||||
|| (isset($item['credits']) && $item['credits'] < 0);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Effettua una richiesta a Services.
|
||||
*
|
||||
|
@ -38,6 +38,15 @@ class Upload extends Model
|
||||
'htm' => 'text/html',
|
||||
];
|
||||
|
||||
/** @var array Elenco delle estensioni file per mime type */
|
||||
protected static $extension_association = [
|
||||
'image/gif' => 'gif',
|
||||
'image/bmp' => 'bmp',
|
||||
'image/jpg' => 'jpg',
|
||||
'image/jpeg' => 'jpg',
|
||||
'image/png' => 'png',
|
||||
];
|
||||
|
||||
protected $table = 'zz_files';
|
||||
|
||||
protected $file_info;
|
||||
@ -211,6 +220,18 @@ class Upload extends Model
|
||||
return in_array($this->extension, $list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function getExtensionFromMimeType($file_content)
|
||||
{
|
||||
$finfo = finfo_open();
|
||||
$mime_type = finfo_buffer($finfo, $file_content, FILEINFO_MIME_TYPE);
|
||||
finfo_close($finfo);
|
||||
|
||||
return self::$extension_association[$mime_type];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
@ -17,6 +17,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Symfony\Component\Filesystem\Filesystem as SymfonyFilesystem;
|
||||
|
||||
/**
|
||||
* Classe dedicata alla gestione delle procedure di aggiornamento del database del progetto.
|
||||
*
|
||||
@ -208,6 +210,11 @@ class Update
|
||||
\Models\Cache::pool('Ultima versione di OpenSTAManager disponibile')->set(null);
|
||||
}
|
||||
|
||||
// Correzione permessi per le cartelle backup e files
|
||||
$fs = new SymfonyFilesystem();
|
||||
$fs->chmod('backup', 0777, 0000, true);
|
||||
$fs->chmod('files', 0777, 0000, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user