diff --git a/ereuse_devicehub/resources/device/models.py b/ereuse_devicehub/resources/device/models.py index 18487ba5..c42d9bec 100644 --- a/ereuse_devicehub/resources/device/models.py +++ b/ereuse_devicehub/resources/device/models.py @@ -401,6 +401,12 @@ class Device(Thing): return history + @property + def sid(self): + actions = [x for x in self.actions if x.t == 'Snapshot' and x.sid] + if actions: + return actions[0].sid + @property def tradings(self): return {str(x.id): self.trading(x.lot) for x in self.actions if x.t == 'Trade'} diff --git a/ereuse_devicehub/static/js/print.pdf.js b/ereuse_devicehub/static/js/print.pdf.js index f0b1817c..019b6510 100644 --- a/ereuse_devicehub/static/js/print.pdf.js +++ b/ereuse_devicehub/static/js/print.pdf.js @@ -24,6 +24,7 @@ function save_settings() { var sizePreset = $("#printerType").val(); var data = {"height": height, "width": width, "sizePreset": sizePreset}; data['dhid'] = $("#dhidCheck").prop('checked'); + data['sid'] = $("#sidCheck").prop('checked'); data['qr'] = $("#qrCheck").prop('checked'); data['serial_number'] = $("#serialNumberCheck").prop('checked'); data['manufacturer'] = $("#manufacturerCheck").prop('checked'); @@ -39,6 +40,7 @@ function load_settings() { $("#printerType").val(data.sizePreset); $("#qrCheck").prop('checked', data.qr); $("#dhidCheck").prop('checked', data.dhid); + $("#sidCheck").prop('checked', data.sid); $("#serialNumberCheck").prop('checked', data.serial_number); $("#manufacturerCheck").prop('checked', data.manufacturer); $("#modelCheck").prop('checked', data.model); @@ -50,6 +52,7 @@ function reset_settings() { $("#printerType").val('brotherSmall'); $("#qrCheck").prop('checked', true); $("#dhidCheck").prop('checked', true); + $("#sidCheck").prop('checked', true); $("#serialNumberCheck").prop('checked', false); $("#manufacturerCheck").prop('checked', false); $("#modelCheck").prop('checked', false); @@ -74,6 +77,11 @@ function change_check() { } else { $(".dhid").hide(); } + if ($("#sidCheck").prop('checked')) { + $(".sid").show(); + } else { + $(".sid").hide(); + } if ($("#serialNumberCheck").prop('checked')) { $(".serial_number").show(); } else { @@ -109,6 +117,9 @@ function printpdf() { min_tag_side = (Math.min(height, width)/2) + border; var last_tag_code = ''; + if ($("#sidCheck").prop('checked')) { + height += line; + }; if ($("#serialNumberCheck").prop('checked')) { height += line; }; @@ -145,6 +156,12 @@ function printpdf() { space += line; } }; + if ($("#sidCheck").prop('checked')) { + var sn = $(y).data('sid'); + pdf.setFontSize(15); + pdf.text(sn, border, space); + space += line; + }; if ($("#serialNumberCheck").prop('checked')) { var sn = $(y).data('serial-number'); pdf.setFontSize(12); diff --git a/ereuse_devicehub/templates/labels/print_labels.html b/ereuse_devicehub/templates/labels/print_labels.html index 3c9ffaae..e0693c98 100644 --- a/ereuse_devicehub/templates/labels/print_labels.html +++ b/ereuse_devicehub/templates/labels/print_labels.html @@ -35,7 +35,13 @@
{{ dev.devicehub_id }} + data-model="{{ dev.model or '' }}" + data-sid="{{ dev.sid or '' }}">{{ dev.devicehub_id }} +
+ + @@ -103,6 +109,10 @@ +
+ + +