Aggiunta marchi articoli

This commit is contained in:
Beppe 2024-09-30 14:54:27 +02:00
parent dc435e1037
commit a07ad860b3
8 changed files with 265 additions and 2 deletions

View File

@ -148,6 +148,7 @@ switch (post('op')) {
$articolo->servizio = post('servizio'); $articolo->servizio = post('servizio');
$articolo->volume = post('volume'); $articolo->volume = post('volume');
$articolo->peso_lordo = post('peso_lordo'); $articolo->peso_lordo = post('peso_lordo');
$articolo->id_marchio = post('id_marchio');
$articolo->um_secondaria = post('um_secondaria'); $articolo->um_secondaria = post('um_secondaria');
$articolo->fattore_um_secondaria = post('fattore_um_secondaria'); $articolo->fattore_um_secondaria = post('fattore_um_secondaria');

View File

@ -50,15 +50,20 @@ use Modules\Iva\Aliquota;
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-6"> <div class="col-md-4">
<?php echo (!empty($record['id_categoria'])) ? <?php echo (!empty($record['id_categoria'])) ?
Modules::link('Categorie articoli', $record['id_categoria'], null, null, 'class="pull-right"') : ''; ?> Modules::link('Categorie articoli', $record['id_categoria'], null, null, 'class="pull-right"') : ''; ?>
{[ "type": "select", "label": "<?php echo tr('Categoria'); ?>", "name": "categoria", "required": 0, "value": "$id_categoria$", "ajax-source": "categorie", "icon-after": "add|<?php echo Module::where('name', 'Categorie articoli')->first()->id; ?>" ]} {[ "type": "select", "label": "<?php echo tr('Categoria'); ?>", "name": "categoria", "required": 0, "value": "$id_categoria$", "ajax-source": "categorie", "icon-after": "add|<?php echo Module::where('name', 'Categorie articoli')->first()->id; ?>" ]}
</div> </div>
<div class="col-md-6"> <div class="col-md-4">
{[ "type": "select", "label": "<?php echo tr('Sottocategoria'); ?>", "name": "subcategoria", "value": "$id_sottocategoria$", "ajax-source": "sottocategorie", "select-options": <?php echo json_encode(['id_categoria' => $record['id_categoria']]); ?>, "icon-after": "add|<?php echo Module::where('name', 'Categorie articoli')->first()->id; ?>|id_original=<?php echo $record['id_categoria']; ?>" ]} {[ "type": "select", "label": "<?php echo tr('Sottocategoria'); ?>", "name": "subcategoria", "value": "$id_sottocategoria$", "ajax-source": "sottocategorie", "select-options": <?php echo json_encode(['id_categoria' => $record['id_categoria']]); ?>, "icon-after": "add|<?php echo Module::where('name', 'Categorie articoli')->first()->id; ?>|id_original=<?php echo $record['id_categoria']; ?>" ]}
</div> </div>
<div class="col-md-4">
<?php echo ( !empty($record['id_marchio']) ? Modules::link('Marchi', $record['id_marchio'], null, null, 'class="pull-right"') : '' ) ?>
{[ "type": "select", "label": "<?php echo tr('Marchio'); ?>", "name": "id_marchio", "value":"$id_marchio$", "values": "query=SELECT id, nome AS descrizione FROM mg_marchi ORDER BY descrizione ASC" ]}
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,53 @@
<?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 (post('op')) {
// Aggiorno informazioni di base impianto
case 'update':
$dbo->update('mg_marchi',[
'nome' => post('nome'),
],['id' => $id_record]);
flash()->info(tr('Informazioni salvate correttamente!'));
break;
// Aggiungo impianto
case 'add':
$dbo->insert('mg_marchi',[
'nome' => post('nome'),
]);
$id_record = $dbo->lastInsertedID();
flash()->info(tr('Aggiunto nuovo marchio!'));
break;
// Rimuovo impianto e scollego tutti i suoi componenti
case 'delete':
$dbo->query('DELETE FROM mg_marchi WHERE id='.prepare($id_record));
flash()->info(tr('Marchio eliminato!'));
break;
}

40
modules/marchi/add.php Normal file
View File

@ -0,0 +1,40 @@
<?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';
$id_anagrafica = filter('id_anagrafica');
?><form action="" method="post" id="add-form">
<input type="hidden" name="op" value="add">
<input type="hidden" name="backto" value="record-edit">
<div class="row">
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1, "validation": "nome" ]}
</div>
</div>
<!-- PULSANTI -->
<div class="row">
<div class="col-md-12 text-right">
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
</div>
</div>
</form>

78
modules/marchi/edit.php Normal file
View File

@ -0,0 +1,78 @@
<?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';
?><form action="" method="post" id="edit-form" enctype="multipart/form-data">
<input type="hidden" name="backto" value="record-edit">
<input type="hidden" name="op" value="update">
<input type="hidden" name="matricola" value="<?php echo $id_record; ?>">
<!-- DATI ANAGRAFICI -->
<div class="card card-primary">
<div class="card-header">
<h3 class="panel-title"><?php echo tr('Dati marchio'); ?></h3>
</div>
<div class="card-body">
<div class="row">
<div class="col-md-4">
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "value":"$nome$", "required": 1, "validation": "nome" ]}
</div>
</div>
</div>
</div>
</form>
<?php
$elementi = $dbo->fetchArray('SELECT `mg_articoli`.`id`, CONCAT(`mg_articoli`.`codice`, " - ", `mg_articoli_lang`.`title`) AS `descrizione` FROM `mg_articoli` INNER JOIN mg_articoli_lang ON (`mg_articoli_lang`.`id_record` = `mg_articoli`.`id` AND `mg_articoli_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') WHERE `mg_articoli`.`id_marchio` = '.prepare($id_record));
$class = '';
if (!empty($elementi)) {
echo '
<div class="card card-warning collapsable collapsed-card">
<div class="card-header with-border">
<h3 class="card-title"><i class="fa fa-warning"></i> '.tr('Articoli collegati: _NUM_', [
'_NUM_' => count($elementi),
]).'</h3>
<div class="card-tools pull-right">
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fa fa-plus"></i></button>
</div>
</div>
<div class="card-body">
<ul>';
foreach ($elementi as $elemento) {
echo '
<li>'.Modules::link('Articoli', $elemento['id'], $elemento['descrizione']).'</li>';
}
$class = 'disabled';
echo '
</ul>
</div>
</div>';
}
echo '
<a class="btn btn-danger ask '.$class.'" data-backto="record-list">
<i class="fa fa-trash"></i> '.tr('Elimina').'
</a>';

24
modules/marchi/init.php Normal file
View File

@ -0,0 +1,24 @@
<?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';
if (isset($id_record)) {
$record = $dbo->fetchOne('SELECT * FROM mg_marchi WHERE id='.prepare($id_record));
}

View File

@ -0,0 +1,40 @@
<?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';
$name = filter('name');
$value = filter('value');
switch ($name) {
case 'nome':
$disponibile = $dbo->table('mg_marchi')->where([
['nome', $value],
['id', '<>', $id_record],
])->count() == 0;
$message = $disponibile ? tr('Il nome è disponbile') : tr('Il nome è già utilizzato in un altro marchio');
$response = [
'result' => $disponibile,
'message' => $message,
];
break;
}

22
update/2_5_6.sql Normal file
View File

@ -0,0 +1,22 @@
-- Aggiunta Marchio articolo
ALTER TABLE `mg_articoli` ADD `id_marchio` INT NULL DEFAULT NULL;
CREATE TABLE `mg_marchi` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`nome` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)) ENGINE = InnoDB;
INSERT INTO `zz_modules` (`id`, `name`, `directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES (NULL, 'Marchi', 'marchi', 'SELECT |select| FROM `mg_marchi` WHERE 1=1 HAVING 2=2 ORDER BY `mg_marchi`.`nome`', '', 'fa fa-angle-right', '2.5.6', '2.5.6', '7', (SELECT `id` FROM `zz_modules` AS `t` WHERE `name` = 'Articoli'), '1', '1', '1', '1');
INSERT INTO `zz_modules_lang` (`id`, `id_lang`, `id_record`, `title`) VALUES (NULL, '1', (SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi'), 'Marchi');
INSERT INTO `zz_views` (`id_module`, `name`, `query`, `order`, `search`, `slow`, `format`, `html_format`, `search_inside`, `order_by`, `visible`, `summable`, `default`) VALUES
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi'), 'id', 'mg_marchi.id', '0', '0', '0', '0', '0', '', '', '0', '0', '0'),
((SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi'), 'Nome', 'mg_marchi.nome', '1', '0', '0', '0', '0', '', '', '1', '0', '0');
INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `title`) VALUES
(1, (SELECT `id` FROM `zz_views` WHERE `name` = 'id' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi')), 'id'),
(1, (SELECT `id` FROM `zz_views` WHERE `name` = 'Nome' AND `id_module` = (SELECT `id` FROM `zz_modules` WHERE `name` = 'Marchi')), 'Nome');