Skip to content

Commit a0fa0a0

Browse files
committed
Aggiunta Modulo Ubicazioni
1 parent 5503399 commit a0fa0a0

6 files changed

Lines changed: 397 additions & 12 deletions

File tree

modules/articoli/ajax/select.php

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
$query = "SELECT
4343
DISTINCT `mg_articoli`.`id`,
4444
IF(`categoria_lang`.`title` IS NOT NULL, CONCAT(`categoria_lang`.`title`, IF(`sottocategoria_lang`.`title` IS NOT NULL, CONCAT(' (', `sottocategoria_lang`.`title`, ')'), '-')), '<i>".tr('Nessuna categoria')."</i>') AS optgroup,
45-
`mg_articoli_barcode`.`barcode` AS barcode,
45+
`mg_articoli`.`barcode`,
4646
`mg_articoli`.".($prezzi_ivati ? '`prezzo_vendita_ivato`' : '`prezzo_vendita`').' AS prezzo_vendita,
4747
`mg_articoli`.`prezzo_vendita_ivato` AS prezzo_vendita_ivato,
4848
`mg_articoli`.'.($prezzi_ivati ? '`minimo_vendita_ivato`' : '`minimo_vendita`').' AS minimo_vendita,';
@@ -114,8 +114,7 @@
114114
LEFT JOIN `co_iva` AS iva_articolo ON `iva_articolo`.`id` = `mg_articoli`.`idiva_vendita`
115115
LEFT JOIN `co_iva_lang` AS iva_articolo_lang on (`iva_articolo`.`id` = `iva_articolo_lang`.`id_record` AND `iva_articolo_lang`.`id_lang` = ".prepare(Models\Locale::getDefault()->id).")
116116
LEFT JOIN `co_iva` AS `iva_predefinita` ON `iva_predefinita`.`id` = '.$iva_predefinita.'
117-
LEFT JOIN `co_iva_lang` AS iva_predefinita_lang on (`iva_predefinita`.`id` = `iva_predefinita_lang`.`id_record` AND `iva_predefinita_lang`.`id_lang` = ".prepare(Models\Locale::getDefault()->id).')
118-
LEFT JOIN mg_articoli_barcode ON mg_articoli_barcode.idarticolo = mg_articoli.id';
117+
LEFT JOIN `co_iva_lang` AS iva_predefinita_lang on (`iva_predefinita`.`id` = `iva_predefinita_lang`.`id_record` AND `iva_predefinita_lang`.`id_lang` = ".prepare(Models\Locale::getDefault()->id).')';
119118

120119
if ($usare_iva_anagrafica) {
121120
$query .= '
@@ -180,8 +179,8 @@
180179
if (!empty($search)) {
181180
$search_fields[] = '`mg_articoli_lang`.`title` LIKE '.prepare('%'.$search.'%');
182181
$search_fields[] = '`mg_articoli`.`codice` LIKE '.prepare('%'.$search.'%');
182+
$search_fields[] = '`mg_articoli`.`barcode` LIKE '.prepare('%'.$search.'%');
183183
$search_fields[] = '`categoria_lang`.`title` LIKE '.prepare('%'.$search.'%');
184-
$search_fields[] = '`mg_articoli_barcode`.`barcode` LIKE '.prepare('%'.$search.'%');
185184
$search_fields[] = '`sottocategoria_lang`.`title` LIKE '.prepare('%'.$search.'%');
186185

187186
if ($usare_dettaglio_fornitore) {
@@ -217,7 +216,6 @@
217216
$results = [
218217
'results' => $rs,
219218
'recordsFiltered' => $data['recordsFiltered'],
220-
'link' => 'module:Articoli',
221219
];
222220

223221
break;
@@ -236,8 +234,6 @@
236234
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
237235
}
238236

239-
$custom['link'] = 'module:Categorie';
240-
241237
break;
242238

243239
/*
@@ -258,8 +254,6 @@
258254
if (!empty($search)) {
259255
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
260256
}
261-
262-
$custom['link'] = 'module:Categorie';
263257
}
264258
break;
265259

@@ -275,6 +269,20 @@
275269

276270
break;
277271

272+
case 'ubicaz':
273+
$query = 'SELECT `mg_ubicazioni`.`u_label` AS id, `mg_ubicazioni_lang`.`title` AS descrizione FROM `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni_lang`.`id_record` = `mg_ubicazioni`.`id` AND `mg_ubicazioni_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY `title`';
274+
//$query = 'SELECT `u_label` AS id, `u_label` AS descrizione FROM `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni_lang`.`id_record` = `mg_ubicazioni`.`id` AND `mg_ubicazioni_lang`.`id_lang` = '.prepare(Models\Locale::getDefault()->id).') |where| ORDER BY TRIM(`mg_ubicazioni`.`u_label`)';
275+
276+
foreach ($elements as $element) {
277+
$filter[] = '`u_label`='.prepare($element);
278+
}
279+
if (!empty($search)) {
280+
//$search_fields[] = '`u_label` LIKE '.prepare('%'.$search.'%');
281+
$search_fields[] = '`title` LIKE '.prepare('%'.$search.'%');
282+
}
283+
284+
break;
285+
278286
/*
279287
* Opzioni utilizzate:
280288
* - idanagrafica
@@ -298,15 +306,14 @@
298306
`mg_fornitore_articolo`.`id` AS id_dettaglio_fornitore
299307
FROM `mg_articoli`
300308
LEFT JOIN `mg_fornitore_articolo` ON `mg_fornitore_articolo`.`id_articolo` = `mg_articoli`.`id` AND `mg_fornitore_articolo`.`deleted_at` IS NULL AND `mg_fornitore_articolo`.`id_fornitore` = '.prepare($id_anagrafica).'
301-
LEFT JOIN `mg_articoli_barcode` ON `mg_articoli`.`id` = `mg_articoli_barcode`.`idarticolo`
302309
|where|';
303310

304311
$where[] = '`mg_articoli`.`attivo` = 1';
305312
$where[] = '`mg_articoli`.`deleted_at` IS NULL';
306313

307314
if (!empty($search)) {
308315
$search_fields[] = '`mg_articoli`.`codice` LIKE '.prepare('%'.$search.'%');
309-
$search_fields[] = '`mg_articoli_barcode`.`barcode` LIKE '.prepare('%'.$search.'%');
316+
$search_fields[] = '`mg_articoli`.`barcode` LIKE '.prepare('%'.$search.'%');
310317
}
311318

312319
break;

modules/ubicazioni/actions.php

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
/*
3+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
4+
* Copyright (C) DevCode s.r.l.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
include_once __DIR__.'/../../core.php';
21+
use Modules\Ubicazioni;
22+
//use Modules\Articoli\Categoria;
23+
24+
switch (filter('op')) {
25+
case 'update':
26+
$u_label = filter('u_label');
27+
//$u_label_info = filter('u_label_info');
28+
$title = filter('title');
29+
$colore = filter('colore');
30+
$notes = filter('notes');
31+
$u_tags = filter('u_tags');
32+
//$u_id = filter('id');
33+
34+
if (isset($u_label)) {
35+
if ($dbo->fetchNum('SELECT * FROM `mg_ubicazioni` WHERE `mg_ubicazioni`.`u_label`='.prepare($u_label).' AND `mg_ubicazioni`.`id`!='.prepare($id_record)) == 0) {
36+
$dbo->query('UPDATE `mg_ubicazioni` LEFT JOIN `mg_ubicazioni_lang` ON (`mg_ubicazioni`.`id` = `mg_ubicazioni_lang`.`id_record` AND `mg_ubicazioni_lang`.`id_lang` = '.prepare(parameter: Models\Locale::getDefault()->id).')
37+
SET `mg_ubicazioni`.`u_label`='.prepare($u_label).',
38+
`mg_ubicazioni`.`u_tags`='.prepare($u_tags).',
39+
`mg_ubicazioni`.`colore`='.prepare($colore).',
40+
`mg_ubicazioni_lang`.`title`='.prepare($title).',
41+
`mg_ubicazioni_lang`.`notes`='.prepare($notes).'
42+
WHERE `mg_ubicazioni`.`id`='.prepare($id_record));
43+
//$ubicazione->colore = $colore;
44+
//$categoria->parent = $id_original ?: null;
45+
//$ubicazione->setTranslation('title', $title);
46+
//$ubicazione->setTranslation('notes', $notes);
47+
//$ubicazione->save();
48+
flash()->info(tr('Salvataggio completato.'));
49+
} else {
50+
flash()->error(tr("E' già presente una tipologia di _TYPE_ con lo stesso valore.", [
51+
'_TYPE_' => 'ubicazione',
52+
]));
53+
}
54+
} else {
55+
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio'));
56+
}
57+
58+
break;
59+
60+
//aggiornato con l'aggiunta di mg_ubicazioni_lang
61+
case 'add':
62+
$u_label = filter('u_label');
63+
//$u_label_info = filter('u_label_info');
64+
$title = filter('title');
65+
$colore = filter('colore');
66+
$notes = filter('notes');
67+
$u_tags = filter('u_tags');
68+
//$u_id = filter('id');
69+
70+
if (isset($u_label)) {
71+
if ($dbo->fetchNum('SELECT * FROM `mg_ubicazioni` WHERE `u_label`='.prepare($u_label)) == 0) {
72+
$dbo->query('INSERT INTO `mg_ubicazioni` (`u_label`,`u_tags`,`colore`) VALUES ('.prepare($u_label).','.prepare($u_tags).','.prepare($colore).')');
73+
$id_record = $dbo->lastInsertedID();
74+
$dbo->query('INSERT INTO `mg_ubicazioni_lang` (`id_lang`,`id_record`,`title`,`notes`) VALUES ('.prepare(parameter: Models\Locale::getDefault()->id).','.prepare($id_record).','.prepare($title).','.prepare($notes).')');
75+
76+
if (isAjaxRequest()) {
77+
echo json_encode(['id' => $u_label, 'text' => $u_label]);
78+
}
79+
80+
flash()->info(tr('Aggiunta nuova tipologia di _TYPE_', [
81+
'_TYPE_' => 'ubicazione',
82+
]));
83+
} else {
84+
flash()->error(tr("E' già presente una tipologia di _TYPE_ con lo stesso valore.", [
85+
'_TYPE_' => 'ubicazione',
86+
]));
87+
}
88+
} else {
89+
flash()->error(tr('Ci sono stati alcuni errori durante il salvataggio'));
90+
}
91+
92+
break;
93+
94+
case 'delete':
95+
//$righe = $dbo->fetchNum('SELECT `id` FROM `co_righe_documenti` WHERE `um`='.prepare($record['valore']).'
96+
// UNION SELECT `id` FROM `dt_righe_ddt` WHERE `um`='.prepare($record['valore']).'
97+
// UNION SELECT `id` FROM `or_righe_ordini` WHERE `um`='.prepare($record['valore']).'
98+
// UNION SELECT `id` FROM `co_righe_contratti` WHERE `um`='.prepare($record['valore']).'
99+
// UNION SELECT `id` FROM `mg_articoli` WHERE `um`='.prepare($record['valore']).'
100+
// UNION SELECT `id` FROM `co_righe_preventivi` WHERE `um`='.prepare($record['valore']));
101+
102+
//aggiornato con il delete anche dei record mg_ubicazione_lang
103+
if (!empty($id_record)) {
104+
$dbo->query('DELETE FROM `mg_ubicazioni` WHERE `id`='.prepare($id_record));
105+
flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [
106+
'_TYPE_' => 'ubicazione',
107+
]));
108+
$dbo->query('DELETE FROM `mg_ubicazioni_lang` WHERE `id_record`='.prepare($id_record));
109+
flash()->info(tr('Tipologia di _TYPE_ eliminata con successo!', [
110+
'_TYPE_' => 'ubicazione_lang',
111+
]));
112+
} else {
113+
flash()->error(tr('Errore cancellazione di questa ubicazione.'));
114+
}
115+
116+
break;
117+
}

modules/ubicazioni/add.php

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/*
3+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
4+
* Copyright (C) DevCode s.r.l.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
include_once __DIR__.'/../../core.php';
21+
22+
?><form action="" method="post" id="add-form">
23+
<input type="hidden" name="op" value="add">
24+
<input type="hidden" name="backto" value="record-edit">
25+
26+
<div class="row">
27+
<div class="col-md-3">
28+
{[ "type": "text", "label": "<?php echo tr('Etichetta'); ?>", "name": "u_label", "required": 1, "value": "$u_label$" ]}
29+
</div>
30+
<!--<div class="col-md-4">
31+
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "u_label_info", "value": "$u_label_info$" ]}
32+
</div>
33+
<div class="col-md-8">
34+
{[ "type": "text", "label": "<?php echo tr('Note'); ?>", "name": "u_notes", "value": "$u_notes$" ]}
35+
</div>-->
36+
<div class="col-md-4">
37+
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "title", "value": "$title$" ]}
38+
</div>
39+
<div class="col-md-8">
40+
{[ "type": "text", "label": "<?php echo tr('Note'); ?>", "name": "notes", "value": "$notes$" ]}
41+
</div>
42+
<div class="col-md-6">
43+
{[ "type": "text", "label": "<?php echo tr('Tags'); ?>", "name": "u_tags", "value": "$u_tags$" ]}
44+
</div>
45+
<div class="col-md-2">
46+
{[ "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>" ]}
47+
</div>
48+
</div>
49+
50+
<!-- PULSANTI -->
51+
<div class="row">
52+
<div class="col-md-12 text-right">
53+
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo tr('Aggiungi'); ?></button>
54+
</div>
55+
</div>
56+
</form>
57+
<script>
58+
$(document).ready( function() {
59+
$('#modals > div .colorpicker').colorpicker({ format: 'hex' }).on('changeColor', function() {
60+
$('#modals > div #colore_').parent().find('.square').css('background', $('#modals > div #colore_').val());
61+
});
62+
63+
$('#modals > div #colore_').parent().find('.square').css('background', $('#modals > div #colore_').val());
64+
65+
$('#modals > div .colorpicker').colorpicker({ format: 'hex' }).on('changeColor', function() {
66+
$('#modals > div #colore_').parent().find('.square').css('background', $('#modals > div #colore_').val());
67+
});
68+
69+
$('#modals > div #colore_').parent().find('.square').css('background', $('#modals > div #colore_').val());
70+
});
71+
</script>

modules/ubicazioni/edit.php

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
/*
3+
* OpenSTAManager: il software gestionale open source per l'assistenza tecnica e la fatturazione
4+
* Copyright (C) DevCode s.r.l.
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
*/
19+
20+
include_once __DIR__.'/../../core.php';
21+
//use Modules\Barcode;
22+
//use Modules\Articoli\Articolo;
23+
use Models\Module;
24+
use Modules\Ubicazioni;
25+
26+
?>
27+
<form action="" method="post" id="edit-form">
28+
<input type="hidden" name="backto" value="record-edit">
29+
<input type="hidden" name="op" value="update">
30+
31+
<!-- DATI -->
32+
<div class="card card-primary">
33+
<div class="card-header">
34+
<h3 class="card-title"><?php echo tr('Dati'); ?></h3>
35+
</div>
36+
37+
<div class="card-body">
38+
<div class="row">
39+
<div class="col-md-3">
40+
{[ "type": "text", "label": "<?php echo tr('Etichetta'); ?>", "name": "u_label", "required": 1, "value": "$u_label$" ]}
41+
</div>
42+
<!--<div class="col-md-4">
43+
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "u_label_info", "value": "$u_label_info$" ]}
44+
</div>
45+
<div class="col-md-8">
46+
{[ "type": "text", "label": "<?php echo tr('Note'); ?>", "name": "u_notes", "value": "$u_notes$" ]}
47+
</div>-->
48+
<div class="col-md-4">
49+
{[ "type": "text", "label": "<?php echo tr('Descrizione'); ?>", "name": "title", "value": "$title$" ]}
50+
</div>
51+
<div class="col-md-8">
52+
{[ "type": "text", "label": "<?php echo tr('Note'); ?>", "name": "notes", "value": "$notes$" ]}
53+
</div>
54+
<div class="col-md-6">
55+
{[ "type": "text", "label": "<?php echo tr('Tags'); ?>", "name": "u_tags", "value": "$u_tags$" ]}
56+
</div>
57+
<div class="col-md-2">
58+
{[ "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>" ]}
59+
</div>
60+
</div>
61+
<a class="btn btn-info" href="/osm/pdfgen.php?id_print=56&id_record=<?php echo $record['id']; ?>" target="_blank" id="print-button">
62+
<i class="fa fa-print"> Stampa Etichetta</i>
63+
</a>
64+
<a class="btn btn-info" href="/osm/pdfgen.php?id_print=58&id_record=<?php echo $record['id']; ?>" target="_blank" id="print-button">
65+
<i class="fa fa-print"> Stampa Etichetta BIG</i>
66+
</a>
67+
</div>
68+
</div>
69+
70+
</form>
71+
72+
<script>
73+
$(document).ready(function() {
74+
$('.colorpicker').colorpicker({ format: 'hex' }).on('changeColor', function() {
75+
$(this).parent().find('.square').css('background', $(this).val());
76+
});
77+
$('.colorpicker').parent().find('.square').css('background', $('.colorpicker').val());
78+
});
79+
</script>
80+
81+
82+
<?php
83+
84+
$righe = $dbo->fetchNum('SELECT `id` FROM `mg_articoli` WHERE `ubicazione`='.prepare($record['u_label']));
85+
if (!empty($righe)) {
86+
echo '
87+
<div class="alert alert-danger">
88+
'.tr('Ci sono _NUM_ righe collegate', [
89+
'_NUM_' => $righe,
90+
]).'
91+
</div>';
92+
}
93+
94+
$elementi = $dbo->fetchArray('SELECT `id`,`codice`,`barcode`,`ubicazione` FROM `mg_articoli` WHERE `ubicazione`='.prepare($record['u_label']));
95+
echo '<div class="alert alert-danger">';
96+
foreach ($elementi as $elemento) {
97+
$descrizione = tr('Articolo _CODICE_', [
98+
'_CODICE_' => !empty($elemento['codice']) ? $elemento['codice'] : $elemento['barcode'],
99+
]);
100+
$modulo = 'Articoli';
101+
$id = $elemento['id'];
102+
echo '<li>'.Modules::link($modulo, $id, $descrizione).'</li>';
103+
}
104+
echo '</div>';
105+
106+
?>
107+
108+
<a class="btn btn-danger ask" data-backto="record-list">
109+
<i class="fa fa-trash"></i> <?php echo tr('Elimina'); ?>
110+
</a>
111+

0 commit comments

Comments
 (0)