Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Print form and submit to database at the same time

#1297

Is there a way I can have the user print the data they've entered into a form and at the same time, save that data to the database?

Reported by BJ Kline · June 13th, 2015 @ 12:43 PM

State: new
Milestone: none
Assigned to: dleffler dleffler

Activity

  1. BJ Kline
    BJ Kline

    "We DO provide a view AFTER the user clicks on the 'Submit' button which details all the form entries...this is also the same 'view' an admin can bring up later"

    This is what I want to print. My client doesn't want to go to online ordering yet. So what they've done in the past is have a simple HTML form, but instead of submitting it to a database or email recipient, the end user prints it off and writes their CC info on the printed page and snail mails it to my client.

    I think I need to add an onsubmit to framework/modules/forms/views/forms/confirm_data.tpl line #48 to make this happen?

    June 15th, 2015 @ 05:29 PM

  2. BJ Kline
    BJ Kline

    I tried changing line 48 to this:

    {form onclick="window.print();" action=submit_data}

    But it doesn't bring up the print dialog, the onclick is completely ignored.

    June 17th, 2015 @ 02:34 PM

  3. BJ Kline
    BJ Kline

    I should be able to use that and then create a print stylesheet to only display what I want have the user print.

    June 17th, 2015 @ 06:50 PM

  4. BJ Kline
    BJ Kline

    That code, along with my print style sheet work as long as a user is logged into the site. If not logged in, the print dialog doesn't appear, the form just gets submitted. The page the form is on is set to Public and Active.

    Here is my print stylesheet

    @media print {
        body {
                font-size: 12pt;
                color: #000000;
            }
        #main-menu, #sidebar { 
                display: none;
            }
            
        a.triggerlogin {
                display: none;
            }
        #main { 
                width:100%;
            }
        .print {
                display: block;
                }
        
        .col-xs-6 {
                width: 100%;
                }
        a[href]:after {
        content: none !important;
      }     
        }
    

    June 18th, 2015 @ 12:45 PM

  5. BJ Kline
    BJ Kline

    Adding an id fixed it.

    Here is the working code.

        {form action=submit_data id="orderconf"}
            {foreach from=$postdata item=data key=name}
                {control type=hidden name=$name value=$data}
            {/foreach}
            {control type=antispam}
            {control type=buttongroup submit="Submit Form"|gettext cancel="Change Responses"|gettext}
        {/form}
        
        {script unique=confirm jquery=1}
    {literal}
        $(document).ready(function(){
            $('#orderconf').on('submit', function(e){
                window.print();
            });
        });
    {/literal}
    {/script}
    

    June 18th, 2015 @ 06:25 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.