mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-24 23:37:51 +01:00
Aggiunti i campi marca e modello in Impianti
This commit is contained in:
parent
6b7fa73bc3
commit
f9c5b4aa35
@ -37,6 +37,8 @@ switch ($op) {
|
||||
'idanagrafica' => post('idanagrafica'),
|
||||
'nome' => post('nome'),
|
||||
'matricola' => $matricola,
|
||||
'id_marca' => post('id_marca'),
|
||||
'modello' => post('modello'),
|
||||
'id_categoria' => post('id_categoria') ?: null,
|
||||
'id_sottocategoria' => post('id_sottocategoria') ?: null,
|
||||
'descrizione' => post('descrizione'),
|
||||
|
@ -21,6 +21,7 @@ include_once __DIR__.'/../../core.php';
|
||||
use Models\Module;
|
||||
|
||||
$id_modulo_categorie_impianti = (new Module())->getByField('name', 'Categorie Impianti', Models\Locale::getPredefined()->id);
|
||||
$id_modulo_marca_impianti = (new Module())->getByField('name', 'Marche Impianti', Models\Locale::getPredefined()->id);
|
||||
|
||||
$img = null;
|
||||
if (!empty($record['immagine'])) {
|
||||
@ -50,25 +51,43 @@ if (!empty($record['immagine'])) {
|
||||
|
||||
<div class="col-md-9">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Matricola'); ?>", "name": "matricola", "required": 1, "class": "text-center", "maxlength": 25, "value": "$matricola$", "validation": "matricola" ]}
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "nome", "required": 1, "value": "$nome$" ]}
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
{[ "type": "date", "label": "<?php echo tr('Data installazione'); ?>", "name": "data", "value": "$data$" ]}
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<?php
|
||||
echo Modules::link('Anagrafiche', $record['idanagrafica'], null, null, 'class="pull-right"');
|
||||
?>
|
||||
<div class="col-md-4">
|
||||
<?php echo Modules::link('Anagrafiche', $record['idanagrafica'], null, null, 'class="pull-right"');?>
|
||||
{[ "type": "select", "label": "<?php echo tr('Cliente'); ?>", "name": "idanagrafica", "required": 1, "value": "$idanagrafica$", "extra": "", "ajax-source": "clienti" ]}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<?php
|
||||
echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "value": "$idsede$", "required": "1", "ajax-source": "sedi", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica']]).', "placeholder": "'.tr('Sede legale').'" ]}
|
||||
</div>';
|
||||
?>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "<?php echo tr('Tecnico predefinito'); ?>", "name": "idtecnico", "ajax-source": "tecnici", "value": "$idtecnico$" ]}
|
||||
</div>
|
||||
</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; ?>" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Modello'); ?>", "name": "modello", "value": "$modello$" ]}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Proprietario'); ?>", "name": "proprietario", "value": "$proprietario$" ]}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<?php echo (!empty($record['id_categoria'])) ?
|
||||
@ -83,22 +102,6 @@ if (!empty($record['immagine'])) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
{[ "type": "date", "label": "<?php echo tr('Data installazione'); ?>", "name": "data", "value": "$data$" ]}
|
||||
</div>
|
||||
|
||||
<?php
|
||||
echo '
|
||||
<div class="col-md-4">
|
||||
{[ "type": "select", "label": "'.tr('Sede').'", "name": "idsede", "value": "$idsede$", "required": "1", "ajax-source": "sedi", "select-options": '.json_encode(['idanagrafica' => $record['idanagrafica']]).', "placeholder": "'.tr('Sede legale').'" ]}
|
||||
</div>';
|
||||
?>
|
||||
<div class="col-md-4">
|
||||
{[ "type": "text", "label": "<?php echo tr('Proprietario'); ?>", "name": "proprietario", "value": "$proprietario$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "<?php echo tr('Descrizione'); ?>", "name": "descrizione", "value": "$descrizione$" ]}
|
||||
|
71
modules/impianti_marche/actions.php
Normal file
71
modules/impianti_marche/actions.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?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')) {
|
||||
case 'update':
|
||||
$id_marca = post('id_record');
|
||||
$name = post('name');
|
||||
|
||||
// Verifico che il nome non esista già
|
||||
$n = $dbo->fetchNum('SELECT `id` FROM `my_impianti_marche` WHERE (`name`='.prepare($name).' AND `id` !='.prepare($id_marca));
|
||||
|
||||
// Marca già esistente
|
||||
if ($n > 0) {
|
||||
flash()->error(tr('Marca già esistente!'));
|
||||
}
|
||||
// Marca non esistente
|
||||
else {
|
||||
$dbo->query('UPDATE `my_impianti_marche` SET `name`='.prepare($name).' WHERE `id`='.prepare($id_marca));
|
||||
flash()->info(tr('Informazioni salvate correttamente!'));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
$name = post('name');
|
||||
|
||||
// Verifico che il nome non sia duplicato
|
||||
$n = $dbo->fetchNum('SELECT `id` FROM `my_impianti_marche` WHERE `name`='.prepare($name));
|
||||
|
||||
if ($n > 0) {
|
||||
flash()->error(tr('Nome già esistente!'));
|
||||
} else {
|
||||
$query = 'INSERT INTO my_impianti_marche (`name`) VALUES ('.prepare($name).')';
|
||||
$dbo->query($query);
|
||||
|
||||
$id_record = $dbo->lastInsertedID();
|
||||
|
||||
if (isAjaxRequest()) {
|
||||
echo json_encode(['id' => $id_record, 'text' => $name]);
|
||||
}
|
||||
|
||||
flash()->info(tr('Aggiunta una nuova marca!'));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$dbo->query('DELETE FROM `my_impianti_marche` WHERE `id`='.prepare($id_record));
|
||||
|
||||
flash()->info(tr('Marca eliminata!'));
|
||||
|
||||
break;
|
||||
}
|
38
modules/impianti_marche/add.php
Normal file
38
modules/impianti_marche/add.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?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="add-form">
|
||||
<input type="hidden" name="op" value="add">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "required": 1 ]}
|
||||
</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>
|
34
modules/impianti_marche/ajax/select.php
Normal file
34
modules/impianti_marche/ajax/select.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?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`, `name` AS `descrizione` FROM `my_impianti_marche` |where| ORDER BY `descrizione` ASC';
|
||||
|
||||
foreach ($elements as $element) {
|
||||
$filter[] = '`id`='.prepare($element);
|
||||
}
|
||||
if (!empty($search)) {
|
||||
$search_fields[] = '`name` LIKE '.prepare('%'.$search.'%');
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
37
modules/impianti_marche/edit.php
Normal file
37
modules/impianti_marche/edit.php
Normal 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';
|
||||
|
||||
?>
|
||||
<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; ?>">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{[ "type": "text", "label": "<?php echo tr('Nome'); ?>", "name": "name", "required": 1, "value": "$name$" ]}
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<a class="btn btn-danger ask" data-backto="record-list">
|
||||
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
|
||||
</a>
|
24
modules/impianti_marche/init.php
Normal file
24
modules/impianti_marche/init.php
Normal 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 (!empty($id_record)) {
|
||||
$record = $dbo->fetchOne('SELECT * FROM `my_impianti_marche` WHERE `id`='.prepare($id_record));
|
||||
}
|
@ -233,3 +233,25 @@ INSERT INTO `zz_views` (`id_module`, `query`, `order`) VALUES
|
||||
((SELECT `id_record` FROM `zz_modules_lang` WHERE `name` = 'Categorie documenti' LIMIT 1), '(SELECT GROUP_CONCAT(\' \', `nome`) FROM `zz_groups` WHERE `id` IN (SELECT `id_gruppo` FROM `do_permessi` WHERE `id_categoria` = `do_categorie`.`id`))', 5);
|
||||
INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `name`) VALUES
|
||||
(1, (SELECT MAX(`id`) FROM `zz_views` ), 'Gruppi abilitati');
|
||||
|
||||
-- Aggiunta tabella my_impianti_marche
|
||||
CREATE TABLE IF NOT EXISTS `my_impianti_marche` (
|
||||
`id` INT NOT NULL AUTO_INCREMENT ,
|
||||
`name` TEXT NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
|
||||
ALTER TABLE `my_impianti` ADD `id_marca` INT NULL AFTER `idanagrafica`;
|
||||
ALTER TABLE `my_impianti` ADD `modello` TEXT NULL AFTER `id_marca`;
|
||||
|
||||
-- Modulo Marche impianto
|
||||
INSERT INTO `zz_modules` (`directory`, `options`, `options2`, `icon`, `version`, `compatibility`, `order`, `parent`, `default`, `enabled`, `use_notes`, `use_checklists`) VALUES ('impianti_marche', 'SELECT |select| FROM `my_impianti_marche` WHERE 1=1 HAVING 2=2', '', 'fa fa-angle-right', '2.5.1', '2.5.1', '2', '30', '1', '1', '0', '0');
|
||||
INSERT INTO `zz_modules_lang` (`id_lang`, `id_record`, `name`, `title`) VALUES ('1', (SELECT MAX(id) FROM `zz_modules`), 'Marche impianti', 'Marche impianti');
|
||||
|
||||
INSERT INTO `zz_views` (`id_module`, `query`, `order`) VALUES
|
||||
((SELECT `id_record` FROM `zz_modules_lang` WHERE `name` = 'Marche impianti' LIMIT 1), 'id', 1),
|
||||
((SELECT `id_record` FROM `zz_modules_lang` WHERE `name` = 'Marche impianti' LIMIT 1), 'name', 1);
|
||||
INSERT INTO `zz_views_lang` (`id_lang`, `id_record`, `name`) VALUES
|
||||
(1, (SELECT MAX(`id`)-1 FROM `zz_views` ), 'id'),
|
||||
(1, (SELECT MAX(`id`) FROM `zz_views` ), 'Nome');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user