diff --git a/core.php b/core.php
index d38fe8d72..f868e4510 100644
--- a/core.php
+++ b/core.php
@@ -96,6 +96,7 @@ if (!API::isAPIRequest()) {
// Disabilita la segnalazione degli errori (se il debug è disabilitato)
if (!App::debug()) {
error_reporting(0);
+ ini_set("display_errors", 0);
}
// Imposta il formato di salvataggio dei log
diff --git a/include/common/articolo.php b/include/common/articolo.php
index 04be5386e..b2f94d2d5 100644
--- a/include/common/articolo.php
+++ b/include/common/articolo.php
@@ -60,11 +60,14 @@ if (!isset($options['edit_articolo']) || !empty($options['edit_articolo'])) {
session_set("superselect,idarticolo", $(this).val(), 0);
$data = $(this).selectData();
+ var id_conto = $data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').';
+
$("#prezzo").val($data.prezzo_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').');
$("#descrizione_riga").val($data.descrizione);
$("#idiva").selectSet($data.idiva_vendita, $data.iva_vendita);
- $("#idconto").selectSetNew($data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').', $data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').'_title);
- console.log($data);
+ if(id_conto) {
+ $("#idconto").selectSetNew(id_conto, $data.idconto_'.($options['dir'] == 'entrata' ? 'vendita' : 'acquisto').'_title);
+ }
$("#um").selectSetNew($data.um, $data.um);
}';
diff --git a/include/init/init.php b/include/init/init.php
index 1512956ac..2e8ede326 100644
--- a/include/init/init.php
+++ b/include/init/init.php
@@ -13,15 +13,21 @@ WHERE `an_tipianagrafiche`.`descrizione` = 'Azienda' AND `an_anagrafiche`.`delet
$has_user = $dbo->fetchNum('SELECT `id` FROM `zz_users`') != 0;
$settings = [
- 'Regime Fiscale',
- 'Tipo Cassa',
- 'Conto predefinito fatture di vendita',
- 'Conto predefinito fatture di acquisto',
+ 'Regime Fiscale' => true,
+ 'Tipo Cassa' => true,
+ 'Conto predefinito fatture di vendita' => true,
+ 'Conto predefinito fatture di acquisto' => true,
+ "Percentuale ritenuta d'acconto" => false,
+ "Causale ritenuta d'acconto" => false,
];
+if (!empty(setting('Regime Fiscale'))) {
+ $settings["Causale ritenuta d'acconto"] = true;
+}
+
$has_settings = true;
-foreach ($settings as $setting) {
- if (empty(setting($setting))) {
+foreach ($settings as $setting => $required) {
+ if (empty(setting($setting)) && $required) {
$has_settings = false;
break;
}
@@ -72,7 +78,7 @@ if (post('action') == 'init') {
}
if (!$has_settings) {
- foreach ($settings as $setting) {
+ foreach ($settings as $setting => $required) {
$setting = Settings::get($setting);
Settings::setValue($setting['nome'], post('setting')[$setting['id']]);
@@ -176,10 +182,10 @@ if (!$has_settings) {
';
- foreach ($settings as $setting) {
+ foreach ($settings as $setting => $required) {
echo '
- '.Settings::input($setting, true).'
+ '.Settings::input($setting, $required).'
';
}
diff --git a/modules/articoli/ajax/select.php b/modules/articoli/ajax/select.php
index 79da1b142..f1aa91bf3 100644
--- a/modules/articoli/ajax/select.php
+++ b/modules/articoli/ajax/select.php
@@ -4,7 +4,7 @@ include_once __DIR__.'/../../../core.php';
switch ($resource) {
case 'articoli':
- $query = 'SELECT mg_articoli.*, (SELECT CONCAT(numero, " ", descrizione) FROM co_pianodeiconti3 WHERE co_pianodeiconti3.id = idconto_vendita) AS idconto_vendita_title, (SELECT CONCAT(numero, " ", descrizione) FROM co_pianodeiconti3 WHERE co_pianodeiconti3.id = idconto_acquisto) AS idconto_acquisto_title, co_iva.descrizione AS iva_vendita FROM mg_articoli LEFT OUTER JOIN co_iva ON mg_articoli.idiva_vendita=co_iva.id |where| ORDER BY mg_articoli.id_categoria ASC, mg_articoli.id_sottocategoria ASC';
+ $query = 'SELECT mg_articoli.*, (SELECT CONCAT(co_pianodeiconti2.numero, ".", co_pianodeiconti3.numero, " ", co_pianodeiconti3.descrizione) FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE co_pianodeiconti3.id = idconto_vendita) AS idconto_vendita_title, (SELECT CONCAT(co_pianodeiconti2.numero, ".", co_pianodeiconti3.numero, " ", co_pianodeiconti3.descrizione) FROM co_pianodeiconti3 INNER JOIN co_pianodeiconti2 ON co_pianodeiconti3.idpianodeiconti2=co_pianodeiconti2.id WHERE co_pianodeiconti3.id = idconto_acquisto) AS idconto_acquisto_title, co_iva.descrizione AS iva_vendita FROM mg_articoli LEFT OUTER JOIN co_iva ON mg_articoli.idiva_vendita=co_iva.id |where| ORDER BY mg_articoli.id_categoria ASC, mg_articoli.id_sottocategoria ASC';
$idiva_predefinita = setting('Iva predefinita');
$rs = $dbo->fetchArray('SELECT descrizione FROM co_iva WHERE id='.prepare($idiva_predefinita));
diff --git a/modules/categorie_documenti/actions.php b/modules/categorie_documenti/actions.php
index a17c756d9..bc8c53de5 100644
--- a/modules/categorie_documenti/actions.php
+++ b/modules/categorie_documenti/actions.php
@@ -7,7 +7,7 @@ switch (post('op')) {
$descrizione = post('descrizione');
// Verifico che il nome non sia duplicato
- $count = $dbo->fetchNum('SELECT descrizione FROM zz_documenti_categorie WHERE descrizione='.prepare($descrizione).' AND deleted = 0');
+ $count = $dbo->fetchNum('SELECT descrizione FROM zz_documenti_categorie WHERE descrizione='.prepare($descrizione).' AND deleted_at IS NULL');
if ($count != 0) {
flash()->error(tr('Categoria _NAME_ già esistente!', [
'_NAME_' => $descrizione,
@@ -27,7 +27,7 @@ switch (post('op')) {
if (isset($_POST['descrizione'])) {
// Verifico che il nome non sia duplicato
- $count = $dbo->fetchNum('SELECT descrizione FROM zz_documenti_categorie WHERE descrizione='.prepare($descrizione).' AND deleted = 0');
+ $count = $dbo->fetchNum('SELECT descrizione FROM zz_documenti_categorie WHERE descrizione='.prepare($descrizione).' AND deleted_at IS NULL');
if ($count != 0) {
flash()->error(tr('Categoria _NAME_ già esistente!', [
'_NAME_' => $descrizione,
@@ -45,7 +45,7 @@ switch (post('op')) {
break;
case 'delete':
- $dbo->query('UPDATE zz_documenti_categorie SET deleted=1 WHERE id = '.prepare($id_record));
+ $dbo->query('UPDATE zz_documenti_categorie SET deleted_at = NOW() WHERE id = '.prepare($id_record));
flash()->info(tr('Categoria docimenti eliminata!'));
diff --git a/modules/causali/actions.php b/modules/causali/actions.php
index 5354be17b..d34939b20 100644
--- a/modules/causali/actions.php
+++ b/modules/causali/actions.php
@@ -8,7 +8,7 @@ switch (filter('op')) {
if (isset($descrizione)) {
if ($dbo->fetchNum('SELECT * FROM `dt_causalet` WHERE `descrizione`='.prepare($descrizione).' AND `id`!='.prepare($id_record)) == 0) {
- $predefined = post('dt_causalet');
+ $predefined = post('predefined');
if (!empty($predefined)) {
$dbo->query('UPDATE dt_porto SET predefined = 0');
}
diff --git a/modules/fatture/actions.php b/modules/fatture/actions.php
index 4a85eae24..433c9aa69 100644
--- a/modules/fatture/actions.php
+++ b/modules/fatture/actions.php
@@ -495,9 +495,13 @@ switch (post('op')) {
$articolo->id_iva = post('idiva');
$articolo->idconto = post('idconto');
- $articolo->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto');
- $articolo->id_ritenuta_acconto = post('id_ritenuta_acconto');
- $articolo->id_rivalsa_inps = post('id_rivalsa_inps');
+ if (post('id_ritenuta_acconto')) {
+ $articolo->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto');
+ $articolo->id_ritenuta_acconto = post('id_ritenuta_acconto');
+ }
+ if (post('id_rivalsa_inps')) {
+ $articolo->id_rivalsa_inps = post('id_rivalsa_inps');
+ }
$articolo->costo_unitario = post('prezzo');
$articolo->qta = $qta;
@@ -529,9 +533,13 @@ switch (post('op')) {
$riga->id_iva = post('idiva');
$riga->idconto = post('idconto');
- $riga->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto');
- $riga->id_ritenuta_acconto = post('id_ritenuta_acconto');
- $riga->id_rivalsa_inps = post('id_rivalsa_inps');
+ if (post('id_ritenuta_acconto')) {
+ $riga->calcolo_ritenuta_acconto = post('calcolo_ritenuta_acconto');
+ $riga->id_ritenuta_acconto = post('id_ritenuta_acconto');
+ }
+ if (post('id_rivalsa_inps')) {
+ $riga->id_rivalsa_inps = post('id_rivalsa_inps');
+ }
$riga->costo_unitario = post('prezzo');
$riga->qta = $qta;
diff --git a/modules/gestione_documentale/add.php b/modules/gestione_documentale/add.php
index d834414dc..e22769ed1 100644
--- a/modules/gestione_documentale/add.php
+++ b/modules/gestione_documentale/add.php
@@ -12,7 +12,7 @@ include_once __DIR__.'/../../core.php';
- {[ "type": "select", "label": "Categoria", "name": "idcategoria", "required": 1, "class": "", "values": "query=SELECT id, descrizione FROM zz_documenti_categorie WHERE deleted = 0", "value": "", "extra": "" ]}
+ {[ "type": "select", "label": "Categoria", "name": "idcategoria", "required": 1, "class": "", "values": "query=SELECT id, descrizione FROM zz_documenti_categorie WHERE deleted_at IS NULL", "value": "", "extra": "" ]}
diff --git a/modules/gestione_documentale/edit.php b/modules/gestione_documentale/edit.php
index a6cb7da16..5151bfd98 100644
--- a/modules/gestione_documentale/edit.php
+++ b/modules/gestione_documentale/edit.php
@@ -28,7 +28,7 @@ include_once __DIR__.'/../../core.php';
- {[ "type": "select", "label": "Categoria", "name": "idcategoria", "required": 1, "class": "", "values": "query=SELECT id, descrizione FROM zz_documenti_categorie WHERE deleted = 0", "value": "$idcategoria$", "extra": "" ]}
+ {[ "type": "select", "label": "Categoria", "name": "idcategoria", "required": 1, "class": "", "values": "query=SELECT id, descrizione FROM zz_documenti_categorie WHERE deleted_at IS NULL", "value": "$idcategoria$", "extra": "" ]}
diff --git a/modules/segmenti/actions.php b/modules/segmenti/actions.php
index 147a162d3..535878f2d 100644
--- a/modules/segmenti/actions.php
+++ b/modules/segmenti/actions.php
@@ -6,27 +6,28 @@ switch (post('op')) {
case 'update':
$pattern = str_contains(post('pattern'), '#') ? post('pattern') : '####';
$predefined = post('predefined');
+ $module = post('module');
- if (empty(Modules::getSegments($id_module))) {
+ if (empty(Modules::getSegments($module))) {
$predefined = 1;
}
if ($predefined) {
- $dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($id_module));
+ $dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($module));
}
$predefined_accredito = post('predefined_accredito');
if ($predefined_accredito) {
- $dbo->query('UPDATE zz_segments SET predefined_accredito = 0 WHERE id_module = '.prepare($id_module));
+ $dbo->query('UPDATE zz_segments SET predefined_accredito = 0 WHERE id_module = '.prepare($module));
}
$predefined_addebito = post('predefined_addebito');
if ($predefined_addebito) {
- $dbo->query('UPDATE zz_segments SET predefined_addebito = 0 WHERE id_module = '.prepare($id_module));
+ $dbo->query('UPDATE zz_segments SET predefined_addebito = 0 WHERE id_module = '.prepare($module));
}
$dbo->update('zz_segments', [
- 'id_module' => post('module'),
+ 'id_module' => $module,
'name' => post('name'),
'clause' => post('clause'),
'pattern' => $pattern,
@@ -44,7 +45,6 @@ switch (post('op')) {
case 'add':
$pattern = str_contains(post('pattern'), '#') ? post('pattern') : '####';
$predefined = post('predefined');
-
$module = post('module');
if (empty(Modules::getSegments($module))) {
@@ -52,11 +52,11 @@ switch (post('op')) {
}
if ($predefined) {
- $dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($id_module));
+ $dbo->query('UPDATE zz_segments SET predefined = 0 WHERE id_module = '.prepare($module));
}
$dbo->insert('zz_segments', [
- 'id_module' => post('module'),
+ 'id_module' => $module,
'name' => post('name'),
'clause' => '1=1',
'pattern' => $pattern,
diff --git a/modules/segmenti/edit.php b/modules/segmenti/edit.php
index 577a2d816..bcea30c76 100644
--- a/modules/segmenti/edit.php
+++ b/modules/segmenti/edit.php
@@ -25,9 +25,6 @@ include_once __DIR__.'/../../core.php';
-
{[ "type": "checkbox", "label": "", "name": "predefined", "value": "$predefined$", "help": "", "placeholder": "", "extra": "" ]}
diff --git a/modules/smtp/actions.php b/modules/smtp/actions.php
index 2869f49db..0b5bfbd2c 100644
--- a/modules/smtp/actions.php
+++ b/modules/smtp/actions.php
@@ -17,6 +17,11 @@ switch (post('op')) {
break;
case 'update':
+ $predefined = post('predefined');
+ if (!empty($predefined)) {
+ $dbo->query('UPDATE zz_smtps SET predefined = 0');
+ }
+
$dbo->update('zz_smtps', [
'name' => post('name'),
'note' => post('note'),
@@ -28,13 +33,9 @@ switch (post('op')) {
'from_address' => post('from_address'),
'encryption' => post('encryption'),
'pec' => post('pec'),
- 'main' => post('main'),
+ 'predefined' => $predefined,
], ['id' => $id_record]);
- if (!empty(post('main'))) {
- $dbo->query('UPDATE zz_smtps SET main = 0 WHERE id != '.prepare($id_record));
- }
-
flash()->info(tr('Informazioni salvate correttamente!'));
// Validazione indirizzo email mittente
diff --git a/modules/smtp/edit.php b/modules/smtp/edit.php
index 993d4da6c..5102104a8 100644
--- a/modules/smtp/edit.php
+++ b/modules/smtp/edit.php
@@ -24,7 +24,7 @@ include_once __DIR__.'/../../core.php';
- {[ "type": "checkbox", "label": "", "name": "main", "value": "$main$", "help": "" ]}
+ {[ "type": "checkbox", "label": "", "name": "predefined", "value": "$predefined$", "help": "" ]}
diff --git a/src/API.php b/src/API.php
index a3d70824e..b306e568b 100644
--- a/src/API.php
+++ b/src/API.php
@@ -143,11 +143,13 @@ class API extends \Util\Singleton
$query = $database->select($table, $select, $where, $order, [], true);
}
- $response['records'] = $database->fetchArray($query.' LIMIT '.($page * $length).', '.$length, $parameters);
- $count = $database->fetchNum($query, $parameters);
+ if (!empty($query)) {
+ $response['records'] = $database->fetchArray($query.' LIMIT '.($page * $length).', '.$length, $parameters);
+ $count = $database->fetchNum($query, $parameters);
- $response['total-count'] = $count;
- $response['pages'] = ceil($count / $length);
+ $response['total-count'] = $count;
+ $response['pages'] = ceil($count / $length);
+ }
} catch (PDOException $e) {
// Log dell'errore
$logger = logger();
@@ -291,7 +293,8 @@ class API extends \Util\Singleton
foreach ($operations as $operation) {
// Individua la tipologia e il modulo delle operazioni
- $module = basename(dirname(dirname($operation)));
+ $path = explode('/api/', $operation)[0];
+ $module = explode('modules/', $path)[1];
$kind = basename($operation, '.php');
$resources[$kind] = isset($resources[$kind]) ? (array) $resources[$kind] : [];
diff --git a/src/HTMLBuilder/Manager/FileManager.php b/src/HTMLBuilder/Manager/FileManager.php
index ced0240df..b6ee8770c 100644
--- a/src/HTMLBuilder/Manager/FileManager.php
+++ b/src/HTMLBuilder/Manager/FileManager.php
@@ -211,11 +211,20 @@ $(document).ready(function(){
};
$("#'.$attachment_id.' #upload").click(function(){
- $("#'.$attachment_id.' #upload-form").ajaxSubmit({
+ $form = $("#'.$attachment_id.' #upload-form");
+
+ if($form.find("input[name=nome_allegato]").val() == "" || $form.find("input[name=blob]").val() == "") {
+ swal({
+ type: "error",
+ title: "'.tr('Errore').'",
+ text: "'.tr('Alcuni campi obbligatori non sono stati compilati correttamente.').'",
+ });
+
+ return;
+ }
+
+ $form.ajaxSubmit({
url: globals.rootdir + "/actions.php",
- beforeSubmit: function(arr, $form, options) {
- return $form.find("input[name=nome_allegato]").val() && $form.find("input[name=blob]").val();
- },
data: data,
type: "post",
uploadProgress: function(event, position, total, percentComplete) {
diff --git a/src/Mail.php b/src/Mail.php
index 7de3fdd29..868d1c4c9 100644
--- a/src/Mail.php
+++ b/src/Mail.php
@@ -44,8 +44,8 @@ class Mail extends PHPMailer\PHPMailer\PHPMailer
$result = MailAccount::get($account);
if (empty($return)) {
- $result = $accounts->first(function ($item) use ($group) {
- return !empty($item->main);
+ $result = $accounts->first(function ($item) {
+ return !empty($item->predefined);
});
}
diff --git a/update/tables.php b/update/tables.php
index e94d10fa5..28ea26745 100644
--- a/update/tables.php
+++ b/update/tables.php
@@ -86,6 +86,8 @@ return [
'zz_fields',
'zz_files',
'zz_groups',
+ 'zz_group_module',
+ 'zz_group_view',
'zz_logs',
'zz_modules',
'zz_operations',