Compare commits

...

7 Commits

Author SHA1 Message Date
Pek5892 b3d8779005 Fix per php8.1 2024-04-17 11:44:13 +02:00
Pek5892 4152b51b83 Aggiunta campi marca e modello in import Impianti 2024-04-17 11:43:58 +02:00
Beppe 9df84eb7fb Merge branch 'master' of https://github.com/devcode-it/openstamanager 2024-04-17 11:30:19 +02:00
Beppe ec326c35f5 Fix eliminazione destinatari collegati ad anagrafiche rimosse 2024-04-17 11:30:17 +02:00
Pek5892 f9c5b4aa35 Aggiunti i campi marca e modello in Impianti 2024-04-17 11:21:05 +02:00
Pek5892 6b7fa73bc3 Fix per php8.1 2024-04-17 10:39:25 +02:00
FabioL 9b1e2e82e0 Fix per lettura file XML fuori dalla root 2024-04-17 09:34:07 +02:00
14 changed files with 286 additions and 32 deletions

View File

@ -289,7 +289,7 @@ class CSV extends CSVImporter
$id_settore = '';
if (!empty($record['id_settore'])) {
$settore = $record['id_settore'];
$id_settore = $database->fetchOne('SELECT `an_settori`.`id` FROM `an_settori` LEFT JOIN (`an_settori_lang` ON`an_settori`.`id` = `an_settori_lang`.`id_record` AND `an_settori_lang`.`id_lang` = '.prepare(\Models\Locale::getDefault()->id).') WHERE LOWER(`name`) = LOWER('.prepare($settore).')')['id'];
$id_settore = $database->fetchArray('SELECT `an_settori`.`id` FROM `an_settori` LEFT JOIN `an_settori_lang` ON (`an_settori`.`id` = `an_settori_lang`.`id_record` AND `an_settori_lang`.`id_lang` = '.prepare(\Models\Locale::getDefault()->id).') WHERE LOWER(`name`) = LOWER('.prepare($settore).')');
if (empty($id_settore)) {
$id_settore = database()->query('INSERT INTO `an_settori` (`id`, `created_at`, `updated_at`) VALUES (NULL, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)');

View File

@ -81,9 +81,7 @@ if (!empty($id_record)) {
$fattura_acquisto_originale = null;
if (!empty($fattura)) {
$reverse_charge = $fattura->getRighe()->first(function ($item, $key) {
return $item->aliquota != null && $item->aliquota->codice_natura_fe !== null && substr($item->aliquota->codice_natura_fe, 0, 2) == 'N6';
})->id;
$reverse_charge = $fattura->getRighe()->first(fn($item, $key) => $item->aliquota != null && $item->aliquota->codice_natura_fe !== null && substr($item->aliquota->codice_natura_fe, 0, 2) == 'N6')->id;
$autofattura_vendita = Fattura::find($fattura->id_autofattura);
$abilita_autofattura = (($fattura->anagrafica->nazione->iso2 != 'IT' && !empty($fattura->anagrafica->nazione->iso2)) || $reverse_charge) && $dir == 'uscita' && $fattura->id_autofattura == null;

View File

@ -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'),

View File

@ -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,26 +51,44 @@ 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>
<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'])) ?
Modules::link('Categorie impianti', $record['id_categoria'], null, null, 'class="pull-right"') : ''; ?>
@ -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$" ]}

View File

@ -86,6 +86,14 @@ class CSV extends CSVImporter
'field' => 'data',
'label' => 'Data installazione',
],
[
'field' => 'marca',
'label' => 'Marca',
],
[
'field' => 'modello',
'label' => 'Modello',
],
];
}
@ -128,6 +136,21 @@ class CSV extends CSVImporter
}
}
// Gestione marca
$id_marca = null;
if (!empty($record['marca'])) {
// Marca
$n = $database->fetchOne('SELECT `id` FROM `my_impianti_marche` WHERE `name`='.prepare($record['marca']))['id'];
if (empty($n)) {
$query = 'INSERT INTO `my_impianti_marche` (`name`) VALUES ('.prepare($record['marca']).')';
$database->query($query);
$id_marca = $database->lastInsertedID();
} else {
$id_marca = $n;
}
}
// Individuazione impianto e generazione
$impianto = null;
@ -145,6 +168,8 @@ class CSV extends CSVImporter
}
$impianto->idanagrafica = $anagrafica->idanagrafica;
$impianto->id_marca = $id_marca;
$impianto->modello = $record['modello'];
$impianto->save();
if (!empty($record['sede'])) {

View 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;
}

View 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>

View 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;
}

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';
?>
<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>

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 (!empty($id_record)) {
$record = $dbo->fetchOne('SELECT * FROM `my_impianti_marche` WHERE `id`='.prepare($id_record));
}

View File

@ -123,7 +123,7 @@ foreach ($destinatari_filtrati as $destinatario) {
<a class="btn btn-warning btn-xs" data-type="'.get_class($origine).'" data-id="'.$origine->id.'" data-email="'.$origine->email.'" onclick="testInvio(this)">
<i class="fa fa-paper-plane "></i>
</a>' : '').'
<a class="btn btn-danger ask btn-xs" data-backto="record-edit" data-op="remove_receiver" data-type="'.get_class($origine).'" data-id="'.$origine->id.'">
<a class="btn btn-danger ask btn-xs" data-backto="record-edit" data-op="remove_receiver" data-type="'.$destinatario->record_type.'" data-id="'.$destinatario->record_id.'">
<i class="fa fa-trash"></i>
</a>
</div>',

View File

@ -36,8 +36,8 @@ abstract class CSVImporter implements ImporterInterface
public function __construct($file)
{
// Impostazione automatica per i caratteri di fine riga
if (!ini_get('auto_detect_line_endings')) {
ini_set('auto_detect_line_endings', '1');
if (!ini_get('default_socket_timeout')) {
ini_set('default_socket_timeout', '0');
}
// Gestione del file CSV

View File

@ -338,7 +338,7 @@ class Upload extends Model
*/
public function getContent()
{
return file_get_contents($this->local_filepath);
return file_get_contents(base_dir().'/'.$this->local_filepath);
}
public static function getInfo($file)

View File

@ -232,4 +232,26 @@ HAVING
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');
(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');