openstamanager/modules/segmenti/edit.php

223 lines
10 KiB
PHP
Raw Normal View History

2018-05-11 15:56:08 +02:00
<?php
2020-09-07 15:04:06 +02:00
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
2021-01-20 15:08:51 +01:00
* Copyright (C) DevCode s.r.l.
2020-09-07 15:04:06 +02:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2018-05-11 15:56:08 +02:00
include_once __DIR__.'/../../core.php';
2024-03-06 10:56:09 +01:00
use Models\Module;
2018-05-11 15:56:08 +02:00
?><form action="" method="post" id="edit-form">
2017-12-15 10:05:08 +01:00
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="update">
2018-02-17 14:32:40 +01:00
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>">
2017-12-15 10:05:08 +01:00
<!-- DATI SEGMENTO -->
2024-05-16 18:02:50 +02:00
<div class="card card-primary">
2024-05-17 12:11:00 +02:00
<div class="card-header">
2024-05-16 18:02:50 +02:00
<h3 class="card-title"><?php echo tr('Segmento'); ?></h3>
2017-12-15 10:05:08 +01:00
</div>
2018-02-17 14:32:40 +01:00
2024-05-16 18:02:50 +02:00
<div class="card-body">
2017-12-15 10:05:08 +01:00
<div class="row">
2018-05-11 15:56:08 +02:00
<div class="col-md-3">
2024-04-19 16:44:08 +02:00
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "required": 1, "value": "$title$" ]}
2017-12-15 10:05:08 +01:00
</div>
2018-05-11 15:56:08 +02:00
<div class="col-md-3">
2024-04-18 17:44:05 +02:00
{[ "type": "select", "label": "<?php echo tr('Modulo'); ?>", "name": "module", "required": 1, "values": "query=SELECT `zz_modules`.`id`, `title` AS descrizione FROM `zz_modules` LEFT JOIN `zz_modules_lang` ON(`zz_modules`.`id` = `zz_modules_lang`.`id_record` AND `zz_modules_lang`.`id_lang` = <?php echo Models\Locale::getDefault()->id; ?>) WHERE (`enabled` = 1 AND `options` != 'custom' ) OR `zz_modules`.`id` = <?php echo $record['id_module']; ?> ORDER BY `title` ASC", "value": "<?php echo $record['id_module']; ?>", "extra": "<?php echo ($record['predefined']) ? 'readonly' : ''; ?>" ]}
2018-02-17 14:32:40 +01:00
</div>
2018-05-11 15:56:08 +02:00
<div class="col-md-2">
2024-03-22 15:52:24 +01:00
{[ "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 $record['predefined'] || ($record['is_sezionale'] == 0) ? 'readonly' : ''; ?>" ]}
2018-03-21 19:33:33 +01:00
</div>
2018-05-11 15:56:08 +02:00
<div class="col-md-2">
2024-11-15 13:05:31 +01:00
{[ "type": "checkbox", "label": "<?php echo tr('Tipologia'); ?>", "help": "<?php echo tr('Se sezionale verrà utilizzato il contatore'); ?>", "name": "is_sezionale", "value": "$is_sezionale$", "extra": "readonly", "values": "Sezionale,Segmento" ]}
</div>
<div class="col-md-2">
{[ "type": "text", "label": "<?php echo tr('Maschera'); ?>", "name": "pattern", "value": "$pattern$", "maxlength": 25, "placeholder":"####/YYYY", "extra": "<?php echo ($tot > 0) ? 'readonly' : ''; ?>", "extra": "<?php echo (!$record['is_sezionale']) ? 'readonly' : ''; ?>" ]}
</div>
2017-12-15 10:05:08 +01:00
</div>
2018-05-11 15:56:08 +02:00
<div class="row">
2018-05-11 15:56:08 +02:00
<div class="col-md-8">
{[ "type": "textarea", "label": "<?php echo tr('Filtro'); ?>", "name": "clause", "required": 1, "value": "$clause$", "extra": "<?php echo ($record['is_sezionale']) ? 'readonly' : ''; ?>" ]}
</div>
2018-05-11 15:56:08 +02:00
<div class="col-md-4">
{[ "type": "select", "label": "<?php echo tr('Posizione'); ?>", "name": "position", "required": 1, "values":"list=\"WHR\": \"WHERE\", \"HVN\": \"HAVING\"", "value": "$position$", "extra": "<?php echo ($record['is_sezionale']) ? 'readonly' : ''; ?>" ]}
</div>
2018-05-11 15:56:08 +02:00
</div>
2018-09-27 15:50:03 +02:00
<?php
$previous = $_SESSION['module_'.$record['id_module']]['id_segment'];
$previous_module = $_SESSION['module_'.$record['id_module']]['id_segment'];
$_SESSION['module_'.$id_module]['id_segment'] = $id_record;
$_SESSION['module_'.$record['id_module']]['id_segment'] = $id_record;
2024-03-06 10:56:09 +01:00
$current_module = Module::find($record['id_module']);
2019-02-01 17:44:31 +01:00
$total = Util\Query::readQuery($current_module);
2018-09-27 15:50:03 +02:00
$module_query = Modules::replaceAdditionals($record['id_module'], $total['query']);
echo '
<p><strong>'.tr('Query risultante').':</strong></p>
2024-05-23 11:36:25 +02:00
<p>'.htmlentities((string) $module_query).'</p>';
2018-05-11 15:56:08 +02:00
2018-09-27 15:50:03 +02:00
$_SESSION['module_'.$id_module]['id_segment'] = $previous;
$_SESSION['module_'.$record['id_module']]['id_segment'] = $previous_module;
?>
2017-12-15 10:05:08 +01:00
<div class="row">
<div class="col-md-12">
2018-08-03 09:34:06 +02:00
{[ "type": "textarea", "label": "<?php echo tr('Note'); ?>", "name": "note", "value": "$note$" ]}
2017-12-15 10:05:08 +01:00
</div>
</div>
<?php
if (!empty($record['is_fiscale'])) {
2023-08-04 14:54:28 +02:00
?>
<div class="row">
<div class="col-md-12">
{[ "type": "textarea", "label": "<?php echo tr('Dicitura fissa'); ?>", "name": "dicitura_fissa", "value": "$dicitura_fissa$" ]}
</div>
</div>
<?php
}
2024-01-31 14:23:46 +01:00
echo '
<div class="row">
<div class="col-md-12">
2024-04-18 17:44:05 +02:00
{[ "type": "select", "label": "'.tr('Gruppi con accesso').'", "name": "gruppi[]", "multiple": "1", "values": "query=SELECT `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).') ORDER BY `zz_groups`.`id` ASC", "value": "';
2024-03-12 16:39:34 +01:00
$results = $dbo->fetchArray('SELECT GROUP_CONCAT(DISTINCT `id_gruppo` SEPARATOR \',\') AS gruppi FROM `zz_group_segment` WHERE `id_segment`='.prepare($id_record));
2024-01-15 15:30:45 +01:00
echo $results[0]['gruppi'].'"';
2024-01-15 15:30:45 +01:00
echo ', "help": "'.tr('Gruppi di utenti in grado di visualizzare questo segmento').'" ]}
</div>
</div>';
?>
</div>
</div>
2018-05-11 15:56:08 +02:00
2018-09-27 15:50:03 +02:00
<?php
if ($record['is_sezionale']) {
2018-09-27 15:50:03 +02:00
?>
<!-- Campi extra -->
2024-05-16 18:02:50 +02:00
<div class="card card-primary">
2024-05-17 12:11:00 +02:00
<div class="card-header">
2024-05-16 18:02:50 +02:00
<h3 class="card-title"><?php echo tr('Sezionale'); ?></h3>
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body">
<div class="row">
2018-09-27 15:50:03 +02:00
<div class="col-md-6">
2023-08-04 14:54:28 +02:00
{[ "type": "checkbox", "label": "<?php echo tr('Sezionale fiscale'); ?>", "name": "is_fiscale", "value": "$is_fiscale$", "extra": "<?php echo ($tot > 0 || ($record['modulo'] != 'Fatture di vendita' && $record['modulo'] != 'Fatture di acquisto')) ? 'readonly' : ''; ?>" ]}
2018-09-27 15:50:03 +02:00
</div>
</div>
<div class="row">
<div class="col-md-3">
2023-08-04 14:54:28 +02:00
{[ "type": "checkbox", "label": "<?php echo tr('Predefinito note di credito'); ?>", "name": "predefined_accredito", "value": "$predefined_accredito$", "help": "<?php echo tr('Seleziona per rendere il sezionale predefinito per le note di credito'); ?>", "placeholder": "<?php echo tr('Sezionale predefinito per le note di credito'); ?>", "extra": "<?php echo ($record['modulo'] != 'Fatture di vendita' && $record['modulo'] != 'Fatture di acquisto') ? 'readonly' : ''; ?>" ]}
2018-09-27 15:50:03 +02:00
</div>
<div class="col-md-3">
2023-08-04 14:54:28 +02:00
{[ "type": "checkbox", "label": "<?php echo tr('Predefinito note di debito'); ?>", "name": "predefined_addebito", "value": "$predefined_addebito$", "help": "<?php echo tr('Seleziona per rendere il sezionale predefinito per le note di debito'); ?>", "placeholder": "<?php echo tr('Sezionale predefinito per le note di debito'); ?>", "extra": "<?php echo ($record['modulo'] != 'Fatture di vendita' && $record['modulo'] != 'Fatture di acquisto') ? 'readonly' : ''; ?>" ]}
2018-09-27 15:50:03 +02:00
</div>
<div class="col-md-3">
{[ "type": "checkbox", "label": "<?php echo tr('Utilizzabile per autofatture'); ?>", "name": "autofatture", "value": "$autofatture$", "help": "<?php echo tr('Seleziona per rendere utilizzabile il sezionale per le autofatture'); ?>", "extra": "<?php echo ($record['modulo'] != 'Fatture di vendita' && $record['modulo'] != 'Fatture di acquisto') ? 'readonly' : ''; ?>" ]}
</div>
<div class="col-md-3">
{[ "type": "checkbox", "label": "<?php echo tr('Utilizzabile per fatture elettroniche'); ?>", "name": "for_fe", "value": "$for_fe$", "help": "<?php echo tr('Seleziona per rendere utilizzabile il sezionale per le fatture elettroniche'); ?>", "extra": "<?php echo ($record['modulo'] != 'Fatture di vendita' && $record['modulo'] != 'Fatture di acquisto') ? 'readonly' : ''; ?>" ]}
</div>
</div>
2018-05-11 15:56:08 +02:00
<!-- Istruzioni per il contenuto -->
2024-05-16 18:02:50 +02:00
<div class="card card-info">
<div class="card-header">
<h3 class="card-title"><?php echo tr('Istruzioni per il campo _FIELD_', [
'_FIELD_' => tr('Maschera'),
]); ?></h3>
</div>
2024-05-16 18:02:50 +02:00
<div class="card-body">
<p><?php echo tr('Le seguenti sequenze di testo vengono sostituite nel seguente modo'); ?>:</p>
<ul>
<?php
$list = [
'####' => tr('Numero progressivo del documento, con zeri non significativi per raggiungere il numero desiderato di caratteri'),
'YYYY' => tr('Anno corrente a 4 cifre'),
'yy' => tr('Anno corrente a 2 cifre'),
];
2018-09-27 15:50:03 +02:00
foreach ($list as $key => $value) {
echo '
<li>'.tr('_TEXT_: _FIELD_', [
2024-03-22 15:52:24 +01:00
'_TEXT_' => '<code>'.$key.'</code>',
'_FIELD_' => $value,
]).'</li>';
2018-09-27 15:50:03 +02:00
} ?>
</ul>
2018-05-11 15:56:08 +02:00
<p><?php echo tr("E' inoltre possibile aggiungere altri caratteri fissi (come lettere, trattini, eccetera) prima e/o dopo le sequenze di cui sopra"); ?>.</p>
</div>
</div>
2018-05-11 15:56:08 +02:00
2017-12-15 10:05:08 +01:00
</div>
</div>
2018-09-27 15:50:03 +02:00
<?php
}
?>
2017-12-15 10:05:08 +01:00
</form>
2018-02-17 14:32:40 +01:00
<?php
2018-05-11 15:56:08 +02:00
if ($tot > 0) {
echo "<div class='alert alert-danger' style='margin:0px;'>";
2018-05-11 15:56:08 +02:00
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'.", [
2018-05-11 15:56:08 +02:00
'_TOT_' => $tot,
2018-07-18 15:20:10 +02:00
'_MODULO_' => $record['modulo'],
2018-05-11 15:56:08 +02:00
]);
echo '</div>';
2018-09-04 12:34:54 +02:00
} elseif ($records['predefined']) {
echo "<div class='alert alert-danger' style='margin:0px;'>";
2018-05-11 15:56:08 +02:00
echo tr("Questo è il segmento predefinito per il modulo '_MODULO_'. Il comando elimina è stato disattivato.", [
2018-07-18 15:20:10 +02:00
'_MODULO_' => $record['modulo'],
2018-05-11 15:56:08 +02:00
]);
echo '</div>';
2018-09-04 12:34:54 +02:00
} elseif ($record['n_sezionali'] < 2) {
echo "<div class='alert alert-danger' style='margin:0px;'>";
2018-05-11 15:56:08 +02:00
echo tr("Questo è l'unico segmento per il modulo '_MODULO_'. Il comando elimina è stato disattivato.", [
2018-07-18 15:20:10 +02:00
'_MODULO_' => $record['modulo'],
2018-05-11 15:56:08 +02:00
]);
echo '</div>';
} else {
echo '
2018-05-11 15:56:08 +02:00
<a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>';
}
2018-05-11 15:56:08 +02:00
?>