mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-24 07:17:55 +01:00
Gestione categorie impianti
This commit is contained in:
parent
83849196da
commit
afd3cfda4e
@ -79,7 +79,7 @@ $res = $dbo->fetchNum('SELECT * FROM `mg_articoli` WHERE `id_categoria`='.prepar
|
||||
if ($res) {
|
||||
echo '
|
||||
<div class="alert alert-danger">
|
||||
<p>'.tr('Ci sono '.count($res).' articoli collegati questa categoria. Non è possibile eliminarla.').'</p>
|
||||
<p>'.tr('Ci sono '.count($res).' articoli collegati a questa categoria. Non è possibile eliminarla.').'</p>
|
||||
</div>';
|
||||
} else {
|
||||
echo '
|
61
modules/categorie_impianti/actions.php
Normal file
61
modules/categorie_impianti/actions.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
switch (filter('op')) {
|
||||
case 'update':
|
||||
$nome = filter('nome');
|
||||
$nota = filter('nota');
|
||||
$colore = filter('colore');
|
||||
|
||||
if (isset($nome) && isset($nota) && isset($colore)) {
|
||||
$dbo->query('UPDATE `my_impianti_categorie` SET `nome`='.prepare($nome).', `nota`='.prepare($nota).', `colore`='.prepare($colore).' WHERE `id`='.prepare($id_record));
|
||||
flash()->info(tr('Salvataggio completato!'));
|
||||
} else {
|
||||
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
$nome = filter('nome');
|
||||
$nota = filter('nota');
|
||||
$colore = filter('colore');
|
||||
|
||||
if (isset($nome)) {
|
||||
$dbo->query('INSERT INTO `my_impianti_categorie` (`nome`, `colore`, `nota`) VALUES ('.prepare($nome).', '.prepare($colore).', '.prepare($nota).')');
|
||||
|
||||
$id_record = $dbo->lastInsertedID();
|
||||
|
||||
if (isAjaxRequest()) {
|
||||
echo json_encode(['id' => $id_record, 'text' => $nome]);
|
||||
}
|
||||
|
||||
flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [
|
||||
'_TYPE_' => 'categoria',
|
||||
]));
|
||||
} else {
|
||||
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio!'));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$id = filter('id');
|
||||
if (empty($id)) {
|
||||
$id = $id_record;
|
||||
}
|
||||
|
||||
if ($dbo->fetchNum('SELECT * FROM `my_impianti` WHERE `id_categoria`='.prepare($id)) == 0) {
|
||||
$dbo->query('DELETE FROM `my_impianti_categorie` WHERE `id`='.prepare($id));
|
||||
|
||||
flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [
|
||||
'_TYPE_' => 'categoria',
|
||||
]));
|
||||
} else {
|
||||
flash()->error(tr('Esistono ancora alcuni articoli sotto questa categoria!'));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
73
modules/categorie_impianti/add.php
Normal file
73
modules/categorie_impianti/add.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$id_original = filter('id_original');
|
||||
|
||||
if (isset($id_record)) {
|
||||
include __DIR__.'/init.php';
|
||||
}
|
||||
|
||||
?><form action="editor.php?id_module=$id_module$<?php
|
||||
if (isset($id_record)) {
|
||||
echo '&id_record='.$id_record;
|
||||
}
|
||||
?>" method="post" id="add-form">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
|
||||
<?php
|
||||
if (!isset($id_original)) {
|
||||
?>
|
||||
<input type="hidden" name="op" value="add">
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<input type="hidden" name="op" value="row">
|
||||
<input type="hidden" name="id_original" value="<?php echo $id_original; ?>">
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1, "value": "$nome$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Colore'); ?>", "name": "colore", "id": "colore_", "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength=\"7\"", "icon-after": "<div class=\"img-circle square\"></div>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "<?php echo tr('Nota'); ?>", "name": "nota", "value": "$nota$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<?php
|
||||
if (isset($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>
|
||||
|
||||
<script>
|
||||
$(document).ready( function(){
|
||||
$('.colorpicker').colorpicker().on('changeColor', function(){
|
||||
$('#colore_').parent().find('.square').css('background', $('#colore_').val());
|
||||
});
|
||||
|
||||
$('#colore_').parent().find('.square').css('background', $('#colore_').val());
|
||||
});
|
||||
</script>
|
60
modules/categorie_impianti/edit.php
Normal file
60
modules/categorie_impianti/edit.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
?><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": "nome", "required": 1, "value": "$nome$" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Colore'); ?>", "name": "colore", "class": "colorpicker text-center", "value": "$colore$", "extra": "maxlength='7'", "icon-after": "<div class='img-circle square'></div>" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "<?php echo tr('Nota'); ?>", "name": "nota", "value": "$nota$" ]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$(document).ready( function(){
|
||||
$('.colorpicker').colorpicker().on('changeColor', function(){
|
||||
$('#colore').parent().find('.square').css( 'background', $('#colore').val() );
|
||||
});
|
||||
|
||||
$('#colore').parent().find('.square').css( 'background', $('#colore').val() );
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
$res = $dbo->fetchNum('SELECT * FROM `my_impianti` WHERE `id_categoria`='.prepare($id_record));
|
||||
|
||||
if ($res) {
|
||||
echo '
|
||||
<div class="alert alert-danger">
|
||||
<p>'.tr('Ci sono '.count($res).' impianti collegati a questa categoria. Non è possibile eliminarla.').'</p>
|
||||
</div>';
|
||||
} else {
|
||||
echo '
|
||||
<a class="btn btn-danger ask" data-backto="record-list">
|
||||
<i class="fa fa-trash"></i> '.tr('Elimina').'
|
||||
</a>';
|
||||
}
|
7
modules/categorie_impianti/init.php
Normal file
7
modules/categorie_impianti/init.php
Normal file
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
if (isset($id_record)) {
|
||||
$record = $dbo->fetchOne('SELECT * FROM `my_impianti_categorie` WHERE id='.prepare($id_record));
|
||||
}
|
@ -16,6 +16,7 @@ switch ($op) {
|
||||
'idanagrafica' => post('idanagrafica'),
|
||||
'nome' => post('nome'),
|
||||
'matricola' => $matricola,
|
||||
'id_categoria' => post('id_categoria'),
|
||||
'descrizione' => post('descrizione'),
|
||||
'idsede' => post('idsede'),
|
||||
'data' => post('data'),
|
||||
|
@ -42,12 +42,15 @@ if (!empty($record['immagine'])) {
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<div class="col-md-8">
|
||||
<?php
|
||||
echo Modules::link('Anagrafiche', $record['idanagrafica'], null, null, 'class="pull-right"');
|
||||
?>
|
||||
{[ "type": "select", "label": "<?php echo tr('Cliente'); ?>", "name": "idanagrafica", "required": 1, "values": "query=SELECT an_anagrafiche.idanagrafica AS id, ragione_sociale AS descrizione FROM an_anagrafiche INNER JOIN (an_tipianagrafiche_anagrafiche INNER JOIN an_tipianagrafiche ON an_tipianagrafiche_anagrafiche.idtipoanagrafica=an_tipianagrafiche.idtipoanagrafica) ON an_anagrafiche.idanagrafica=an_tipianagrafiche_anagrafiche.idanagrafica WHERE descrizione='Cliente' AND deleted_at IS NULL ORDER BY ragione_sociale", "value": "$idanagrafica$", "extra": "", "ajax-source": "clienti" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "<?php echo tr('Categoria'); ?>", "name": "id_categoria", "required": 0, "class": "", "value": "$id_categoria$", "values": "query=SELECT id, nome AS descrizione FROM my_impianti_categorie" ]}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -554,4 +554,26 @@ INSERT INTO `zz_plugins` (`id`, `name`, `title`, `idmodule_from`, `idmodule_to`,
|
||||
UPDATE `zz_modules` SET `options` = 'SELECT |select| FROM `co_preventivi` WHERE 1=1 AND default_revision=1 HAVING 2=2 AND ((\'|period_start|\' >= `data_bozza` AND \'|period_start|\' <= `data_conclusione`) OR (\'|period_end|\' >= `data_bozza` AND \'|period_end|\' <= `data_conclusione`) OR (`data_bozza` >= \'|period_start|\' AND `data_bozza` <= \'|period_end|\') OR (`data_conclusione` >= \'|period_start|\' AND `data_conclusione` <= \'|period_end|\') OR (`data_bozza` >= \'|period_start|\' AND `data_conclusione` = \'0000-00-00\')) ORDER BY `id` DESC' WHERE `zz_modules`.`name` = 'Preventivi';
|
||||
|
||||
-- Chiave secondaria per le righe del preventivo
|
||||
ALTER TABLE `co_righe_preventivi` ADD FOREIGN KEY (`idpreventivo`) REFERENCES `co_preventivi`(`id`) ON DELETE CASCADE;
|
||||
ALTER TABLE `co_righe_preventivi` ADD FOREIGN KEY (`idpreventivo`) REFERENCES `co_preventivi`(`id`) ON DELETE CASCADE;
|
||||
|
||||
-- Categoria impianto
|
||||
ALTER TABLE `my_impianti` ADD `id_categoria` INT NOT NULL AFTER `idanagrafica`;
|
||||
|
||||
-- Tabella categorie
|
||||
CREATE TABLE IF NOT EXISTS `my_impianti_categorie` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`nome` varchar(255) NOT NULL,
|
||||
`colore` varchar(255) NOT NULL,
|
||||
`nota` varchar(1000) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
-- Rinominato Categorie in Categorie articoli
|
||||
UPDATE `zz_modules` SET `name` = 'Categorie articoli', `title` = 'Categorie articoli', `directory` = 'categorie_articoli' WHERE `zz_modules`.`id` = 47;
|
||||
|
||||
-- Modulo Categorie impianti
|
||||
INSERT INTO `zz_modules` (`id`, `name`, `title`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`) VALUES (NULL, 'Categorie impianti', 'Categorie impianti', 'categorie_impianti', 'SELECT |select| FROM `my_impianti_categorie` WHERE 1=1 HAVING 2=2', '', 'fa fa-angle-right', '2.4.2', '2.4.2', '1', '40', '1', '1');
|
||||
|
||||
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `visible`, `default`) VALUES
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie impianti'), 'id', 'id', 1, 1, 0, 0, 1),
|
||||
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Categorie impianti'), 'Nome', 'nome', 2, 1, 0, 1, 1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user