Skip to content

Commit e98264f

Browse files
committed
feat: Scelta quantità di etichette da stampare
1 parent d2c8e2f commit e98264f

5 files changed

Lines changed: 97 additions & 10 deletions

File tree

modules/articoli/bulk.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,15 @@
172172

173173
case 'print_labels':
174174
$_SESSION['superselect']['id_articolo_barcode'] = $id_records;
175+
$qta = (post('qta')>0 ? post('qta') : 1);
175176

176177
if (post('tipologia') == 'singola') {
177178
$id_print = Prints::getPrints()['Barcode'];
178179
} else {
179180
$id_print = Prints::getPrints()['Barcode bulk'];
180181
}
181182

182-
redirect(base_path().'/pdfgen.php?id_print='.$id_print.'&id_record='.Articolo::where('codice', '!=', '')->first()->id);
183+
redirect(base_path().'/pdfgen.php?id_print='.$id_print.'&id_record='.Articolo::where('codice', '!=', '')->first()->id.'&qta='.$qta);
183184
exit;
184185

185186
case 'change_quantity':
@@ -714,6 +715,8 @@
714715
'data' => [
715716
'title' => tr('Stampare i barcode?'),
716717
'msg' => tr('Verranno stampati i barcode per ciascun articolo selezionato').'<br><br>
718+
{[ "type": "number", "label": "'.tr('Q.tà').'", "name": "qta", "required": 1, "value": "1", "decimals":"0", "help":"'.tr('Definisci quante etichette stampare per questo barcode').'" ]}
719+
<br>
717720
{[ "type": "select", "label": "'.tr('Tipologia stampa').'", "name": "tipologia", "required": 1, "values": "list=\"singola\":\"Singola\",\"a4\":\"Formato A4\"", "value": "singola" ]}<br>',
718721
'button' => tr('Procedi'),
719722
'class' => 'btn btn-lg btn-warning',

plugins/barcode_articoli/edit.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<div class="row">
3838
<div class="col-md-12">
3939
<button type="button" class="btn btn-default btn-xs tip pull-right" id="generaBarcode"><i class="fa fa-refresh"></i> '.tr('Genera').'</button>
40-
{[ "type": "text", "label": "'.tr('Barcode').'", "name": "barcode", "required": 1, "value": "'.$barcode->barcode.'", "validation": "barcode|'.$id_module.'|'.$id_record.'" ]}
40+
{[ "type": "text", "label": "'.tr('Barcode').'", "name": "barcode", "required": 1, "value": "'.$barcode->barcode.'", "validation": "barcode|'.$id_module.'|'.$id_record.'", "class": "text-center" ]}
4141
</div>
4242
</div>
4343
@@ -48,7 +48,7 @@
4848
<i class="fa fa-trash"></i> '.tr('Elimina').'
4949
</button>
5050
51-
<a type="button" class="btn btn-info" href="'.$rootdir.'/pdfgen.php?id_print='.Prints::getPrints()['Barcode'].'&id_record='.$id_parent.'&idbarcode='.$id_record.'" target="_blank"><i class="fa fa-print"></i> '.tr('Stampa barcode').'</a>
51+
<a type="button" class="btn btn-info" onclick="launch_modal(\''.tr('Stampa barcode').'\', \''.$rootdir.'/plugins/barcode_articoli/print_barcode.php?id_record='.$id_record.'&id_parent='.$id_parent.'\');"><i class="fa fa-print"></i> '.tr('Stampa barcode').'</a>
5252
<button type="submit" class="btn btn-primary pull-right"><i class="fa fa-edit"></i> '.tr('Modifica').'</button>
5353
</div>
5454
</div>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
$id_record = get('id_record');
23+
$id_parent = get('id_parent');
24+
25+
$barcode = $dbo->table('mg_articoli_barcode')->where('id',$id_record)->first();
26+
27+
echo '
28+
<div class="row">
29+
<div class="col-md-3">
30+
{[ "type": "number", "label": "'.tr('Q.tà').'", "name": "qta", "required": 1, "value": "1", "decimals":"0", "help":"'.tr('Definisci quante etichette stampare per questo barcode').'" ]}
31+
</div>
32+
<div class="col-md-3">
33+
{[ "type": "select", "label": "'.tr('Tipologia stampa').'", "name": "tipologia", "required": 1, "values": "list=\"singola\":\"Singola\",\"a4\":\"Formato A4\"", "value": "singola" ]}
34+
</div>
35+
</div>
36+
<div class="row">
37+
<div class="col-md-12 text-right">
38+
<a class="btn btn-primary" onclick="stampaBarcode();"><i class="fa fa-print"></i> '.tr('Stampa').'</a>
39+
</div>
40+
</div>';
41+
42+
echo '
43+
<script>
44+
45+
function stampaBarcode() {
46+
let qta = input("qta").get();
47+
48+
if ($("#tipologia").val() == "singola") {
49+
var id_print = '.Prints::getPrints()['Barcode'].';
50+
} else {
51+
var id_print = '.Prints::getPrints()['Barcode bulk'].';
52+
}
53+
54+
window.open("'.$rootdir.'/pdfgen.php?id_print=" + id_print + "&id_record='.$id_parent.'&idbarcode='.$id_record.'&qta=" + qta, "_blank");
55+
}
56+
57+
</script>';

templates/barcode/init.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,23 @@
2424

2525
if (!empty($_SESSION['superselect']['id_articolo_barcode'])) {
2626
$articoli = Articolo::whereIn('id', $_SESSION['superselect']['id_articolo_barcode'])->get();
27-
$records = $dbo->table('mg_articoli_barcode')->whereIn('idarticolo',$_SESSION['superselect']['id_articolo_barcode'])->get();
27+
$barcodes = $dbo->table('mg_articoli_barcode')->whereIn('idarticolo',$_SESSION['superselect']['id_articolo_barcode'])->get();
2828
unset($_SESSION['superselect']['id_articolo_barcode']);
2929
} elseif( !empty(get('idbarcode')) ){
30-
$records = $dbo->table('mg_articoli_barcode')->where('id',get('idbarcode'))->get();
30+
$barcodes = $dbo->table('mg_articoli_barcode')->where('id',get('idbarcode'))->get();
3131
} else {
3232
$articoli = Articolo::where('id', '=', $id_record)->get();
33-
$records = $dbo->table('mg_articoli_barcode')->where('idarticolo',$id_record)->get();
33+
$barcodes = $dbo->table('mg_articoli_barcode')->where('idarticolo',$id_record)->get();
34+
}
35+
36+
if( !empty(get('qta')) ){
37+
foreach($barcodes as $barcode) {
38+
for( $i=0; $i<get('qta'); $i++ ){
39+
$records[] = $barcode;
40+
}
41+
}
42+
}else{
43+
$records = $barcodes;
3444
}
3545

3646
$pages = count($records);

templates/barcode_bulk/body.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,24 @@
3434
}
3535
</style>';
3636

37-
$articoli = Articolo::whereIn('id', $_SESSION['superselect']['id_articolo_barcode'])->get();
38-
unset($_SESSION['superselect']['id_articolo_barcode']);
37+
if (!empty($_SESSION['superselect']['id_articolo_barcode'])) {
38+
$barcodes = $dbo->table('mg_articoli_barcode')->whereIn('idarticolo',$_SESSION['superselect']['id_articolo_barcode'])->get();
39+
unset($_SESSION['superselect']['id_articolo_barcode']);
40+
} elseif( !empty(get('idbarcode')) ){
41+
$barcodes = $dbo->table('mg_articoli_barcode')->where('id',get('idbarcode'))->get();
42+
} else {
43+
$barcodes = $dbo->table('mg_articoli_barcode')->where('idarticolo',$id_record)->get();
44+
}
45+
46+
if( !empty(get('qta')) ){
47+
foreach($barcodes as $barcode) {
48+
for( $i=0; $i<get('qta'); $i++ ){
49+
$records[] = $barcode;
50+
}
51+
}
52+
}else{
53+
$records = $barcodes;
54+
}
3955

4056
echo "
4157
<table style='width:100%'>
@@ -44,8 +60,9 @@
4460
$i = 0;
4561
$prezzi_ivati = setting('Utilizza prezzi di vendita comprensivi di IVA');
4662

47-
foreach ($articoli as $articolo) {
48-
$barcode = $articolo->barcode ?: $articolo->codice;
63+
foreach ($records as $record) {
64+
$articolo = Articolo::find($record->idarticolo);
65+
$barcode = $record->barcode;
4966

5067
if ($i % 5 == 0) {
5168
echo '</tr><tr>';

0 commit comments

Comments
 (0)