Compare commits

...

3 Commits

Author SHA1 Message Date
Pek5892 857a8694f9 Aggiunta gestione marca e modello su Impianti 2024-05-09 16:57:11 +02:00
FabioL 540fe7b4d2 Aggiunta gestione calcolo media su colonne 2024-05-09 16:51:13 +02:00
Pek5892 44a9355477 Fix minori 2024-05-09 10:29:53 +02:00
30 changed files with 533 additions and 179 deletions

View File

@ -167,5 +167,15 @@ switch (filter('op')) {
echo json_encode($results);
break;
case 'avg-results':
$ids = post('ids') ?: [];
$results = Util\Query::getAverages($structure, [
'id' => $ids,
]);
echo json_encode($results);
break;
}

View File

@ -52,6 +52,7 @@ $results = [
'recordsTotal' => 0,
'recordsFiltered' => 0,
'summable' => [],
'avg' => [],
'draw' => $draw_numer,
];
@ -76,6 +77,9 @@ if (!empty($query)) {
// SOMME
$results['summable'] = Query::getSums($structure, $search);
// MEDIE
$results['avg'] = Query::getAverages($structure, $search);
// Allineamento delle righe
$align = [];
$row = isset($rows[0]) ? $rows[0] : [];

View File

@ -423,11 +423,17 @@ function footerCallback(row, data, start, end, display) {
this.api().columns().every(function () {
if (json.summable[i] !== undefined) {
$(this.footer()).addClass("text-right")
$(this.footer()).css("text-align", "right")
.attr("id", "summable")
.html(json.summable[i]);
}
if (json.avg[i] !== undefined) {
$(this.footer()).css("text-align", "right")
.attr("id", "avg")
.html(json.avg[i]);
}
i++;
});
}
@ -532,7 +538,11 @@ function getTable(selector) {
getSelectedRowsFooter: function () {
let ids = this.getSelectedRows();
return $.ajax({
let summable_results = [];
let avg_results = [];
let results = [];
summable_results = $.ajax({
url: globals.rootdir + "/ajax.php",
type: "POST",
dataType: "json",
@ -543,10 +553,25 @@ function getTable(selector) {
ids: ids,
}
});
avg_results = $.ajax({
url: globals.rootdir + "/ajax.php",
type: "POST",
dataType: "json",
data: {
id_module: this.id_module,
id_plugin: this.id_plugin,
op: "avg-results",
ids: ids,
}
});
results = $.when(summable_results, avg_results);
return results;
},
/**
* Aggiornamento dei campi summable
* Aggiornamento dei campi summable e avg
*/
updateFooterForSelectedRows: function () {
let datatable = this.datatable;
@ -555,9 +580,12 @@ function getTable(selector) {
for (let [column, value] of Object.entries(response)) {
let index = parseInt(column) + 1;
let sel = datatable.column(index).footer();
$(sel).addClass("text-right")
$(sel).css("text-align", "right")
.attr("id", "summable")
.html(value);
$(sel).css("text-align", "right")
.attr("id", "avg")
.html(value);
}
});
},

View File

@ -259,11 +259,11 @@ if (empty($record) || !$has_access) {
<div class="clearfix"></div>
<br>';
// Eventuale header personalizzato
$header = $structure->filepath('header.php');
if ($header) {
include_once $header;
}
// Eventuale header personalizzato
$header = $structure->filepath('header.php');
if ($header) {
include_once $header;
}
}
// Contenuti del modulo

View File

@ -241,7 +241,7 @@ function translateTemplate()
// Informazioni estese sulle azioni dell'utente
$op = post('op');
if (!empty($op) && $op != 'summable-results') {
if (!empty($op) && $op != 'summable-results' && $op != 'avg-results') {
OperationLog::setInfo('id_module', $id_module);
OperationLog::setInfo('id_plugin', $id_plugin);
OperationLog::setInfo('id_record', $id_record);

View File

@ -23,17 +23,17 @@ use Modules\Impianti\Categoria;
$subcategorie = Categoria::where('parent', '=', $id_record)->get();
foreach ($subcategorie as $sub) {
$n_impianti = $dbo->fetchNum('SELECT * FROM `my_impianti` WHERE `id_sottocategoria`='.prepare($sub->id).' AND deleted_at IS NULL');
$impianti = $dbo->fetchArray('SELECT * FROM `my_impianti` WHERE `id_sottocategoria`='.prepare($sub->id));
echo '
<tr>
<td>'.$sub->getTranslation('title').'</td>
<td>'.$sub->colore.'</td>
<td>'.$sub->nota.'</td>
<td>
<a class="btn btn-warning btn-sm" title="Modifica riga" onclick="launch_modal(\''.tr('Modifica sottocategoria').'\', \''.base_path().'/add.php?id_module='.$id_module.'&id_record='.$sub->id.'&id_original='.$id_record.'\');"><i class="fa fa-edit"></i></a>
<a class="btn btn-sm btn-danger ask '.(($n_impianti > 0) ? 'disabled tip' : '').'" data-backto="record-edit" data-id="'.$sub->id.'" title="'.(($n_impianti > 0) ? 'Sottocategoria collegata a '.$n_impianti.' articoli' : '').'">
<i class="fa fa-trash"></i>
</a>
</td>
</tr>';
}
<tr>
<td>'.$sub->getTranslation('title').'</td>
<td>'.$sub->colore.'</td>
<td>'.$sub->nota.'</td>
<td>
<a class="btn btn-warning btn-sm" title="Modifica riga" onclick="launch_modal(\''.tr('Modifica sottocategoria').'\', \''.base_path().'/add.php?id_module='.$id_module.'&id_record='.$sub->id.'&id_original='.$id_record.'\');"><i class="fa fa-edit"></i></a>
<a class="btn btn-sm btn-danger ask '.((!empty($impianti)) ? 'disabled tip' : '').'" data-backto="record-edit" data-id="'.$sub->id.'" title="'.(($n_impianti > 0) ? 'Sottocategoria collegata a '.$n_impianti.' articoli' : '').'">
<i class="fa fa-trash"></i>
</a>
</td>
</tr>';
}

View File

@ -48,7 +48,7 @@ $id_anagrafica = $documento_finale->idanagrafica;
echo '
<div class="row">
<div class="col-md-12">
{[ "type": "select", "label": "'.tr('Ddt').'", "name": "id_documento", "values": "query=SELECT `dt_ddt`.`id`, CONCAT(IF(`numero_esterno` != \'\', `numero_esterno`, `numero`), \' del \', DATE_FORMAT(`data`, \'%d-%m-%Y\')) AS descrizione FROM `dt_ddt` INNER JOIN `dt_statiddt` ON `dt_ddt`.`idstatoddt` = `dt_statiddt`.`id` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` INNER JOIN `dt_righe_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt` WHERE `dt_statiddt_lang`.`title` IN(\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\') AND `dt_tipiddt`.`dir`='.prepare($dir == "entrata" ? "uscita" : "entrata").' AND (`dt_righe_ddt`.`qta` - `dt_righe_ddt`.`qta_evasa`) > 0 ORDER BY `data` DESC, `numero` DESC" ]}
{[ "type": "select", "label": "'.tr('Ddt').'", "name": "id_documento", "values": "query=SELECT `dt_ddt`.`id`, CONCAT(IF(`numero_esterno` != \'\', `numero_esterno`, `numero`), \' del \', DATE_FORMAT(`data`, \'%d-%m-%Y\')) AS descrizione FROM `dt_ddt` INNER JOIN `dt_statiddt` ON `dt_ddt`.`idstatoddt` = `dt_statiddt`.`id` LEFT JOIN `dt_statiddt_lang` ON (`dt_statiddt`.`id` = `dt_statiddt_lang`.`id_record` AND `dt_statiddt_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') INNER JOIN `dt_tipiddt` ON `dt_ddt`.`idtipoddt` = `dt_tipiddt`.`id` INNER JOIN `dt_righe_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt` WHERE `dt_statiddt_lang`.`title` IN(\'Evaso\', \'Parzialmente evaso\', \'Parzialmente fatturato\') AND `dt_tipiddt`.`dir`='.prepare($dir == 'entrata' ? 'uscita' : 'entrata').' AND (`dt_righe_ddt`.`qta` - `dt_righe_ddt`.`qta_evasa`) > 0 ORDER BY `data` DESC, `numero` DESC" ]}
</div>
</div>

View File

@ -799,7 +799,7 @@ class Fattura extends Document
$pagamento = $this->pagamento;
if ($pagamento->isRiBa()) {
$banca = Banca::find($this->id_banca_controparte) ?: Banca::where('id_anagrafica', $this->idanagrafica)->where('predefined', 1)->first();;
$banca = Banca::find($this->id_banca_controparte) ?: Banca::where('id_anagrafica', $this->idanagrafica)->where('predefined', 1)->first();
} else {
$banca = Banca::find($this->id_banca_azienda);
}

View File

@ -39,6 +39,8 @@ switch ($op) {
'matricola' => $matricola,
'id_categoria' => post('id_categoria') ?: null,
'id_sottocategoria' => post('id_sottocategoria') ?: null,
'id_marca' => post('id_marca') ?: null,
'id_modello' => post('id_modello') ?: null,
'descrizione' => post('descrizione'),
'idsede' => post('idsede'),
'data' => post('data') ?: null,

View File

@ -140,7 +140,7 @@ switch ($resource) {
*/
case 'sottocategorie_imp':
if (isset($superselect['id_categoria'])) {
$query = 'SELECT ``my_impianti_categorie`.`id`, `my_impianti_categorie_lang`.`title` AS descrizione FROM `my_impianti_categorie` LEFT JOIN `my_impianti_categorie_lang` ON (`my_impianti_categorie`.`id`=`my_impianti_categorie_lang`.`id_record` AND `my_impianti_categorie_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
$query = 'SELECT `my_impianti_categorie`.`id`, `my_impianti_categorie_lang`.`title` AS descrizione FROM `my_impianti_categorie` LEFT JOIN `my_impianti_categorie_lang` ON (`my_impianti_categorie`.`id`=`my_impianti_categorie_lang`.`id_record` AND `my_impianti_categorie_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
foreach ($elements as $element) {
$filter[] = '`my_impianti_categorie`.`id`='.prepare($element);
@ -153,4 +153,35 @@ switch ($resource) {
}
}
break;
case 'marca':
$query = 'SELECT `my_impianti_marche`.`id`, `my_impianti_marche_lang`.`title` AS descrizione FROM `my_impianti_marche` LEFT JOIN `my_impianti_marche_lang` ON (`my_impianti_marche`.`id`=`my_impianti_marche_lang`.`id_record` AND `my_impianti_marche_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
foreach ($elements as $element) {
$filter[] = '`my_impianti_marche`.`id`='.prepare($element);
}
$where[] = '`parent` = 0';
if (!empty($search)) {
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
}
break;
case 'modello':
if (isset($superselect['id_marca'])) {
$query = 'SELECT `my_impianti_marche`.`id`, `my_impianti_marche_lang`.`title` AS descrizione FROM `my_impianti_marche` LEFT JOIN `my_impianti_marche_lang` ON (`my_impianti_marche`.`id`=`my_impianti_marche_lang`.`id_record` AND `my_impianti_marche_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
foreach ($elements as $element) {
$filter[] = '`my_impianti_marche`.`id`='.prepare($element);
}
$where[] = '`parent`='.prepare($superselect['id_marca']);
if (!empty($search)) {
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
}
}
break;
}

View File

@ -79,10 +79,10 @@ if (!empty($record['immagine'])) {
</div>
<div class ="row">
<div class="col-md-4">
<!--{[ "type": "select", "label": "<?php echo tr('Marca'); ?>", "name": "id_marca", "value": "$id_marca$", "ajax-source": "marca", "icon-after": "add|<?php echo $id_modulo_marca_impianti; ?>" ]}-->
{[ "type": "select", "label": "<?php echo tr('Marca'); ?>", "name": "id_marca", "value": "$id_marca$", "ajax-source": "marca", "icon-after": "add|<?php echo $id_modulo_marca_impianti; ?>" ]}
</div>
<div class="col-md-4">
<!--{[ "type": "text", "label": "<?php echo tr('Modello'); ?>", "name": "modello", "value": "$modello$" ]}-->
{[ "type": "select", "label": "<?php echo tr('Modello'); ?>", "name": "id_modello", "value": "$id_modello$","ajax-source": "modello", "select-options": <?php echo json_encode(['id_marca' => $record['id_marca']]); ?>, "icon-after": "add|<?php echo $id_modulo_marca_impianti; ?>|id_original=<?php echo $record['id_marca']; ?>" ]}
</div>
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Proprietario'); ?>", "name": "proprietario", "value": "$proprietario$" ]}
@ -205,10 +205,14 @@ $(document).ready(function() {
.selectReset();
});
$("#id_categoria").change(function() {
updateSelectOption("id_categoria", $(this).val());
$("#id_categoria").on("change", function() {
updateSelectOption("id_categoria", $(this).val());
$("#id_sottocategoria").val(null).trigger("change");
});
$("#id_sottocategoria").val(null).trigger("change");
$("#id_marca").on("change", function() {
updateSelectOption("id_marca", $(this).val());
$("#id_modello").val(null).trigger("change");
});
});

View File

@ -0,0 +1,61 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
namespace Modules\Impianti;
use Common\SimpleModelTrait;
use Illuminate\Database\Eloquent\Model;
use Traits\HierarchyTrait;
use Traits\RecordTrait;
class Marca extends Model
{
use SimpleModelTrait;
use HierarchyTrait;
use RecordTrait;
protected $table = 'my_impianti_marche';
protected static $parent_identifier = 'parent';
protected static $translated_fields = [
'title',
];
public static function build()
{
$model = new static();
$model->save();
return $model;
}
public function impianti()
{
return $this->hasMany(Impianto::class, 'id_marca');
}
public function getModuleAttribute()
{
return 'Marche impianti';
}
public static function getTranslatedFields()
{
return self::$translated_fields;
}
}

View File

@ -19,53 +19,87 @@
include_once __DIR__.'/../../core.php';
switch (post('op')) {
use Models\Module;
use Modules\Impianti\Marca;
$id_modulo_marca_impianti = (new Module())->getByField('title', 'Marche Impianti', Models\Locale::getPredefined()->id);
switch (filter('op')) {
case 'update':
$id_marca = post('id_record');
$name = post('name');
$title = filter('title');
$id_original = filter('id_original') ?: 0;
// Verifico che il nome non esista già
$n = $dbo->fetchNum('SELECT `id` FROM `my_impianti_marche` WHERE (`title`='.prepare($name).' AND `id` !='.prepare($id_marca));
if (isset($title)) {
$marca->parent = $id_original;
$marca->setTranslation('title', $title);
$marca->save();
// Marca già esistente
if ($n > 0) {
flash()->error(tr('Marca già esistente!'));
flash()->info(tr('Salvataggio completato!'));
} else {
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
}
// Marca non esistente
else {
$dbo->query('UPDATE `my_impianti_marche` SET `title`='.prepare($name).' WHERE `id`='.prepare($id_marca));
flash()->info(tr('Informazioni salvate correttamente!'));
// Redirect alla marca se si sta modificando una sottomarca
if (!empty($id_original)) {
$database->commitTransaction();
redirect(base_path().'/editor.php?id_module='.$id_module.'&id_record='.($id_original ?: $id_record));
exit;
}
break;
case 'add':
$name = post('name');
$title = filter('title');
$id_original = filter('id_original') ?: null;
// Verifico che il nome non sia duplicato
$n = $dbo->fetchNum('SELECT `id` FROM `my_impianti_marche` WHERE `title`='.prepare($name));
if ($n > 0) {
flash()->error(tr('Nome già esistente!'));
$marca_new = Marca::where('id', '=', (new Marca())->getByField('title', $title));
if (!empty($id_original)) {
$marca_new = $marca_new->where('parent', '=', $id_original);
} else {
$query = 'INSERT INTO my_impianti_marche (`title`) VALUES ('.prepare($name).')';
$dbo->query($query);
$marca_new = $marca_new->whereNull('parent');
}
$marca_new = $marca_new->first();
if (!empty($marca_new)) {
flash()->error(tr('Questo nome è già stato utilizzato per un altra marca.'));
} else {
$marca = Marca::build();
$id_record = $dbo->lastInsertedID();
$marca->parent = $id_original ?: 0;
$marca->setTranslation('title', $title);
$marca->save();
if (isAjaxRequest()) {
echo json_encode(['id' => $id_record, 'text' => $name]);
}
flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [
'_TYPE_' => 'marca',
]));
}
flash()->info(tr('Aggiunta una nuova marca!'));
if (isAjaxRequest()) {
echo json_encode(['id' => $id_record, 'text' => $title]);
} else {
// Redirect alla marca se si sta aggiungendo un modello
$database->commitTransaction();
redirect(base_path().'/editor.php?id_module='.$id_module.'&id_record='.($id_original ?: $id_record));
exit;
}
break;
case 'delete':
$dbo->query('DELETE FROM `my_impianti_marche` WHERE `id`='.prepare($id_record));
$id = filter('id');
if (empty($id)) {
$id = $id_record;
}
flash()->info(tr('Marca eliminata!'));
if (empty($dbo->fetchArray('SELECT * FROM `my_impianti` WHERE (`id_marca`='.prepare($id).' OR `id_modello`='.prepare($id).' OR `id_modello` IN (SELECT `id` FROM `my_impianti_marche` WHERE `parent`='.prepare($id).'))'))) {
$dbo->query('DELETE FROM `my_impianti_marche` WHERE `id`='.prepare($id));
flash()->info(tr('_TYPE_ eliminata con successo!', [
'_TYPE_' => 'marca',
]));
} else {
flash()->error(tr('Esistono alcuni impianti collegati a questa marca. Impossibile eliminarla.'));
}
break;
}

View File

@ -19,20 +19,45 @@
include_once __DIR__.'/../../core.php';
?><form action="" method="post" id="add-form">
<input type="hidden" name="op" value="add">
$id_original = filter('id_original');
if (!empty($id_record)) {
include __DIR__.'/init.php';
}
?><form action="<?php
if (isset($id_original)) {
echo base_path().'/controller.php?id_module='.$id_module;
if (!empty($id_record)) {
echo '&id_record='.$id_record;
}
}
?>" method="post" id="add-form">
<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'; ?>">
<div class="row">
<div class="col-md-12">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "required": 1 ]}
</div>
</div>
<div class="col-md-8">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "title", "required": 1, "value": "$title$" ]}
</div>
</div>
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<?php
if (!empty($id_record)) {
?>
<button type="submit" class="btn btn-success"><i class="fa fa-save"></i> <?php echo tr('Salva'); ?></button>
<?php
} else {
?>
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
<?php
}
?>
</div>
</div>
</form>

View File

@ -1,34 +0,0 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
include_once __DIR__.'/../../../core.php';
switch ($resource) {
case 'marca':
$query = 'SELECT `id`, `title` AS `descrizione` FROM `my_impianti_marche` |where| ORDER BY `descrizione` ASC';
foreach ($elements as $element) {
$filter[] = '`id`='.prepare($element);
}
if (!empty($search)) {
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
}
break;
}

View File

@ -19,19 +19,92 @@
include_once __DIR__.'/../../core.php';
?>
<form action="" method="post" id="edit-form">
<input type="hidden" name="op" value="update">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="id_record" value="<?php echo $id_record; ?>">
use Models\Module;
<div class="row">
<div class="col-md-8">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "required": 1, "value": "$title$" ]}
?><form action="" method="post" id="edit-form">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="update">
<!-- DATI -->
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><?php echo tr('Dati'); ?></h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-8">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "title", "required": 1, "value": "$title$" ]}
</div>
</div>
</div>
</div>
</form>
<a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
</a>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><?php echo tr('Modelli'); ?></h3>
</div>
<div class="panel-body">
<div class="pull-left">
<a class="btn btn-primary" data-href="<?php echo base_path(); ?>/add.php?id_module=<?php echo $id_module; ?>&id_original=<?php echo $id_record; ?>" data-toggle="modal" data-title="<?php echo tr('Aggiungi riga'); ?>"><i class="fa fa-plus"></i> <?php echo tr('Modello'); ?></a><br>
</div>
<div class="clearfix"></div>
<hr>
<div class="row">
<div class="col-md-12">
<table class="table table-striped table-hover table-condensed">
<tr>
<th><?php echo tr('Nome'); ?></th>
<th width="20%"><?php echo tr('Opzioni'); ?></th>
</tr>
<?php include base_dir().'/modules/'.Module::find($id_module)->directory.'/row-list.php'; ?>
</table>
</div>
</div>
</div>
</div>
<?php
$elementi = $dbo->fetchArray('SELECT `my_impianti`.`id`, `my_impianti`.`matricola`, `my_impianti`.`nome` FROM `my_impianti` WHERE (`id_marca`='.prepare($id_record).' OR `id_modello`='.prepare($id_record).' OR `id_modello` IN (SELECT `id` FROM `my_impianti_marche` WHERE `parent`='.prepare($id_record).'))');
if (!empty($elementi)) {
echo '
<div class="box box-warning collapsable collapsed-box">
<div class="box-header with-border">
<h3 class="box-title"><i class="fa fa-warning"></i> '.tr('Impianti collegati: _NUM_', [
'_NUM_' => count($elementi),
]).'</h3>
<div class="box-tools pull-right">
<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>
</div>
</div>
<div class="box-body">
<ul>';
foreach ($elementi as $elemento) {
$descrizione = tr('Impianto _MATRICOLA_', [
'_MATRICOLA_' => $elemento['matricola'],
]);
$modulo = 'Impianti';
$id = $elemento['id'];
echo '
<li>'.Modules::link($modulo, $id, $descrizione).'</li>';
}
echo '
</ul>
</div>
</div>';
} else {
echo '
<a class="btn btn-danger ask" data-backto="record-list">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>';
}

View File

@ -18,7 +18,10 @@
*/
include_once __DIR__.'/../../core.php';
use Modules\Impianti\Marca;
if (!empty($id_record)) {
$record = $dbo->fetchOne('SELECT * FROM `my_impianti_marche` WHERE `id`='.prepare($id_record));
$record = $dbo->fetchOne('SELECT * FROM `my_impianti_marche` LEFT JOIN `my_impianti_marche_lang` ON (`my_impianti_marche`.`id`=`my_impianti_marche_lang`.`id_record` AND `my_impianti_marche_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `my_impianti_marche`.`id`='.prepare($id_record));
$marca = Marca::find($id_record);
}

View File

@ -0,0 +1,37 @@
<?php
/*
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
* Copyright (C) DevCode s.r.l.
*
* 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/>.
*/
include_once __DIR__.'/../../core.php';
use Modules\Impianti\Marca;
$modelli = Marca::where('parent', '=', $id_record)->get();
foreach ($modelli as $modello) {
$n_impianti = $dbo->fetchNum('SELECT * FROM `my_impianti` WHERE `id_modello`='.prepare($modello->id));
echo '
<tr>
<td>'.$modello->getTranslation('title').'</td>
<td>
<a class="btn btn-warning btn-sm" title="Modifica riga" onclick="launch_modal(\''.tr('Modifica modello').'\', \''.base_path().'/add.php?id_module='.$id_module.'&id_record='.$modello->id.'&id_original='.$id_record.'\');"><i class="fa fa-edit"></i></a>
<a class="btn btn-sm btn-danger ask '.(($n_impianti > 0) ? 'disabled tip' : '').'" data-backto="record-edit" data-id="'.$modello->id.'" title="'.(($n_impianti > 0) ? 'Modello collegata a '.$n_impianti.' impianti' : '').'">
<i class="fa fa-trash"></i>
</a>
</td>
</tr>';
}

View File

@ -93,7 +93,7 @@ switch (post('op')) {
$tags_presenti = [];
foreach ($tags as $tag) {
$tags_presenti[]= $tag;
$tags_presenti[] = $tag;
}
// Assegnazione dei tecnici all'intervento
@ -596,7 +596,7 @@ switch (post('op')) {
$riga->save();
if (!empty(post('idriga'))){
if (!empty(post('idriga'))) {
flash()->info(tr('Riga modificata!'));
} else {
flash()->info(tr('Riga aggiunta!'));

View File

@ -124,7 +124,7 @@ echo '
if ($record['idagente'] != 0) {
echo Modules::link('Anagrafiche', $record['idagente'], null, null, 'class="pull-right"');
}
echo '
echo '
<div class="col-md-3">
{[ "type": "select", "label": "'.tr('Agente').'", "name": "idagente", "ajax-source": "agenti", "select-options": {"idanagrafica": '.$record['idanagrafica'].'}, "value": "$idagente$" ]}
</div>
@ -186,7 +186,7 @@ if (!empty($intervento->idsede_destinazione)) {
$anagrafica_azienda = Anagrafica::find(setting('Azienda predefinita'));
$sede_azienda = $anagrafica_azienda->sedeLegale;
echo'
echo '
<script>
function modificaPosizione() {
openModal("'.tr('Modifica posizione').'", "'.$module->fileurl('modals/posizione.php').'?id_module='.$id_module.'&id_record='.$id_record.'");
@ -324,9 +324,9 @@ echo '
{[ "type": "select", "label": "'.tr('Tecnici assegnati').'", "multiple": "1", "name": "tecnici_assegnati[]", "ajax-source": "tecnici", "value": "'.implode(',', $tecnici_assegnati).'", "icon-after": "add|'.$id_modulo_anagrafiche.'|tipoanagrafica=Tecnico&readonly_tipo=1" ]}
</div>
';
// Conteggio numero articoli intervento per eventuale blocco della sede di partenza
$articoli = $intervento->articoli;
echo '
// Conteggio numero articoli intervento per eventuale blocco della sede di partenza
$articoli = $intervento->articoli;
echo '
<div class="col-md-4">
{[ "type": "select", "label": "'.tr('Partenza merce').'", "name": "idsede_partenza", "ajax-source": "sedi_azienda", "value": "$idsede_partenza$", "readonly": "'.(($record['flag_completato'] || !$articoli->isEmpty()) ? 1 : 0).'" ]}
</div>

View File

@ -20,15 +20,15 @@
include_once __DIR__.'/../../core.php';
use Carbon\Carbon;
use Models\Upload;
use Models\Module;
use Models\Upload;
use Modules\Anagrafiche\Anagrafica;
use Modules\Anagrafiche\Sede;
use Modules\Contratti\Contratto;
use Modules\Interventi\Intervento;
use Modules\Scadenzario\Scadenza;
use Modules\Preventivi\Preventivo;
use Modules\Ordini\Ordine;
use Modules\Preventivi\Preventivo;
use Modules\Scadenzario\Scadenza;
// Anagrafica
$anagrafica = $intervento->anagrafica;
@ -139,14 +139,14 @@ echo '
<p style="margin:3px 0;"><i class="fa '.(count($interventi_programmati) == 0 ? 'fa-clock-o text-success' : 'fa-clock-o text-warning').'"></i> '.(count($interventi_programmati) == 0 ? tr('Non sono presenti altre attività programmate') : 'Attività aperte:');
if (count($interventi_programmati) != 0) {
foreach ($interventi_programmati as $intervento_programmato) {
echo ' <a class="btn btn-default btn-xs" href="'.base_path().'/editor.php?id_module='.Modules::get('Interventi')['id'].'&id_record='.$intervento_programmato->id.'" target="_blank">'.$intervento_programmato->codice.' ('.( new Carbon($intervento_programmato->data_richiesta))->diffForHumans().')</a>';
echo ' <a class="btn btn-default btn-xs" href="'.base_path().'/editor.php?id_module='.Modules::get('Interventi')['id'].'&id_record='.$intervento_programmato->id.'" target="_blank">'.$intervento_programmato->codice.' ('.(new Carbon($intervento_programmato->data_richiesta))->diffForHumans().')</a>';
}
}
echo '
</p>';
// Contratto
if ($contratto) {
echo'
echo '
<p style="margin:3px 0;"><i class="fa fa-book text-info"></i>
'.Modules::link('Contratti', $contratto->id, tr('Contratto num. _NUM_ del _DATA_', ['_NUM_' => $contratto->numero, '_DATA_' => Translator::dateToLocale($contratto->data_bozza)]));
if ($ore_previste > 0) {
@ -157,7 +157,7 @@ if ($contratto) {
<div class="progress-bar progress-bar-'.$color.'" style="width:'.$perc_ore.'%"></div>
</div>';
}
echo'
echo '
</p>';
}
@ -167,16 +167,16 @@ if ($preventivo) {
<p style="margin:3px 0;"><i class="fa fa-book text-info"></i>
'.Modules::link('Preventivi', $preventivo->id, tr('Preventivo num. _NUM_ del _DATA_', ['_NUM_' => $preventivo->numero, '_DATA_' => Translator::dateToLocale($preventivo->data_bozza)])).'
</p>';
}
}
// Ordine
if($ordine) {
if ($ordine) {
echo '
<p style="margin:3px 0;"><i class="fa fa-book text-info"></i>
'.Modules::link('Ordini cliente', $ordine->id, tr('Ordine num. _NUM_ del _DATA_', ['_NUM_' => $ordine->numero, '_DATA_' => Translator::dateToLocale($ordine->data)])).'
</p>';
}
echo'
echo '
</div>
</div>
</div>';
@ -244,7 +244,7 @@ if (!empty($sede_cliente->gaddress) || (!empty($sede_cliente->lat) && !empty($se
</div>';
}
echo '
echo '
</div>
</div>
</div>

View File

@ -19,9 +19,9 @@
include_once __DIR__.'/../../core.php';
use Models\PrintTemplate;
use Models\Module;
use Models\OperationLog;
use Models\PrintTemplate;
use Modules\Anagrafiche\Anagrafica;
use Modules\Emails\Mail;
use Modules\Emails\Template;

View File

@ -53,7 +53,7 @@ switch (post('op')) {
flash()->info(tr('Nuovo tag aggiunto!'));
}
break;
case 'delete':

View File

@ -19,8 +19,6 @@
include_once __DIR__.'/../../core.php';
if (!empty($id_record)) {
$record = $dbo->fetchOne('SELECT * FROM `in_tags` WHERE `in_tags`.`id`='.prepare($id_record));
}

View File

@ -58,7 +58,8 @@ switch (filter('op')) {
'slow' => post('slow')[$c],
'format' => post('format')[$c],
'html_format' => post('html_format')[$c],
'summable' => post('sum')[$c],
'summable' => post('sum-avg')[$c] === 'sum' ? 1 : 0,
'avg' => post('sum-avg')[$c] === 'avg' ? 1 : 0,
'search_inside' => post('search_inside')[$c],
'order_by' => post('order_by')[$c],
'id_module' => $id_record,

View File

@ -96,7 +96,7 @@ foreach ($fields as $key => $field) {
</div>
<div class="col-md-4">
{[ "type": "checkbox", "label": "'.tr('Sommabile').'", "name": "sum['.$key.']", "value": "'.$field->summable.'", "help": "'.tr('Indica se il campo è da sommare').'" ]}
{[ "type": "select", "label": "'.tr('Calcolo a fine colonna').'", "name": "sum-avg['.$key.']", "values": "list=\"0\":\"'.tr('Nessuno').'\",\"sum\":\"'.tr('Somma').'\",\"avg\":\"'.tr('Media').'\"", "value": "'.( $field->summable ? 'sum' : ($field->avg ? 'avg' : '' )).'", "help": "'.tr('Scegli quale tipo di totale valori vuoi calcolare a fine tabella').'" ]}
</div>
</div>
@ -210,17 +210,21 @@ echo '
</div>
<div class="row">
<div class="col-md-4">
<div class="col-md-3">
{[ "type": "checkbox", "label": "'.tr('Ricercabile').'", "name": "search[-id-]" ]}
</div>
<div class="col-md-4">
<div class="col-md-3">
{[ "type": "checkbox", "label": "'.tr('Ricerca lenta').'", "name": "slow[-id-]" ]}
</div>
<div class="col-md-4">
<div class="col-md-3">
{[ "type": "checkbox", "label": "'.tr('Sommabile').'", "name": "sum[-id-]" ]}
</div>
<div class="col-md-3">
{[ "type": "checkbox", "label": "'.tr('Media').'", "name": "avg[-id-]" ]}
</div>
</div>
<div class="row">

View File

@ -1667,7 +1667,7 @@ class FatturaElettronica
foreach ($co_scadenziario as $scadenza) {
$co_pagamenti = Pagamento::find($scadenza['id_pagamento']);
$banca = ($co_pagamenti->isRiBa()) ? Banca::find($scadenza['id_banca_controparte']) ?: Banca::where('id_anagrafica', $scadenza['idanagrafica'])->where('predefined', 1)->first() : Banca::find($scadenza['id_banca_azienda']);
$pagamento = [
'ModalitaPagamento' => $co_pagamenti['codice_modalita_pagamento_fe'],
'DataScadenzaPagamento' => $scadenza['scadenza'],

View File

@ -553,48 +553,48 @@ class Gestore
protected static function cleanString($string)
{
// sostituisci tutti i caratteri accentati con la versione non accentata
$replace = array(
'ъ'=>'-', 'Ь'=>'-', 'Ъ'=>'-', 'ь'=>'-',
'Ă'=>'A', 'Ą'=>'A', 'À'=>'A', 'Ã'=>'A', 'Á'=>'A', 'Æ'=>'A', 'Â'=>'A', 'Å'=>'A', 'Ä'=>'Ae',
'Þ'=>'B',
'Ć'=>'C', 'ץ'=>'C', 'Ç'=>'C',
'È'=>'E', 'Ę'=>'E', 'É'=>'E', 'Ë'=>'E', 'Ê'=>'E',
'Ğ'=>'G',
'İ'=>'I', 'Ï'=>'I', 'Î'=>'I', 'Í'=>'I', 'Ì'=>'I',
'Ł'=>'L',
'Ñ'=>'N', 'Ń'=>'N',
'Ø'=>'O', 'Ó'=>'O', 'Ò'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'Oe',
'Ş'=>'S', 'Ś'=>'S', 'Ș'=>'S', 'Š'=>'S',
'Ț'=>'T',
'Ù'=>'U', 'Û'=>'U', 'Ú'=>'U', 'Ü'=>'Ue',
'Ý'=>'Y',
'Ź'=>'Z', 'Ž'=>'Z', 'Ż'=>'Z',
'â'=>'a', 'ǎ'=>'a', 'ą'=>'a', 'á'=>'a', 'ă'=>'a', 'ã'=>'a', 'Ǎ'=>'a', 'а'=>'a', 'А'=>'a', 'å'=>'a', 'à'=>'a', 'א'=>'a', 'Ǻ'=>'a', 'Ā'=>'a', 'ǻ'=>'a', 'ā'=>'a', 'ä'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I',
'Ł' => 'L',
'Ñ' => 'N', 'Ń' => 'N',
'Ø' => 'O', 'Ó' => 'O', 'Ò' => 'O', 'Ô' => 'O', 'Õ' => 'O', 'Ö' => 'Oe',
'Ş' => 'S', 'Ś' => 'S', 'Ș' => 'S', 'Š' => 'S',
'Ț' => 'T',
'Ù' => 'U', 'Û' => 'U', 'Ú' => 'U', 'Ü' => 'Ue',
'Ý' => 'Y',
'Ź' => 'Z', 'Ž' => 'Z', 'Ż' => 'Z',
'â' => 'a', 'ǎ' => 'a', 'ą' => 'a', 'á' => 'a', 'ă' => 'a', 'ã' => 'a', 'Ǎ' => 'a', 'а' => 'a', 'А' => 'a', 'å' => 'a', 'à' => 'a', 'א' => 'a', 'Ǻ' => 'a', 'Ā' => 'a', 'ǻ' => 'a', 'ā' => 'a', 'ä' => 'ae', 'æ' => 'ae', 'Ǽ' => 'ae', 'ǽ' => 'ae',
'б' => 'b', 'ב' => 'b', 'Б' => 'b', 'þ' => 'b',
'ĉ' => 'c', 'Ĉ' => 'c', 'Ċ' => 'c', 'ć' => 'c', 'ç' => 'c', 'ц' => 'c', 'צ' => 'c', 'ċ' => 'c', 'Ц' => 'c', 'Č' => 'c', 'č' => 'c', 'Ч' => 'ch', 'ч' => 'ch',
'ד' => 'd', 'ď' => 'd', 'Đ' => 'd', 'Ď' => 'd', 'đ' => 'd', 'д' => 'd', 'Д' => 'D', 'ð' => 'd',
'є' => 'e', 'ע' => 'e', 'е' => 'e', 'Е' => 'e', 'Ə' => 'e', 'ę' => 'e', 'ĕ' => 'e', 'ē' => 'e', 'Ē' => 'e', 'Ė' => 'e', 'ė' => 'e', 'ě' => 'e', 'Ě' => 'e', 'Є' => 'e', 'Ĕ' => 'e', 'ê' => 'e', 'ə' => 'e', 'è' => 'e', 'ë' => 'e', 'é' => 'e',
'ф' => 'f', 'ƒ' => 'f', 'Ф' => 'f',
'ġ' => 'g', 'Ģ' => 'g', 'Ġ' => 'g', 'Ĝ' => 'g', 'Г' => 'g', 'г' => 'g', 'ĝ' => 'g', 'ğ' => 'g', 'ג' => 'g', 'Ґ' => 'g', 'ґ' => 'g', 'ģ' => 'g',
'ח' => 'h', 'ħ' => 'h', 'Х' => 'h', 'Ħ' => 'h', 'Ĥ' => 'h', 'ĥ' => 'h', 'х' => 'h', 'ה' => 'h',
'î' => 'i', 'ï' => 'i', 'í' => 'i', 'ì' => 'i', 'į' => 'i', 'ĭ' => 'i', 'ı' => 'i', 'Ĭ' => 'i', 'И' => 'i', 'ĩ' => 'i', 'ǐ' => 'i', 'Ĩ' => 'i', 'Ǐ' => 'i', 'и' => 'i', 'Į' => 'i', 'י' => 'i', 'Ї' => 'i', 'Ī' => 'i', 'І' => 'i', 'ї' => 'i', 'і' => 'i', 'ī' => 'i', 'ij' => 'ij', 'IJ' => 'ij',
'й' => 'j', 'Й' => 'j', 'Ĵ' => 'j', 'ĵ' => 'j', 'я' => 'ja', 'Я' => 'ja', 'Э' => 'je', 'э' => 'je', 'ё' => 'jo', 'Ё' => 'jo', 'ю' => 'ju', 'Ю' => 'ju',
'ĸ' => 'k', 'כ' => 'k', 'Ķ' => 'k', 'К' => 'k', 'к' => 'k', 'ķ' => 'k', 'ך' => 'k',
'Ŀ' => 'l', 'ŀ' => 'l', 'Л' => 'l', 'ł' => 'l', 'ļ' => 'l', 'ĺ' => 'l', 'Ĺ' => 'l', 'Ļ' => 'l', 'л' => 'l', 'Ľ' => 'l', 'ľ' => 'l', 'ל' => 'l',
'מ' => 'm', 'М' => 'm', 'ם' => 'm', 'м' => 'm',
'ñ' => 'n', 'н' => 'n', 'Ņ' => 'n', 'ן' => 'n', 'ŋ' => 'n', 'נ' => 'n', 'Н' => 'n', 'ń' => 'n', 'Ŋ' => 'n', 'ņ' => 'n', 'ʼn' => 'n', 'Ň' => 'n', 'ň' => 'n',
'о' => 'o', 'О' => 'o', 'ő' => 'o', 'õ' => 'o', 'ô' => 'o', 'Ő' => 'o', 'ŏ' => 'o', 'Ŏ' => 'o', 'Ō' => 'o', 'ō' => 'o', 'ø' => 'o', 'ǿ' => 'o', 'ǒ' => 'o', 'ò' => 'o', 'Ǿ' => 'o', 'Ǒ' => 'o', 'ơ' => 'o', 'ó' => 'o', 'Ơ' => 'o', 'œ' => 'oe', 'Œ' => 'oe', 'ö' => 'oe',
'פ' => 'p', 'ף' => 'p', 'п' => 'p', 'П' => 'p',
'ק' => 'q',
'ŕ' => 'r', 'ř' => 'r', 'Ř' => 'r', 'ŗ' => 'r', 'Ŗ' => 'r', 'ר' => 'r', 'Ŕ' => 'r', 'Р' => 'r', 'р' => 'r',
'ș' => 's', 'с' => 's', 'Ŝ' => 's', 'š' => 's', 'ś' => 's', 'ס' => 's', 'ş' => 's', 'С' => 's', 'ŝ' => 's', 'Щ' => 'sch', 'щ' => 'sch', 'ш' => 'sh', 'Ш' => 'sh', 'ß' => 'ss',
'т' => 't', 'ט' => 't', 'ŧ' => 't', 'ת' => 't', 'ť' => 't', 'ţ' => 't', 'Ţ' => 't', 'Т' => 't', 'ț' => 't', 'Ŧ' => 't', 'Ť' => 't', '™' => 'tm',
'ū' => 'u', 'у' => 'u', 'Ũ' => 'u', 'ũ' => 'u', 'Ư' => 'u', 'ư' => 'u', 'Ū' => 'u', 'Ǔ' => 'u', 'ų' => 'u', 'Ų' => 'u', 'ŭ' => 'u', 'Ŭ' => 'u', 'Ů' => 'u', 'ů' => 'u', 'ű' => 'u', 'Ű' => 'u', 'Ǖ' => 'u', 'ǔ' => 'u', 'Ǜ' => 'u', 'ù' => 'u', 'ú' => 'u', 'û' => 'u', 'У' => 'u', 'ǚ' => 'u', 'ǜ' => 'u', 'Ǚ' => 'u', 'Ǘ' => 'u', 'ǖ' => 'u', 'ǘ' => 'u', 'ü' => 'ue',
'в' => 'v', 'ו' => 'v', 'В' => 'v',
'ש' => 'w', 'ŵ' => 'w', 'Ŵ' => 'w',
'ы' => 'y', 'ŷ' => 'y', 'ý' => 'y', 'ÿ' => 'y', 'Ÿ' => 'y', 'Ŷ' => 'y',
'Ы' => 'y', 'ž' => 'z', 'З' => 'z', 'з' => 'z', 'ź' => 'z', 'ז' => 'z', 'ż' => 'z', 'ſ' => 'z', 'Ж' => 'zh', 'ж' => 'zh',
];
$unaccentedString = strtr($string, $replace);

View File

@ -350,6 +350,46 @@ class Query
return $results;
}
/**
* Restituisce la media dei valori dalla query prevista dalla struttura.
*
* @param array $search
*
* @throws \Exception
*
* @return array
*/
public static function getAverages($structure, $search = [])
{
$total = self::readQuery($structure);
// Calcolo di eventuali somme
if (empty($total['avg'])) {
return [];
}
$result_query = self::getQuery($structure, $search);
// Filtri derivanti dai permessi (eventuali)
if (empty($structure->originalModule)) {
$result_query = \Modules::replaceAdditionals($structure->id, $result_query);
}
$query = self::str_replace_once('SELECT', 'SELECT '.implode(', ', $total['avg']).' FROM(SELECT ', $result_query).') AS `z`';
$avgs = database()->fetchOne($query);
$results = [];
if (!empty($avgs)) {
foreach ($avgs as $key => $avg) {
if (string_contains($key, 'avg_')) {
$results[str_replace('avg_', '', $key)] = \Translator::numberToLocale($avg);
}
}
}
return $results;
}
/**
* Sostituisce la prima occorenza di una determinata stringa.
*
@ -383,6 +423,7 @@ class Query
{
$fields = [];
$summable = [];
$avg = [];
$search_inside = [];
$search = [];
$format = [];
@ -423,6 +464,10 @@ class Query
if ($view['summable']) {
$summable[] = 'SUM(`'.trim($view['name']."`) AS 'sum_".(count($fields) - 1)."'");
}
if ($view['avg']) {
$avg[] = 'AVG(`'.trim($view['name']."`) AS 'avg_".(count($fields) - 1)."'");
}
}
}
@ -440,6 +485,7 @@ class Query
'format' => $format,
'html_format' => $html_format,
'summable' => $summable,
'avg' => $avg,
];
}

View File

@ -74,4 +74,31 @@ UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_module
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`) VALUES
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Interventi'), 'Tags', 'tags.nomi', 10);
INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `title`) VALUES
(1, (SELECT MAX(`id`) FROM `zz_views` ), 'Tags');
(1, (SELECT MAX(`id`) FROM `zz_views` ), 'Tags');
-- Aggiunta flag per calcolo media su viste
ALTER TABLE `zz_views` ADD `avg` BOOLEAN NOT NULL DEFAULT FALSE AFTER `summable`;
-- Aggiunta tabella my_impianti_marche_lang
CREATE TABLE IF NOT EXISTS `my_impianti_marche_lang` (
`id` int NOT NULL,
`id_lang` int NOT NULL,
`id_record` int NOT NULL,
`title` VARCHAR(255) NOT NULL
);
ALTER TABLE `my_impianti_marche_lang`
ADD PRIMARY KEY (`id`);
ALTER TABLE `my_impianti_marche_lang`
MODIFY `id` int NOT NULL AUTO_INCREMENT;
ALTER TABLE `my_impianti_marche_lang` ADD CONSTRAINT `my_impianti_marche_lang_ibfk_1` FOREIGN KEY (`id_record`) REFERENCES `my_impianti_marche`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `my_impianti_marche_lang` ADD CONSTRAINT `my_impianti_marche_lang_ibfk_2` FOREIGN KEY (`id_lang`) REFERENCES `zz_langs`(`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ALTER TABLE `my_impianti_marche` DROP `nota`;
UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `my_impianti_marche` LEFT JOIN `my_impianti_marche_lang` ON (my_impianti_marche.id = my_impianti_marche_lang.id_record AND my_impianti_marche_lang.|lang|) WHERE 1=1 AND parent = 0 HAVING 2=2' WHERE `zz_modules`.`name` = 'Marche impianti';
UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` SET `zz_views`.`query` = 'my_impianti_marche.id' WHERE `zz_modules`.`name` = 'Marche impianti' AND `zz_views`.`name` = 'id';
UPDATE `zz_views` INNER JOIN `zz_modules` ON `zz_views`.`id_module` = `zz_modules`.`id` SET `zz_views`.`query` = 'my_impianti_marche_lang.title' WHERE `zz_modules`.`name` = 'Marche impianti' AND `zz_views`.`name` = 'Nome';