mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
style: formattazione stile codice
This commit is contained in:
@@ -20,8 +20,8 @@
|
||||
|
||||
include_once __DIR__.'/core.php';
|
||||
|
||||
use Util\Query;
|
||||
use Models\Module;
|
||||
use Util\Query;
|
||||
|
||||
// Informazioni fondamentali
|
||||
$columns = (array) filter('columns', null, true);
|
||||
@@ -185,8 +185,8 @@ if (!empty($query)) {
|
||||
// Immagine
|
||||
elseif ($field == '_img_') {
|
||||
$module = Module::where('id', $id_module)->first();
|
||||
if( !empty($r['_img_']) ){
|
||||
$fileinfo = \Uploads::fileInfo($r['_img_']);
|
||||
if (!empty($r['_img_'])) {
|
||||
$fileinfo = Uploads::fileInfo($r['_img_']);
|
||||
|
||||
$directory = '/'.$module->upload_directory.'/';
|
||||
$image = $directory.$r['_img_'];
|
||||
|
4
core.php
4
core.php
@@ -151,9 +151,9 @@ foreach ($handlers as $handler) {
|
||||
$handler = new Monolog\ErrorHandler($logger);
|
||||
if (!API\Response::isAPIRequest()) {
|
||||
$handler->registerErrorHandler([]);
|
||||
//$handler->registerExceptionHandler(); // Handled by Whoops above
|
||||
// $handler->registerExceptionHandler(); // Handled by Whoops above
|
||||
}
|
||||
$handler->registerFatalHandler(\Psr\Log\LogLevel::ERROR);
|
||||
$handler->registerFatalHandler(Psr\Log\LogLevel::ERROR);
|
||||
|
||||
// Database
|
||||
$dbo = $database = database();
|
||||
|
@@ -192,10 +192,8 @@ if (empty($record) || !$has_access) {
|
||||
// Successivo
|
||||
$next = $posizioni[$key + 1]['id'];
|
||||
|
||||
|
||||
echo '<span class="d-sm-inline">';
|
||||
|
||||
|
||||
echo '
|
||||
<a class="btn btn-default'.($prev ? '' : ' disabled').'" href="'.base_path().'/editor.php?id_module='.$id_module.'&id_record='.$prev.'">
|
||||
<i class="fa fa-arrow-circle-left"></i>
|
||||
@@ -205,10 +203,8 @@ if (empty($record) || !$has_access) {
|
||||
</a>
|
||||
</span>';
|
||||
|
||||
|
||||
echo '<div class="extra-buttons d-sm-inline">';
|
||||
|
||||
|
||||
// Pulsanti personalizzati
|
||||
$buttons = $structure->filepath('buttons.php');
|
||||
|
||||
|
@@ -215,8 +215,8 @@ if (empty($creation) && (!file_exists('config.inc.php') || !$valid_config)) {
|
||||
<h3 class="card-title">'.tr('Configurazione incompleta').'</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>'.tr("Mancano alcuni parametri necessari nella configurazione").'.</p>
|
||||
<p>'.tr("Verifica che il file _FILE_ contenga tutti i parametri di connessione al database", [
|
||||
<p>'.tr('Mancano alcuni parametri necessari nella configurazione').'.</p>
|
||||
<p>'.tr('Verifica che il file _FILE_ contenga tutti i parametri di connessione al database', [
|
||||
'_FILE_' => '<b>config.inc.php</b>',
|
||||
]).'.</p>
|
||||
<p>'.tr("Se il problema persiste, contatta l'assistenza").'.</p>
|
||||
@@ -454,12 +454,12 @@ if (empty($creation) && (!file_exists('config.inc.php') || !$valid_config)) {
|
||||
echo '
|
||||
<div class="config-section-content">
|
||||
<h4 class="config-section-header">'.tr('Benvenuto in _NAME_!', [
|
||||
'_NAME_' => '<strong>OpenSTAManager</strong>',
|
||||
]).'</h4>
|
||||
'_NAME_' => '<strong>OpenSTAManager</strong>',
|
||||
]).'</h4>
|
||||
<p>'.tr("Prima di procedere con l'installazione, verifica che il sistema soddisfi i seguenti requisiti").'.</p>
|
||||
<p class="config-info-text"><i class="fa fa-info-circle text-info mr-1"></i> '.tr('Le impostazioni PHP possono essere modificate nel file _FILE_', [
|
||||
'_FILE_' => '<b>php.ini</b>',
|
||||
]).'</p>
|
||||
'_FILE_' => '<b>php.ini</b>',
|
||||
]).'</p>
|
||||
</div>';
|
||||
|
||||
// REQUISITI PER IL CORRETTO FUNZIONAMENTO
|
||||
@@ -474,8 +474,8 @@ if (empty($creation) && (!file_exists('config.inc.php') || !$valid_config)) {
|
||||
<div class="config-section-content">
|
||||
<h4 class="config-section-header">'.tr('Licenza del software').'</h4>
|
||||
<p>'.tr('OpenSTAManager è tutelato dalla licenza _LICENSE_', [
|
||||
'_LICENSE_' => '<strong>GPL 3.0</strong>',
|
||||
]).':</p>
|
||||
'_LICENSE_' => '<strong>GPL 3.0</strong>',
|
||||
]).':</p>
|
||||
</div>
|
||||
|
||||
<div class="config-license-container">
|
||||
|
@@ -47,7 +47,7 @@ if (filter('action') == 'do_update') {
|
||||
<script>
|
||||
updateCurrentFile("'.tr('Database aggiornato').': '.$update['filename'].'.sql");
|
||||
</script>';
|
||||
} else if (!empty($update['sql'])) {
|
||||
} elseif (!empty($update['sql'])) {
|
||||
echo '
|
||||
<script>
|
||||
updateCurrentFile("'.tr('Aggiornamento database').': '.$update['filename'].'.sql");
|
||||
@@ -96,7 +96,7 @@ if (filter('action') == 'do_update') {
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="alert alert-light border-left border-danger">
|
||||
<h5 class="text-danger font-weight-bold"><i class="fa fa-info-circle mr-2"></i>'.tr("Messaggio di errore").'</h5>
|
||||
<h5 class="text-danger font-weight-bold"><i class="fa fa-info-circle mr-2"></i>'.tr('Messaggio di errore').'</h5>
|
||||
<p class="mb-0 font-weight-bold">'.$error_message.'</p>
|
||||
</div>';
|
||||
|
||||
@@ -107,14 +107,14 @@ if (filter('action') == 'do_update') {
|
||||
<div class="card-header">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<h5 class="mb-0 font-weight-bold"><i class="fa fa-database mr-2"></i>'.tr("Query SQL che ha causato l'errore").'</h5>
|
||||
<button type="button" class="btn btn-sm btn-danger copy-query-btn" data-query="'.htmlspecialchars($error_query).'">
|
||||
<i class="fa fa-copy mr-1"></i>'.tr("Copia query").'
|
||||
<button type="button" class="btn btn-sm btn-danger copy-query-btn" data-query="'.htmlspecialchars((string) $error_query).'">
|
||||
<i class="fa fa-copy mr-1"></i>'.tr('Copia query').'
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="p-3 bg-light code-container">
|
||||
<pre class="mb-0" style="white-space: pre-wrap; word-wrap: break-word;"><code>'.htmlspecialchars($error_query).'</code></pre>
|
||||
<pre class="mb-0" style="white-space: pre-wrap; word-wrap: break-word;"><code>'.htmlspecialchars((string) $error_query).'</code></pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -130,7 +130,7 @@ if (filter('action') == 'do_update') {
|
||||
// Show feedback
|
||||
var $btn = $(this);
|
||||
var originalText = $btn.html();
|
||||
$btn.html(\'<i class="fa fa-check mr-1"></i>'.tr("Copiato!").'\');
|
||||
$btn.html(\'<i class="fa fa-check mr-1"></i>'.tr('Copiato!').'\');
|
||||
$btn.addClass("btn-success").removeClass("btn-outline-light");
|
||||
|
||||
setTimeout(function() {
|
||||
@@ -173,8 +173,8 @@ if (filter('action') == 'do_update') {
|
||||
<div class="alert alert-warning mb-4">
|
||||
<i class="fa fa-exclamation-triangle mr-2"></i>
|
||||
'.tr('Per maggiore sicurezza, rimuovi i permessi di scrittura dal file _FILE_', [
|
||||
'_FILE_' => '<b>config.inc.php</b>',
|
||||
]).'
|
||||
'_FILE_' => '<b>config.inc.php</b>',
|
||||
]).'
|
||||
</div>';
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ if (filter('action') == 'do_update') {
|
||||
<p><strong>'.tr("Benvenuto! Procediamo con l'installazione del database").'.</strong></p>';
|
||||
} else {
|
||||
echo '
|
||||
<p>'.tr("È necessario aggiornare il database alla nuova versione").'.</p>';
|
||||
<p>'.tr('È necessario aggiornare il database alla nuova versione').'.</p>';
|
||||
}
|
||||
|
||||
// Prepara l'HTML per l'elenco degli aggiornamenti, ma non lo mostra ancora
|
||||
@@ -256,7 +256,7 @@ if (filter('action') == 'do_update') {
|
||||
$column_updates = array_chunk($updates, $updates_per_column);
|
||||
|
||||
// Per ogni colonna
|
||||
for ($col = 0; $col < count($column_updates); $col++) {
|
||||
for ($col = 0; $col < count($column_updates); ++$col) {
|
||||
$updates_html .= '
|
||||
<div class="col-md-3">
|
||||
<ul class="list-unstyled mb-0">';
|
||||
@@ -290,8 +290,8 @@ if (filter('action') == 'do_update') {
|
||||
echo '
|
||||
<div id="install-instructions">
|
||||
<p>'.tr("Clicca su _BUTTON_ per avviare l'".(!$dbo->isInstalled() ? tr('installazione') : tr('aggiornamento')), [
|
||||
'_BUTTON_' => '<b>"'.$button.'"</b>',
|
||||
]).'</p>
|
||||
'_BUTTON_' => '<b>"'.$button.'"</b>',
|
||||
]).'</p>
|
||||
<input type="button" class="btn btn-primary btn-lg" value="'.$button.'" onclick="continue_update()" id="continue_button">
|
||||
</div>
|
||||
|
||||
|
@@ -124,7 +124,7 @@ if (!empty($type) && $type != 'menu' && $type != 'custom') {
|
||||
$attr_td .= " width='100'";
|
||||
}
|
||||
|
||||
//Immagine
|
||||
// Immagine
|
||||
elseif (trim((string) $field) == '_img_') {
|
||||
$attr_td .= " width='30'";
|
||||
$field = str_replace('_img_', '', $field);
|
||||
|
@@ -40,7 +40,7 @@ if ($source->isArticolo()) {
|
||||
$articolo_riga = Articolo::find($source->idarticolo);
|
||||
echo $articolo_riga->codice.' - '.$source->descrizione;
|
||||
} else {
|
||||
echo nl2br($source->descrizione);
|
||||
echo nl2br((string) $source->descrizione);
|
||||
}
|
||||
echo '
|
||||
</h3>
|
||||
|
@@ -92,7 +92,7 @@ if (Auth::check()) {
|
||||
$array = $_SESSION['module_'.$id_module];
|
||||
if (!empty($array)) {
|
||||
foreach ($array as $field => $value) {
|
||||
if (!empty($value) && str_contains($field, 'search_')) {
|
||||
if (!empty($value) && str_contains((string) $field, 'search_')) {
|
||||
echo '
|
||||
search.push("'.$field.'");
|
||||
search["'.$field.'"] = "'.addslashes((string) $value).'";';
|
||||
@@ -395,11 +395,9 @@ echo '
|
||||
<body class="sidebar-mini layout-fixed '.(!empty($hide_sidebar) ? ' sidebar-collapse' : '').(!Auth::check() ? ' hold-transition login-page' : '').'">
|
||||
<div class="'.(!Auth::check() ? '' : 'wrapper').'">';
|
||||
|
||||
|
||||
$isInstallation = (!$dbo->isInstalled() || !$dbo->isConnected() || Update::isUpdateAvailable());
|
||||
|
||||
if (Auth::check()) {
|
||||
|
||||
$calendar_color_label = ($_SESSION['period_start'] != date('Y').'-01-01' || $_SESSION['period_end'] != date('Y').'-12-31') ? 'danger' : 'secondary';
|
||||
|
||||
echo '
|
||||
@@ -442,8 +440,8 @@ if (Auth::check()) {
|
||||
<!-- Navbar Right Menu -->
|
||||
<ul class="navbar-nav ml-auto">';
|
||||
|
||||
if (!$config['disable_hooks'] && !$isInstallation) {
|
||||
echo '
|
||||
if (!$config['disable_hooks'] && !$isInstallation) {
|
||||
echo '
|
||||
<div class="nav-item dropdown">
|
||||
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown">
|
||||
<i class="fa fa-bell-o"></i>
|
||||
@@ -715,8 +713,8 @@ if (Auth::check()) {
|
||||
}
|
||||
|
||||
// Non mostrare la card nella pagina di login quando ci sono solo errori
|
||||
if ((!empty($messages['warning']) || (!empty($messages['error']) && ($pageTitle != tr('Login')))) &&
|
||||
!($pageTitle == tr('Login') && empty($messages['warning']) && !empty($messages['error']))) {
|
||||
if ((!empty($messages['warning']) || (!empty($messages['error']) && ($pageTitle != tr('Login'))))
|
||||
&& !($pageTitle == tr('Login') && empty($messages['warning']) && !empty($messages['error']))) {
|
||||
echo '
|
||||
<div class="card card-warning card-center card-center-large">
|
||||
<div class="card-header with-border text-center">
|
||||
@@ -746,7 +744,7 @@ if (!empty($messages['error']) && (Auth::check() || $pageTitle != tr('Login')))
|
||||
|
||||
foreach ($messages['error'] as $value) {
|
||||
// Rimuovi il codice errore dal messaggio
|
||||
$value = preg_replace('/\[uid: ([a-z0-9]+)\]/i', '', $value);
|
||||
$value = preg_replace('/\[uid: ([a-z0-9]+)\]/i', '', (string) $value);
|
||||
|
||||
if ($is_admin) {
|
||||
// Visualizzazione migliorata per amministratori
|
||||
@@ -793,9 +791,9 @@ if (!empty($messages['warning'])) {
|
||||
}
|
||||
|
||||
// Chiusura della card informazioni - non mostrare nella pagina di login quando ci sono solo errori
|
||||
if (!Auth::check() &&
|
||||
(!empty($messages['info']) || !empty($messages['warning']) ||
|
||||
(!empty($messages['error']) && $pageTitle != tr('Login')))) {
|
||||
if (!Auth::check()
|
||||
&& (!empty($messages['info']) || !empty($messages['warning'])
|
||||
|| (!empty($messages['error']) && $pageTitle != tr('Login')))) {
|
||||
echo '
|
||||
</div>
|
||||
</div>';
|
||||
|
18
index.php
18
index.php
@@ -105,7 +105,6 @@ $pageTitle = (!$dbo->isInstalled() || !$dbo->isConnected()) ? tr('Installazione'
|
||||
|
||||
include_once App::filepath('include|custom|', 'top.php');
|
||||
|
||||
|
||||
// Controllo se è una beta e in caso mostro un warning
|
||||
if (Update::isBeta()) {
|
||||
echo '
|
||||
@@ -177,7 +176,6 @@ if (!empty(flash()->getMessage('error'))) {
|
||||
</script>';
|
||||
}
|
||||
|
||||
|
||||
if ($dbo->isInstalled() && $dbo->isConnected() && !Update::isUpdateAvailable()) {
|
||||
echo '
|
||||
<form action="?op=login" method="post" autocomplete="off">
|
||||
@@ -191,11 +189,11 @@ if ($dbo->isInstalled() && $dbo->isConnected() && !Update::isUpdateAvailable())
|
||||
<p class="login-box-msg text-secondary mb-4"><i class="fa fa-lock mr-2"></i>'.tr('Accedi con le tue credenziali').'</p>
|
||||
<div class="input-group mb-4">
|
||||
<input type="text" name="username" autocomplete="username" class="form-control form-control-lg" placeholder="'.tr('Nome utente').'"';
|
||||
if (isset($username)) {
|
||||
echo ' value="'.$username.'"';
|
||||
}
|
||||
if (isset($username)) {
|
||||
echo ' value="'.$username.'"';
|
||||
}
|
||||
|
||||
echo ' required>
|
||||
echo ' required>
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text bg-light">
|
||||
<i class="fa fa-user text-primary"></i>
|
||||
@@ -216,8 +214,8 @@ echo ' required>
|
||||
<i class="fa fa-question-circle mr-1"></i>'.tr('Password dimenticata?').'
|
||||
</a>
|
||||
</div>';
|
||||
if ($microsoft) {
|
||||
echo '
|
||||
if ($microsoft) {
|
||||
echo '
|
||||
<div class="social-auth-links text-center mt-4 pt-3 border-top">
|
||||
<p class="text-muted">'.tr('- oppure -').'</p>
|
||||
|
||||
@@ -225,8 +223,8 @@ if ($microsoft) {
|
||||
<i class="fa fa-windows mr-2"></i>'.tr('Accedi con Microsoft').'
|
||||
</a>
|
||||
</div>';
|
||||
}
|
||||
echo '
|
||||
}
|
||||
echo '
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -24,12 +24,12 @@
|
||||
* @since 2.4.2
|
||||
*/
|
||||
use Common\Components\Accounting;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Modules\Contratti\Contratto;
|
||||
use Modules\DDT\DDT;
|
||||
use Modules\Fatture\Fattura;
|
||||
use Modules\Interventi\Intervento;
|
||||
use Modules\Ordini\Ordine;
|
||||
use Intervention\Image\ImageManager;
|
||||
|
||||
/**
|
||||
* Esegue una somma precisa tra due interi/array.
|
||||
@@ -429,6 +429,7 @@ function hasArticoliFiglio($id_articolo)
|
||||
*
|
||||
* @return ImageManager
|
||||
*/
|
||||
function getImageManager() {
|
||||
function getImageManager()
|
||||
{
|
||||
return extension_loaded('gd') ? ImageManager::gd() : ImageManager::imagick();
|
||||
}
|
@@ -111,7 +111,7 @@ function setting($name, $again = false)
|
||||
|
||||
$user = Auth::user();
|
||||
if ($user) {
|
||||
$user_options = json_decode($user->options ?: '', true) ?: [];
|
||||
$user_options = json_decode((string) $user->options ?: '', true) ?: [];
|
||||
}
|
||||
|
||||
if ($user_options['settings'][$setting->id] !== null) {
|
||||
|
@@ -29,7 +29,6 @@ class OSMFilesystem extends Filesystem
|
||||
'php' => 'application/php',
|
||||
'php5' => 'application/php',
|
||||
'phtml' => 'application/php',
|
||||
|
||||
];
|
||||
|
||||
public function upload($directory, $filename, $contents)
|
||||
|
@@ -70,9 +70,9 @@ switch (filter('op')) {
|
||||
foreach ($queries as $query) {
|
||||
try {
|
||||
$dbo->query($query);
|
||||
$executed++;
|
||||
++$executed;
|
||||
} catch (Exception $e) {
|
||||
$errors[] = $query . ' - ' . $e->getMessage();
|
||||
$errors[] = $query.' - '.$e->getMessage();
|
||||
}
|
||||
}
|
||||
$dbo->query('SET FOREIGN_KEY_CHECKS=1');
|
||||
@@ -86,7 +86,7 @@ switch (filter('op')) {
|
||||
|
||||
echo json_encode([
|
||||
'success' => true,
|
||||
'message' => $success_message . '<br><br>' . tr('Query eseguite:') . '<br>' . $debug_queries,
|
||||
'message' => $success_message.'<br><br>'.tr('Query eseguite:').'<br>'.$debug_queries,
|
||||
'flash_message' => true,
|
||||
]);
|
||||
} else {
|
||||
@@ -99,7 +99,7 @@ switch (filter('op')) {
|
||||
|
||||
echo json_encode([
|
||||
'success' => false,
|
||||
'message' => $error_message . '<br>' . implode('<br>', $errors) . '<br><br>' . tr('Query da eseguire:') . '<br>' . $debug_queries,
|
||||
'message' => $error_message.'<br>'.implode('<br>', $errors).'<br><br>'.tr('Query da eseguire:').'<br>'.$debug_queries,
|
||||
'flash_message' => true,
|
||||
]);
|
||||
}
|
||||
|
@@ -25,7 +25,8 @@ echo '<div class="module-aggiornamenti px-3">';
|
||||
|
||||
$query_conflitti = [];
|
||||
|
||||
function saveQueriesToSession($queries) {
|
||||
function saveQueriesToSession($queries)
|
||||
{
|
||||
$_SESSION['query_conflitti'] = $queries;
|
||||
}
|
||||
|
||||
@@ -148,7 +149,6 @@ $results_settings = settings_diff($data_settings, $settings);
|
||||
$results_settings_added = settings_diff($settings, $data_settings);
|
||||
|
||||
if (!empty($results) || !empty($results_added) || !empty($results_settings) || !empty($results_settings_added)) {
|
||||
|
||||
if ($results) {
|
||||
echo '
|
||||
<div class="row align-items-center">
|
||||
@@ -164,10 +164,10 @@ if (!empty($results) || !empty($results_added) || !empty($results_settings) || !
|
||||
<div>
|
||||
<div class="alert alert-warning">
|
||||
<i class="fa fa-warning"></i> '.tr('Attenzione: questa funzionalità può presentare dei risultati falsamente positivi, sulla base del contenuto del file _FILE_ e la versione _MYSQL_VERSION_ di _DBMS_TYPE_ rilevata a sistema', [
|
||||
'_FILE_' => '<b>'.$file_to_check_database.'</b>',
|
||||
'_MYSQL_VERSION_' => '<b>'.$database->getMySQLVersion().'</b>',
|
||||
'_DBMS_TYPE_' => '<b>'.$database->getType().'</b>',
|
||||
]).'.
|
||||
'_FILE_' => '<b>'.$file_to_check_database.'</b>',
|
||||
'_MYSQL_VERSION_' => '<b>'.$database->getMySQLVersion().'</b>',
|
||||
'_DBMS_TYPE_' => '<b>'.$database->getType().'</b>',
|
||||
]).'.
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
@@ -296,13 +296,10 @@ if (!empty($results) || !empty($results_added) || !empty($results_settings) || !
|
||||
if ($results_added) {
|
||||
foreach ($results_added as $table => $errors) {
|
||||
if (($results[$table] && array_keys($results[$table]) != array_keys($errors)) || (empty($results[$table]) && !empty($errors))) {
|
||||
|
||||
$has_content = false;
|
||||
|
||||
|
||||
$table_not_expected = array_key_exists('current', $errors) && $errors['current'] == null;
|
||||
|
||||
|
||||
$has_keys = false;
|
||||
foreach ($errors as $name => $diff) {
|
||||
if ($name != 'foreign_keys' && !isset($results[$table][$name]) && isset($diff['key'])) {
|
||||
@@ -311,10 +308,8 @@ if (!empty($results) || !empty($results_added) || !empty($results_settings) || !
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$foreign_keys = $errors['foreign_keys'] ?: [];
|
||||
|
||||
|
||||
if ($table_not_expected || $has_keys || !empty($foreign_keys)) {
|
||||
echo '
|
||||
<h5 class="table-name">'.$table.'</h5>';
|
||||
@@ -381,14 +376,11 @@ if (!empty($results) || !empty($results_added) || !empty($results_settings) || !
|
||||
<tbody>';
|
||||
|
||||
foreach ($foreign_keys as $name => $diff) {
|
||||
|
||||
$query = 'ALTER TABLE `'.$table.'` ADD FOREIGN KEY (`'.$name.'`) REFERENCES ';
|
||||
|
||||
|
||||
if (isset($diff['referenced_table']) && isset($diff['referenced_column'])) {
|
||||
$query .= '`'.$diff['referenced_table']['current'].'`(`'.$diff['referenced_column']['current'].'`)';
|
||||
} else {
|
||||
|
||||
$query .= 'altra_tabella(id)';
|
||||
}
|
||||
$query .= ' ON DELETE CASCADE ON UPDATE CASCADE';
|
||||
@@ -423,7 +415,7 @@ if (!empty($results) || !empty($results_added) || !empty($results_settings) || !
|
||||
$campi_non_previsti[] = [
|
||||
'tabella' => $table,
|
||||
'campo' => $name,
|
||||
'valore' => isset($diff['expected']) ? $diff['expected'] : ''
|
||||
'valore' => $diff['expected'] ?? '',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -452,7 +444,7 @@ if (!empty($results) || !empty($results_added) || !empty($results_settings) || !
|
||||
} else {
|
||||
$class = 'warning';
|
||||
|
||||
$query = "UPDATE `zz_settings` SET `tipo` = ".prepare($setting['expected'])." WHERE `nome` = ".prepare($key);
|
||||
$query = 'UPDATE `zz_settings` SET `tipo` = '.prepare($setting['expected']).' WHERE `nome` = '.prepare($key);
|
||||
$query_conflitti[] = $query.';';
|
||||
}
|
||||
|
||||
@@ -500,7 +492,6 @@ if (!empty($results) || !empty($results_added) || !empty($results_settings) || !
|
||||
</table>';
|
||||
}
|
||||
|
||||
|
||||
if (!empty($campi_non_previsti)) {
|
||||
echo '
|
||||
<h4 class="table-title">Campi non previsti</h4>
|
||||
@@ -534,7 +525,6 @@ if (!empty($results) || !empty($results_added) || !empty($results_settings) || !
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
||||
if (!empty($query_conflitti)) {
|
||||
echo '
|
||||
<script>
|
||||
|
@@ -349,7 +349,7 @@ if (filter('op') == 'aggiungi-allegato' || filter('op') == 'modifica-allegato')
|
||||
$nome = $upload->name;
|
||||
|
||||
$logo_stampe = ['logo stampe', 'logo_stampe', 'logo stampe.jpg', 'logo stampe.png'];
|
||||
if (in_array(strtolower($nome), $logo_stampe)) {
|
||||
if (in_array(strtolower((string) $nome), $logo_stampe)) {
|
||||
$nome = 'Logo stampe';
|
||||
$uploads = $structure->uploads($id_record)->where('filename', $upload->filename);
|
||||
foreach ($uploads as $logo) {
|
||||
@@ -359,7 +359,7 @@ if (filter('op') == 'aggiungi-allegato' || filter('op') == 'modifica-allegato')
|
||||
}
|
||||
|
||||
$filigrana_stampe = ['filigrana stampe', 'filigrana_stampe', 'filigrana stampe.jpg', 'filigrana stampe.png'];
|
||||
if (in_array(strtolower($nome), $filigrana_stampe)) {
|
||||
if (in_array(strtolower((string) $nome), $filigrana_stampe)) {
|
||||
$nome = 'Filigrana stampe';
|
||||
$uploads = $structure->uploads($id_record)->where('filename', $upload->filename);
|
||||
foreach ($uploads as $filigrana) {
|
||||
|
@@ -116,8 +116,8 @@ switch ($resource) {
|
||||
LEFT JOIN `co_pagamenti_lang` co_pagamenti_lang ON (`co_pagamenti`.`id` = `co_pagamenti_lang`.`id_record` AND `co_pagamenti_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).")
|
||||
LEFT JOIN `co_banche` banca_acquisti ON `co_pagamenti`.`idconto_acquisti` = `banca_acquisti`.`id_pianodeiconti3` AND `banca_acquisti`.`id_anagrafica` = '.prepare($id_azienda).' AND `banca_acquisti`.`deleted_at` IS NULL AND `banca_acquisti`.`predefined` = 1
|
||||
LEFT JOIN an_relazioni ON an_anagrafiche.idrelazione=an_relazioni.id
|
||||
LEFT JOIN `an_relazioni_lang` ON (`an_relazioni`.`id`=`an_relazioni_lang`.`id_record` AND `an_relazioni_lang`.`id_lang`= ".prepare(Models\Locale::getDefault()->id).")
|
||||
|where| ".Modules::getAdditionalsQuery(Module::where('name', 'Anagrafiche')->first()->id).'
|
||||
LEFT JOIN `an_relazioni_lang` ON (`an_relazioni`.`id`=`an_relazioni_lang`.`id_record` AND `an_relazioni_lang`.`id_lang`= ".prepare(Models\Locale::getDefault()->id).')
|
||||
|where| '.Modules::getAdditionalsQuery(Module::where('name', 'Anagrafiche')->first()->id).'
|
||||
ORDER BY
|
||||
`ragione_sociale`';
|
||||
|
||||
|
@@ -145,6 +145,4 @@ $operations['search_coordinates'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
return $operations;
|
||||
|
@@ -779,7 +779,7 @@ if (!empty($elementi)) {
|
||||
'_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($elemento['data']),
|
||||
'_DELETED_AT_' => (!empty($elemento['deleted_at']) ? tr('Eliminato il:').' '.Translator::dateToLocale($elemento['deleted_at']) : ''),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? "(".$elemento['stato_documento'].")" : ''),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? '('.$elemento['stato_documento'].')' : ''),
|
||||
]);
|
||||
|
||||
// se non è un preventivo è un ddt o una fattura
|
||||
|
@@ -248,9 +248,10 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Importa un record nel database.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
*
|
||||
* @return bool|null True se l'importazione è riuscita, false altrimenti, null se l'operazione è stata saltata
|
||||
*/
|
||||
public function import($record, $update_record = true, $add_record = true)
|
||||
@@ -353,10 +354,24 @@ class CSV extends CSVImporter
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Codice', 'Ragione sociale', 'Nome', 'Cognome', 'Codice destinatario', 'Provincia', 'Città', 'Telefono', 'Indirizzo', 'CAP', 'Cellulare', 'Fax', 'Email', 'PEC', 'Sito Web', 'Codice fiscale', 'Data di nascita', 'Luogo di nascita', 'Sesso', 'Partita IVA', 'IBAN', 'Note', 'Nazione', 'ID Agente', 'ID pagamento', 'Tipo', 'Tipologia', 'Split Payment', 'Settore merceologico'],
|
||||
['001', 'Mario Rossi', '', '', '12345', 'PD', 'Este', '+39 0429 60 25 12', 'Via Rovigo, 51', '35042', '+39 321 12 34 567', '', 'email@anagrafica.it', 'email@pec.it', 'www.sito.it', '', '', '', '', '123456789', 'IT60 X054 2811 1010 0000 0123 456', 'Note dell\'anagrafica di esempio', 'Italia', '', '', 'Cliente', 'Privato', '0', 'Tessile'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa le tipologie dell'anagrafica.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return array Array di ID delle tipologie
|
||||
*/
|
||||
private function processaTipologie($record)
|
||||
@@ -400,6 +415,7 @@ class CSV extends CSVImporter
|
||||
* Processa il settore merceologico.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return string|null ID del settore merceologico
|
||||
*/
|
||||
private function processaSettore($record)
|
||||
@@ -409,7 +425,7 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
$database = database();
|
||||
$settore = trim($record['id_settore']);
|
||||
$settore = trim((string) $record['id_settore']);
|
||||
|
||||
$result = $database->fetchArray('SELECT `an_settori`.`id` FROM `an_settori`
|
||||
LEFT JOIN `an_settori_lang` ON (`an_settori`.`id` = `an_settori_lang`.`id_record`
|
||||
@@ -436,8 +452,9 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Processa l'IBAN.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
* @param array $record Record da processare
|
||||
* @param Anagrafica $anagrafica Anagrafica associata
|
||||
*
|
||||
* @return string|null ID della banca
|
||||
*/
|
||||
private function processaIBAN($record, $anagrafica)
|
||||
@@ -447,7 +464,7 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
$database = database();
|
||||
$iban = trim($record['codiceiban']);
|
||||
$iban = trim((string) $record['codiceiban']);
|
||||
|
||||
$result = $database->fetchOne('SELECT `co_banche`.`id` FROM `co_banche`
|
||||
WHERE LOWER(`iban`) = LOWER('.prepare($iban).')
|
||||
@@ -458,7 +475,7 @@ class CSV extends CSVImporter
|
||||
|
||||
if (empty($id_banca)) {
|
||||
$database->query('INSERT INTO `co_banche` (`iban`, `nome`, `id_anagrafica`)
|
||||
VALUES ('.prepare($iban).', "Banca da importazione '.addslashes($anagrafica->ragione_sociale).'", '.$anagrafica->id.')');
|
||||
VALUES ('.prepare($iban).', "Banca da importazione '.addslashes((string) $anagrafica->ragione_sociale).'", '.$anagrafica->id.')');
|
||||
$id_banca = $database->lastInsertedID();
|
||||
}
|
||||
|
||||
@@ -468,8 +485,9 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Estrae i dati della sede legale dal record.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
* @param array $record Record da processare
|
||||
* @param string $primary_key Chiave primaria
|
||||
*
|
||||
* @return array Dati della sede legale
|
||||
*/
|
||||
private function estraiDatiSede(&$record, $primary_key)
|
||||
@@ -501,17 +519,4 @@ class CSV extends CSVImporter
|
||||
|
||||
return $dati_sede;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Codice', 'Ragione sociale', 'Nome', 'Cognome', 'Codice destinatario', 'Provincia', 'Città', 'Telefono', 'Indirizzo', 'CAP', 'Cellulare', 'Fax', 'Email', 'PEC', 'Sito Web', 'Codice fiscale', 'Data di nascita', 'Luogo di nascita', 'Sesso', 'Partita IVA', 'IBAN', 'Note', 'Nazione', 'ID Agente', 'ID pagamento', 'Tipo', 'Tipologia', 'Split Payment', 'Settore merceologico'],
|
||||
['001', 'Mario Rossi', '', '', '12345', 'PD', 'Este', '+39 0429 60 25 12', 'Via Rovigo, 51', '35042', '+39 321 12 34 567', '', 'email@anagrafica.it', 'email@pec.it', 'www.sito.it', '', '', '', '', '123456789', 'IT60 X054 2811 1010 0000 0123 456', 'Note dell\'anagrafica di esempio', 'Italia', '', '', 'Cliente', 'Privato', '0', 'Tessile'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -63,7 +63,7 @@ switch (post('op')) {
|
||||
}
|
||||
|
||||
if (post('genera_barcode')) {
|
||||
$codice = '200'.str_pad($articolo->id, 9, '0', STR_PAD_LEFT);
|
||||
$codice = '200'.str_pad((string) $articolo->id, 9, '0', STR_PAD_LEFT);
|
||||
$barcode = (new Picqer\Barcode\Types\TypeEan13())->getBarcode($codice)->getBarcode();
|
||||
}
|
||||
$articolo->barcode = $barcode ?: post('barcode');
|
||||
|
@@ -582,7 +582,6 @@ $operations['add_price_list'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$operations['change_active'] = [
|
||||
'text' => '<span><i class="fa fa-refresh"></i> '.tr('Attiva/disattiva articoli').'</span>',
|
||||
'data' => [
|
||||
@@ -629,8 +628,6 @@ $operations['create_estimate'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
$operations['generate_barcode_bulk'] = [
|
||||
'text' => '<span><i class="fa fa-magic"></i> '.tr('Genera barcode').'</span>',
|
||||
'data' => [
|
||||
@@ -677,6 +674,4 @@ $operations['print_labels'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
return $operations;
|
||||
|
@@ -443,7 +443,7 @@ if (!empty($elementi)) {
|
||||
'_DOC_' => $elemento['tipo_documento'],
|
||||
'_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($elemento['data']),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? "(".$elemento['stato_documento'].")" : ''),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? '('.$elemento['stato_documento'].')' : ''),
|
||||
]);
|
||||
|
||||
// se non è un preventivo è un ddt o una fattura
|
||||
|
@@ -138,7 +138,7 @@ echo '
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-map-marker mr-1"></i> '.tr('Ubicazione').'</td>
|
||||
<td class="text-right font-weight-bold">'.($articolo->ubicazione ? $articolo->ubicazione : '<span class="text-muted">-</span>').'</td>
|
||||
<td class="text-right font-weight-bold">'.($articolo->ubicazione ?: '<span class="text-muted">-</span>').'</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><i class="fa fa-balance-scale mr-1"></i> '.tr('Peso lordo').'</td>
|
||||
|
@@ -24,8 +24,6 @@ $record['abilita_serial'] = ($record['serial'] > 0) ? 1 : $record['abilita_seria
|
||||
if (empty($record['abilita_serial'])) {
|
||||
echo '
|
||||
<script>$("li.btn-default.nav-item:has(#link-tab_'.$plugin['id'].')").addClass("disabled");</script>';
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Visualizzo, in base alle impostazioni scelte, se il magazzino verrà movimentato
|
||||
|
@@ -278,7 +278,7 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
// Crea una chiave univoca per evitare duplicati
|
||||
$key = $record[$primary_key] . '|' . $record['anagrafica_listino'];
|
||||
$key = $record[$primary_key].'|'.$record['anagrafica_listino'];
|
||||
if (isset($processed_records[$key])) {
|
||||
continue; // Evita di elaborare lo stesso record più volte
|
||||
}
|
||||
@@ -319,171 +319,13 @@ class CSV extends CSVImporter
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa la categoria dell'articolo.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
* @return Categoria|null Categoria processata
|
||||
*/
|
||||
protected function processaCategoria($record)
|
||||
{
|
||||
if (empty($record['categoria'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$categoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['categoria'])))->where('is_articolo', '=', 0)->first();
|
||||
|
||||
if (empty($categoria)) {
|
||||
$categoria = Categoria::build();
|
||||
$categoria->setTranslation('title', $record['categoria']);
|
||||
$categoria->is_articolo = 1;
|
||||
$categoria->save();
|
||||
}
|
||||
|
||||
return $categoria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa la sottocategoria dell'articolo.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
* @param Categoria|null $categoria Categoria padre
|
||||
* @return Categoria|null Sottocategoria processata
|
||||
*/
|
||||
protected function processaSottocategoria($record, $categoria)
|
||||
{
|
||||
if (empty($record['sottocategoria']) || empty($categoria)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sottocategoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['sottocategoria'])))->first();
|
||||
|
||||
if (empty($sottocategoria)) {
|
||||
$sottocategoria = Categoria::build();
|
||||
$sottocategoria->setTranslation('title', $record['sottocategoria']);
|
||||
$sottocategoria->parent()->associate($categoria);
|
||||
$sottocategoria->save();
|
||||
}
|
||||
|
||||
return $sottocategoria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa la marca dell'articolo.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
* @return Marca|null Marca processata
|
||||
*/
|
||||
protected function processaMarca($record)
|
||||
{
|
||||
if (empty($record['marca'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$marca = Marca::where('name', $record['marca'])->first();
|
||||
|
||||
if (empty($marca)) {
|
||||
$marca = Marca::build($record['marca']);
|
||||
$marca->save();
|
||||
}
|
||||
|
||||
return $marca;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa l'unità di misura dell'articolo.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
* @return void
|
||||
*/
|
||||
protected function processaUnitaMisura($record)
|
||||
{
|
||||
if (empty($record['um'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$database = database();
|
||||
$um = $database->fetchOne('SELECT id FROM `mg_unitamisura` WHERE `valore`='.prepare($record['um']));
|
||||
if (empty($um)) {
|
||||
$database->query('INSERT INTO `mg_unitamisura` (`valore`) VALUES ('.prepare($record['um']).')');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa l'immagine dell'articolo.
|
||||
*
|
||||
* @param Articolo $articolo Articolo da aggiornare
|
||||
* @param string $url URL dell'immagine
|
||||
* @param array $record Record da processare
|
||||
* @return void
|
||||
*/
|
||||
protected function processaImmagine($articolo, $url, $record)
|
||||
{
|
||||
if (empty($url) || empty($record['import_immagine'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$file_content = @file_get_contents($url);
|
||||
|
||||
if (empty($file_content)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$database = database();
|
||||
|
||||
/**
|
||||
* Import immagine options:
|
||||
*
|
||||
* - 1: Permette di importare l'immagine come principale dell'articolo mantenendo gli altri allegati già presenti.
|
||||
* - 2: Permette di importare l'immagine come principale dell'articolo rimuovendo tutti gli allegati presenti.
|
||||
* - 3: Permette di importare l'immagine come allegato dell'articolo.
|
||||
* - 4: Permette di importare l'immagine come allegato dell'articolo rimuovendo tutti gli allegati presenti.
|
||||
*/
|
||||
if ($record['import_immagine'] == 2 || $record['import_immagine'] == 4) {
|
||||
\Uploads::deleteLinked([
|
||||
'id_module' => Module::where('name', 'Articoli')->first()->id,
|
||||
'id_record' => $articolo->id,
|
||||
]);
|
||||
|
||||
$database->update('mg_articoli', [
|
||||
'immagine' => '',
|
||||
], [
|
||||
'id' => $articolo->id,
|
||||
]);
|
||||
}
|
||||
|
||||
$name = 'immagine_'.$articolo->id.'.'.Upload::getExtensionFromMimeType($file_content);
|
||||
|
||||
$upload = \Uploads::upload($file_content, [
|
||||
'name' => 'Immagine',
|
||||
'category' => 'Immagini',
|
||||
'original_name' => $name,
|
||||
'id_module' => Module::where('name', 'Articoli')->first()->id,
|
||||
'id_record' => $articolo->id,
|
||||
], [
|
||||
'thumbnails' => true,
|
||||
]);
|
||||
|
||||
if ($upload && !empty($upload->filename) && ($record['import_immagine'] == 1 || $record['import_immagine'] == 2)) {
|
||||
$database->update('mg_articoli', [
|
||||
'immagine' => $upload->filename,
|
||||
], [
|
||||
'id' => $articolo->id,
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore ma continua con l'importazione
|
||||
error_log('Errore durante l\'importazione dell\'immagine: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Importa un record nel database.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
*
|
||||
* @return bool|null True se l'importazione è riuscita, false altrimenti, null se l'operazione è stata saltata
|
||||
*/
|
||||
public function import($record, $update_record = true, $add_record = true)
|
||||
@@ -557,7 +399,7 @@ class CSV extends CSVImporter
|
||||
$nome_sede = $record['nome_sede'] ?? '';
|
||||
|
||||
// Aggiornamento dettaglio prezzi
|
||||
$dettagli['anagrafica_listino'] = $dettagli['anagrafica_listino'] ?? $record['anagrafica_listino'];
|
||||
$dettagli['anagrafica_listino'] ??= $record['anagrafica_listino'];
|
||||
$dettagli['partita_iva'] = $record['p_iva'] ?? '';
|
||||
$dettagli['qta_minima'] = $record['qta_minima'] ?? '';
|
||||
$dettagli['qta_massima'] = $record['qta_massima'] ?? '';
|
||||
@@ -575,9 +417,9 @@ class CSV extends CSVImporter
|
||||
|
||||
// Rimuovi i campi già elaborati
|
||||
unset($record['anagrafica_listino'], $record['p_iva'], $record['qta_minima'],
|
||||
$record['qta_massima'], $record['prezzo_listino'], $record['sconto_listino'],
|
||||
$record['dir'], $record['codice_fornitore'], $record['barcode_fornitore'],
|
||||
$record['descrizione_fornitore'], $record['id_fornitore']);
|
||||
$record['qta_massima'], $record['prezzo_listino'], $record['sconto_listino'],
|
||||
$record['dir'], $record['codice_fornitore'], $record['barcode_fornitore'],
|
||||
$record['descrizione_fornitore'], $record['id_fornitore']);
|
||||
|
||||
// Gestione immagine
|
||||
$this->processaImmagine($articolo, $url, $record);
|
||||
@@ -617,18 +459,192 @@ class CSV extends CSVImporter
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore in un log
|
||||
error_log('Errore durante l\'importazione dell\'articolo: ' . $e->getMessage());
|
||||
error_log('Errore durante l\'importazione dell\'articolo: '.$e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Codice', 'Immagine', 'Import immagine', 'Descrizione', 'Quantità', 'Data inventario', 'Unità misura', 'Prezzo acquisto', 'Prezzo vendita', 'Peso', 'Volume', 'Categoria', 'Sottocategoria', 'marca', 'Modello', 'Barcode', 'Fornitore predefinito', 'Partita IVA', 'Codice IVA vendita', 'Ubicazione', 'Note', 'Anagrafica listino', 'Codice fornitore', 'Barcode fornitore', 'Descrizione fornitore', 'Qta minima', 'Qta massima', 'Prezzo listino', 'Sconto listino', 'Cliente/Fornitore listino', 'Sede'],
|
||||
['OSM-BUDGET', 'https://openstamanager.com/moduli/budget/budget.webp', '2', 'Modulo Budget per OpenSTAManager', '1', '28/11/2023', 'PZ', '90.00', '180.00', '', '', 'Software gestionali', 'Moduli aggiuntivi', 'DevCode', 'Budget', '4006381333931', 'DevCode s.r.l.', '05024030289', '', '', 'Nota ad uso interno', 'DevCode s.r.l.', 'DEV-BUDGET', '0123456789012', 'Strumento gestionale utilizzato per pianificare e monitorare le entrate e uscite aziendali', '1', '10', '180.00', '20', 'Fornitore', 'Sede'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa la categoria dell'articolo.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return Categoria|null Categoria processata
|
||||
*/
|
||||
protected function processaCategoria($record)
|
||||
{
|
||||
if (empty($record['categoria'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$categoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['categoria'])))->where('is_articolo', '=', 0)->first();
|
||||
|
||||
if (empty($categoria)) {
|
||||
$categoria = Categoria::build();
|
||||
$categoria->setTranslation('title', $record['categoria']);
|
||||
$categoria->is_articolo = 1;
|
||||
$categoria->save();
|
||||
}
|
||||
|
||||
return $categoria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa la sottocategoria dell'articolo.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
* @param Categoria|null $categoria Categoria padre
|
||||
*
|
||||
* @return Categoria|null Sottocategoria processata
|
||||
*/
|
||||
protected function processaSottocategoria($record, $categoria)
|
||||
{
|
||||
if (empty($record['sottocategoria']) || empty($categoria)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$sottocategoria = Categoria::where('id', '=', (new Categoria())->getByField('title', strtolower((string) $record['sottocategoria'])))->first();
|
||||
|
||||
if (empty($sottocategoria)) {
|
||||
$sottocategoria = Categoria::build();
|
||||
$sottocategoria->setTranslation('title', $record['sottocategoria']);
|
||||
$sottocategoria->parent()->associate($categoria);
|
||||
$sottocategoria->save();
|
||||
}
|
||||
|
||||
return $sottocategoria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa la marca dell'articolo.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return Marca|null Marca processata
|
||||
*/
|
||||
protected function processaMarca($record)
|
||||
{
|
||||
if (empty($record['marca'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$marca = Marca::where('name', $record['marca'])->first();
|
||||
|
||||
if (empty($marca)) {
|
||||
$marca = Marca::build($record['marca']);
|
||||
$marca->save();
|
||||
}
|
||||
|
||||
return $marca;
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa l'unità di misura dell'articolo.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processaUnitaMisura($record)
|
||||
{
|
||||
if (empty($record['um'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$database = database();
|
||||
$um = $database->fetchOne('SELECT id FROM `mg_unitamisura` WHERE `valore`='.prepare($record['um']));
|
||||
if (empty($um)) {
|
||||
$database->query('INSERT INTO `mg_unitamisura` (`valore`) VALUES ('.prepare($record['um']).')');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Processa l'immagine dell'articolo.
|
||||
*
|
||||
* @param Articolo $articolo Articolo da aggiornare
|
||||
* @param string $url URL dell'immagine
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function processaImmagine($articolo, $url, $record)
|
||||
{
|
||||
if (empty($url) || empty($record['import_immagine'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
$file_content = @file_get_contents($url);
|
||||
|
||||
if (empty($file_content)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$database = database();
|
||||
|
||||
/*
|
||||
* Import immagine options:
|
||||
*
|
||||
* - 1: Permette di importare l'immagine come principale dell'articolo mantenendo gli altri allegati già presenti.
|
||||
* - 2: Permette di importare l'immagine come principale dell'articolo rimuovendo tutti gli allegati presenti.
|
||||
* - 3: Permette di importare l'immagine come allegato dell'articolo.
|
||||
* - 4: Permette di importare l'immagine come allegato dell'articolo rimuovendo tutti gli allegati presenti.
|
||||
*/
|
||||
if ($record['import_immagine'] == 2 || $record['import_immagine'] == 4) {
|
||||
\Uploads::deleteLinked([
|
||||
'id_module' => Module::where('name', 'Articoli')->first()->id,
|
||||
'id_record' => $articolo->id,
|
||||
]);
|
||||
|
||||
$database->update('mg_articoli', [
|
||||
'immagine' => '',
|
||||
], [
|
||||
'id' => $articolo->id,
|
||||
]);
|
||||
}
|
||||
|
||||
$name = 'immagine_'.$articolo->id.'.'.Upload::getExtensionFromMimeType($file_content);
|
||||
|
||||
$upload = \Uploads::upload($file_content, [
|
||||
'name' => 'Immagine',
|
||||
'category' => 'Immagini',
|
||||
'original_name' => $name,
|
||||
'id_module' => Module::where('name', 'Articoli')->first()->id,
|
||||
'id_record' => $articolo->id,
|
||||
], [
|
||||
'thumbnails' => true,
|
||||
]);
|
||||
|
||||
if ($upload && !empty($upload->filename) && ($record['import_immagine'] == 1 || $record['import_immagine'] == 2)) {
|
||||
$database->update('mg_articoli', [
|
||||
'immagine' => $upload->filename,
|
||||
], [
|
||||
'id' => $articolo->id,
|
||||
]);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore ma continua con l'importazione
|
||||
error_log('Errore durante l\'importazione dell\'immagine: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiorna la giacenza dell'articolo.
|
||||
*
|
||||
* @param Articolo $articolo Articolo da aggiornare
|
||||
* @param float $nuova_qta Nuova quantità
|
||||
* @param string $nome_sede Nome della sede
|
||||
* @param array $record Record da processare
|
||||
* @param Articolo $articolo Articolo da aggiornare
|
||||
* @param float $nuova_qta Nuova quantità
|
||||
* @param string $nome_sede Nome della sede
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function aggiornaGiacenza($articolo, $nuova_qta, $nome_sede, $record)
|
||||
@@ -659,18 +675,10 @@ class CSV extends CSVImporter
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore ma continua con l'importazione
|
||||
error_log('Errore durante l\'aggiornamento della giacenza: ' . $e->getMessage());
|
||||
error_log('Errore durante l\'aggiornamento della giacenza: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Codice', 'Immagine', 'Import immagine', 'Descrizione', 'Quantità', 'Data inventario', 'Unità misura', 'Prezzo acquisto', 'Prezzo vendita', 'Peso', 'Volume', 'Categoria', 'Sottocategoria', 'marca', 'Modello', 'Barcode', 'Fornitore predefinito', 'Partita IVA', 'Codice IVA vendita', 'Ubicazione', 'Note', 'Anagrafica listino', 'Codice fornitore', 'Barcode fornitore', 'Descrizione fornitore', 'Qta minima', 'Qta massima', 'Prezzo listino', 'Sconto listino', 'Cliente/Fornitore listino', 'Sede'],
|
||||
['OSM-BUDGET', 'https://openstamanager.com/moduli/budget/budget.webp', '2', 'Modulo Budget per OpenSTAManager', '1', '28/11/2023', 'PZ', '90.00', '180.00', '', '', 'Software gestionali', 'Moduli aggiuntivi', 'DevCode', 'Budget', '4006381333931', 'DevCode s.r.l.', '05024030289', '', '', 'Nota ad uso interno', 'DevCode s.r.l.', 'DEV-BUDGET', '0123456789012', 'Strumento gestionale utilizzato per pianificare e monitorare le entrate e uscite aziendali', '1', '10', '180.00', '20', 'Fornitore', 'Sede'],
|
||||
];
|
||||
}
|
||||
|
||||
protected function aggiornaDettaglioPrezzi(Articolo $articolo, $dettagli)
|
||||
{
|
||||
// Listini
|
||||
@@ -699,17 +707,11 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
$dettagli['dir'] = strtolower((string) $dettagli['dir']);
|
||||
switch ($dettagli['dir']) {
|
||||
case 'fornitore':
|
||||
$dettagli['dir'] = 'uscita';
|
||||
break;
|
||||
case 'cliente':
|
||||
$dettagli['dir'] = 'entrata';
|
||||
break;
|
||||
default:
|
||||
$dettagli['dir'] = null;
|
||||
break;
|
||||
}
|
||||
$dettagli['dir'] = match ($dettagli['dir']) {
|
||||
'fornitore' => 'uscita',
|
||||
'cliente' => 'entrata',
|
||||
default => null,
|
||||
};
|
||||
|
||||
// Aggiungo Listino
|
||||
if (!empty($anagrafica) && !empty($dettagli['dir']) && $dettagli['prezzo_listino']) {
|
||||
|
@@ -188,7 +188,7 @@ if (string_starts_with($backup_dir, base_dir())) {
|
||||
echo '
|
||||
<div class="alert alert-warning mt-3">
|
||||
<i class="fa fa-warning"></i> '.tr('Per motivi di sicurezza si consiglia di modificare il percorso della cartella di backup al di fuori della cartella di OSM, possibilmente in una unità esterna.').'
|
||||
<p class="mt-2">'.tr('Puoi modificare il percorso di backup da:').' <a href="'.base_path().'/controller.php?id_module='.\Models\Module::where('name', 'Impostazioni')->first()->id.'&search=Adattatore archiviazione backup#" class="btn btn-sm btn-info"><i class="fa fa-cog"></i> '.tr('Menu <b>Strumenti</b> → <b>Impostazioni</b> → sezione <b>Backup</b> → impostazione <b>Adattatore archiviazione backup</b>').'</a>
|
||||
<p class="mt-2">'.tr('Puoi modificare il percorso di backup da:').' <a href="'.base_path().'/controller.php?id_module='.Models\Module::where('name', 'Impostazioni')->first()->id.'&search=Adattatore archiviazione backup#" class="btn btn-sm btn-info"><i class="fa fa-cog"></i> '.tr('Menu <b>Strumenti</b> → <b>Impostazioni</b> → sezione <b>Backup</b> → impostazione <b>Adattatore archiviazione backup</b>').'</a>
|
||||
</p>
|
||||
</div>';
|
||||
}
|
||||
@@ -300,11 +300,11 @@ if (file_exists($backup_dir)) {
|
||||
<div class="card-header bg-light">
|
||||
<h5 class="card-title mb-0">
|
||||
<i class="fa fa-calendar-o mr-2"></i><strong>'.tr('Backup del _DATE_', [
|
||||
'_DATE_' => Translator::dateToLocale($data),
|
||||
]).'</strong>
|
||||
'_DATE_' => Translator::dateToLocale($data),
|
||||
]).'</strong>
|
||||
<span class="text-muted ml-2">'.tr('alle _TIME_', [
|
||||
'_TIME_' => Translator::timeToLocale($ora),
|
||||
]).'</span>
|
||||
'_TIME_' => Translator::timeToLocale($ora),
|
||||
]).'</span>
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@@ -379,11 +379,11 @@ if (file_exists($backup_dir)) {
|
||||
<div class="card-header bg-light">
|
||||
<h5 class="card-title mb-0">
|
||||
<i class="fa fa-calendar-o mr-2"></i><strong>'.tr('Backup del _DATE_', [
|
||||
'_DATE_' => Translator::dateToLocale($data),
|
||||
]).'</strong>
|
||||
'_DATE_' => Translator::dateToLocale($data),
|
||||
]).'</strong>
|
||||
<span class="text-muted ml-2">'.tr('alle _TIME_', [
|
||||
'_TIME_' => Translator::timeToLocale($ora),
|
||||
]).'</span>
|
||||
'_TIME_' => Translator::timeToLocale($ora),
|
||||
]).'</span>
|
||||
</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@@ -449,7 +449,7 @@ if (file_exists($backup_dir)) {
|
||||
<div class="alert alert-danger">'.tr('La cartella di backup non esiste!').' '.tr('Non è possibile eseguire i backup!').'</div>';
|
||||
}
|
||||
|
||||
echo'
|
||||
echo '
|
||||
<div class="row mt-4 mb-4">
|
||||
<div class="col-md-8 mx-auto text-center">
|
||||
<a class="btn btn-lg btn-success" aria-haspopup="true" aria-expanded="false" onclick="creaBackup(this)">
|
||||
|
@@ -18,11 +18,11 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Anagrafiche\Nazione;
|
||||
use Modules\Banche\Banca;
|
||||
use Modules\Banche\IBAN;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
@@ -128,7 +128,7 @@ switch (filter('op')) {
|
||||
]);
|
||||
|
||||
echo $response->getBody()->getContents();
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => 'Errore durante la connessione a ibanapi.com: '.$e->getMessage()]);
|
||||
exit;
|
||||
@@ -147,16 +147,16 @@ switch (filter('op')) {
|
||||
$response = $client->request('POST', $endpoint, [
|
||||
'form_params' => [
|
||||
'iban' => $iban,
|
||||
'api_key' => $api_key
|
||||
'api_key' => $api_key,
|
||||
],
|
||||
'headers' => [
|
||||
'Accept' => 'application/json'
|
||||
'Accept' => 'application/json',
|
||||
],
|
||||
'http_errors' => false,
|
||||
]);
|
||||
|
||||
echo $response->getBody()->getContents();
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
http_response_code(500);
|
||||
echo json_encode(['error' => 'Errore durante la connessione a ibanapi.com: '.$e->getMessage()]);
|
||||
exit;
|
||||
|
@@ -40,7 +40,7 @@ echo '
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "'.tr('IBAN').'", "name": "iban", "required": "1", "class": "alphanumeric-mask", "maxlength": 32, "value": "$iban$", "icon-after": "'.(!empty($ibanapi_key) && !empty($endpoint)?'<a class=\'fa fa-search clickable\' id=\'check-iban\'></a>':'<span class=\'tip\' title=\'Da impostazioni sezione API è possibile attivare la verifica iban tramite ibanapi.com\'><i class=\'fa fa-search text-danger clickable\'></i></span>').'" ]}
|
||||
{[ "type": "text", "label": "'.tr('IBAN').'", "name": "iban", "required": "1", "class": "alphanumeric-mask", "maxlength": 32, "value": "$iban$", "icon-after": "'.(!empty($ibanapi_key) && !empty($endpoint) ? '<a class=\'fa fa-search clickable\' id=\'check-iban\'></a>' : '<span class=\'tip\' title=\'Da impostazioni sezione API è possibile attivare la verifica iban tramite ibanapi.com\'><i class=\'fa fa-search text-danger clickable\'></i></span>').'" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
@@ -290,7 +290,7 @@ echo '
|
||||
+ "<div class='card h-100'>"
|
||||
+ "<div class='card-body p-1 d-flex align-items-center'>"
|
||||
+ "<span class='small' style='font-size:9pt'>" + label + "</span>"
|
||||
+ "<span class='badge badge-" + badgeClass + " ml-auto small' style='font-size: 0.75rem;'>" + (status ? '<?php echo tr("Attivo"); ?>' : '<?php echo tr("Non attivo"); ?>') + "</span>"
|
||||
+ "<span class='badge badge-" + badgeClass + " ml-auto small' style='font-size: 0.75rem;'>" + (status ? '<?php echo tr('Attivo'); ?>' : '<?php echo tr('Non attivo'); ?>') + "</span>"
|
||||
+ "</div></div></div>";
|
||||
}
|
||||
|
||||
|
@@ -60,7 +60,7 @@ $endpoint = setting('Endpoint ibanapi.com');
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('IBAN'); ?>", "name": "iban", "required": "1", "class": "alphanumeric-mask", "maxlength": 32, "value": "$iban$", "icon-after": "<?=(!empty($ibanapi_key) && !empty($endpoint)?'<a class=\'fa fa-search clickable\' id=\'check-iban\'></a>':'<span class=\'tip\' title=\'Da impostazioni sezione API è possibile attivare la verifica iban tramite ibanapi.com\'><i class=\'fa fa-search text-danger clickable\'></i></span>')?>" ]}
|
||||
{[ "type": "text", "label": "<?php echo tr('IBAN'); ?>", "name": "iban", "required": "1", "class": "alphanumeric-mask", "maxlength": 32, "value": "$iban$", "icon-after": "<?php echo !empty($ibanapi_key) && !empty($endpoint) ? '<a class=\'fa fa-search clickable\' id=\'check-iban\'></a>' : '<span class=\'tip\' title=\'Da impostazioni sezione API è possibile attivare la verifica iban tramite ibanapi.com\'><i class=\'fa fa-search text-danger clickable\'></i></span>'; ?>" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
@@ -365,7 +365,7 @@ if (!empty($numero_documenti)) {
|
||||
+ "<div class='card h-100'>"
|
||||
+ "<div class='card-body p-1 d-flex align-items-center'>"
|
||||
+ "<span class='small' style='font-size:9pt'>" + label + "</span>"
|
||||
+ "<span class='badge badge-" + badgeClass + " ml-auto small' style='font-size: 0.75rem;'>" + (status ? '<?php echo tr("Attivo"); ?>' : '<?php echo tr("Non attivo"); ?>') + "</span>"
|
||||
+ "<span class='badge badge-" + badgeClass + " ml-auto small' style='font-size: 0.75rem;'>" + (status ? '<?php echo tr('Attivo'); ?>' : '<?php echo tr('Non attivo'); ?>') + "</span>"
|
||||
+ "</div></div></div>";
|
||||
}
|
||||
|
||||
|
@@ -27,8 +27,8 @@ switch (filter('op')) {
|
||||
$nota = filter('nota');
|
||||
$colore = filter('colore');
|
||||
$id_original = filter('id_original') ?: null;
|
||||
$is_articolo = filter('is_articolo_add') ?: filter('is_articolo') ?: 0;
|
||||
$is_impianto = filter('is_impianto_add') ?: filter('is_impianto') ?: 0;
|
||||
$is_articolo = (filter('is_articolo_add') ?: filter('is_articolo')) ?: 0;
|
||||
$is_impianto = (filter('is_impianto_add') ?: filter('is_impianto')) ?: 0;
|
||||
|
||||
// Verifica che almeno uno dei due flag sia selezionato
|
||||
if ($is_articolo == 0 && $is_impianto == 0) {
|
||||
@@ -92,8 +92,8 @@ switch (filter('op')) {
|
||||
$nota = filter('nota');
|
||||
$colore = filter('colore');
|
||||
$id_original = filter('id_original') ?: null;
|
||||
$is_articolo = filter('is_articolo_add') ?: filter('is_articolo') ?: 0;
|
||||
$is_impianto = filter('is_impianto_add') ?: filter('is_impianto') ?: 0;
|
||||
$is_articolo = (filter('is_articolo_add') ?: filter('is_articolo')) ?: 0;
|
||||
$is_impianto = (filter('is_impianto_add') ?: filter('is_impianto')) ?: 0;
|
||||
|
||||
// Verifica che almeno uno dei due flag sia selezionato
|
||||
if ($is_articolo == 0 && $is_impianto == 0) {
|
||||
|
@@ -38,10 +38,10 @@ if (isset($id_original)) {
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="id_original" value="<?php echo $id_original; ?>">
|
||||
<input type="hidden" name="op" value="<?php echo $id_record ? 'update' : 'add'; ?>">
|
||||
<?php if (!empty($id_original)) : ?>
|
||||
<?php if (!empty($id_original)) { ?>
|
||||
<input type="hidden" name="is_articolo" value="<?php echo $id_original ? Categoria::find($id_original)->is_articolo : 1; ?>">
|
||||
<input type="hidden" name="is_impianto" value="<?php echo $id_original ? Categoria::find($id_original)->is_impianto : 0; ?>">
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
|
@@ -18,7 +18,6 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Models\Module;
|
||||
use Modules\Articoli\Articolo;
|
||||
use Modules\Articoli\Categoria;
|
||||
|
||||
@@ -41,7 +40,7 @@ foreach ($subcategorie as $sub) {
|
||||
'.($sub->is_impianto ? '<span class="badge badge-primary"><i class="fa fa-check"></i></span>' : '<span class="badge badge-secondary"><i class="fa fa-times"></i></span>').'
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<small>'.nl2br(htmlentities(substr($sub->getTranslation('note'), 0, 100))).(strlen($sub->getTranslation('note')) > 100 ? '...' : '').'</small>
|
||||
<small>'.nl2br(htmlentities(substr((string) $sub->getTranslation('note'), 0, 100))).(strlen((string) $sub->getTranslation('note')) > 100 ? '...' : '').'</small>
|
||||
</td>
|
||||
<td class="text-center align-middle">
|
||||
<div class="btn-group">
|
||||
|
@@ -25,7 +25,7 @@ use Modules\CategorieFiles\Categoria;
|
||||
switch (post('op')) {
|
||||
case 'update':
|
||||
$name = post('name');
|
||||
$categoria_new = Categoria::where('name', '=', $name)->where('deleted_at', '=', null)->where('id','!=', $id_record)->first();
|
||||
$categoria_new = Categoria::where('name', '=', $name)->where('deleted_at', '=', null)->where('id', '!=', $id_record)->first();
|
||||
|
||||
if (!empty($categoria_new)) {
|
||||
flash()->error(tr('Categoria _NAME_ già esistente!', [
|
||||
|
@@ -40,7 +40,7 @@ if ($main_check) {
|
||||
'label' => tr('Descrizione'),
|
||||
'name' => 'content_edit',
|
||||
'required' => 1,
|
||||
'value' => htmlentities($record->content),
|
||||
'value' => htmlentities((string) $record->content),
|
||||
]);
|
||||
?>
|
||||
</div>
|
||||
|
@@ -54,22 +54,22 @@ if (!function_exists('renderChecklist')) {
|
||||
<td style="border-top:0px;">
|
||||
<span class="badge text-muted pull-right verificato '.(!$check->checked_at ? 'hidden' : '').'" style="margin-right:5px;padding:6px 8px;">
|
||||
'.(!empty($check->checked_at) ? tr('Verificato da _NAME_ _DATE_', [
|
||||
'_NAME_' => $check->checkUser->username.' <br>',
|
||||
'_DATE_' => timestampFormat($check->checked_at),
|
||||
]) : '').'
|
||||
'_NAME_' => $check->checkUser->username.' <br>',
|
||||
'_DATE_' => timestampFormat($check->checked_at),
|
||||
]) : '').'
|
||||
</span>
|
||||
</td>';
|
||||
|
||||
$result .= '
|
||||
<td style="width:400px;border-top:0px;">
|
||||
'.input([
|
||||
'type' => 'textarea',
|
||||
'name' => 'note_checklist',
|
||||
'id' => 'note_'.$check->id,
|
||||
'class' => 'unblockable',
|
||||
'placeholder' => tr('Note').'...',
|
||||
'value' => $check->note,
|
||||
]).'
|
||||
'type' => 'textarea',
|
||||
'name' => 'note_checklist',
|
||||
'id' => 'note_'.$check->id,
|
||||
'class' => 'unblockable',
|
||||
'placeholder' => tr('Note').'...',
|
||||
'value' => $check->note,
|
||||
]).'
|
||||
</td>';
|
||||
|
||||
$result .= '
|
||||
|
@@ -148,7 +148,7 @@ switch (post('op')) {
|
||||
// Lettura righe selezionate
|
||||
foreach ($id_records as $id) {
|
||||
$contratto = Contratto::find($id);
|
||||
$rinnova = !empty($contratto->data_accettazione) && !empty($contratto->data_conclusione) && $contratto->data_accettazione != '0000-00-00' && $contratto->data_conclusione != '0000-00-00' && $contratto->stato->is_bloccato& $contratto->rinnovabile;
|
||||
$rinnova = !empty($contratto->data_accettazione) && !empty($contratto->data_conclusione) && $contratto->data_accettazione != '0000-00-00' && $contratto->data_conclusione != '0000-00-00' && $contratto->stato->is_bloccato & $contratto->rinnovabile;
|
||||
|
||||
if ($rinnova) {
|
||||
$diff = $contratto->data_conclusione->diffAsCarbonInterval($contratto->data_accettazione);
|
||||
|
@@ -141,7 +141,7 @@ echo '
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "select", "multiple": "1", "label": "<?php echo tr('Impianti'); ?>", "name": "matricolaimpianto[]", "ajax-source": "impianti-cliente", "select-options": {"idanagrafica": <?php echo ($record['idanagrafica'] ?: '""'); ?>, "idsede_destinazione": "", "idcontratto": ""}, "value": "$idimpianti$", "icon-after": "add|<?php echo Module::where('name', 'Impianti')->first()->id; ?>|<?php echo 'id_anagrafica='.$record['idanagrafica']; ?>||<?php echo (empty($block_edit)) ? '' : 'disabled'; ?>" ]}
|
||||
{[ "type": "select", "multiple": "1", "label": "<?php echo tr('Impianti'); ?>", "name": "matricolaimpianto[]", "ajax-source": "impianti-cliente", "select-options": {"idanagrafica": <?php echo $record['idanagrafica'] ?: '""'; ?>, "idsede_destinazione": "", "idcontratto": ""}, "value": "$idimpianti$", "icon-after": "add|<?php echo Module::where('name', 'Impianti')->first()->id; ?>|<?php echo 'id_anagrafica='.$record['idanagrafica']; ?>||<?php echo (empty($block_edit)) ? '' : 'disabled'; ?>" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
@@ -637,7 +637,7 @@ if (!empty($elementi)) {
|
||||
'_DOC_' => $elemento['tipo_documento'],
|
||||
'_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($elemento['data']),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? "(".$elemento['stato_documento'].")" : ''),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? '('.$elemento['stato_documento'].')' : ''),
|
||||
]);
|
||||
|
||||
echo '
|
||||
|
@@ -38,7 +38,7 @@ if (!empty($riga_id)) {
|
||||
// Caso singola riga
|
||||
$riga = Riga::find($riga_id) ?: Articolo::find($riga_id);
|
||||
$riga = $riga ?: Sconto::find($riga_id);
|
||||
$righe_totali++;
|
||||
++$righe_totali;
|
||||
|
||||
if (!empty($riga) && !empty($riga->idiva) && !empty($riga->aliquota)) {
|
||||
$aliquote_iva[$riga->idiva] = [
|
||||
@@ -46,19 +46,19 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 1
|
||||
'count' => 1,
|
||||
];
|
||||
} else {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
} elseif (!empty($righe_ids)) {
|
||||
// Caso multiple righe
|
||||
$righe_array = explode(',', $righe_ids);
|
||||
$righe_array = explode(',', (string) $righe_ids);
|
||||
$righe_totali = count($righe_array);
|
||||
|
||||
foreach ($righe_array as $id_riga) {
|
||||
@@ -72,16 +72,16 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 0
|
||||
'count' => 0,
|
||||
];
|
||||
}
|
||||
$aliquote_iva[$riga->idiva]['count']++;
|
||||
++$aliquote_iva[$riga->idiva]['count'];
|
||||
} elseif (!empty($riga)) {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -92,20 +92,20 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
?>
|
||||
|
||||
<form id="modifica-iva-form">
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<?php if (count($aliquote_iva) > 1): ?>
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<?php endif; ?>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<?php if (count($aliquote_iva) > 1) { ?>
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -117,38 +117,38 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?= tr('eliminata') ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?= prepare(Models\Locale::getDefault()->id) ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?php echo tr('eliminata'); ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($show_form): ?>
|
||||
<?php } elseif ($show_form) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (count($righe_senza_iva) > 0): ?>
|
||||
<p><strong><?= tr('Righe senza aliquota IVA valida') ?>:</strong> <span class="badge"><?= count($righe_senza_iva) ?></span></p>
|
||||
<?php endif; ?>
|
||||
<?php if (count($righe_senza_iva) > 0) { ?>
|
||||
<p><strong><?php echo tr('Righe senza aliquota IVA valida'); ?>:</strong> <span class="badge"><?php echo count($righe_senza_iva); ?></span></p>
|
||||
<?php } ?>
|
||||
|
||||
<p class="text-muted"><?= tr('Totale righe selezionate') ?>: <?= $righe_totali ?></p>
|
||||
<p class="text-muted"><?php echo tr('Totale righe selezionate'); ?>: <?php echo $righe_totali; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -159,31 +159,31 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?= tr('eliminata') ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?= prepare(Models\Locale::getDefault()->id) ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?php echo tr('eliminata'); ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php } else { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-warning">
|
||||
<p><?= tr('Nessuna riga selezionata') ?></p>
|
||||
<p><?php echo tr('Nessuna riga selezionata'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="button" class="btn btn-primary" onclick="salvaIva()">
|
||||
<i class="fa fa-save"></i> <?= tr('Salva') ?>
|
||||
<i class="fa fa-save"></i> <?php echo tr('Salva'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -216,7 +216,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -237,7 +237,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -95,7 +95,7 @@ foreach ($righe as $riga) {
|
||||
<td>';
|
||||
|
||||
// Descrizione
|
||||
$descrizione = nl2br($riga->descrizione);
|
||||
$descrizione = nl2br((string) $riga->descrizione);
|
||||
if ($riga->isArticolo()) {
|
||||
$descrizione = Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$descrizione);
|
||||
}
|
||||
@@ -123,7 +123,7 @@ foreach ($righe as $riga) {
|
||||
|
||||
if (!empty($riga->note)) {
|
||||
echo '
|
||||
<br><span class="text-xs">'.nl2br($riga->note).'</small>';
|
||||
<br><span class="text-xs">'.nl2br((string) $riga->note).'</small>';
|
||||
}
|
||||
echo '
|
||||
</td>
|
||||
|
@@ -101,7 +101,7 @@ switch (filter('op')) {
|
||||
if (setting('Visualizzazione colori sessioni') == 'Sfondo colore stato - bordo colore tecnico') {
|
||||
$backgroundcolor = strtoupper((string) $sessione['colore']);
|
||||
$bordercolor = strtoupper((string) $sessione['colore_tecnico']);
|
||||
} else if (setting('Visualizzazione colori sessioni') == 'Sfondo colore tecnico - bordo colore stato') {
|
||||
} elseif (setting('Visualizzazione colori sessioni') == 'Sfondo colore tecnico - bordo colore stato') {
|
||||
$backgroundcolor = strtoupper((string) $sessione['colore_tecnico']);
|
||||
$bordercolor = strtoupper((string) $sessione['colore']);
|
||||
}
|
||||
@@ -434,7 +434,7 @@ switch (filter('op')) {
|
||||
if (fullEl.is(":visible")) {
|
||||
fullEl.hide();
|
||||
textEl.show();
|
||||
$(this).text("' . tr('Mostra tutto') . '");
|
||||
$(this).text("'.tr('Mostra tutto').'");
|
||||
|
||||
// Forza il ridimensionamento del tooltip alla dimensione originale
|
||||
var instance = $(".tooltipstered").tooltipster("instance");
|
||||
@@ -445,7 +445,7 @@ switch (filter('op')) {
|
||||
} else {
|
||||
textEl.hide();
|
||||
fullEl.show();
|
||||
$(this).text("' . tr('Comprimi') . '");
|
||||
$(this).text("'.tr('Comprimi').'");
|
||||
|
||||
// Forza il ridimensionamento del tooltip solo verticalmente
|
||||
var instance = $(".tooltipstered").tooltipster("instance");
|
||||
@@ -583,7 +583,7 @@ switch (filter('op')) {
|
||||
<div id="id-'.$sessione['id'].'" class="fc-event fc-event-'.$class.'" data-id="'.$sessione['id'].'" data-idcontratto="'.$sessione['idcontratto'].'" data-ref="'.$sessione['ref'].'" data-id_tecnico="'.$sessione['id_tecnico'].'">'.($sessione['ref'] == 'intervento' ? Modules::link($modulo_riferimento, $id_riferimento, '<i class="fa fa-wrench"></i>', null, 'title="'.tr('Visualizza scheda').'" class="btn btn-'.$class.' btn-xs pull-right"') : Modules::link($modulo_riferimento, $id_riferimento, '<i class="fa fa-file-text-o"></i>', null, 'title="'.tr('Visualizza scheda').'" class="btn btn-'.$class.' btn-xs pull-right"')).'
|
||||
<b>'.$sessione['ragione_sociale'].'</b>
|
||||
<br>'.dateFormat($sessione['data_richiesta']).' ('.$sessione['tipo_intervento'].')
|
||||
'.(!empty($sessione['richiesta']) ? '<div class="request-wrapper"><span class="request-text">' . (strlen(strip_tags((string) $sessione['richiesta'])) > 200 ? substr(strip_tags((string) $sessione['richiesta']), 0, 200).'...' : strip_tags((string) $sessione['richiesta'])) . '</span><span class="request-full">' . strip_tags((string) $sessione['richiesta']) . '</span><a href="#" class="request-toggle">' . tr('Mostra tutto') . '</a></div>' : '').'
|
||||
'.(!empty($sessione['richiesta']) ? '<div class="request-wrapper"><span class="request-text">'.(strlen(strip_tags((string) $sessione['richiesta'])) > 200 ? substr(strip_tags((string) $sessione['richiesta']), 0, 200).'...' : strip_tags((string) $sessione['richiesta'])).'</span><span class="request-full">'.strip_tags((string) $sessione['richiesta']).'</span><a href="#" class="request-toggle">'.tr('Mostra tutto').'</a></div>' : '').'
|
||||
'.(!empty($sessione['numero_contratto']) ? '<span class="badge badge-'.$class.'">'.tr('Contratto numero: ').$sessione['numero_contratto'].tr(' del ').dateFormat($sessione['data_contratto']).'<span>' : '').' '.(!empty($sessione['data_scadenza'] && $sessione['data_scadenza'] != '0000-00-00 00:00:00') ? '<span class="badge badge-'.$class.'" >'.tr('Entro il: ').dateFormat($sessione['data_scadenza']).'</span>' : '').' '.(!empty($sessione['id_tecnico']) ? '<span class="badge" style="color:'.color_inverse($sessione['colore']).';background-color:'.$sessione['colore'].';" >'.tr('Tecnico').': '.$sessione['ragione_sociale_tecnico'].'</span>' : '').'
|
||||
</div>';
|
||||
}
|
||||
@@ -601,13 +601,13 @@ switch (filter('op')) {
|
||||
if (fullEl.is(":visible")) {
|
||||
fullEl.hide();
|
||||
textEl.show();
|
||||
$(this).text("' . tr('Mostra tutto') . '");
|
||||
$(this).text("'.tr('Mostra tutto').'");
|
||||
|
||||
// Gli stili sono ora definiti nel CSS
|
||||
} else {
|
||||
textEl.hide();
|
||||
fullEl.show();
|
||||
$(this).text("' . tr('Comprimi') . '");
|
||||
$(this).text("'.tr('Comprimi').'");
|
||||
|
||||
// Forza il ridimensionamento del tooltip solo verticalmente
|
||||
var instance = $(".tooltipstered").tooltipster("instance");
|
||||
|
@@ -66,7 +66,7 @@ foreach ($moduli as $module_id => $note) {
|
||||
</tr>';
|
||||
|
||||
foreach ($note as $nota) {
|
||||
$class = (strtotime($nota->notification_date) < strtotime(date('Y-m-d')) && !empty($nota->notification_date)) ? 'danger' : '';
|
||||
$class = (strtotime((string) $nota->notification_date) < strtotime(date('Y-m-d')) && !empty($nota->notification_date)) ? 'danger' : '';
|
||||
|
||||
$documento = '';
|
||||
if ($modulo->getTranslation('title') == 'Attività') {
|
||||
|
@@ -179,7 +179,6 @@ switch (post('op')) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$operations['change_status'] = [
|
||||
'text' => '<span><i class="fa fa-refresh"></i> '.tr('Cambia stato'),
|
||||
'data' => [
|
||||
@@ -201,7 +200,6 @@ $operations['delete_bulk'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$operations['create_invoice'] = [
|
||||
'text' => '<span><i class="fa fa-file-code-o"></i> '.tr('Fattura _TYPE_', ['_TYPE_' => strtolower((string) $module->getTranslation('title'))]),
|
||||
'data' => [
|
||||
@@ -216,5 +214,4 @@ $operations['create_invoice'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
return $operations;
|
||||
|
@@ -681,7 +681,7 @@ if (!empty($elementi)) {
|
||||
'_DOC_' => $elemento['tipo_documento'],
|
||||
'_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($elemento['data']),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? "(".$elemento['stato_documento'].")" : ''),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? '('.$elemento['stato_documento'].')' : ''),
|
||||
]);
|
||||
|
||||
echo '
|
||||
|
@@ -38,7 +38,7 @@ if (!empty($riga_id)) {
|
||||
// Caso singola riga
|
||||
$riga = Riga::find($riga_id) ?: Articolo::find($riga_id);
|
||||
$riga = $riga ?: Sconto::find($riga_id);
|
||||
$righe_totali++;
|
||||
++$righe_totali;
|
||||
|
||||
if (!empty($riga) && !empty($riga->idiva) && !empty($riga->aliquota)) {
|
||||
$aliquote_iva[$riga->idiva] = [
|
||||
@@ -46,19 +46,19 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 1
|
||||
'count' => 1,
|
||||
];
|
||||
} else {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
} elseif (!empty($righe_ids)) {
|
||||
// Caso multiple righe
|
||||
$righe_array = explode(',', $righe_ids);
|
||||
$righe_array = explode(',', (string) $righe_ids);
|
||||
$righe_totali = count($righe_array);
|
||||
|
||||
foreach ($righe_array as $id_riga) {
|
||||
@@ -72,16 +72,16 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 0
|
||||
'count' => 0,
|
||||
];
|
||||
}
|
||||
$aliquote_iva[$riga->idiva]['count']++;
|
||||
++$aliquote_iva[$riga->idiva]['count'];
|
||||
} elseif (!empty($riga)) {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -92,20 +92,20 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
?>
|
||||
|
||||
<form id="modifica-iva-form">
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<?php if (count($aliquote_iva) > 1): ?>
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<?php endif; ?>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<?php if (count($aliquote_iva) > 1) { ?>
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -117,38 +117,38 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?= tr('eliminata') ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?= prepare(Models\Locale::getDefault()->id) ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?php echo tr('eliminata'); ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($show_form): ?>
|
||||
<?php } elseif ($show_form) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (count($righe_senza_iva) > 0): ?>
|
||||
<p><strong><?= tr('Righe senza aliquota IVA valida') ?>:</strong> <span class="badge"><?= count($righe_senza_iva) ?></span></p>
|
||||
<?php endif; ?>
|
||||
<?php if (count($righe_senza_iva) > 0) { ?>
|
||||
<p><strong><?php echo tr('Righe senza aliquota IVA valida'); ?>:</strong> <span class="badge"><?php echo count($righe_senza_iva); ?></span></p>
|
||||
<?php } ?>
|
||||
|
||||
<p class="text-muted"><?= tr('Totale righe selezionate') ?>: <?= $righe_totali ?></p>
|
||||
<p class="text-muted"><?php echo tr('Totale righe selezionate'); ?>: <?php echo $righe_totali; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -159,31 +159,31 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?= tr('eliminata') ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?= prepare(Models\Locale::getDefault()->id) ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?php echo tr('eliminata'); ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php } else { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-warning">
|
||||
<p><?= tr('Nessuna riga selezionata') ?></p>
|
||||
<p><?php echo tr('Nessuna riga selezionata'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="button" class="btn btn-primary" onclick="salvaIva()">
|
||||
<i class="fa fa-save"></i> <?= tr('Salva') ?>
|
||||
<i class="fa fa-save"></i> <?php echo tr('Salva'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -216,7 +216,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -237,7 +237,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -105,7 +105,7 @@ foreach ($righe as $riga) {
|
||||
if ($riga->isArticolo()) {
|
||||
echo Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$riga->descrizione);
|
||||
} else {
|
||||
echo nl2br($riga->descrizione);
|
||||
echo nl2br((string) $riga->descrizione);
|
||||
}
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
|
||||
@@ -128,7 +128,7 @@ foreach ($righe as $riga) {
|
||||
|
||||
if (!empty($riga->note)) {
|
||||
echo '
|
||||
<br><span class="text-xs">'.nl2br($riga->note).'</small>';
|
||||
<br><span class="text-xs">'.nl2br((string) $riga->note).'</small>';
|
||||
}
|
||||
echo '
|
||||
</td>';
|
||||
|
@@ -19,26 +19,25 @@
|
||||
*/
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
use Modules\DDT\Causale;
|
||||
|
||||
switch (filter('op')) {
|
||||
case 'update':
|
||||
$dbo->update('zz_default_description', [
|
||||
'name' => filter('name'),
|
||||
'descrizione' => filter('descrizione'),
|
||||
'note' => filter('note')
|
||||
'note' => filter('note'),
|
||||
], [
|
||||
'id' => $id_record
|
||||
'id' => $id_record,
|
||||
]);
|
||||
|
||||
$dbo->delete('zz_default_description_module', [
|
||||
'id_description' => $id_record
|
||||
'id_description' => $id_record,
|
||||
]);
|
||||
$id_moduli = (array) post('id_moduli');
|
||||
foreach ($id_moduli as $id_modulo) {
|
||||
$dbo->insert('zz_default_description_module', [
|
||||
'id_description' => $id_record,
|
||||
'id_module' => $id_modulo
|
||||
'id_module' => $id_modulo,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -50,7 +49,7 @@ switch (filter('op')) {
|
||||
$dbo->insert('zz_default_description', [
|
||||
'name' => filter('name'),
|
||||
'descrizione' => filter('descrizione'),
|
||||
'note' => filter('note')
|
||||
'note' => filter('note'),
|
||||
]);
|
||||
|
||||
$id_record = $dbo->lastInsertedId();
|
||||
@@ -58,7 +57,7 @@ switch (filter('op')) {
|
||||
foreach ($id_moduli as $id_modulo) {
|
||||
$dbo->insert('zz_default_description_module', [
|
||||
'id_description' => $id_record,
|
||||
'id_module' => $id_modulo
|
||||
'id_module' => $id_modulo,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -68,7 +67,7 @@ switch (filter('op')) {
|
||||
|
||||
case 'delete':
|
||||
$dbo->delete('zz_default_description', [
|
||||
'id' => $id_record
|
||||
'id' => $id_record,
|
||||
]);
|
||||
|
||||
flash()->info(tr('Risposta predefinita eliminata!'));
|
||||
|
@@ -18,12 +18,10 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use Modules\DDT\Causale;
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
if (!empty($id_record)) {
|
||||
$record = $dbo->fetchOne('SELECT * FROM `zz_default_description` WHERE `zz_default_description`.`id`='.prepare($id_record));
|
||||
$id_moduli = $dbo->select('zz_default_description_module', '*', [], ['id_description' => $id_record]);
|
||||
$id_moduli = implode(',' ,array_column($id_moduli, 'id_module'));
|
||||
$id_moduli = implode(',', array_column($id_moduli, 'id_module'));
|
||||
}
|
||||
|
@@ -120,7 +120,7 @@ echo '
|
||||
</div>
|
||||
</div>';
|
||||
|
||||
echo '
|
||||
echo '
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "select", "multiple": "1", "label": "'.tr('Mansioni').'", "name": "idmansioni[]", "value": "'.implode(',', $selected_mansioni).'", "ajax-source": "mansioni" ]}
|
||||
|
@@ -82,7 +82,7 @@ class Template extends Model
|
||||
return $this->belongsToMany(PrintTemplate::class, 'em_print_template', 'id_template', 'id_print');
|
||||
}
|
||||
|
||||
public function categories()
|
||||
public function categories()
|
||||
{
|
||||
return $this->belongsToMany(Categoria::class, 'em_files_categories_template', 'id_template', 'id_category');
|
||||
}
|
||||
|
@@ -953,8 +953,8 @@ switch ($op) {
|
||||
if ($imponibile) {
|
||||
$totale_imponibile = setting('Utilizza prezzi di vendita comprensivi di IVA') ? ($imponibile - $sconto) + (($imponibile - $sconto) * $iva->percentuale / 100) : ($imponibile - $sconto);
|
||||
$totale_imponibile = $fattura->tipo->reversed == 1 ? -$totale_imponibile : $totale_imponibile;
|
||||
} else if ($imponibile_indetraibile) {
|
||||
$totale_imponibile = setting('Utilizza prezzi di vendita comprensivi di IVA') ? ($imponibile_indetraibile - $sconto_indetraibile) + (($imponibile_indetraibile - $sconto_indetraibile) * $iva_indetraibile->percentuale / 100) : ($imponibile_indetraibile - $sconto_indetraibile);
|
||||
} elseif ($imponibile_indetraibile) {
|
||||
$totale_imponibile = setting('Utilizza prezzi di vendita comprensivi di IVA') ? ($imponibile_indetraibile - $sconto_indetraibile) + (($imponibile_indetraibile - $sconto_indetraibile) * $iva_indetraibile->percentuale / 100) : ($imponibile_indetraibile - $sconto_indetraibile);
|
||||
$totale_imponibile = $fattura->tipo->reversed == 1 ? -$totale_imponibile : $totale_imponibile;
|
||||
}
|
||||
|
||||
@@ -967,9 +967,9 @@ switch ($op) {
|
||||
|
||||
$riga = Riga::build($autofattura);
|
||||
$riga->descrizione = $tipo->getTranslation('title');
|
||||
$riga->id_iva = $imponibile ? $iva->id: $iva_indetraibile->id;
|
||||
$riga->id_iva = $imponibile ? $iva->id : $iva_indetraibile->id;
|
||||
$riga->idconto = setting('Conto per autofattura') ?: setting('Conto predefinito fatture di vendita');
|
||||
$riga->setPrezzoUnitario($totale_imponibile, $imponibile ? $iva->id: $iva_indetraibile->id);
|
||||
$riga->setPrezzoUnitario($totale_imponibile, $imponibile ? $iva->id : $iva_indetraibile->id);
|
||||
$riga->qta = 1;
|
||||
$riga->save();
|
||||
|
||||
|
@@ -22,17 +22,17 @@ include_once __DIR__.'/../../core.php';
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Models\Module;
|
||||
use Models\OperationLog;
|
||||
use Modules\Aggiornamenti\Controlli\DatiFattureElettroniche;
|
||||
use Modules\Anagrafiche\Anagrafica;
|
||||
use Modules\Emails\Template;
|
||||
use Modules\Fatture\Export\CSV;
|
||||
use Modules\Fatture\Fattura;
|
||||
use Modules\Fatture\Stato;
|
||||
use Notifications\EmailNotification;
|
||||
use Plugins\ExportFE\FatturaElettronica;
|
||||
use Plugins\ExportFE\Interaction;
|
||||
use Plugins\ReceiptFE\Ricevuta;
|
||||
use Modules\Emails\Template;
|
||||
use Notifications\EmailNotification;
|
||||
use Models\OperationLog;
|
||||
use Util\Zip;
|
||||
|
||||
$anagrafica_azienda = Anagrafica::find(setting('Azienda predefinita'));
|
||||
@@ -216,8 +216,8 @@ switch (post('op')) {
|
||||
$dst = $fe->getFilename();
|
||||
$src = $dbo->selectOne('zz_files', 'filename', ['original' => $dst])['filename'];
|
||||
} else {
|
||||
$src = basename($fattura->uploads()->where('name', 'Fattura Elettronica')->first()->filename);
|
||||
$dst = basename($fattura->uploads()->where('name', 'Fattura Elettronica')->first()->original_name);
|
||||
$src = basename((string) $fattura->uploads()->where('name', 'Fattura Elettronica')->first()->filename);
|
||||
$dst = basename((string) $fattura->uploads()->where('name', 'Fattura Elettronica')->first()->original_name);
|
||||
}
|
||||
|
||||
$file = slashes('files/'.$module->attachments_directory.'/'.$src);
|
||||
@@ -275,8 +275,8 @@ switch (post('op')) {
|
||||
foreach ($fatture as $r) {
|
||||
$fattura = Fattura::find($r['id']);
|
||||
$zz_file = $dbo->table('zz_files')->where('id_module', '=', $id_module)->where('id_record', '=', $fattura->id)->where('name', 'like', 'Ricevuta%')->first();
|
||||
$src = basename($fattura->uploads()->where('id', $zz_file->id)->first()->filename);
|
||||
$dst = basename($fattura->uploads()->where('id', $zz_file->id)->first()->original_name);
|
||||
$src = basename((string) $fattura->uploads()->where('id', $zz_file->id)->first()->filename);
|
||||
$dst = basename((string) $fattura->uploads()->where('id', $zz_file->id)->first()->original_name);
|
||||
|
||||
$file = slashes($module->upload_directory.'/'.$src);
|
||||
$dest = slashes($dir.'tmp/'.$dst);
|
||||
@@ -320,22 +320,22 @@ switch (post('op')) {
|
||||
|
||||
// + 1 giorno
|
||||
if (post('skip_time') == 'Giorno') {
|
||||
$data = date('Y-m-d', strtotime('+1 day', strtotime($fattura->data)));
|
||||
$data = date('Y-m-d', strtotime('+1 day', strtotime((string) $fattura->data)));
|
||||
}
|
||||
|
||||
// + 1 settimana
|
||||
if (post('skip_time') == 'Settimana') {
|
||||
$data = date('Y-m-d', strtotime('+1 week', strtotime($fattura->data)));
|
||||
$data = date('Y-m-d', strtotime('+1 week', strtotime((string) $fattura->data)));
|
||||
}
|
||||
|
||||
// + 1 mese
|
||||
if (post('skip_time') == 'Mese') {
|
||||
$data = date('Y-m-d', strtotime('+1 month', strtotime($fattura->data)));
|
||||
$data = date('Y-m-d', strtotime('+1 month', strtotime((string) $fattura->data)));
|
||||
}
|
||||
|
||||
// + 1 anno
|
||||
if (post('skip_time') == 'Anno') {
|
||||
$data = date('Y-m-d', strtotime('+1 year', strtotime($fattura->data)));
|
||||
$data = date('Y-m-d', strtotime('+1 year', strtotime((string) $fattura->data)));
|
||||
}
|
||||
|
||||
$new = $fattura->replicate();
|
||||
@@ -628,7 +628,7 @@ switch (post('op')) {
|
||||
|
||||
// Se non ci sono destinatari, salta questa fattura
|
||||
if (empty($emails)) {
|
||||
$failed_count++;
|
||||
++$failed_count;
|
||||
$failed_emails[] = $fattura->numero_esterno;
|
||||
continue;
|
||||
}
|
||||
@@ -669,10 +669,10 @@ switch (post('op')) {
|
||||
if ($email_success) {
|
||||
OperationLog::setInfo('id_email', $mail->id);
|
||||
$list[] = $fattura->numero_esterno;
|
||||
$success_count++;
|
||||
++$success_count;
|
||||
} else {
|
||||
$mail->delete();
|
||||
$failed_count++;
|
||||
++$failed_count;
|
||||
$failed_emails[] = $fattura->numero_esterno;
|
||||
}
|
||||
}
|
||||
@@ -800,14 +800,10 @@ $operations['copy_bulk'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
$operations['delete_bulk'] = [
|
||||
'text' => '<span><i class="fa fa-trash"></i> '.tr('Elimina').'</span>',
|
||||
];
|
||||
|
||||
|
||||
|
||||
if ($dir == 'entrata') {
|
||||
$operations['change_status'] = [
|
||||
'text' => '<span><i class="fa fa-refresh"></i> '.tr('Emetti fatture').'</span>',
|
||||
@@ -875,7 +871,6 @@ $operations['export_xml_bulk'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
if ($module->name == 'Fatture di vendita') {
|
||||
$operations['generate_xml'] = [
|
||||
'text' => '<span><i class="fa fa-file-code-o"></i> '.tr('Genera fatture elettroniche').'</span>',
|
||||
@@ -899,7 +894,6 @@ $operations['send-invoices'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$operations['registrazione_contabile'] = [
|
||||
'text' => '<span><i class="fa fa-calculator"></i> '.tr('Registrazione contabile').'</span>',
|
||||
'data' => [
|
||||
@@ -923,7 +917,4 @@ if (Interaction::isEnabled()) {
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return $operations;
|
||||
|
@@ -195,7 +195,7 @@ if ($dir == 'entrata') {
|
||||
$carbonDate = Carbon::createFromFormat($dateFormat, setting('Data inizio verifica contatore fattura di vendita'));
|
||||
$data_inizio_verifica_contatore = (($carbonDate !== false) ? strtotime($carbonDate->format('Y-m-d')) : null);
|
||||
}
|
||||
$data = ($fattura->data ? strtotime($fattura->data) : '');
|
||||
$data = ($fattura->data ? strtotime((string) $fattura->data) : '');
|
||||
if ($data >= $data_inizio_verifica_contatore || empty($data_inizio_verifica_contatore)) {
|
||||
$numero_previsto = verifica_numero_fattura($fattura);
|
||||
}
|
||||
@@ -503,8 +503,6 @@ if ($fattura->stato->id != $id_stato_bozza && $fattura->stato->id != $id_stato_a
|
||||
</div>
|
||||
<div class="clearfix"></div>';
|
||||
|
||||
|
||||
|
||||
foreach ($scadenze as $scadenza) {
|
||||
$pagamento_iniziato = !empty(floatval($scadenza->pagato)) || $scadenza->da_pagare == 0;
|
||||
|
||||
|
@@ -38,7 +38,7 @@ if (!empty($riga_id)) {
|
||||
// Caso singola riga
|
||||
$riga = Riga::find($riga_id) ?: Articolo::find($riga_id);
|
||||
$riga = $riga ?: Sconto::find($riga_id);
|
||||
$righe_totali++;
|
||||
++$righe_totali;
|
||||
|
||||
if (!empty($riga) && !empty($riga->idiva) && !empty($riga->aliquota)) {
|
||||
$aliquote_iva[$riga->idiva] = [
|
||||
@@ -46,19 +46,19 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 1
|
||||
'count' => 1,
|
||||
];
|
||||
} else {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
} elseif (!empty($righe_ids)) {
|
||||
// Caso multiple righe
|
||||
$righe_array = explode(',', $righe_ids);
|
||||
$righe_array = explode(',', (string) $righe_ids);
|
||||
$righe_totali = count($righe_array);
|
||||
|
||||
foreach ($righe_array as $id_riga) {
|
||||
@@ -72,16 +72,16 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 0
|
||||
'count' => 0,
|
||||
];
|
||||
}
|
||||
$aliquote_iva[$riga->idiva]['count']++;
|
||||
++$aliquote_iva[$riga->idiva]['count'];
|
||||
} elseif (!empty($riga)) {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -92,20 +92,20 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
?>
|
||||
|
||||
<form id="modifica-iva-form">
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<?php if (count($aliquote_iva) > 1): ?>
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<?php endif; ?>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<?php if (count($aliquote_iva) > 1) { ?>
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -117,38 +117,38 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?= tr('eliminata') ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?= prepare(Models\Locale::getDefault()->id) ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?php echo tr('eliminata'); ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($show_form): ?>
|
||||
<?php } elseif ($show_form) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (count($righe_senza_iva) > 0): ?>
|
||||
<p><strong><?= tr('Righe senza aliquota IVA valida') ?>:</strong> <span class="badge"><?= count($righe_senza_iva) ?></span></p>
|
||||
<?php endif; ?>
|
||||
<?php if (count($righe_senza_iva) > 0) { ?>
|
||||
<p><strong><?php echo tr('Righe senza aliquota IVA valida'); ?>:</strong> <span class="badge"><?php echo count($righe_senza_iva); ?></span></p>
|
||||
<?php } ?>
|
||||
|
||||
<p class="text-muted"><?= tr('Totale righe selezionate') ?>: <?= $righe_totali ?></p>
|
||||
<p class="text-muted"><?php echo tr('Totale righe selezionate'); ?>: <?php echo $righe_totali; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -159,31 +159,31 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?= tr('eliminata') ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?= prepare(Models\Locale::getDefault()->id) ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?php echo tr('eliminata'); ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php } else { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-warning">
|
||||
<p><?= tr('Nessuna riga selezionata') ?></p>
|
||||
<p><?php echo tr('Nessuna riga selezionata'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="button" class="btn btn-primary" onclick="salvaIva()">
|
||||
<i class="fa fa-save"></i> <?= tr('Salva') ?>
|
||||
<i class="fa fa-save"></i> <?php echo tr('Salva'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -216,7 +216,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -237,7 +237,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -152,7 +152,7 @@ foreach ($righe as $riga) {
|
||||
if ($riga->isArticolo()) {
|
||||
echo Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$riga->descrizione);
|
||||
} else {
|
||||
echo nl2br($riga->descrizione);
|
||||
echo nl2br((string) $riga->descrizione);
|
||||
}
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->articolo->deleted_at)) {
|
||||
@@ -186,9 +186,9 @@ foreach ($righe as $riga) {
|
||||
}
|
||||
|
||||
if (!empty($riga->note)) {
|
||||
if (strlen($riga->note) > 50) {
|
||||
$prima_parte = substr($riga->note, 0, (strpos($riga->note, ' ', 50) < 60) && (!str_starts_with($riga->note, ' ')) ? strpos($riga->note, ' ', 50) : 50);
|
||||
$seconda_parte = substr($riga->note, (strpos($riga->note, ' ', 50) < 60) && (!str_starts_with($riga->note, ' ')) ? strpos($riga->note, ' ', 50) : 50);
|
||||
if (strlen((string) $riga->note) > 50) {
|
||||
$prima_parte = substr((string) $riga->note, 0, (strpos((string) $riga->note, ' ', 50) < 60) && (!str_starts_with((string) $riga->note, ' ')) ? strpos((string) $riga->note, ' ', 50) : 50);
|
||||
$seconda_parte = substr((string) $riga->note, (strpos((string) $riga->note, ' ', 50) < 60) && (!str_starts_with((string) $riga->note, ' ')) ? strpos((string) $riga->note, ' ', 50) : 50);
|
||||
$stringa_modificata = '<span class="text-xs">'.$prima_parte.'</small>
|
||||
<span id="read-more-target-'.$riga->id.'" class="read-more-target"><span class="text-xs">'.$seconda_parte.'</small></span><a href="#read-more-target-'.$riga->id.'" class="read-more-trigger">...</a>';
|
||||
} else {
|
||||
|
@@ -170,7 +170,7 @@ class Movimenti
|
||||
}
|
||||
}
|
||||
// Caso 2: Fattura senza split payment - IVA normale (acquisti o vendite)
|
||||
else if (empty($split_payment)) {
|
||||
elseif (empty($split_payment)) {
|
||||
$id_conto = $is_acquisto ? setting('Conto per Iva su acquisti') : setting('Conto per Iva su vendite');
|
||||
$movimenti[] = [
|
||||
'id_conto' => $id_conto,
|
||||
|
@@ -33,7 +33,7 @@ if (!empty($record['last_executed_at'])) {
|
||||
$status_class = 'success';
|
||||
$status_text = tr('Eseguito recentemente');
|
||||
$status_icon = 'fa-check-circle';
|
||||
} else if ($diff->days < 7) {
|
||||
} elseif ($diff->days < 7) {
|
||||
$status_class = 'info';
|
||||
$status_text = tr('Eseguito da %d giorni', [$diff->days]);
|
||||
$status_icon = 'fa-clock-o';
|
||||
|
@@ -54,7 +54,7 @@ switch ($resource) {
|
||||
$where[] = 'my_impianti.idanagrafica='.prepare($superselect['idanagrafica']);
|
||||
}
|
||||
|
||||
if (isset($superselect['idsede_destinazione']) && $superselect['idsede_destinazione'] != "") {
|
||||
if (isset($superselect['idsede_destinazione']) && $superselect['idsede_destinazione'] != '') {
|
||||
$where[] = 'my_impianti.idsede='.prepare($superselect['idsede_destinazione'] ?: 0);
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ switch (post('op')) {
|
||||
|
||||
break;
|
||||
|
||||
// Rimuovo impianto e scollego tutti i suoi componenti
|
||||
// Rimuovo impianto e scollego tutti i suoi componenti
|
||||
case 'delete_bulk':
|
||||
$n_impianti = 0;
|
||||
|
||||
@@ -105,6 +105,4 @@ $operations['export_csv'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
return $operations;
|
||||
|
@@ -170,7 +170,7 @@ if (!empty($elementi)) {
|
||||
'_DOC_' => $elemento['tipo_documento'],
|
||||
'_NUM_' => $elemento['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($elemento['data']),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? "(".$elemento['stato_documento'].")" : ''),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? '('.$elemento['stato_documento'].')' : ''),
|
||||
]);
|
||||
|
||||
if ($elemento['tipo_documento'] == 'Attività') {
|
||||
|
@@ -37,7 +37,7 @@ class Impianto extends Model
|
||||
return $this->belongsTo(Anagrafica::class, 'idanagrafica');
|
||||
}
|
||||
|
||||
public static function build($matricola = null, $nome = null, ?\Modules\Articoli\Categoria $categoria = null, $anagrafica = null)
|
||||
public static function build($matricola = null, $nome = null, ?Categoria $categoria = null, $anagrafica = null)
|
||||
{
|
||||
$model = new static();
|
||||
$model->is_impianto = 1;
|
||||
@@ -53,6 +53,6 @@ class Impianto extends Model
|
||||
|
||||
public function categoria()
|
||||
{
|
||||
return $this->belongsTo(\Modules\Articoli\Categoria::class, 'id_categoria');
|
||||
return $this->belongsTo(Categoria::class, 'id_categoria');
|
||||
}
|
||||
}
|
||||
|
@@ -110,9 +110,10 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Importa un record nel database.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
*
|
||||
* @return bool|null True se l'importazione è riuscita, false altrimenti, null se l'operazione è stata saltata
|
||||
*/
|
||||
public function import($record, $update_record = true, $add_record = true)
|
||||
@@ -179,15 +180,34 @@ class CSV extends CSVImporter
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore in un log
|
||||
error_log('Errore durante l\'importazione dell\'impianto: ' . $e->getMessage());
|
||||
error_log('Errore durante l\'importazione dell\'impianto: '.$e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Matricola', 'Immagine', 'Import immagine', 'Nome', 'Partita IVA Cliente', 'Codice Fiscale Cliente', 'Categoria', 'Sottocategoria', 'Sede', 'Descrizione', 'Data installazione', 'Marca', 'Modello'],
|
||||
['00001', 'https://openstamanager.com/moduli/budget/budget.webp', '2', 'Lavatrice Samsung', '12345678901', '', 'Elettrodomestici', 'Lavatrici', 'Sede Principale', 'Lavatrice a carica frontale 8kg', '2023-01-01', 'Samsung', 'WW80TA046AX'],
|
||||
['00002', 'https://openstamanager.com/moduli/3cx/3cx.webp', '2', 'Caldaia Ariston', '', 'RSSMRA80A01H501U', 'Riscaldamento', 'Caldaie', 'Sede Secondaria', 'Caldaia a condensazione 24kW', '2023-03-06', 'Ariston', 'Genus One Net'],
|
||||
['00003', 'https://openstamanager.com/moduli/disponibilita-tecnici/tecnici.webp', '2', 'Forno Electrolux', '98765432109', '', 'Elettrodomestici', 'Forni', 'Sede Principale', 'Forno elettrico multifunzione', '2023-04-01', 'Electrolux', 'EOC6P77WX'],
|
||||
['00004', 'https://openstamanager.com/moduli/distinta-base/distinta.webp', '2', 'Lavastoviglie Bosch', '12345678901', '', 'Elettrodomestici', 'Lavastoviglie', 'Sede Principale', 'Lavastoviglie da incasso 60cm', '2023-08-06', 'Bosch', 'SMV4HCX48E'],
|
||||
['00005', '', '', 'Condizionatore Daikin', '', 'VRDLGI75M15F205Z', 'Climatizzazione', 'Split', 'Sede Principale', 'Condizionatore inverter 12000 BTU', '2023-05-15', 'Daikin', 'FTXM35R'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova l'anagrafica cliente in base alla partita IVA o al codice fiscale.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
*
|
||||
* @return Anagrafica|null
|
||||
*/
|
||||
protected function trovaAnagrafica($record)
|
||||
@@ -208,8 +228,9 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Trova l'impianto esistente in base alla chiave primaria.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param array $record Record da importare
|
||||
* @param string $primary_key Chiave primaria
|
||||
*
|
||||
* @return Impianto|null
|
||||
*/
|
||||
protected function trovaImpianto($record, $primary_key)
|
||||
@@ -225,6 +246,7 @@ class CSV extends CSVImporter
|
||||
* Processa la categoria dell'impianto.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
*
|
||||
* @return Categoria|null
|
||||
*/
|
||||
protected function processaCategoria($record)
|
||||
@@ -247,8 +269,9 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Processa la sottocategoria dell'impianto.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param array $record Record da importare
|
||||
* @param Categoria|null $categoria Categoria padre
|
||||
*
|
||||
* @return Categoria|null
|
||||
*/
|
||||
protected function processaSottocategoria($record, $categoria)
|
||||
@@ -272,8 +295,9 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Processa la marca dell'impianto.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
protected function processaMarca($record, $database)
|
||||
@@ -297,10 +321,10 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Aggiorna i campi dell'impianto.
|
||||
*
|
||||
* @param Impianto $impianto Impianto da aggiornare
|
||||
* @param array $record Record da importare
|
||||
* @param Impianto $impianto Impianto da aggiornare
|
||||
* @param array $record Record da importare
|
||||
* @param Anagrafica $anagrafica Anagrafica cliente
|
||||
* @param int|null $id_marca ID della marca
|
||||
* @param int|null $id_marca ID della marca
|
||||
*/
|
||||
protected function aggiornaImpianto($impianto, $record, $anagrafica, $id_marca)
|
||||
{
|
||||
@@ -324,8 +348,8 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Collega la sede all'impianto.
|
||||
*
|
||||
* @param Impianto $impianto Impianto da aggiornare
|
||||
* @param array $record Record da importare
|
||||
* @param Impianto $impianto Impianto da aggiornare
|
||||
* @param array $record Record da importare
|
||||
* @param Anagrafica $anagrafica Anagrafica cliente
|
||||
*/
|
||||
protected function collegaSede($impianto, $record, $anagrafica)
|
||||
@@ -347,9 +371,9 @@ class CSV extends CSVImporter
|
||||
* Processa l'immagine dell'impianto.
|
||||
*
|
||||
* @param Impianto $impianto Impianto da aggiornare
|
||||
* @param string $url URL dell'immagine
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
* @param string $url URL dell'immagine
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
*/
|
||||
protected function processaImmagine($impianto, $url, $record, $database)
|
||||
{
|
||||
@@ -398,24 +422,7 @@ class CSV extends CSVImporter
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore ma continua con l'importazione
|
||||
error_log('Errore durante l\'importazione dell\'immagine: ' . $e->getMessage());
|
||||
error_log('Errore durante l\'importazione dell\'immagine: '.$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Matricola', 'Immagine', 'Import immagine', 'Nome', 'Partita IVA Cliente', 'Codice Fiscale Cliente', 'Categoria', 'Sottocategoria', 'Sede', 'Descrizione', 'Data installazione', 'Marca', 'Modello'],
|
||||
['00001', 'https://openstamanager.com/moduli/budget/budget.webp', '2', 'Lavatrice Samsung', '12345678901', '', 'Elettrodomestici', 'Lavatrici', 'Sede Principale', 'Lavatrice a carica frontale 8kg', '2023-01-01', 'Samsung', 'WW80TA046AX'],
|
||||
['00002', 'https://openstamanager.com/moduli/3cx/3cx.webp', '2', 'Caldaia Ariston', '', 'RSSMRA80A01H501U', 'Riscaldamento', 'Caldaie', 'Sede Secondaria', 'Caldaia a condensazione 24kW', '2023-03-06', 'Ariston', 'Genus One Net'],
|
||||
['00003', 'https://openstamanager.com/moduli/disponibilita-tecnici/tecnici.webp', '2', 'Forno Electrolux', '98765432109', '', 'Elettrodomestici', 'Forni', 'Sede Principale', 'Forno elettrico multifunzione', '2023-04-01', 'Electrolux', 'EOC6P77WX'],
|
||||
['00004', 'https://openstamanager.com/moduli/distinta-base/distinta.webp', '2', 'Lavastoviglie Bosch', '12345678901', '', 'Elettrodomestici', 'Lavastoviglie', 'Sede Principale', 'Lavastoviglie da incasso 60cm', '2023-08-06', 'Bosch', 'SMV4HCX48E'],
|
||||
['00005', '', '', 'Condizionatore Daikin', '', 'VRDLGI75M15F205Z', 'Climatizzazione', 'Split', 'Sede Principale', 'Condizionatore inverter 12000 BTU', '2023-05-15', 'Daikin', 'FTXM35R'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -63,9 +63,9 @@ switch (filter('op')) {
|
||||
VALUES ("example-'.strtolower((string) $import->getTranslation('title')).'", "example-'.strtolower((string) $import->getTranslation('title')).'.csv", '.$id_module.', NULL, '.$id_import.', '.filesize($filepath).', 1, "'.basename($filepath).'", '.Auth::user()->id.', NOW())');
|
||||
|
||||
echo base_path().'/'.$file;
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
// Log dell'errore
|
||||
error_log('Errore durante la generazione del file di esempio: ' . $e->getMessage());
|
||||
error_log('Errore durante la generazione del file di esempio: '.$e->getMessage());
|
||||
|
||||
// Risposta di errore
|
||||
echo json_encode([
|
||||
@@ -112,7 +112,7 @@ switch (filter('op')) {
|
||||
if (!isset($page) || empty($page)) {
|
||||
if (!$csv->areRequiredFieldsMapped()) {
|
||||
// Verifica se è il caso speciale delle anagrafiche (telefono o partita IVA)
|
||||
$is_anagrafica_import = strpos(get_class($csv), 'Anagrafiche') !== false;
|
||||
$is_anagrafica_import = str_contains($csv::class, 'Anagrafiche');
|
||||
$error_message = $is_anagrafica_import ?
|
||||
tr('Alcuni campi obbligatori non sono stati mappati. La ragione sociale è obbligatoria e almeno uno tra telefono e partita IVA deve essere mappato.') :
|
||||
tr('Alcuni campi obbligatori non sono stati mappati');
|
||||
|
@@ -69,9 +69,8 @@ if (empty($id_record)) {
|
||||
|
||||
// Caso speciale per anagrafiche: telefono e partita IVA (almeno uno dei due è obbligatorio)
|
||||
foreach ($fields as $key => $value) {
|
||||
if (($value['field'] === 'telefono' || $value['field'] === 'piva') &&
|
||||
isset($value['required']) && $value['required'] === false) {
|
||||
|
||||
if (($value['field'] === 'telefono' || $value['field'] === 'piva')
|
||||
&& isset($value['required']) && $value['required'] === false) {
|
||||
// Sposta questi campi tra quelli obbligatori
|
||||
foreach ($campi_opzionali as $index => $campo) {
|
||||
if ($campo['id'] === $key + 1) {
|
||||
@@ -86,9 +85,7 @@ if (empty($id_record)) {
|
||||
}
|
||||
|
||||
// Ordina i campi opzionali in ordine alfabetico
|
||||
usort($campi_opzionali, function($a, $b) {
|
||||
return strcmp($a['text'], $b['text']);
|
||||
});
|
||||
usort($campi_opzionali, fn ($a, $b) => strcmp((string) $a['text'], (string) $b['text']));
|
||||
|
||||
// Unisci i campi, prima gli obbligatori e poi gli opzionali ordinati alfabeticamente
|
||||
$campi_disponibili = array_merge($campi_obbligatori, array_values($campi_opzionali));
|
||||
@@ -102,41 +99,40 @@ if (empty($id_record)) {
|
||||
<i class="fa fa-info-circle"></i> <strong>'.tr('Informazioni importanti:').'</strong>
|
||||
<div style="margin-top: 8px;">'.tr('I campi con * sono obbligatori e devono essere mappati nel file CSV.').'</div>';
|
||||
|
||||
if ($import_selezionato === 'Modules\Anagrafiche\Import\CSV') {
|
||||
echo '<div style="margin-top: 8px;"><i class="fa fa-exclamation-triangle"></i> <strong>'.tr('Requisiti:').'</strong> '.tr('Mappare almeno uno tra Telefono e Partita IVA.').'</div>
|
||||
if ($import_selezionato === Modules\Anagrafiche\Import\CSV::class) {
|
||||
echo '<div style="margin-top: 8px;"><i class="fa fa-exclamation-triangle"></i> <strong>'.tr('Requisiti:').'</strong> '.tr('Mappare almeno uno tra Telefono e Partita IVA.').'</div>
|
||||
<div style="margin-top: 8px;"><i class="fa fa-magic"></i> <strong>'.tr('Automatismi:').'</strong> '.tr('I campi Tipo anagrafica e Settore merceologico vengono generati automaticamente se mappati.').'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($import_selezionato === 'Modules\Articoli\Import\CSV') {
|
||||
echo '<div style="margin-top: 8px;"><i class="fa fa-exclamation-triangle"></i> <strong>'.tr('Formato numeri:').'</strong> '.tr('Gli importi inseriti devono avere come separatore il punto e presentare due decimali.').'</div>
|
||||
if ($import_selezionato === Modules\Articoli\Import\CSV::class) {
|
||||
echo '<div style="margin-top: 8px;"><i class="fa fa-exclamation-triangle"></i> <strong>'.tr('Formato numeri:').'</strong> '.tr('Gli importi inseriti devono avere come separatore il punto e presentare due decimali.').'</div>
|
||||
<div style="margin-top: 8px;"><i class="fa fa-link"></i> <strong>'.tr('Associazione anagrafiche:').'</strong> '.tr('L\'importazione dell\'anagrafica collegata all\'articolo avviene utilizzando come chiave primaria la Partita IVA, e in seguito la ragione sociale se non viene trovata corrispondenza. È opportuno pertanto indicare nel file CSV di importazione la partita IVA dell\'anagrafica per associare correttamente l\'anagrafica cliente/fornitore del listino.').'</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($import_selezionato === 'Modules\Interventi\Import\CSV') {
|
||||
echo '<div class="alert alert-info" style="background-color: #17a2b8; color: white; border: none; padding: 10px 15px;">
|
||||
if ($import_selezionato === Modules\Interventi\Import\CSV::class) {
|
||||
echo '<div class="alert alert-info" style="background-color: #17a2b8; color: white; border: none; padding: 10px 15px;">
|
||||
<div style="margin-top: 8px;"><i class="fa fa-link"></i> <strong>'.tr('Anagrafiche:').'</strong> '.tr('La ricerca dell\'anagrafica da collegare all\'attività avviene sulla base della partita IVA o del codice fiscale mappato. Per procedere all\'importazione dell\'attività è pertanto necessario che almeno uno dei due valori siano censiti in anagrafica.').'</div>
|
||||
<div style="margin-top: 8px;"><i class="fa fa-cogs"></i> <strong>'.tr('Impianti:').'</strong> '.tr('Per procedere all\'importazione di attività collegate ad impianti è necessario che la matricola indicata sia già censita in impianti. Procedere quindi prima all\'importazione degli impianti e successivamente delle attività.').'</div>
|
||||
<div style="margin-top: 8px;"><i class="fa fa-magic"></i> <strong>'.tr('Automatismi:').'</strong> '.tr('È presente in fase di importazione un automatismo che genera automaticamente i valori dei seguenti campi se mappati: la sessione del tecnico se mappato l\'orario di inizio attività, lo stato attività se non è già presente a gestionale.').'</div>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($import_selezionato === 'Modules\Impianti\Import\CSV') {
|
||||
echo '<div class="alert alert-info" style="background-color: #17a2b8; color: white; border: none; padding: 10px 15px;">
|
||||
if ($import_selezionato === Modules\Impianti\Import\CSV::class) {
|
||||
echo '<div class="alert alert-info" style="background-color: #17a2b8; color: white; border: none; padding: 10px 15px;">
|
||||
<div style="margin-top: 8px;"><i class="fa fa-link"></i> <strong>'.tr('Anagrafiche:').'</strong> '.tr('La ricerca dell\'anagrafica da collegare all\'impianto avviene sulla base della partita IVA o del codice fiscale mappato. Per procedere all\'importazione dell\'impianto è pertanto necessario che almeno uno dei due valori siano censiti in anagrafica.').'</div>
|
||||
<div style="margin-top: 8px;"><i class="fa fa-exclamation-triangle"></i> <strong>'.tr('Requisiti:').'</strong> '.tr('I campi Matricola e Nome sono obbligatori. Inoltre, è necessario mappare almeno uno tra Partita IVA cliente e Codice Fiscale cliente.').'</div>
|
||||
<div style="margin-top: 8px;"><i class="fa fa-magic"></i> <strong>'.tr('Automatismi:').'</strong> '.tr('Le categorie e sottocategorie vengono create automaticamente se non esistenti. Le marche vengono create automaticamente se non esistenti.').'</div>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
if ($import_selezionato === 'Modules\ListiniCliente\Import\CSV') {
|
||||
echo '<div class="alert alert-info" style="background-color: #17a2b8; color: white; border: none; padding: 10px 15px;">
|
||||
if ($import_selezionato === Modules\ListiniCliente\Import\CSV::class) {
|
||||
echo '<div class="alert alert-info" style="background-color: #17a2b8; color: white; border: none; padding: 10px 15px;">
|
||||
<div style="margin-top: 8px;"><i class="fa fa-exclamation-triangle"></i> <strong>'.tr('Requisiti:').'</strong> '.tr('I campi Nome listino, Codice articolo e Prezzo unitario sono obbligatori.').'</div>
|
||||
<div style="margin-top: 8px;"><i class="fa fa-magic"></i> <strong>'.tr('Automatismi:').'</strong> '.tr('Se il listino o l\'articolo non esistono, l\'importazione verrà saltata.').'</div>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo '</div><div class="alert alert-warning" style="background-color: #ffc107; color: #212529; border: none; padding: 10px 15px;">
|
||||
echo '</div><div class="alert alert-warning" style="background-color: #ffc107; color: #212529; border: none; padding: 10px 15px;">
|
||||
<i class="fa fa-warning"></i> <strong>'.tr('ATTENZIONE:').'</strong>
|
||||
<div style="margin-top: 8px;">'.tr('Per record esistenti, tutti i campi mappati sovrascriveranno i dati attuali, anche se vuoti nel CSV. Non mappare le colonne che non si desidera modificare.').'</div>
|
||||
</div>';
|
||||
|
@@ -66,7 +66,7 @@ switch (filter('op')) {
|
||||
}
|
||||
$results[$setting->sezione][] = [
|
||||
'id' => $setting->id,
|
||||
'nome' => $setting->nome
|
||||
'nome' => $setting->nome,
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -69,8 +69,8 @@ foreach ($gruppi as $key => $gruppo) {
|
||||
<div class="card-title">
|
||||
<i class="fa fa-sliders mr-2"></i>
|
||||
'.tr('_SEZIONE_', [
|
||||
'_SEZIONE_' => $gruppo->nome,
|
||||
]).'
|
||||
'_SEZIONE_' => $gruppo->nome,
|
||||
]).'
|
||||
</div>
|
||||
<div class="card-tools pull-right">
|
||||
<div class="badge">'.$gruppo->numero.'</div>
|
||||
|
@@ -41,8 +41,6 @@ use Modules\TipiIntervento\Tipo as TipoSessione;
|
||||
use Plugins\ComponentiImpianti\Componente;
|
||||
use Plugins\ListinoClienti\DettaglioPrezzo;
|
||||
use Plugins\PianificazioneInterventi\Promemoria;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Intervention\Image\Drivers\Imagick\Driver;
|
||||
|
||||
$id_modulo_impianti = Module::where('name', 'Impianti')->first()->id;
|
||||
$plugin_impianti = Plugin::where('name', 'Impianti')->first()->id;
|
||||
@@ -405,13 +403,13 @@ switch (post('op')) {
|
||||
foreach ($sessioni as $sessione) {
|
||||
// Se è la prima sessione che copio importo la data con quella della richiesta
|
||||
if ($numero_sessione == 0) {
|
||||
$orario_inizio = date('Y-m-d', strtotime((string) $data_ricorrenza)).' '.date('H:i:s', strtotime($sessione->orario_inizio));
|
||||
$orario_inizio = date('Y-m-d', strtotime((string) $data_ricorrenza)).' '.date('H:i:s', strtotime((string) $sessione->orario_inizio));
|
||||
} else {
|
||||
$diff = strtotime($sessione->orario_inizio) - strtotime((string) $inizio_old);
|
||||
$orario_inizio = date('Y-m-d H:i:s', strtotime($new_sessione->orario_inizio) + $diff);
|
||||
$diff = strtotime((string) $sessione->orario_inizio) - strtotime((string) $inizio_old);
|
||||
$orario_inizio = date('Y-m-d H:i:s', strtotime((string) $new_sessione->orario_inizio) + $diff);
|
||||
}
|
||||
|
||||
$diff_fine = strtotime($sessione->orario_fine) - strtotime($sessione->orario_inizio);
|
||||
$diff_fine = strtotime((string) $sessione->orario_fine) - strtotime((string) $sessione->orario_inizio);
|
||||
$orario_fine = date('Y-m-d H:i:s', strtotime($orario_inizio) + $diff_fine);
|
||||
|
||||
$new_sessione = $sessione->replicate();
|
||||
@@ -753,8 +751,8 @@ switch (post('op')) {
|
||||
});
|
||||
|
||||
if (setting('Sistema di firma') == 'Tavoletta Wacom') {
|
||||
$img->brightness((float)setting('Luminosità firma Wacom'));
|
||||
$img->contrast((float)setting('Contrasto firma Wacom'));
|
||||
$img->brightness((float) setting('Luminosità firma Wacom'));
|
||||
$img->contrast((float) setting('Contrasto firma Wacom'));
|
||||
}
|
||||
|
||||
if (!$img->save(base_dir().'/files/interventi/'.$firma_file)) {
|
||||
@@ -1110,13 +1108,13 @@ switch (post('op')) {
|
||||
foreach ($sessioni as $sessione) {
|
||||
// Se è la prima sessione che copio importo la data con quella della richiesta
|
||||
if ($numero_sessione == 0) {
|
||||
$orario_inizio = date('Y-m-d', strtotime($data_richiesta)).' '.date('H:i:s', strtotime($sessione->orario_inizio));
|
||||
$orario_inizio = date('Y-m-d', strtotime($data_richiesta)).' '.date('H:i:s', strtotime((string) $sessione->orario_inizio));
|
||||
} else {
|
||||
$diff = strtotime($sessione->orario_inizio) - strtotime((string) $inizio_old);
|
||||
$orario_inizio = date('Y-m-d H:i:s', strtotime($new_sessione->orario_inizio) + $diff);
|
||||
$diff = strtotime((string) $sessione->orario_inizio) - strtotime((string) $inizio_old);
|
||||
$orario_inizio = date('Y-m-d H:i:s', strtotime((string) $new_sessione->orario_inizio) + $diff);
|
||||
}
|
||||
|
||||
$diff_fine = strtotime($sessione->orario_fine) - strtotime($sessione->orario_inizio);
|
||||
$diff_fine = strtotime((string) $sessione->orario_fine) - strtotime((string) $sessione->orario_inizio);
|
||||
$orario_fine = date('Y-m-d H:i:s', strtotime($orario_inizio) + $diff_fine);
|
||||
|
||||
$new_sessione = $sessione->replicate();
|
||||
|
@@ -66,7 +66,6 @@ $anagrafica = $dbo->fetchOne('SELECT idtipointervento_default, idzona FROM an_an
|
||||
$id_tipo = $anagrafica['idtipointervento_default'];
|
||||
$id_zona = $anagrafica['idzona'];
|
||||
|
||||
|
||||
// Trasformazione di un Promemoria dei Contratti in Intervento
|
||||
if (!empty($id_contratto) && !empty($id_promemoria_contratto)) {
|
||||
$contratto = $dbo->fetchOne('SELECT *, (SELECT idzona FROM an_anagrafiche WHERE idanagrafica = co_contratti.idanagrafica) AS idzona FROM co_contratti WHERE id = '.prepare($id_contratto));
|
||||
|
@@ -80,14 +80,14 @@ if ($show_prezzi) {
|
||||
</tr>
|
||||
</tbody>';
|
||||
|
||||
// Calcoli
|
||||
$imponibile = abs($intervento->imponibile);
|
||||
$sconto = -$intervento->sconto;
|
||||
$totale_imponibile = abs($intervento->totale_imponibile);
|
||||
$iva = abs($intervento->iva);
|
||||
$totale = abs($intervento->totale);
|
||||
// Calcoli
|
||||
$imponibile = abs($intervento->imponibile);
|
||||
$sconto = -$intervento->sconto;
|
||||
$totale_imponibile = abs($intervento->totale_imponibile);
|
||||
$iva = abs($intervento->iva);
|
||||
$totale = abs($intervento->totale);
|
||||
|
||||
echo '
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b>'.tr('Imponibile', [], ['upper' => true]).':</b>
|
||||
@@ -97,9 +97,9 @@ if ($show_prezzi) {
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
// Totale sconto
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
// Totale sconto
|
||||
if (!empty($sconto)) {
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b><span class="tip" title="'.tr('Un importo positivo indica uno sconto, mentre uno negativo indica una maggiorazione').'"> <i class="fa fa-question-circle-o"></i> '.tr('Sconto/maggiorazione', [], ['upper' => true]).':</span></b>
|
||||
@@ -109,8 +109,8 @@ if ($show_prezzi) {
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
// Totale imponibile
|
||||
echo '
|
||||
// Totale imponibile
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b>'.tr('Totale imponibile', [], ['upper' => true]).':</b>
|
||||
@@ -119,10 +119,10 @@ if ($show_prezzi) {
|
||||
'.moneyFormat($totale_imponibile, 2).'
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
// Totale iva
|
||||
echo '
|
||||
// Totale iva
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b><i class="fa fa-question-circle-o tip" title="'.tr("Il valore dell'IVA totale è esclusivamente indicativo e basato sulle impostazioni di default del gestionale se non è impostata l'iva predefinita nell'anagrafica").'."></i> '.tr('IVA', [], ['upper' => true]).':</b>
|
||||
@@ -132,8 +132,8 @@ if ($show_prezzi) {
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
// Totale attività
|
||||
echo '
|
||||
// Totale attività
|
||||
echo '
|
||||
<tr>
|
||||
<td colspan="3" class="text-right">
|
||||
<b>'.tr('Totale documento', [], ['upper' => true]).':</b>
|
||||
@@ -143,7 +143,7 @@ if ($show_prezzi) {
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
echo '
|
||||
echo '
|
||||
</table>
|
||||
</div>';
|
||||
}
|
||||
|
@@ -265,13 +265,13 @@ switch (post('op')) {
|
||||
foreach ($sessioni as $sessione) {
|
||||
// Se è la prima sessione che copio importo la data con quella della richiesta
|
||||
if ($numero_sessione == 0) {
|
||||
$orario_inizio = date('Y-m-d', strtotime($data_richiesta)).' '.date('H:i:s', strtotime($sessione->orario_inizio));
|
||||
$orario_inizio = date('Y-m-d', strtotime($data_richiesta)).' '.date('H:i:s', strtotime((string) $sessione->orario_inizio));
|
||||
} else {
|
||||
$diff = strtotime($sessione->orario_inizio) - strtotime((string) $inizio_old);
|
||||
$orario_inizio = date('Y-m-d H:i:s', strtotime($new_sessione->orario_inizio) + $diff);
|
||||
$diff = strtotime((string) $sessione->orario_inizio) - strtotime((string) $inizio_old);
|
||||
$orario_inizio = date('Y-m-d H:i:s', strtotime((string) $new_sessione->orario_inizio) + $diff);
|
||||
}
|
||||
|
||||
$diff_fine = strtotime($sessione->orario_fine) - strtotime($sessione->orario_inizio);
|
||||
$diff_fine = strtotime((string) $sessione->orario_fine) - strtotime((string) $sessione->orario_inizio);
|
||||
$orario_fine = date('Y-m-d H:i:s', strtotime($orario_inizio) + $diff_fine);
|
||||
|
||||
$new_sessione = $sessione->replicate();
|
||||
@@ -531,6 +531,4 @@ $operations['print_summary'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
|
||||
return $operations;
|
||||
|
@@ -779,7 +779,7 @@ if (!empty($elementi)) {
|
||||
'_DOC_' => $fattura['tipo_documento'],
|
||||
'_NUM_' => !empty($fattura['numero_esterno']) ? $fattura['numero_esterno'] : $fattura['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($fattura['data']),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? "(".$elemento['stato_documento'].")" : ''),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? '('.$elemento['stato_documento'].')' : ''),
|
||||
]);
|
||||
|
||||
$modulo = ($fattura['dir'] == 'entrata') ? 'Fatture di vendita' : 'Fatture di acquisto';
|
||||
|
@@ -196,7 +196,7 @@ echo '
|
||||
|
||||
<div class="mb-3 status-item attivita-item">
|
||||
<div class="d-flex align-items-center mb-2">
|
||||
<span class="status-icon badge badge-'.(count($interventi_programmati) == 0 ? 'success' : 'warning').' mr-2"><i class="fa fa-'.( count($interventi_programmati) == 0 ? 'check-circle' : 'calendar').'"></i></span>
|
||||
<span class="status-icon badge badge-'.(count($interventi_programmati) == 0 ? 'success' : 'warning').' mr-2"><i class="fa fa-'.(count($interventi_programmati) == 0 ? 'check-circle' : 'calendar').'"></i></span>
|
||||
<span class="status-text">'.(count($interventi_programmati) == 0 ? tr('Non sono presenti altre attività programmate') : tr('Attività aperte')).'</span>
|
||||
</div>';
|
||||
if (count($interventi_programmati) != 0) {
|
||||
|
@@ -38,7 +38,7 @@ if (!empty($riga_id)) {
|
||||
// Caso singola riga
|
||||
$riga = Riga::find($riga_id) ?: Articolo::find($riga_id);
|
||||
$riga = $riga ?: Sconto::find($riga_id);
|
||||
$righe_totali++;
|
||||
++$righe_totali;
|
||||
|
||||
if (!empty($riga) && !empty($riga->idiva) && !empty($riga->aliquota)) {
|
||||
$aliquote_iva[$riga->idiva] = [
|
||||
@@ -46,19 +46,19 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 1
|
||||
'count' => 1,
|
||||
];
|
||||
} else {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
} elseif (!empty($righe_ids)) {
|
||||
// Caso multiple righe
|
||||
$righe_array = explode(',', $righe_ids);
|
||||
$righe_array = explode(',', (string) $righe_ids);
|
||||
$righe_totali = count($righe_array);
|
||||
|
||||
foreach ($righe_array as $id_riga) {
|
||||
@@ -72,16 +72,16 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 0
|
||||
'count' => 0,
|
||||
];
|
||||
}
|
||||
$aliquote_iva[$riga->idiva]['count']++;
|
||||
++$aliquote_iva[$riga->idiva]['count'];
|
||||
} elseif (!empty($riga)) {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -92,20 +92,20 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
?>
|
||||
|
||||
<form id="modifica-iva-form">
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<?php if (count($aliquote_iva) > 1): ?>
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<?php endif; ?>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<?php if (count($aliquote_iva) > 1) { ?>
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -117,38 +117,38 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?= tr('eliminata') ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?= prepare(Models\Locale::getDefault()->id) ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?php echo tr('eliminata'); ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($show_form): ?>
|
||||
<?php } elseif ($show_form) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (count($righe_senza_iva) > 0): ?>
|
||||
<p><strong><?= tr('Righe senza aliquota IVA valida') ?>:</strong> <span class="badge"><?= count($righe_senza_iva) ?></span></p>
|
||||
<?php endif; ?>
|
||||
<?php if (count($righe_senza_iva) > 0) { ?>
|
||||
<p><strong><?php echo tr('Righe senza aliquota IVA valida'); ?>:</strong> <span class="badge"><?php echo count($righe_senza_iva); ?></span></p>
|
||||
<?php } ?>
|
||||
|
||||
<p class="text-muted"><?= tr('Totale righe selezionate') ?>: <?= $righe_totali ?></p>
|
||||
<p class="text-muted"><?php echo tr('Totale righe selezionate'); ?>: <?php echo $righe_totali; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -159,31 +159,31 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?= tr('eliminata') ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?= prepare(Models\Locale::getDefault()->id) ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?php echo tr('eliminata'); ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php } else { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-warning">
|
||||
<p><?= tr('Nessuna riga selezionata') ?></p>
|
||||
<p><?php echo tr('Nessuna riga selezionata'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="button" class="btn btn-primary" onclick="salvaIva()">
|
||||
<i class="fa fa-save"></i> <?= tr('Salva') ?>
|
||||
<i class="fa fa-save"></i> <?php echo tr('Salva'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -216,7 +216,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -237,7 +237,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -243,7 +243,7 @@ if (!function_exists('aggiungi_sessioni_in_fattura')) {
|
||||
$riga = Riga::build($fattura);
|
||||
|
||||
foreach ($gruppo as $sessione) {
|
||||
$dateValue = date('d/m/Y', strtotime($sessione->orario_fine));
|
||||
$dateValue = date('d/m/Y', strtotime((string) $sessione->orario_fine));
|
||||
if (!in_array($dateValue, $date)) {
|
||||
$date[] = $dateValue;
|
||||
}
|
||||
@@ -293,7 +293,7 @@ if (!function_exists('aggiungi_sessioni_in_fattura')) {
|
||||
$riga = Riga::build($fattura);
|
||||
|
||||
foreach ($gruppo as $sessione) {
|
||||
$dateValue = date('d/m/Y', strtotime($sessione->orario_fine));
|
||||
$dateValue = date('d/m/Y', strtotime((string) $sessione->orario_fine));
|
||||
if (!in_array($dateValue, $date)) {
|
||||
$date[] = $dateValue;
|
||||
}
|
||||
@@ -334,7 +334,7 @@ if (!function_exists('aggiungi_sessioni_in_fattura')) {
|
||||
}
|
||||
|
||||
foreach ($gruppo as $sessione) {
|
||||
$dateValue = date('d/m/Y', strtotime($sessione->orario_fine));
|
||||
$dateValue = date('d/m/Y', strtotime((string) $sessione->orario_fine));
|
||||
if (!in_array($dateValue, $date)) {
|
||||
$date[] = $dateValue;
|
||||
}
|
||||
|
@@ -106,7 +106,7 @@ foreach ($righe as $riga) {
|
||||
|
||||
if (!empty($riga->note)) {
|
||||
echo '
|
||||
<br><span class="text-xs">'.nl2br($riga->note).'</small>';
|
||||
<br><span class="text-xs">'.nl2br((string) $riga->note).'</small>';
|
||||
}
|
||||
echo '
|
||||
</td>
|
||||
|
@@ -127,9 +127,10 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Importa un record nel database.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
*
|
||||
* @return bool|null True se l'importazione è riuscita, false altrimenti, null se l'operazione è stata saltata
|
||||
*/
|
||||
public function import($record, $update_record = true, $add_record = true)
|
||||
@@ -139,8 +140,8 @@ class CSV extends CSVImporter
|
||||
$primary_key = $this->getPrimaryKey();
|
||||
|
||||
// Validazione dei campi obbligatori
|
||||
if (empty($record['codice']) || empty($record['data']) || empty($record['data_richiesta']) ||
|
||||
empty($record['ora_inizio']) || empty($record['tecnico']) || empty($record['richiesta'])) {
|
||||
if (empty($record['codice']) || empty($record['data']) || empty($record['data_richiesta'])
|
||||
|| empty($record['ora_inizio']) || empty($record['tecnico']) || empty($record['richiesta'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -205,15 +206,31 @@ class CSV extends CSVImporter
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore in un log
|
||||
error_log('Errore durante l\'importazione dell\'intervento: ' . $e->getMessage());
|
||||
error_log('Errore durante l\'importazione dell\'intervento: '.$e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Codice', 'Partita IVA Cliente', 'Codice Fiscale Cliente', 'Data', 'Data richiesta', 'Ora inizio', 'Ora fine', 'Tecnico', 'Tipo', 'Note', 'Impianto', 'Richiesta', 'Descrizione', 'Stato'],
|
||||
['00001/2024', '123456789', '123456789', '07/11/2024', '03/11/2025', '8:30', '9:30', 'Stefano Bianchi', '', '', '12345-85A22', 'Manutenzione ordinaria', 'eseguito intervento di manutenzione', 'Da programmare'],
|
||||
['0002/2024', '123456789', '123456789', '08/11/2024', '04/11/2025', '11:20', '', 'Stefano Bianchi', '', '', '12345-85B23', 'Manutenzione ordinaria', 'eseguito intervento di manutenzione', ''],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova l'anagrafica cliente in base alla partita IVA o al codice fiscale.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return Anagrafica|null Anagrafica trovata o null se non trovata
|
||||
*/
|
||||
protected function trovaAnagrafica($record)
|
||||
@@ -235,6 +252,7 @@ class CSV extends CSVImporter
|
||||
* Trova l'impianto in base alla matricola.
|
||||
*
|
||||
* @param string $matricola Matricola dell'impianto
|
||||
*
|
||||
* @return Impianto|null Impianto trovato o null se non trovato
|
||||
*/
|
||||
protected function trovaImpianto($matricola)
|
||||
@@ -250,6 +268,7 @@ class CSV extends CSVImporter
|
||||
* Trova o crea il tipo di intervento.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return TipoIntervento Tipo di intervento
|
||||
*/
|
||||
protected function trovaTipoIntervento($record)
|
||||
@@ -265,6 +284,7 @@ class CSV extends CSVImporter
|
||||
* Trova o crea lo stato dell'intervento.
|
||||
*
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return Stato Stato dell'intervento
|
||||
*/
|
||||
protected function trovaStatoIntervento($record)
|
||||
@@ -280,7 +300,8 @@ class CSV extends CSVImporter
|
||||
* Aggiorna i campi dell'intervento.
|
||||
*
|
||||
* @param Intervento $intervento Intervento da aggiornare
|
||||
* @param array $record Record da processare
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function aggiornaIntervento($intervento, $record)
|
||||
@@ -304,7 +325,8 @@ class CSV extends CSVImporter
|
||||
* Collega un impianto all'intervento.
|
||||
*
|
||||
* @param Intervento $intervento Intervento da collegare
|
||||
* @param Impianto $impianto Impianto da collegare
|
||||
* @param Impianto $impianto Impianto da collegare
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function collegaImpianto($intervento, $impianto)
|
||||
@@ -327,7 +349,8 @@ class CSV extends CSVImporter
|
||||
* Crea una sessione di lavoro per l'intervento.
|
||||
*
|
||||
* @param Intervento $intervento Intervento associato
|
||||
* @param array $record Record da processare
|
||||
* @param array $record Record da processare
|
||||
*
|
||||
* @return Sessione|null Sessione creata o null se non creata
|
||||
*/
|
||||
protected function creaSessione($intervento, $record)
|
||||
@@ -364,22 +387,9 @@ class CSV extends CSVImporter
|
||||
return $sessione;
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore ma continua con l'importazione
|
||||
error_log('Errore durante la creazione della sessione: ' . $e->getMessage());
|
||||
error_log('Errore durante la creazione della sessione: '.$e->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Codice', 'Partita IVA Cliente', 'Codice Fiscale Cliente', 'Data', 'Data richiesta', 'Ora inizio', 'Ora fine', 'Tecnico', 'Tipo', 'Note', 'Impianto', 'Richiesta', 'Descrizione', 'Stato'],
|
||||
['00001/2024', '123456789', '123456789', '07/11/2024', '03/11/2025', '8:30', '9:30', 'Stefano Bianchi', '', '', '12345-85A22', 'Manutenzione ordinaria', 'eseguito intervento di manutenzione', 'Da programmare'],
|
||||
['0002/2024', '123456789', '123456789', '08/11/2024', '04/11/2025', '11:20', '', 'Stefano Bianchi', '', '', '12345-85B23', 'Manutenzione ordinaria', 'eseguito intervento di manutenzione', ''],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ switch (post('op')) {
|
||||
|
||||
$query = $lista->query;
|
||||
if (check_query($query)) {
|
||||
$lista->query = html_entity_decode($query);
|
||||
$lista->query = html_entity_decode((string) $query);
|
||||
}
|
||||
|
||||
$lista->save();
|
||||
|
@@ -69,9 +69,10 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Importa un record nel database.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
*
|
||||
* @return bool|null True se l'importazione è riuscita, false altrimenti, null se l'operazione è stata saltata
|
||||
*/
|
||||
public function import($record, $update_record = true, $add_record = true)
|
||||
@@ -109,81 +110,12 @@ class CSV extends CSVImporter
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore in un log
|
||||
error_log('Errore durante l\'importazione dell\'articolo nel listino: ' . $e->getMessage());
|
||||
error_log('Errore durante l\'importazione dell\'articolo nel listino: '.$e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova il listino in base al nome.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
* @return array|null
|
||||
*/
|
||||
protected function trovaListino($record, $database)
|
||||
{
|
||||
if (empty($record['nome_listino'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$result = $database->fetchOne('SELECT id FROM mg_listini WHERE nome = '.prepare($record['nome_listino']));
|
||||
return !empty($result) ? $result : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova l'articolo in base al codice.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
* @return array|null
|
||||
*/
|
||||
protected function trovaArticolo($record, $database)
|
||||
{
|
||||
if (empty($record['codice'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$result = $database->fetchOne('SELECT `id` FROM `mg_articoli` WHERE `codice` = '.prepare($record['codice']));
|
||||
return !empty($result) ? $result : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova l'articolo nel listino.
|
||||
*
|
||||
* @param int $id_articolo ID dell'articolo
|
||||
* @param int $id_listino ID del listino
|
||||
* @return Articolo|null
|
||||
*/
|
||||
protected function trovaArticoloListino($id_articolo, $id_listino)
|
||||
{
|
||||
return Articolo::where('id_articolo', $id_articolo)->where('id_listino', $id_listino)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Salva l'articolo nel listino.
|
||||
*
|
||||
* @param Articolo|null $articolo_listino Articolo nel listino esistente
|
||||
* @param array $articolo_originale Articolo originale
|
||||
* @param int $id_listino ID del listino
|
||||
* @param array $record Record da importare
|
||||
*/
|
||||
protected function salvaArticoloListino($articolo_listino, $articolo_originale, $id_listino, $record)
|
||||
{
|
||||
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
||||
$articolo_obj = ArticoloOriginale::find($articolo_originale['id']);
|
||||
$prezzo_unitario = $prezzi_ivati ? $articolo_obj->prezzo_vendita_ivato : $articolo_obj->prezzo_vendita;
|
||||
|
||||
if (!$articolo_listino) {
|
||||
$articolo_listino = Articolo::build($articolo_obj, $id_listino);
|
||||
}
|
||||
|
||||
$articolo_listino->data_scadenza = $record['data_scadenza'] ?: null;
|
||||
$articolo_listino->setPrezzoUnitario($record['prezzo_unitario'] ?: $prezzo_unitario);
|
||||
$articolo_listino->sconto_percentuale = $record['sconto_percentuale'] ?: 0;
|
||||
$articolo_listino->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
@@ -198,4 +130,79 @@ class CSV extends CSVImporter
|
||||
['Listino 1', '9101', '2024-07-31', '100', ''],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova il listino in base al nome.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function trovaListino($record, $database)
|
||||
{
|
||||
if (empty($record['nome_listino'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$result = $database->fetchOne('SELECT id FROM mg_listini WHERE nome = '.prepare($record['nome_listino']));
|
||||
|
||||
return !empty($result) ? $result : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova l'articolo in base al codice.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function trovaArticolo($record, $database)
|
||||
{
|
||||
if (empty($record['codice'])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$result = $database->fetchOne('SELECT `id` FROM `mg_articoli` WHERE `codice` = '.prepare($record['codice']));
|
||||
|
||||
return !empty($result) ? $result : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova l'articolo nel listino.
|
||||
*
|
||||
* @param int $id_articolo ID dell'articolo
|
||||
* @param int $id_listino ID del listino
|
||||
*
|
||||
* @return Articolo|null
|
||||
*/
|
||||
protected function trovaArticoloListino($id_articolo, $id_listino)
|
||||
{
|
||||
return Articolo::where('id_articolo', $id_articolo)->where('id_listino', $id_listino)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Salva l'articolo nel listino.
|
||||
*
|
||||
* @param Articolo|null $articolo_listino Articolo nel listino esistente
|
||||
* @param array $articolo_originale Articolo originale
|
||||
* @param int $id_listino ID del listino
|
||||
* @param array $record Record da importare
|
||||
*/
|
||||
protected function salvaArticoloListino($articolo_listino, $articolo_originale, $id_listino, $record)
|
||||
{
|
||||
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
|
||||
$articolo_obj = ArticoloOriginale::find($articolo_originale['id']);
|
||||
$prezzo_unitario = $prezzi_ivati ? $articolo_obj->prezzo_vendita_ivato : $articolo_obj->prezzo_vendita;
|
||||
|
||||
if (!$articolo_listino) {
|
||||
$articolo_listino = Articolo::build($articolo_obj, $id_listino);
|
||||
}
|
||||
|
||||
$articolo_listino->data_scadenza = $record['data_scadenza'] ?: null;
|
||||
$articolo_listino->setPrezzoUnitario($record['prezzo_unitario'] ?: $prezzo_unitario);
|
||||
$articolo_listino->sconto_percentuale = $record['sconto_percentuale'] ?: 0;
|
||||
$articolo_listino->save();
|
||||
}
|
||||
}
|
||||
|
@@ -93,8 +93,8 @@ include_once __DIR__.'/../../core.php';
|
||||
<?php
|
||||
$rs_stati = $dbo->fetchArray('SELECT * FROM `in_statiintervento`LEFT JOIN `in_statiintervento_lang` ON (`in_statiintervento`.`id` = `in_statiintervento_lang`.`id_record` AND `in_statiintervento_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')');
|
||||
|
||||
foreach ($rs_stati as $stato) {
|
||||
?>
|
||||
foreach ($rs_stati as $stato) {
|
||||
?>
|
||||
<div class="stato-item">
|
||||
<div class="switch-container">
|
||||
<label class="switch">
|
||||
@@ -105,8 +105,8 @@ include_once __DIR__.'/../../core.php';
|
||||
<label class="stato-label"><?php echo $stato['title']; ?></label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -28,9 +28,8 @@ switch (post('op')) {
|
||||
$nome = filter('name');
|
||||
$link = filter('link');
|
||||
$id_original = filter('id_original') ?: null;
|
||||
$is_articolo = filter('is_articolo_add') ?: filter('is_articolo') ?: 0;
|
||||
$is_impianto = filter('is_impianto_add') ?: filter('is_impianto') ?: 0;
|
||||
|
||||
$is_articolo = (filter('is_articolo_add') ?: filter('is_articolo')) ?: 0;
|
||||
$is_impianto = (filter('is_impianto_add') ?: filter('is_impianto')) ?: 0;
|
||||
|
||||
// Verifica che almeno uno dei due flag sia selezionato
|
||||
if ($is_articolo == 0 && $is_impianto == 0) {
|
||||
@@ -60,7 +59,6 @@ switch (post('op')) {
|
||||
$marca->save();
|
||||
}
|
||||
|
||||
|
||||
// Aggiorna i flag delle sottocategorie se è un parent
|
||||
$modello = Marca::where('parent', '=', $id_record)->get();
|
||||
if (!empty($modello)) {
|
||||
@@ -129,8 +127,8 @@ switch (post('op')) {
|
||||
$nome = filter('name');
|
||||
$link = filter('link');
|
||||
$id_original = filter('id_original') ?: null;
|
||||
$is_articolo = filter('is_articolo_add') ?: filter('is_articolo') ?: 0;
|
||||
$is_impianto = filter('is_impianto_add') ?: filter('is_impianto') ?: 0;
|
||||
$is_articolo = (filter('is_articolo_add') ?: filter('is_articolo')) ?: 0;
|
||||
$is_impianto = (filter('is_impianto_add') ?: filter('is_impianto')) ?: 0;
|
||||
|
||||
// Verifica che almeno uno dei due flag sia selezionato
|
||||
if ($is_articolo == 0 && $is_impianto == 0) {
|
||||
|
@@ -37,10 +37,10 @@ if (!empty($id_record)) {
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="id_original" value="<?php echo $id_original; ?>">
|
||||
<input type="hidden" name="op" value="<?php echo $id_record ? 'update' : 'add'; ?>">
|
||||
<?php if (!empty($id_original)) : ?>
|
||||
<?php if (!empty($id_original)) { ?>
|
||||
<input type="hidden" name="is_articolo" value="<?php echo $id_original ? Marca::find($id_original)->is_articolo : 1; ?>">
|
||||
<input type="hidden" name="is_impianto" value="<?php echo $id_original ? Marca::find($id_original)->is_impianto : 0; ?>">
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
|
@@ -19,10 +19,10 @@ switch ($resource) {
|
||||
|
||||
break;
|
||||
|
||||
/*
|
||||
* Opzioni utilizzate:
|
||||
* - id_marca
|
||||
*/
|
||||
/*
|
||||
* Opzioni utilizzate:
|
||||
* - id_marca
|
||||
*/
|
||||
case 'modelli':
|
||||
if (isset($superselect['id_marca'])) {
|
||||
$query = 'SELECT `id`, `name` AS descrizione FROM `zz_marche` |where| ORDER BY `name` ASC';
|
||||
|
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
|
||||
* Copyright (C) DevCode s.r.l.
|
||||
|
@@ -199,7 +199,7 @@ switch (filter('op')) {
|
||||
$lista = Lista::find($id_list);
|
||||
$query = $lista->query;
|
||||
if (check_query($query)) {
|
||||
$lista->query = html_entity_decode($query);
|
||||
$lista->query = html_entity_decode((string) $query);
|
||||
}
|
||||
$lista->save();
|
||||
|
||||
|
@@ -257,5 +257,4 @@ if ($module->name == 'Ordini cliente') {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $operations;
|
||||
|
@@ -594,7 +594,7 @@ if (!empty($elementi)) {
|
||||
'_DOC_' => $elemento['tipo_documento'],
|
||||
'_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($elemento['data']),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? "(".$elemento['stato_documento'].")" : ''),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? '('.$elemento['stato_documento'].')' : ''),
|
||||
]);
|
||||
|
||||
echo '
|
||||
|
@@ -38,7 +38,7 @@ if (!empty($riga_id)) {
|
||||
// Caso singola riga
|
||||
$riga = Riga::find($riga_id) ?: Articolo::find($riga_id);
|
||||
$riga = $riga ?: Sconto::find($riga_id);
|
||||
$righe_totali++;
|
||||
++$righe_totali;
|
||||
|
||||
if (!empty($riga) && !empty($riga->idiva) && !empty($riga->aliquota)) {
|
||||
$aliquote_iva[$riga->idiva] = [
|
||||
@@ -46,19 +46,19 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 1
|
||||
'count' => 1,
|
||||
];
|
||||
} else {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
} elseif (!empty($righe_ids)) {
|
||||
// Caso multiple righe
|
||||
$righe_array = explode(',', $righe_ids);
|
||||
$righe_array = explode(',', (string) $righe_ids);
|
||||
$righe_totali = count($righe_array);
|
||||
|
||||
foreach ($righe_array as $id_riga) {
|
||||
@@ -72,16 +72,16 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 0
|
||||
'count' => 0,
|
||||
];
|
||||
}
|
||||
$aliquote_iva[$riga->idiva]['count']++;
|
||||
++$aliquote_iva[$riga->idiva]['count'];
|
||||
} elseif (!empty($riga)) {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -92,20 +92,20 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
?>
|
||||
|
||||
<form id="modifica-iva-form">
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<?php if (count($aliquote_iva) > 1): ?>
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<?php endif; ?>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<?php if (count($aliquote_iva) > 1) { ?>
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -117,38 +117,38 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?= tr('eliminata') ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?= prepare(Models\Locale::getDefault()->id) ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?php echo tr('eliminata'); ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($show_form): ?>
|
||||
<?php } elseif ($show_form) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (count($righe_senza_iva) > 0): ?>
|
||||
<p><strong><?= tr('Righe senza aliquota IVA valida') ?>:</strong> <span class="badge"><?= count($righe_senza_iva) ?></span></p>
|
||||
<?php endif; ?>
|
||||
<?php if (count($righe_senza_iva) > 0) { ?>
|
||||
<p><strong><?php echo tr('Righe senza aliquota IVA valida'); ?>:</strong> <span class="badge"><?php echo count($righe_senza_iva); ?></span></p>
|
||||
<?php } ?>
|
||||
|
||||
<p class="text-muted"><?= tr('Totale righe selezionate') ?>: <?= $righe_totali ?></p>
|
||||
<p class="text-muted"><?php echo tr('Totale righe selezionate'); ?>: <?php echo $righe_totali; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -159,31 +159,31 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?= tr('eliminata') ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?= prepare(Models\Locale::getDefault()->id) ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "values": "query=SELECT `co_iva`.`id`, IF(`deleted_at` IS NOT NULL, CONCAT(`codice`, ' - ', `title`, ' (<?php echo tr('eliminata'); ?>)'), CONCAT(`codice`, ' - ', `title`)) AS `descrizione` FROM `co_iva` LEFT JOIN `co_iva_lang` ON (`co_iva`.`id` = `co_iva_lang`.`id_record` AND `co_iva_lang`.`id_lang` = <?php echo prepare(Models\Locale::getDefault()->id); ?>) ORDER BY `title` ASC" ]}
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php } else { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-warning">
|
||||
<p><?= tr('Nessuna riga selezionata') ?></p>
|
||||
<p><?php echo tr('Nessuna riga selezionata'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="button" class="btn btn-primary" onclick="salvaIva()">
|
||||
<i class="fa fa-save"></i> <?= tr('Salva') ?>
|
||||
<i class="fa fa-save"></i> <?php echo tr('Salva'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -216,7 +216,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -237,7 +237,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -128,7 +128,7 @@ foreach ($righe as $riga) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
echo nl2br($riga->descrizione);
|
||||
echo nl2br((string) $riga->descrizione);
|
||||
}
|
||||
|
||||
if ($riga->isArticolo() && !empty($riga->abilita_serial)) {
|
||||
@@ -151,7 +151,7 @@ foreach ($righe as $riga) {
|
||||
|
||||
if (!empty($riga->note)) {
|
||||
echo '
|
||||
<br><span class="text-xs">'.nl2br($riga->note).'</small>';
|
||||
<br><span class="text-xs">'.nl2br((string) $riga->note).'</small>';
|
||||
}
|
||||
echo '
|
||||
</td>';
|
||||
|
@@ -40,7 +40,7 @@ $conto_bloccato = [
|
||||
'Iva su vendite',
|
||||
'Iva su acquisti',
|
||||
'Iva indetraibile',
|
||||
'Compensazione per autofattura'
|
||||
'Compensazione per autofattura',
|
||||
];
|
||||
|
||||
$conto_bloccato = in_array($info['descrizione'], $conto_bloccato);
|
||||
@@ -71,12 +71,12 @@ if (!$conto_bloccato && $lvl == 3) {
|
||||
</div>
|
||||
|
||||
<div class="col-md-8">
|
||||
<?php if ($conto_bloccato): ?>
|
||||
<?php if ($conto_bloccato) { ?>
|
||||
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "required": 1, "value": <?php echo json_encode($info['descrizione']); ?>, "readonly": 1, "help": "<?php echo tr('Questo è un conto speciale utilizzato dal sistema. La descrizione non può essere modificata.'); ?>" ]}
|
||||
<input type="hidden" name="conto_bloccato" value="1">
|
||||
<?php else: ?>
|
||||
<?php } else { ?>
|
||||
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "required": 1, "value": <?php echo json_encode($info['descrizione']); ?> ]}
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
@@ -68,9 +68,10 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Importa un record nel database.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
*
|
||||
* @return bool|null True se l'importazione è riuscita, false altrimenti, null se l'operazione è stata saltata
|
||||
*/
|
||||
public function import($record, $update_record = true, $add_record = true)
|
||||
@@ -110,20 +111,36 @@ class CSV extends CSVImporter
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore in un log
|
||||
error_log('Errore durante l\'importazione del piano dei conti: ' . $e->getMessage());
|
||||
error_log('Errore durante l\'importazione del piano dei conti: '.$e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Sezione', 'Conto', 'Descrizione', 'Direzione'],
|
||||
['Economico', '600.000010', 'Costi merci c/acquisto di rivendita', 'uscita'],
|
||||
['Patrimoniale', '110.000010', 'Riepilogativo clienti', ''],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Analizza il numero di conto e lo divide in parti.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
*
|
||||
* @return array|null Array con le parti del conto o null se il formato non è valido
|
||||
*/
|
||||
protected function parseNumeroConto($record)
|
||||
{
|
||||
if (empty($record['numero']) || strpos($record['numero'], '.') === false) {
|
||||
if (empty($record['numero']) || !str_contains((string) $record['numero'], '.')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -141,8 +158,9 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Trova il conto di primo livello (sezione) in base alla descrizione.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function trovaConto1($record, $database)
|
||||
@@ -152,6 +170,7 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
$result = $database->fetchOne('SELECT id FROM co_pianodeiconti1 WHERE LOWER(descrizione)=LOWER('.prepare($record['idpianodeiconti1']).')');
|
||||
|
||||
return !empty($result) ? $result : null;
|
||||
}
|
||||
|
||||
@@ -159,7 +178,8 @@ class CSV extends CSVImporter
|
||||
* Trova il conto di secondo livello in base al numero.
|
||||
*
|
||||
* @param string $codice_conto2 Codice del conto di secondo livello
|
||||
* @param object $database Connessione al database
|
||||
* @param object $database Connessione al database
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function trovaConto2($codice_conto2, $database)
|
||||
@@ -169,15 +189,17 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
$result = $database->fetchOne('SELECT id FROM co_pianodeiconti2 WHERE numero='.prepare($codice_conto2));
|
||||
|
||||
return !empty($result) ? $result : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova il conto di terzo livello in base al numero e al conto2.
|
||||
*
|
||||
* @param string $codice_conto3 Codice del conto di terzo livello
|
||||
* @param int $idpianodeiconti2 ID del conto di secondo livello
|
||||
* @param object $database Connessione al database
|
||||
* @param string $codice_conto3 Codice del conto di terzo livello
|
||||
* @param int $idpianodeiconti2 ID del conto di secondo livello
|
||||
* @param object $database Connessione al database
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
protected function trovaConto3($codice_conto3, $idpianodeiconti2, $database)
|
||||
@@ -187,17 +209,18 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
$result = $database->fetchOne('SELECT id FROM co_pianodeiconti3 WHERE numero='.prepare($codice_conto3).' AND idpianodeiconti2='.prepare($idpianodeiconti2));
|
||||
|
||||
return !empty($result) ? $result : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Aggiunge un nuovo record al piano dei conti.
|
||||
*
|
||||
* @param array $conto1 Conto di primo livello
|
||||
* @param array|null $conto2 Conto di secondo livello
|
||||
* @param array $parti_conto Parti del numero di conto
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
* @param array $conto1 Conto di primo livello
|
||||
* @param array|null $conto2 Conto di secondo livello
|
||||
* @param array $parti_conto Parti del numero di conto
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
*/
|
||||
protected function aggiungiRecord($conto1, $conto2, $parti_conto, $record, $database)
|
||||
{
|
||||
@@ -228,10 +251,10 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Aggiorna un record esistente nel piano dei conti.
|
||||
*
|
||||
* @param array|null $conto2 Conto di secondo livello
|
||||
* @param array $parti_conto Parti del numero di conto
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
* @param array|null $conto2 Conto di secondo livello
|
||||
* @param array $parti_conto Parti del numero di conto
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
*/
|
||||
protected function aggiornaRecord($conto2, $parti_conto, $record, $database)
|
||||
{
|
||||
@@ -256,18 +279,4 @@ class CSV extends CSVImporter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Sezione', 'Conto', 'Descrizione', 'Direzione'],
|
||||
['Economico', '600.000010', 'Costi merci c/acquisto di rivendita', 'uscita'],
|
||||
['Patrimoniale', '110.000010', 'Riepilogativo clienti', ''],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -165,7 +165,6 @@ switch (post('op')) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$operations['change_status'] = [
|
||||
'text' => '<span><i class="fa fa-refresh"></i> '.tr('Cambia stato'),
|
||||
'data' => [
|
||||
@@ -190,5 +189,4 @@ $operations['create_invoice'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
return $operations;
|
||||
|
@@ -484,7 +484,7 @@ if (!empty($elementi)) {
|
||||
'_DOC_' => $elemento['tipo_documento'],
|
||||
'_NUM_' => !empty($elemento['numero_esterno']) ? $elemento['numero_esterno'] : $elemento['numero'],
|
||||
'_DATE_' => Translator::dateToLocale($elemento['data']),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? "(".$elemento['stato_documento'].")" : ''),
|
||||
'_STATO_' => (!empty($elemento['stato_documento']) ? '('.$elemento['stato_documento'].')' : ''),
|
||||
]);
|
||||
|
||||
echo '
|
||||
|
@@ -38,7 +38,7 @@ if (!empty($riga_id)) {
|
||||
// Caso singola riga
|
||||
$riga = Riga::find($riga_id) ?: Articolo::find($riga_id);
|
||||
$riga = $riga ?: Sconto::find($riga_id);
|
||||
$righe_totali++;
|
||||
++$righe_totali;
|
||||
|
||||
if (!empty($riga) && !empty($riga->idiva) && !empty($riga->aliquota)) {
|
||||
$aliquote_iva[$riga->idiva] = [
|
||||
@@ -46,19 +46,19 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 1
|
||||
'count' => 1,
|
||||
];
|
||||
} else {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
} elseif (!empty($righe_ids)) {
|
||||
// Caso multiple righe
|
||||
$righe_array = explode(',', $righe_ids);
|
||||
$righe_array = explode(',', (string) $righe_ids);
|
||||
$righe_totali = count($righe_array);
|
||||
|
||||
foreach ($righe_array as $id_riga) {
|
||||
@@ -72,16 +72,16 @@ if (!empty($riga_id)) {
|
||||
'codice' => $riga->aliquota->codice,
|
||||
'descrizione' => $riga->aliquota->getTranslation('title'),
|
||||
'percentuale' => $riga->aliquota->percentuale,
|
||||
'count' => 0
|
||||
'count' => 0,
|
||||
];
|
||||
}
|
||||
$aliquote_iva[$riga->idiva]['count']++;
|
||||
++$aliquote_iva[$riga->idiva]['count'];
|
||||
} elseif (!empty($riga)) {
|
||||
// Riga senza aliquota IVA o con aliquota non valida
|
||||
$righe_senza_iva[] = [
|
||||
'id' => $riga->id,
|
||||
'descrizione' => $riga->descrizione,
|
||||
'idiva' => $riga->idiva ?: 'N/D'
|
||||
'idiva' => $riga->idiva ?: 'N/D',
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -92,20 +92,20 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
?>
|
||||
|
||||
<form id="modifica-iva-form">
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<?php if (count($aliquote_iva) > 1): ?>
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<?php endif; ?>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<?php if (count($aliquote_iva) > 1) { ?>
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -117,38 +117,38 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "ajax-source": "iva" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= $_GET['righe'] ?>">
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo $_GET['righe']; ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php elseif ($show_form): ?>
|
||||
<?php } elseif ($show_form) { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<div class="alert alert-info">
|
||||
<p><strong><?= tr('Aliquote IVA attuali') ?></strong></p>
|
||||
<p><strong><?php echo tr('Aliquote IVA attuali'); ?></strong></p>
|
||||
|
||||
<?php if (count($aliquote_iva) > 0): ?>
|
||||
<?php if (count($aliquote_iva) > 0) { ?>
|
||||
<ul class="list-unstyled">
|
||||
<?php foreach ($aliquote_iva as $aliquota): ?>
|
||||
<?php foreach ($aliquote_iva as $aliquota) { ?>
|
||||
<li>
|
||||
<strong><?= $aliquota['codice'] ?></strong> - <?= $aliquota['descrizione'] ?> (<?= $aliquota['percentuale'] ?>%)
|
||||
<span class="badge"><?= $aliquota['count'] ?> <?= tr('righe') ?></span>
|
||||
<strong><?php echo $aliquota['codice']; ?></strong> - <?php echo $aliquota['descrizione']; ?> (<?php echo $aliquota['percentuale']; ?>%)
|
||||
<span class="badge"><?php echo $aliquota['count']; ?> <?php echo tr('righe'); ?></span>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if (count($righe_senza_iva) > 0): ?>
|
||||
<p><strong><?= tr('Righe senza aliquota IVA valida') ?>:</strong> <span class="badge"><?= count($righe_senza_iva) ?></span></p>
|
||||
<?php endif; ?>
|
||||
<?php if (count($righe_senza_iva) > 0) { ?>
|
||||
<p><strong><?php echo tr('Righe senza aliquota IVA valida'); ?>:</strong> <span class="badge"><?php echo count($righe_senza_iva); ?></span></p>
|
||||
<?php } ?>
|
||||
|
||||
<p class="text-muted"><?= tr('Totale righe selezionate') ?>: <?= $righe_totali ?></p>
|
||||
<p class="text-muted"><?php echo tr('Totale righe selezionate'); ?>: <?php echo $righe_totali; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -159,31 +159,31 @@ $show_form = count($aliquote_iva) > 0 || count($righe_senza_iva) > 0 || (!empty(
|
||||
<div class="col-md-5">
|
||||
<div class="panel panel-success">
|
||||
<div class="panel-heading">
|
||||
<h4 class="panel-title"><?= tr('Aliquota da applicare') ?></h4>
|
||||
<h4 class="panel-title"><?php echo tr('Aliquota da applicare'); ?></h4>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
{[ "type": "select", "label": "", "name": "iva_id", "required": 1, "ajax-source": "iva" ]}
|
||||
<input type="hidden" name="riga_id" value="<?= get('riga_id') ?>">
|
||||
<input type="hidden" name="righe" value="<?= get('righe') ?>">
|
||||
<input type="hidden" name="riga_id" value="<?php echo get('riga_id'); ?>">
|
||||
<input type="hidden" name="righe" value="<?php echo get('righe'); ?>">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<?php } else { ?>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-warning">
|
||||
<p><?= tr('Nessuna riga selezionata') ?></p>
|
||||
<p><?php echo tr('Nessuna riga selezionata'); ?></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="button" class="btn btn-primary" onclick="salvaIva()">
|
||||
<i class="fa fa-save"></i> <?= tr('Salva') ?>
|
||||
<i class="fa fa-save"></i> <?php echo tr('Salva'); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -216,7 +216,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -237,7 +237,7 @@ function salvaIva() {
|
||||
renderMessages();
|
||||
},
|
||||
error: function() {
|
||||
alert(<?= json_encode(tr('Errore durante il salvataggio')) ?>);
|
||||
alert(<?php echo json_encode(tr('Errore durante il salvataggio')); ?>);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -105,7 +105,7 @@ foreach ($righe as $key => $riga) {
|
||||
<td '.$colspan_titolo.'>';
|
||||
|
||||
// Descrizione
|
||||
$descrizione = nl2br($riga->descrizione);
|
||||
$descrizione = nl2br((string) $riga->descrizione);
|
||||
if ($riga->isArticolo()) {
|
||||
$descrizione = Modules::link('Articoli', $riga->idarticolo, $riga->codice.' - '.$descrizione);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ foreach ($righe as $key => $riga) {
|
||||
|
||||
if (!empty($riga->note)) {
|
||||
echo '
|
||||
<br><span class="text-xs">'.nl2br($riga->note).'</small>';
|
||||
<br><span class="text-xs">'.nl2br((string) $riga->note).'</small>';
|
||||
}
|
||||
echo '
|
||||
</td>
|
||||
|
@@ -99,9 +99,10 @@ class CSV extends CSVImporter
|
||||
/**
|
||||
* Importa un record nel database.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
* @param array $record Record da importare
|
||||
* @param bool $update_record Se true, aggiorna i record esistenti
|
||||
* @param bool $add_record Se true, aggiunge nuovi record
|
||||
*
|
||||
* @return bool|null True se l'importazione è riuscita, false altrimenti, null se l'operazione è stata saltata
|
||||
*/
|
||||
public function import($record, $update_record = true, $add_record = true)
|
||||
@@ -110,9 +111,9 @@ class CSV extends CSVImporter
|
||||
$database = database();
|
||||
|
||||
// Validazione dei campi obbligatori
|
||||
if (empty($record['numero']) || empty($record['nome']) || empty($record['ragione_sociale']) ||
|
||||
empty($record['data_bozza']) || empty($record['codice']) || empty($record['qta']) ||
|
||||
empty($record['prezzo_unitario'])) {
|
||||
if (empty($record['numero']) || empty($record['nome']) || empty($record['ragione_sociale'])
|
||||
|| empty($record['data_bozza']) || empty($record['codice']) || empty($record['qta'])
|
||||
|| empty($record['prezzo_unitario'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -138,16 +139,32 @@ class CSV extends CSVImporter
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// Registra l'errore in un log
|
||||
error_log('Errore durante l\'importazione del preventivo: ' . $e->getMessage());
|
||||
error_log('Errore durante l\'importazione del preventivo: '.$e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Numero', 'Nome Preventivo', 'Descrizione Preventivo', 'Cliente', 'Tipo Attività', 'Data', 'Codice Articolo', 'Quantità riga', 'Data prevista evasione riga', 'Prezzo unitario riga'],
|
||||
['15', 'Preventivo Materiali', 'Preventivo iniziale', 'Rossi', 'Generico', '27/04/2024', '001', '2', '30/04/2024', '50'],
|
||||
['15', 'Preventivo Materiali', 'Preventivo iniziale', 'Rossi', 'Generico', '27/04/2024', '043', '1', '10/05/2024', '100'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Trova il preventivo esistente in base al numero.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
* @param array $record Record da importare
|
||||
* @param object $database Connessione al database
|
||||
*
|
||||
* @return Preventivo|null
|
||||
*/
|
||||
protected function trovaPreventivo($record, $database)
|
||||
@@ -157,6 +174,7 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
$id_preventivo = $database->fetchOne('SELECT id FROM `co_preventivi` WHERE `numero`='.prepare($record['numero']));
|
||||
|
||||
return !empty($id_preventivo) ? Preventivo::find($id_preventivo['id']) : null;
|
||||
}
|
||||
|
||||
@@ -164,6 +182,7 @@ class CSV extends CSVImporter
|
||||
* Crea un nuovo preventivo.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
*
|
||||
* @return Preventivo|null
|
||||
*/
|
||||
protected function creaPreventivo($record)
|
||||
@@ -187,7 +206,8 @@ class CSV extends CSVImporter
|
||||
|
||||
return $preventivo;
|
||||
} catch (\Exception $e) {
|
||||
error_log('Errore durante la creazione del preventivo: ' . $e->getMessage());
|
||||
error_log('Errore durante la creazione del preventivo: '.$e->getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -196,6 +216,7 @@ class CSV extends CSVImporter
|
||||
* Trova o crea l'anagrafica cliente.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
*
|
||||
* @return Anagrafica|null
|
||||
*/
|
||||
protected function trovaOCreaAnagrafica($record)
|
||||
@@ -220,6 +241,7 @@ class CSV extends CSVImporter
|
||||
* Trova il tipo di intervento.
|
||||
*
|
||||
* @param array $record Record da importare
|
||||
*
|
||||
* @return TipoSessione
|
||||
*/
|
||||
protected function trovaTipoIntervento($record)
|
||||
@@ -231,7 +253,8 @@ class CSV extends CSVImporter
|
||||
* Aggiunge un articolo al preventivo.
|
||||
*
|
||||
* @param Preventivo $preventivo Preventivo
|
||||
* @param array $record Record da importare
|
||||
* @param array $record Record da importare
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function aggiungiArticoloAlPreventivo($preventivo, $record)
|
||||
@@ -260,9 +283,11 @@ class CSV extends CSVImporter
|
||||
$riga_articolo->qta = $record['qta'];
|
||||
|
||||
$riga_articolo->save();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
error_log('Errore durante l\'aggiunta dell\'articolo al preventivo: ' . $e->getMessage());
|
||||
error_log('Errore durante l\'aggiunta dell\'articolo al preventivo: '.$e->getMessage());
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -271,6 +296,7 @@ class CSV extends CSVImporter
|
||||
* Converte una stringa data in un oggetto Carbon.
|
||||
*
|
||||
* @param string $data_string Stringa data
|
||||
*
|
||||
* @return Carbon
|
||||
*/
|
||||
protected function parseData($data_string)
|
||||
@@ -284,22 +310,9 @@ class CSV extends CSVImporter
|
||||
}
|
||||
|
||||
// Fallback alla data corrente
|
||||
error_log('Errore nel parsing della data: ' . $e->getMessage());
|
||||
error_log('Errore nel parsing della data: '.$e->getMessage());
|
||||
|
||||
return Carbon::now();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Restituisce un esempio di file CSV per l'importazione.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getExample()
|
||||
{
|
||||
return [
|
||||
['Numero', 'Nome Preventivo', 'Descrizione Preventivo', 'Cliente', 'Tipo Attività', 'Data', 'Codice Articolo', 'Quantità riga', 'Data prevista evasione riga', 'Prezzo unitario riga'],
|
||||
['15', 'Preventivo Materiali', 'Preventivo iniziale', 'Rossi', 'Generico', '27/04/2024', '001', '2', '30/04/2024', '50'],
|
||||
['15', 'Preventivo Materiali', 'Preventivo iniziale', 'Rossi', 'Generico', '27/04/2024', '043', '1', '10/05/2024', '100'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@@ -40,7 +40,7 @@ if (!empty($rs)) {
|
||||
$data_accettazione = ($preventivo->data_accettazione != '0000-00-00') ? Translator::dateToLocale($preventivo->data_accettazione) : '';
|
||||
$data_conclusione = ($preventivo->data_conclusione != '0000-00-00') ? Translator::dateToLocale($preventivo->data_conclusione) : '';
|
||||
|
||||
if ($data_conclusione != '' && strtotime($preventivo->data_conclusione) < strtotime(date('Y-m-d'))) {
|
||||
if ($data_conclusione != '' && strtotime((string) $preventivo->data_conclusione) < strtotime(date('Y-m-d'))) {
|
||||
$attr = ' class="danger"';
|
||||
} else {
|
||||
$attr = '';
|
||||
|
@@ -43,7 +43,7 @@ if (!empty($rs)) {
|
||||
$data_conclusione = ($preventivo->data_conclusione != '0000-00-00') ? Translator::dateToLocale($preventivo->data_conclusione) : '';
|
||||
$stato_preventivo = Stato::find($preventivo->idstato)->getTranslation('title');
|
||||
|
||||
if (strtotime($preventivo->data_conclusione) < strtotime(date('Y-m-d')) && $data_conclusione != '') {
|
||||
if (strtotime((string) $preventivo->data_conclusione) < strtotime(date('Y-m-d')) && $data_conclusione != '') {
|
||||
$attr = ' class="danger"';
|
||||
} else {
|
||||
$attr = '';
|
||||
|
@@ -263,8 +263,8 @@ class Mastrino extends Model
|
||||
$scadenze[$documento] = [];
|
||||
$scadenze_documento = database()->fetchArray('SELECT id FROM co_scadenziario WHERE iddocumento='.prepare($documento));
|
||||
foreach ($scadenze_documento as $scadenza_row) {
|
||||
$id_scadenza = $scadenza_row['id'];
|
||||
$scadenze[$documento][$id_scadenza] = $id_scadenza;
|
||||
$id_scadenza = $scadenza_row['id'];
|
||||
$scadenze[$documento][$id_scadenza] = $id_scadenza;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -194,7 +194,6 @@ $operations['change-bank'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$operations['change_distinta'] = [
|
||||
'text' => '<span><i class="fa fa-edit"></i> '.tr('Info distinta'),
|
||||
'data' => [
|
||||
@@ -207,7 +206,6 @@ $operations['change_distinta'] = [
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$operations['send_reminder'] = [
|
||||
'text' => '<span><i class="fa fa-envelope"></i> '.tr('Invia mail sollecito').'</span>',
|
||||
'data' => [
|
||||
|
@@ -38,28 +38,28 @@ switch (post('op')) {
|
||||
$records = array_filter((array) $id_records);
|
||||
|
||||
// Default query for when there are no valid records
|
||||
$query = "SELECT DISTINCT `zz_groups`.`id`, `title` AS descrizione FROM `zz_groups`
|
||||
$query = 'SELECT DISTINCT `zz_groups`.`id`, `title` AS descrizione FROM `zz_groups`
|
||||
LEFT JOIN `zz_groups_lang` ON (`zz_groups`.`id` = `zz_groups_lang`.`id_record`
|
||||
AND `zz_groups_lang`.`id_lang` = ".prepare(Models\Locale::getDefault()->id).")
|
||||
AND `zz_groups_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).')
|
||||
WHERE `zz_groups`.`id` = 1
|
||||
ORDER BY `zz_groups`.`id` ASC";
|
||||
ORDER BY `zz_groups`.`id` ASC';
|
||||
|
||||
// If we have valid records, use the full query with IN clause
|
||||
if (!empty($records)) {
|
||||
$records_list = implode(',', $records);
|
||||
$query = "SELECT DISTINCT `zz_groups`.`id`, `title` AS descrizione FROM `zz_groups`
|
||||
$query = 'SELECT DISTINCT `zz_groups`.`id`, `title` AS descrizione FROM `zz_groups`
|
||||
LEFT JOIN `zz_groups_lang` ON (`zz_groups`.`id` = `zz_groups_lang`.`id_record`
|
||||
AND `zz_groups_lang`.`id_lang` = ".prepare(Models\Locale::getDefault()->id).")
|
||||
AND `zz_groups_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).")
|
||||
WHERE `zz_groups`.`id` = 1
|
||||
OR `zz_groups`.`id` IN (
|
||||
SELECT DISTINCT `idgruppo` FROM `zz_permissions`
|
||||
WHERE `permessi` IN ('r', 'rw')
|
||||
AND `idmodule` IN (
|
||||
SELECT DISTINCT `id_module` FROM `zz_segments`
|
||||
WHERE `id` IN (".$records_list.")
|
||||
WHERE `id` IN (".$records_list.')
|
||||
)
|
||||
)
|
||||
ORDER BY `zz_groups`.`id` ASC";
|
||||
ORDER BY `zz_groups`.`id` ASC';
|
||||
}
|
||||
|
||||
$msg = '{[ "type": "select", "multiple":"1", "label": "<small>'.tr('Seleziona i gruppi che avranno accesso ai segmenti selezionati:').'</small>", "values": "query='.$query.'", "name": "gruppi[]" ]}';
|
||||
|
@@ -120,28 +120,28 @@ echo '
|
||||
|
||||
<div class="card-body">';
|
||||
|
||||
$available_options = json_decode((string) $record['available_options'], true) ?? [];
|
||||
$available_options = json_decode((string) $record['available_options'], true) ?? [];
|
||||
|
||||
// Add the additional options
|
||||
$additional_options = [
|
||||
"font-size" => "Dimensione del font",
|
||||
"header-font-size" => "Dimensione del font dell'intestazione",
|
||||
"orientation" => "Orientamento pagina",
|
||||
"format" => "Formato pagina"
|
||||
];
|
||||
// Add the additional options
|
||||
$additional_options = [
|
||||
'font-size' => 'Dimensione del font',
|
||||
'header-font-size' => "Dimensione del font dell'intestazione",
|
||||
'orientation' => 'Orientamento pagina',
|
||||
'format' => 'Formato pagina',
|
||||
];
|
||||
|
||||
$available_options = array_merge($available_options, $additional_options);
|
||||
$available_options = array_merge($available_options, $additional_options);
|
||||
|
||||
echo '
|
||||
echo '
|
||||
<p>'.tr('Puoi utilizzare le seguenti opzioni per generare la stampa').':</p>
|
||||
<ul>';
|
||||
|
||||
foreach ($available_options as $option => $value) {
|
||||
echo '
|
||||
<li><code>'.$option.'</code>'.((!empty($value)) ? ' <span class="badge badge-default" >'.$value.'</span>' : '').'</li>';
|
||||
}
|
||||
|
||||
foreach ($available_options as $option => $value) {
|
||||
echo '
|
||||
<li><code>'.$option.'</code>'.((!empty($value)) ? ' <span class="badge badge-default" >'.$value.'</span>' : '').'</li>';
|
||||
}
|
||||
|
||||
echo '
|
||||
</ul>';
|
||||
|
||||
echo '
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user