Aumentata flessibilità segmenti con introduzione dei filtri

This commit is contained in:
Luca 2018-03-22 12:45:29 +01:00
parent 0f8d2e10ca
commit f998adc626
9 changed files with 107 additions and 47 deletions

View File

@ -176,7 +176,7 @@ if (Auth::check()) {
<div id="tiny-loader" style="display:none;"></div>
<header class="main-header">
<a href="http://www.openstamanager.com" class="logo" target="_blank">
<a href="https://www.openstamanager.com" class="logo" target="_blank">
<!-- mini logo for sidebar mini 50x50 pixels -->
<span class="logo-mini">'.tr('OSM').'</span>
<!-- logo for regular state and mobile devices -->

View File

@ -38,6 +38,17 @@ switch (post('op')) {
$data = date('Y-m-d');
$dir = 'entrata';
$idtipodocumento = '2';
if (empty($_SESSION['m'.Modules::get('Fatture di vendita')['id']]['id_segment'])){
$rs = $dbo->fetchArray("SELECT id FROM zz_segments WHERE predefined = 1 AND id_module = ".prepare(Modules::get('Fatture di vendita')['id'])."LIMIT 0,1");
$_SESSION['m'.Modules::get('Fatture di vendita')['id']]['id_segment'] = $rs[0]['id'];
}
$id_segment = $_SESSION['m'.Modules::get('Fatture di vendita')['id']]['id_segment'];
$numero = get_new_numerofattura($data);

View File

@ -4,6 +4,8 @@
$rs = $dbo->fetchArray("SELECT id FROM zz_segments WHERE predefined = 1 AND id_module = ".prepare($id_module)."LIMIT 0,1");
$_SESSION['m'.$id_module]['id_segment'] = $rs[0]['id'];
}
if (count($dbo->fetchArray("SELECT id FROM zz_segments WHERE id_module = \"$id_module\""))>1){
?>
<div class="row">
@ -27,4 +29,8 @@ $(document).ready(function () {
});
});
</script>
</script>
<?php
}
?>

View File

@ -10,7 +10,9 @@ switch (post('op')) {
(strpos(post('pattern'), '#') !== false) ? $pattern = post('pattern') : $maschera = '####';
$id_module_ = post('id_module_');
$note = post('note');
$clause = post('clause');
$predefined = $post['predefined'];
$position = post('position');
if (count($dbo->fetchArray("SELECT id FROM zz_segments WHERE id_module = \"$id_module_\""))==0)
$predefined = 1;
@ -18,7 +20,7 @@ switch (post('op')) {
if ($predefined)
$dbo->query("UPDATE zz_segments SET predefined = 0 WHERE id_module = \"$id_module_\"");
$query = "UPDATE zz_segments SET name=\"$name\", pattern=\"$pattern\", id_module=\"$id_module_\", note=\"$note\", predefined=\"$predefined\" WHERE id=\"$id_record\"";
$query = "UPDATE zz_segments SET name=\"$name\", clause=\"$clause\", position=\"$position\", pattern=\"$pattern\", id_module=\"$id_module_\", note=\"$note\", predefined=\"$predefined\" WHERE id=\"$id_record\"";
$rs = $dbo->query($query);
@ -34,6 +36,7 @@ switch (post('op')) {
$id_module_ = post('id_module_');
$note = post('note');
$predefined = $post['predefined'];
$clause = '1=1';
if (count($dbo->fetchArray("SELECT id FROM zz_segments WHERE id_module = \"$id_module_\""))==0)
$predefined = 1;
@ -41,7 +44,7 @@ switch (post('op')) {
if ($predefined)
$dbo->query("UPDATE zz_segments SET predefined = 0 WHERE id_module = \"$id_module_\"");
$dbo->query("INSERT INTO zz_segments( name, pattern, id_module, note, predefined ) VALUES ( \"$name\", \"$pattern\", \"$id_module_\", \"$note\", \"$predefined\" )");
$dbo->query("INSERT INTO zz_segments( name, clause, pattern, id_module, note, predefined ) VALUES ( \"$name\", \"$clause\", \"$pattern\", \"$id_module_\", \"$note\", \"$predefined\" )");
$id_record = $dbo->last_inserted_id();
$_SESSION['infos'][] = tr('Nuovo segmento aggiunto.');

View File

@ -18,7 +18,7 @@
<div class="row">
<div class="col-md-6">
{[ "type": "select", "label": "<?php echo tr('Modulo'); ?>", "name": "id_module_", "required": 1, "class": "", "values": "list=\"14\": \"Fatture di vendita\", \"15\": \"Fatture di acquisto\"", "value": "$id_module$", "extra": "" ]}
{[ "type": "select", "label": "<?php echo tr('Modulo'); ?>", "name": "id_module_", "required": 1, "class": "", "values": "query=SELECT id, name AS descrizione FROM zz_modules WHERE enabled = 1 AND options != 'custom' ORDER BY name ASC", "value": "$id_module$", "extra": "" ]}
</div>
<div class="col-md-6">

View File

@ -3,7 +3,7 @@
<input type="hidden" name="op" value="update">
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>">
<!-- DATI ARTICOLO -->
<!-- DATI SEGMENTO -->
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><?php echo tr('Segmento'); ?></h3>
@ -12,33 +12,63 @@
<div class="panel-body">
<div class="row">
<div class="col-md-3">
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "required": 1, "class": "", "value": "$name$", "extra": "" ]}
</div>
<div class="col-md-3">
{[ "type": "text", "label": "<?php echo tr('Maschera'); ?>", "name": "pattern", "required": 1, "class": "alphanumeric-mask", "value": "$pattern$", "maxlength": 25, "placeholder":"####/YY", "extra": "" ]}
<div class="col-md-4">
{[ "type": "select", "label": "<?php echo tr('Modulo'); ?>", "name": "id_module_", "required": 1, "class": "", "values": "query=SELECT id, name AS descrizione FROM zz_modules WHERE ( enabled = 1 AND options != 'custom' ) OR id = <?php echo $records[0]['id_module'] ?> ORDER BY name ASC", "value": "$id_module$", "extra": "<?php echo ($records[0]['predefined']) ? 'readonly' : ''; ?>" ]}
</div>
<div class="col-md-3">
{[ "type": "select", "label": "<?php echo tr('Modulo'); ?>", "name": "id_module_", "required": 1, "class": "", "values": "list=\"14\": \"Fatture di vendita\", \"15\": \"Fatture di acquisto\"", "value": "$id_module$", "extra": "<?php echo ($records[0]['predefined']) ? 'readonly' : ''; ?>" ]}
</div>
<div class="col-md-3">
<div class="col-md-4">
<?php
($records[0]['n_sezionali']<2) ? $records[0]['predefined']=1 : '';
//($records[0]['n_sezionali']<2) ? $records[0]['predefined']=1 : '';
?>
{[ "type": "checkbox", "label": "<?php echo tr('Predefinito'); ?>", "name": "predefined", "value": "$predefined$", "help": "<?php echo tr('Seleziona per rendere il segmento predefinito.'); ?>", "placeholder": "<?php echo tr('Segmento predefinito'); ?>", "extra": "<?php echo ($records[0]['predefined']) ? 'readonly' : ''; ?>" ]}
</div>
</div>
<div class="row">
<div class="col-md-8">
{[ "type": "textarea", "label": "<?php echo tr('Filtro'); ?>", "name": "clause", "required": 1, "class": "", "value": "$clause$", "extra": "" ]}
</div>
<div class="col-md-4">
{[ "type": "select", "label": "<?php echo tr('Posizione'); ?>", "name": "position", "required": 1, "values":"list=\"WHR\": \"WHERE\", \"HVN\": \"HAVING\"", "value": "$position$" ]}
</div>
</div>
<div class="row">
<div class="col-md-12">
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note", "required": 0, "class": "", "value": "$note$", "extra": "" ]}
</div>
</div>
</div>
</div>
<!-- Campi extra -->
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><?php echo tr('Extra'); ?></h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-3">
{[ "type": "text", "label": "<?php echo tr('Maschera'); ?>", "name": "pattern", "required": 1, "class": "alphanumeric-mask", "value": "$pattern$", "maxlength": 25, "placeholder":"####/YY", "extra": "" ]}
</div>
</div>
<div class="row">
<div class="col-md-12">
@ -62,7 +92,8 @@
</div>
</div>
</div>
</div>
@ -71,45 +102,52 @@
<?php
$array = preg_match('/(?<=FROM)\s([^\s]+)\s/', $records[0]['options'], $table);
$righe = $dbo->fetchArray("SELECT COUNT(*) AS tot FROM ".$table[0]." WHERE id_segment = ".prepare($id_record));
$tot = $righe[0]['tot'];
if ($tot > 0) {
if (strpos($table[0], 'co_documenti') !== false) {
$righe = $dbo->fetchArray("SELECT COUNT(*) AS tot FROM ".$table[0]." WHERE id_segment = ".prepare($id_record));
$tot = $righe[0]['tot'];
if ($tot > 0) {
echo "<div class='alert alert-danger' style='margin:0px;'>";
echo tr("Ci sono _TOT_ righe collegate al segmento per il modulo '_MODULO_'. Il comando elimina è stato disattivato, eliminare le righe per attivare il comando 'Elimina segmento'.", [
'_TOT_' => $tot,
'_MODULO_' => $records[0]['modulo'],
]);
echo "<div class='alert alert-danger' style='margin:0px;'>";
echo tr("Ci sono _TOT_ righe collegate al segmento per il modulo '_MODULO_'. Il comando elimina è stato disattivato, eliminare le righe per attivare il comando 'Elimina segmento'.", [
'_TOT_' => $tot,
'_MODULO_' => $records[0]['modulo'],
]);
echo "</div>";
echo "</div>";
}
else if ($records[0]['predefined']) {
}
else if ($records[0]['predefined']) {
echo "<div class='alert alert-danger' style='margin:0px;'>";
echo tr("Questo è il segmento predefinito per il modulo '_MODULO_'. Il comando elimina è stato disattivato.", [
'_MODULO_' => $records[0]['modulo'],
]);
echo "<div class='alert alert-danger' style='margin:0px;'>";
echo tr("Questo è il segmento predefinito per il modulo '_MODULO_'. Il comando elimina è stato disattivato.", [
'_MODULO_' => $records[0]['modulo'],
]);
echo "</div>";
echo "</div>";
}
else if ($records[0]['n_sezionali']<2) {
}
else if ($records[0]['n_sezionali']<2) {
echo "<div class='alert alert-danger' style='margin:0px;'>";
echo tr("Questo è l'unico segmento per il modulo '_MODULO_'. Il comando elimina è stato disattivato.", [
'_MODULO_' => $records[0]['modulo'],
]);
echo "<div class='alert alert-danger' style='margin:0px;'>";
echo tr("Questo è l'unico segmento per il modulo '_MODULO_'. Il comando elimina è stato disattivato.", [
'_MODULO_' => $records[0]['modulo'],
]);
echo "</div>";
}
echo "</div>";
}
}
else{
echo '
<a class="btn btn-danger ask" data-backto="record-list">

View File

@ -434,7 +434,7 @@ if (!empty($options) && $options != 'custom') {
<div class="col-md-3">
{[ "type": "select", "label": "'.tr('Posizione').'", "name": "position[-id-]", "list=\"0\":\"'.tr('WHERE').'\",\"1\": \"'.tr('HAVING').'\"" ]}
</div>
</div>
</div>
</div>
</form>';

View File

@ -38,7 +38,7 @@ class Modules
$user = Auth::user();
$results = $database->fetchArray('SELECT * FROM `zz_modules` LEFT JOIN (SELECT `idmodule`, `permessi` FROM `zz_permissions` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `id` = '.prepare($user['id_utente']).')) AS `zz_permissions` ON `zz_modules`.`id`=`zz_permissions`.`idmodule` LEFT JOIN (SELECT `idmodule`, `clause`, `position` FROM `zz_group_module` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `id` = '.prepare($user['id_utente']).') AND `enabled` = 1) AS `zz_group_module` ON `zz_modules`.`id`=`zz_group_module`.`idmodule`');
$results = $database->fetchArray('SELECT * FROM `zz_modules` LEFT JOIN (SELECT `idmodule`, `permessi` FROM `zz_permissions` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `id` = '.prepare($user['id_utente']).')) AS `zz_permissions` ON `zz_modules`.`id`=`zz_permissions`.`idmodule` LEFT JOIN (SELECT `id_module`, `clause`, `position` FROM `zz_segments`) AS `zz_segments` ON `zz_modules`.`id`=`zz_segments`.`id_module` LEFT JOIN (SELECT `idmodule`, `clause`, `position` FROM `zz_group_module` WHERE `idgruppo` = (SELECT `idgruppo` FROM `zz_users` WHERE `id` = '.prepare($user['id_utente']).') AND `enabled` = 1) AS `zz_group_module` ON `zz_modules`.`id`=`zz_group_module`.`idmodule`');
$modules = [];
$additionals = [];

View File

@ -166,6 +166,8 @@ CREATE TABLE IF NOT EXISTS `zz_segments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`id_module` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`clause` TEXT NOT NULL,
`position` enum('WHR', 'HVN') NOT NULL DEFAULT 'WHR',
`pattern` varchar(255) NOT NULL,
`note` text NOT NULL,
`predefined` BOOLEAN NOT NULL,