From 8ab723cb1c4ccdb76ed50dce32619c8cf731093b Mon Sep 17 00:00:00 2001
From: Thomas Zilio
Date: Thu, 27 Sep 2018 15:50:03 +0200
Subject: [PATCH] Miglioramento segmenti
---
include/init/init.php | 11 +++++--
include/manager.php | 4 +--
modules/fatture/edit.php | 34 ++++++++++++-------
modules/fatture/init.php | 6 +++-
modules/segmenti/actions.php | 1 +
modules/segmenti/edit.php | 64 +++++++++++++++++++++++++-----------
src/Models/Module.php | 12 +------
src/Models/Plugin.php | 12 +------
src/Modules.php | 3 +-
update/2_4.sql | 3 +-
update/2_4_2.sql | 24 ++++++++++++--
11 files changed, 110 insertions(+), 64 deletions(-)
diff --git a/include/init/init.php b/include/init/init.php
index 2e8ede326..08e0af3de 100644
--- a/include/init/init.php
+++ b/include/init/init.php
@@ -21,7 +21,7 @@ $settings = [
"Causale ritenuta d'acconto" => false,
];
-if (!empty(setting('Regime Fiscale'))) {
+if (!empty(setting("Percentuale ritenuta d'acconto"))) {
$settings["Causale ritenuta d'acconto"] = true;
}
@@ -81,7 +81,10 @@ if (post('action') == 'init') {
foreach ($settings as $setting => $required) {
$setting = Settings::get($setting);
- Settings::setValue($setting['nome'], post('setting')[$setting['id']]);
+ $value = post('setting')[$setting['id']];
+ if (!empty($value)) {
+ Settings::setValue($setting['nome'], $value);
+ }
}
}
@@ -183,10 +186,12 @@ if (!$has_settings) {
';
foreach ($settings as $setting => $required) {
- echo '
+ if (empty(setting($setting))) {
+ echo '
'.Settings::input($setting, $required).'
';
+ }
}
echo '
diff --git a/include/manager.php b/include/manager.php
index c099c00d7..3e03b0ed2 100644
--- a/include/manager.php
+++ b/include/manager.php
@@ -68,9 +68,9 @@ if (!empty($type) && $type != 'menu' && $type != 'custom') {
$(document).ready(function () {
$("#id_segment_").on("change", function(){
if ($(this).val() < 1){
- session_set("m'.$id_module.',id_segment", "", 1, 1);
+ session_set("module_'.$id_module.',id_segment", "", 1, 1);
} else {
- session_set("m'.$id_module.',id_segment", $(this).val(), 0, 1);
+ session_set("module_'.$id_module.',id_segment", $(this).val(), 0, 1);
}
});
});
diff --git a/modules/fatture/edit.php b/modules/fatture/edit.php
index 062778f5d..16d55dfc1 100644
--- a/modules/fatture/edit.php
+++ b/modules/fatture/edit.php
@@ -83,11 +83,19 @@ if ($dir == 'entrata') {
{[ "type": "date", "label": "", "maxlength": 10, "name": "data", "required": 1, "value": "$data$" ]}
+
+
- {[ "type": "select", "label": "", "name": "idstatodocumento", "required": 1, "values": "query=SELECT * FROM co_statidocumento", "value": "$idstatodocumento$", "class": "unblockable", "extra": " onchange = \"if ($('#idstatodocumento option:selected').text()=='Pagato' || $('#idstatodocumento option:selected').text()=='Parzialmente pagato' ){if( confirm('') ){ return true; }else{ $('#idstatodocumento').selectSet(); }}\" " ]}
+ {[ "type": "select", "label": "", "name": "idstatodocumento", "required": 1, "values": "query=", "value": "$idstatodocumento$", "class": "unblockable", "extra": " onchange = \"if ($('#idstatodocumento option:selected').text()=='Pagato' || $('#idstatodocumento option:selected').text()=='Parzialmente pagato' ){if( confirm('') ){ return true; }else{ $('#idstatodocumento').selectSet(); }}\" " ]}
-
@@ -171,23 +179,27 @@ if ($dir == 'uscita') {
fetchNum('SELECT id FROM co_movimenti WHERE iddocumento='.prepare($id_record).' AND primanota=1');
+ $n2 = $dbo->fetchNum('SELECT id FROM co_movimenti WHERE iddocumento='.prepare($id_record).' AND primanota=1');
-$rs3 = $dbo->fetchArray('SELECT SUM(da_pagare-pagato) AS differenza, SUM(da_pagare) FROM co_scadenziario GROUP BY iddocumento HAVING iddocumento='.prepare($id_record));
-$differenza = isset($rs3[0]) ? $rs3[0]['differenza'] : null;
-$da_pagare = isset($rs3[0]) ? $rs3[0]['da_pagare'] : null;
+ $rs3 = $dbo->fetchArray('SELECT SUM(da_pagare-pagato) AS differenza, SUM(da_pagare) FROM co_scadenziario GROUP BY iddocumento HAVING iddocumento='.prepare($id_record));
+ $differenza = isset($rs3[0]) ? $rs3[0]['differenza'] : null;
+ $da_pagare = isset($rs3[0]) ? $rs3[0]['da_pagare'] : null;
-if (($n2 <= 0 && $record['stato'] == 'Emessa') || $differenza != 0) {
- ?>
+ if (($n2 <= 0 && $record['stato'] == 'Emessa') || $differenza != 0) {
+ ?>
...
+ if ($record['stato'] == 'Pagato') {
+ ?>
...
diff --git a/modules/fatture/init.php b/modules/fatture/init.php
index 8b7666047..fb627eda5 100644
--- a/modules/fatture/init.php
+++ b/modules/fatture/init.php
@@ -11,7 +11,11 @@ if ($module['name'] == 'Fatture di vendita') {
if (isset($id_record)) {
$fattura = Modules\Fatture\Fattura::with('tipo', 'stato')->find($id_record);
- $record = $dbo->fetchOne('SELECT *, co_tipidocumento.reversed AS is_reversed, co_documenti.idagente AS idagente_fattura, co_documenti.note, co_documenti.note_aggiuntive, co_documenti.idpagamento, co_documenti.id AS iddocumento, co_statidocumento.descrizione AS `stato`, co_tipidocumento.descrizione AS `descrizione_tipodoc`, (SELECT descrizione FROM co_ritenutaacconto WHERE id=idritenutaacconto) AS ritenutaacconto_desc, (SELECT descrizione FROM co_rivalsainps WHERE id=idrivalsainps) AS rivalsainps_desc FROM ((co_documenti LEFT OUTER JOIN co_statidocumento ON co_documenti.idstatodocumento=co_statidocumento.id) INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir = '.prepare($dir).' AND co_documenti.id='.prepare($id_record));
+ $record = $dbo->fetchOne('SELECT *, co_tipidocumento.reversed AS is_reversed, co_documenti.idagente AS idagente_fattura, co_documenti.note, co_documenti.note_aggiuntive, co_documenti.idpagamento, co_documenti.id AS iddocumento, co_statidocumento.descrizione AS `stato`, co_tipidocumento.descrizione AS `descrizione_tipodoc`,
+ (SELECT is_fiscale FROM zz_segments WHERE id = id_segment) AS is_fiscale,
+ (SELECT descrizione FROM co_ritenutaacconto WHERE id=idritenutaacconto) AS ritenutaacconto_desc,
+ (SELECT descrizione FROM co_rivalsainps WHERE id=idrivalsainps) AS rivalsainps_desc
+ FROM ((co_documenti LEFT OUTER JOIN co_statidocumento ON co_documenti.idstatodocumento=co_statidocumento.id) INNER JOIN an_anagrafiche ON co_documenti.idanagrafica=an_anagrafiche.idanagrafica) INNER JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE co_tipidocumento.dir = '.prepare($dir).' AND co_documenti.id='.prepare($id_record));
$note_accredito = $dbo->fetchArray("SELECT co_documenti.id, IF(numero_esterno != '', numero_esterno, numero) AS numero, data FROM co_documenti JOIN co_tipidocumento ON co_documenti.idtipodocumento=co_tipidocumento.id WHERE reversed = 1 AND ref_documento=".prepare($id_record));
}
diff --git a/modules/segmenti/actions.php b/modules/segmenti/actions.php
index 535878f2d..3cdc30db0 100644
--- a/modules/segmenti/actions.php
+++ b/modules/segmenti/actions.php
@@ -34,6 +34,7 @@ switch (post('op')) {
'note' => post('note'),
'position' => post('position'),
'predefined' => $predefined,
+ 'is_fiscale' => post('is_fiscale'),
'predefined_accredito' => $predefined_accredito,
'predefined_addebito' => $predefined_addebito,
], ['id' => $id_record]);
diff --git a/modules/segmenti/edit.php b/modules/segmenti/edit.php
index bcea30c76..06ca98c80 100644
--- a/modules/segmenti/edit.php
+++ b/modules/segmenti/edit.php
@@ -30,17 +30,6 @@ include_once __DIR__.'/../../core.php';
-
-
-
- {[ "type": "checkbox", "label": "", "name": "predefined_accredito", "value": "$predefined_accredito$", "help": "", "placeholder": "" ]}
-
-
- {[ "type": "checkbox", "label": "", "name": "predefined_addebito", "value": "$predefined_addebito$", "help": "", "placeholder": "" ]}
-
-
-
-
@@ -52,7 +41,25 @@ include_once __DIR__.'/../../core.php';
+'.tr('Query risultante').':
+
-
+
-
-
+
{[ "type": "text", "label": "", "name": "pattern", "class": "alphanumeric-mask", "value": "$pattern$", "maxlength": 25, "placeholder":"####/YY", "extra": " 0) ? 'readonly' : ''; ?>" ]}
+
+
+ {[ "type": "checkbox", "label": "", "name": "is_fiscale", "value": "$is_fiscale$" ]}
+
+
+
+
+
+ {[ "type": "checkbox", "label": "", "name": "predefined_accredito", "value": "$predefined_accredito$", "help": "", "placeholder": "" ]}
+
+
+
+ {[ "type": "checkbox", "label": "", "name": "predefined_addebito", "value": "$predefined_addebito$", "help": "", "placeholder": "" ]}
+
@@ -93,15 +117,13 @@ $list = [
'yy' => tr('Anno corrente a 2 cifre'),
];
-foreach ($list as $key => $value) {
- echo '
+ foreach ($list as $key => $value) {
+ echo '
'.tr('_TEXT_: _FIELD_', [
'_TEXT_' => ''.$key.'
',
'_FIELD_' => $value,
]).'';
-}
-
-?>
+ } ?>
.
@@ -110,7 +132,9 @@ foreach ($list as $key => $value) {
-
+
options) ? $this->options : $this->options2;
- }
-
- public function getOptionsAttribute($value)
- {
- return App::replacePlaceholder($value);
- }
-
- public function getOptions2Attribute($value)
- {
- return App::replacePlaceholder($value);
+ return !empty($this->options2) ? $this->options2 : $this->options;
}
/* Relazioni Eloquent */
diff --git a/src/Models/Plugin.php b/src/Models/Plugin.php
index 3aa4d22ac..f545efba3 100644
--- a/src/Models/Plugin.php
+++ b/src/Models/Plugin.php
@@ -47,17 +47,7 @@ class Plugin extends Model
public function getOptionAttribute()
{
- return !empty($this->options) ? $this->options : $this->options2;
- }
-
- public function getOptionsAttribute($value)
- {
- return App::replacePlaceholder($value);
- }
-
- public function getOptions2Attribute($value)
- {
- return App::replacePlaceholder($value);
+ return !empty($this->options2) ? $this->options2 : $this->options;
}
/* Metodi personalizzati */
diff --git a/src/Modules.php b/src/Modules.php
index 3edfebfac..82867c1f7 100644
--- a/src/Modules.php
+++ b/src/Modules.php
@@ -128,8 +128,9 @@ class Modules
// Aggiunta dei segmenti
$segments = self::getSegments($module['id']);
+ $id_segment = $_SESSION['module_'.$module['id']]['id_segment'];
foreach ($segments as $result) {
- if (!empty($result['clause']) && $result['id'] == $_SESSION['module_'.$module['id']]['id_segment']) {
+ if (!empty($result['clause']) && $result['id'] == $id_segment) {
$result['clause'] = App::replacePlaceholder($result['clause']);
$additionals[$result['position']][] = $result['clause'];
diff --git a/update/2_4.sql b/update/2_4.sql
index 62b1d7961..74760ac22 100644
--- a/update/2_4.sql
+++ b/update/2_4.sql
@@ -195,8 +195,7 @@ UPDATE `co_documenti` SET `id_segment`='1' WHERE `idtipodocumento` IN (SELECT `i
UPDATE `co_documenti` SET `id_segment`='2' WHERE `idtipodocumento` IN (SELECT `id` FROM `co_tipidocumento` WHERE `co_tipidocumento`.`dir`='uscita');
-- Innesto modulo segmenti sotto "Strumenti"
-INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES
-(NULL, 'Segmenti', 'Segmenti', 'segmenti', '{ "main_query": [ { "type": "table", "fields": "id, Nome, Modulo, Maschera, Note, Predefinito", "query": "SELECT `id`, (IF(predefined=1, ''Sì'', ''No'')) AS `Predefinito`, `name` AS `Nome`, (SELECT name FROM zz_modules WHERE id = zz_segments.id_module) AS Modulo, `pattern` AS `Maschera`, `note` AS `Note` FROM `zz_segments` HAVING 2=2 ORDER BY name, id_module"} ]}', '', 'fa fa-database', '2.4', '2.4', 1, NULL, 1, 1);
+INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Segmenti', 'Segmenti', 'segmenti', '{ "main_query": [ { "type": "table", "fields": "id, Nome, Modulo, Maschera, Note, Predefinito", "query": "SELECT `id`, (IF(predefined=1, ''Sì'', ''No'')) AS `Predefinito`, `name` AS `Nome`, (SELECT name FROM zz_modules WHERE id = zz_segments.id_module) AS Modulo, `pattern` AS `Maschera`, `note` AS `Note` FROM `zz_segments` HAVING 2=2 ORDER BY name, id_module"} ]}', '', 'fa fa-database', '2.4', '2.4', 1, NULL, 1, 1);
UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Segmenti' AND `t2`.`name` = 'Strumenti') SET `t1`.`parent` = `t2`.`id`;
-- Aggiorno widget Fatturato con i sezionali
diff --git a/update/2_4_2.sql b/update/2_4_2.sql
index ccc0389c0..05247b88b 100644
--- a/update/2_4_2.sql
+++ b/update/2_4_2.sql
@@ -55,7 +55,7 @@ INSERT INTO `fe_regime_fiscale` (`codice`, `descrizione`) VALUES
('RF18','Altro'),
('RF19','Regime forfettario (art.1, c.54-89, L. 190/2014)');
-INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Regime Fiscale', 'RF01', 'query=SELECT codice AS id, descrizione FROM fe_regime_fiscale', 1, 'Generali', 19);
+INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Regime Fiscale', '', 'query=SELECT codice AS id, descrizione FROM fe_regime_fiscale', 1, 'Generali', 19);
CREATE TABLE IF NOT EXISTS `fe_tipo_cassa` (
`codice` varchar(4) NOT NULL,
@@ -87,7 +87,7 @@ INSERT INTO `fe_tipo_cassa` (`codice`, `descrizione`) VALUES
('TC21','Ente nazionale previdenza e assistenza psicologi (ENPAP)'),
('TC22','INPS');
-INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Tipo Cassa', 'TC22', 'query=SELECT codice AS id, descrizione FROM fe_tipo_cassa', 1, 'Fatturazione', 0);
+INSERT INTO `zz_settings` (`idimpostazione`, `nome`, `valore`, `tipo`, `editable`, `sezione`, `order`) VALUES (NULL, 'Tipo Cassa', '', 'query=SELECT codice AS id, descrizione FROM fe_tipo_cassa', 1, 'Fatturazione', 0);
CREATE TABLE IF NOT EXISTS `fe_modalita_pagamento` (
`codice` varchar(4) NOT NULL,
@@ -506,3 +506,23 @@ UPDATE `zz_modules` `t1` INNER JOIN `zz_modules` `t2` ON (`t1`.`name` = 'Tipi di
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `visible`, `default`) VALUES
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di spedizione'), 'Descrizione', 'descrizione', 2, 1, 0, 1, 1),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Tipi di spedizione'), 'id', 'id', 1, 1, 0, 0, 1);
+
+-- Aggiunto flag fiscale nei sezionali
+ALTER TABLE `zz_segments` ADD `is_fiscale` boolean NOT NULL DEFAULT 1;
+
+INSERT INTO `zz_segments` (`id_module`, `name`, `clause`, `position`, `pattern`,`note`, `predefined`, `is_fiscale`) VALUES
+((SELECT `id` FROM `zz_modules` WHERE `name` = 'Fatture di vendita'), 'Fatture pro-forma', '1=1', 'WHR', 'PRO-###', '', 1, 0);
+
+-- Fix campi di ricerca
+UPDATE `zz_modules` SET `options` = "SELECT |select| FROM `zz_segments` WHERE 1=1 HAVING 2=2 ORDER BY name, id_module" WHERE `name` = 'Segmenti';
+INSERT INTO `zz_views` (`id`, `id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `visible`, `summable`, `default`) VALUES
+(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'id', 'id', 0, 0, 0, 0, 0, 0, 1),
+(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'Nome', 'name', 1, 1, 0, 0, 1, 0, 1),
+(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'Modulo', '(SELECT name FROM zz_modules WHERE zz_modules.id = zz_segments.id_module)', 2, 1, 0, 0, 1, 0, 1),
+(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'Maschera', 'pattern', 3, 1, 0, 0, 1, 0, 1),
+(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'Note', 'note', 4, 1, 0, 0, 1, 0, 1),
+(NULL, (SELECT `id` FROM `zz_modules` WHERE `name` = 'Segmenti'), 'Predefinito', 'IF(predefined=1, ''Sì'', ''No'')', 5, 1, 0, 0, 1, 0, 1);
+
+UPDATE `zz_views` SET `search` = 1 WHERE `name` = 'Nome' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche');
+UPDATE `zz_views` SET `search` = 1 WHERE `name` = 'Filiale' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche');
+UPDATE `zz_views` SET `search` = 1 WHERE `name` = 'IBAN' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Banche');