Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Template Roll Printer with options (for 2.2.6, 2.3, 2.3.4, 2.4.0, 2.4.4)

    Scheduled Pinned Locked Moved Captive Portal
    90 Posts 34 Posters 39.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      DanieleIT
      last edited by DanieleIT

      Ciao,

      Here's my contribution for printing captive portal's vouchers using templates.
      The code is based on the work by Reward Gagarin (https://forum.pfsense.org/index.php?topic=100925.0)

      Changelog

      Features (initial release):

      • Print icon in the voucher rolls grid (2.2.6 version).
      • Options to modify the text of the vouchers: Voucher title, voucher info and the possibility to overwrite the voucher duration with a custom text.
      • Option to print only non-expired vouchers.
      • Options are saved in a config file.
      • Fixed a bug on the original code where the duration of the vouchers were always "expired".
      • Html+css template using divs with 21 vouchers per page. (using page-break-before, divs are never printed across pages. Tested with Chrome only).

      Update (18/04/2016):

      • Added "expire voucher" option.
      • 2.3 version.

      Update (01/06/2016):

      • Update 2.3 version zip with portalprint.priv.inc permission (credits: Ikkuranus)

      Update (23/10/2017):

      • 2.3.4 Version
      • 2.4.0 Version

      Update (11/04/2019):

      • 2.4.4 Version
      • Reuploaded old versions (lost in migrating to netgate?)

      Installation Instructions

      Since the installation steps are (mostly) the same for all versions, I'm adding instructions here below; you can still file the same guide in the readme.txt file.

      Prerequisites

      • SSH enabled
      • A client to connect to the portal via SSH (for Windows, I use WinSCP using SCP protocol. Notice: username for SSH connections is root)

      Installation Instructions
      1. Edit css file to fit your needs and overwrite logo.png with your onw logo
      2. in /usr/local/www/ overwrite services_captiveportal_vouchers.php
      3. in /usr/local/www/ upload services_captiveportal_vouchers_options.php and services_captiveportal_vouchers_print.php
      4. create a new folder named: "voucherfiles" (without ", case sensitive)
      5. upload voucherfiles directory's files in the newly created directory
      6. Print from Services -> Captive Portal -> Vouchers
      Extra:
      If you want people with more limited accounts to print out vouchers without having full access to the WebUI add the portalprint.priv.inc file in the /etc/inc/priv/ folder (not tested in 2.4.0)

      ~

      As this is a first release and I'm not mainly a PHP programmer, let me know if you find something strange.
      Hope this helps,
      Daniele

      Voucher-Template-Printer-2.2.6.zip
      Voucher-Template-Printer-2.3.zip
      Voucher-Template-Printer-2.3.4.zip
      Voucher-Template-Printer-2.4.0.zip
      Voucher-Template-Printer-2.4.4.zip

      A D 2 Replies Last reply Reply Quote 1
      • F
        fr0t
        last edited by

        Hi,

        Looks good, any chance to put voucher ID in ean-13 barcode or even code-39?

        1 Reply Last reply Reply Quote 0
        • DerelictD
          Derelict LAYER 8 Netgate
          last edited by

          I would suggest adding an expiration date, which would be the date on which you can delete the roll.

          Chattanooga, Tennessee, USA
          A comprehensive network diagram is worth 10,000 words and 15 conference calls.
          DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
          Do Not Chat For Help! NO_WAN_EGRESS(TM)

          1 Reply Last reply Reply Quote 0
          • F
            fr0t
            last edited by

            @Derelict:

            I would suggest adding an expiration date, which would be the date on which you can delete the roll.

            How can You put expiration date if You don't know when voucher is gonna by initiated?

            1 Reply Last reply Reply Quote 0
            • GertjanG
              Gertjan
              last edited by

              @fr0t:

              How can You put expiration date if You don't know when voucher is gonna by initiated?

              The same way as adding an expiration date to a password.
              You don't care if it was being used, or not.
              See for yourself => System: User Manager and check out a user.

              Expiring vouchers could be useful to "empty" rolls so the can be deleted.

              No "help me" PM's please. Use the forum, the community will thank you.
              Edit : and where are the logs ??

              1 Reply Last reply Reply Quote 0
              • DerelictD
                Derelict LAYER 8 Netgate
                last edited by

                All I know is I want to be able to expire voucher rolls.  Might be a year or two years, but you want to be able to pronounce them dead. If that date is printed on the voucher, WAY easier.

                Chattanooga, Tennessee, USA
                A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                Do Not Chat For Help! NO_WAN_EGRESS(TM)

                1 Reply Last reply Reply Quote 0
                • F
                  fr0t
                  last edited by

                  @Gertjan:

                  @fr0t:

                  How can You put expiration date if You don't know when voucher is gonna by initiated?

                  The same way as adding an expiration date to a password.
                  You don't care if it was being used, or not.
                  See for yourself => System: User Manager and check out a user.

                  Expiring vouchers could be useful to "empty" rolls so the can be deleted.

                  I was asking about voucher, not about user (with password). Its not possible to put the expiry date/time for not initiated voucher, another thing is, if there would be a option to set expiry date for each roll - this date could be printed on as something like: "use by: ….." or "valid until: ...... "

                  1 Reply Last reply Reply Quote 0
                  • DerelictD
                    Derelict LAYER 8 Netgate
                    last edited by

                    The problem is you never know where they are. I suppose if it's important to the site it can just be put in the Title or Info fields.

                    Does it work on 2.3?

                    Chattanooga, Tennessee, USA
                    A comprehensive network diagram is worth 10,000 words and 15 conference calls.
                    DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
                    Do Not Chat For Help! NO_WAN_EGRESS(TM)

                    1 Reply Last reply Reply Quote 0
                    • D
                      dpa
                      last edited by

                      @DanieleIT:

                      Ciao,

                      Here's my contribution for printing captive portal's vouchers using templates.
                      The code is based on the work by Reward Gagarin (https://forum.pfsense.org/index.php?topic=100925.0)

                      Features:

                      • Print icon in the voucher rolls grid.
                      • Options to modify the text of the vouchers: Voucher title, voucher info and the possibility to overwrite the voucher duration with a custom text.
                      • Option to print only non-expired vouchers.
                      • Options are saved in a config file.
                      • Fixed a bug on the original code where the duration of the vouchers were always "expired".
                      • Html+css template using divs with 21 vouchers per page. (using page-break-before, divs are never printed across pages. Tested with Chrome only).

                      In the ZIP file a readme file on how to install the code!

                      As this is a first release and I'm not mainly a PHP programmer, let me know if you find something strange.
                      Hope this helps,

                      Daniele

                      Thanks for improving it! Good job.

                      kind regards,

                      1 Reply Last reply Reply Quote 0
                      • J
                        jassrahal
                        last edited by

                        One question, will the previous issued vouchers work once I replace the files with yours?

                        1 Reply Last reply Reply Quote 0
                        • D
                          DanieleIT
                          last edited by

                          @jassrahal:

                          One question, will the previous issued vouchers work once I replace the files with yours?

                          Yes. This is just a mod to print vouchers. It doesn't interact with vouchers in any other way.

                          1 Reply Last reply Reply Quote 0
                          • D
                            DanieleIT
                            last edited by

                            @Derelict:

                            I would suggest adding an expiration date, which would be the date on which you can delete the roll.

                            Hi this would be a good idea! I'll do that as soon as I find some spare time.
                            In the meanwhile people can use the "Voucher Info" text. By editing the CSS it can easily go 2 lines.

                            Thanks!

                            1 Reply Last reply Reply Quote 0
                            • R
                              redeyes
                              last edited by

                              If possible can you update it for pfSense 2.3  ?

                              1 Reply Last reply Reply Quote 0
                              • D
                                DanieleIT
                                last edited by

                                @redeyes:

                                If possible can you update it for pfSense 2.3  ?

                                Yes, I'v uploaded today the 2.3! let me know if you find any issue!

                                1 Reply Last reply Reply Quote 0
                                • R
                                  redeyes
                                  last edited by

                                  Thanks mate. You're a STAR  :)

                                  1 Reply Last reply Reply Quote 0
                                  • M
                                    misterpat
                                    last edited by

                                    This is great! Any way to make this a package we can install so when we upgrade it will be reinstalled?

                                    1 Reply Last reply Reply Quote 0
                                    • F
                                      fr0t
                                      last edited by

                                      Hi,

                                      Few posts ago I asked about barcode, would it be something nearly impossible to do? I didn't install it yet because voucher w/o barcode can't be used in our site and my second question is - how is the template format like? Is it something I could re-design and try to put barcode myself?

                                      Thanks!

                                      1 Reply Last reply Reply Quote 0
                                      • F
                                        fr0t
                                        last edited by

                                        @fr0t:

                                        Hi,

                                        Few posts ago I asked about barcode, would it be something nearly impossible to do? I didn't install it yet because voucher w/o barcode can't be used in our site and my second question is - how is the template format like? Is it something I could re-design and try to put barcode myself?

                                        Thanks!

                                        Never mind, I have just installed another instance of pfs on another VM box and have seen how it works, it looks like bit complicated and I believe I would probably have to redesign template after every single update if I am right ?!

                                        So I decided to write my own application using Lazarus - it just require to import .csv file with vouchers and choose template with indyvidual information of each roll like valid for xxx minutes/weeks or months, barcode type, logo, place name etc. It has its own build in designer so to change anything in the template require just quick learn (intuitively easy) how it works and thats it.

                                        Its in quite raw format yet but if I see someone interested I can share my app once I finish it.

                                        1 Reply Last reply Reply Quote 0
                                        • D
                                          DanieleIT
                                          last edited by

                                          @fr0t:

                                          Hi,

                                          Few posts ago I asked about barcode, would it be something nearly impossible to do? I didn't install it yet because voucher w/o barcode can't be used in our site and my second question is - how is the template format like? Is it something I could re-design and try to put barcode myself?

                                          Thanks!

                                          Sorry I didn't have the time to look about barcodes generation!
                                          I've checked today, and there are a few nice jquery libraries for barcode generation.

                                          Please check this Fiddle I've created to see how it works:
                                          http://jsfiddle.net/Idioblast/3j1mnwe3/

                                          Basically, from the actual code you just jave to link the needed .js files (both jquery and barcode) and add a(with relative CSS).

                                          Then, and at the end of the page this code:

                                          
                                          $('.barcode').each(function() {
                                              var $this = $(this);
                                              $this.barcode(
                                                   $this.siblings('.vcode').text(),
                                                  'code128',
                                                  {barWidth:1, barHeight:30, output: 'css'} 
                                              );
                                          });
                                          
                                          

                                          This cycles every .barcode div and looks for the code in the .vcode div and creates a code128 barcode.
                                          You can play with the options but it should work fine.

                                          Let me know
                                          Ciao

                                          1 Reply Last reply Reply Quote 0
                                          • I
                                            ikkuranus
                                            last edited by

                                            I have added some permissions so people with more limited accounts can print out vouchers without having full access to the webui

                                            compatible with 2.3.x not sure about older versions
                                            unzip the following file into /etc/inc/priv/

                                            @DanieleIT feel free to add this as part of the package.

                                            portalprint.priv.inc.zip

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.