0

I am working on an ordering system for my company utilizing Open Cart.
Everything is being done in PHP and HTML.

I am trying to modify the invoice page to include a signature line at the bottom of the printed invoice. Invoices can stretch to multiple pages depending on the number of lines/items, and they can also be batched so that one document to be printed has multiple invoices (using a loop). I am not a web developer, and have hit the end of my abilities to get this part of the project done. Please give me pointers or pseudo code samples.

Footer Code:

<style type="text/css">
    .picklistCheck{
        width:15px;
        height:15px;
        border:1px solid #c7c7c7;
        margin:0 auto;
        border-radius:2px;
        box-shadow:inset 0px 0px 2px rgba(0,0,0,0.1);
        font-size:14pt;
    }
    .signature{
        border-bottom-style:solid;
        font-size:14pt;
        page-break-after:always;
    }
    td{
        font-size:14pt;
    }
</style>

<?php
    foreach ($orders as $order) {
        ?>
        //<div>orders go here </div>
        <?php
    }
    include ("footer.php");
?>
DavChana
  • 1,944
  • 17
  • 34
Bagellord
  • 43
  • 2
  • 8

3 Answers3

4

Every time your logic decides to put a page break in the invoice, tell it to insert the following code also:

<?php include ("footer.php"); ?>

Create a footer.php file with the simple html you want to place in the footer. The above code assumes that your script and footer.php are in same directory.

EDIT: To answer your comment,

The Include PHP.net will behave exactly like you actually copy-pasted all the code directly instead of including it. But every include file should have its own <?php ?> tags where-ever required. Without <?php ?> tags, Control will just output whatever it sees there.

Footer.php can be a simple HTML-only file:

<div id="footer">
    Company XYZ (c)2000-2012 All Copyrights Reserved
    Some other footer text.
</div>

You could also name it footer.html, but if later, in future, you decide to put some dynamic data in footer, it will be very difficult to change .html to .php in all include lines written in various files.

Example of Dynamic Footer:

<div id="footer">
    Company XYZ (c)2000-2012 All Copyrights Reserved
    <?php echo $who_printed." ".$who_authorized; ?>
</div>

Of course it is just a simple example.

In a html page, you could force a div by using the following CSS code in an external linked .css file:

#footer{
text-align: right;
height: 20px;
position:fixed;
margin:0px;
bottom:0px;
}

position:fixed; & bottom:0px; is here doing the trick. It is forcing this "footer" div to stick to bottom always, even if page is scrolled or something. Like the way Facebook sticks its header menu to top & chat bar to bottom. You can also define left, right properties

Update: Ok, based on your comments, here is the sample code:

In CSS Style section, use:

.signature{
    border-bottom-style:solid;
    font-size:14pt;
    page-break-after:always;

    text-align: center;
    height: 20px;
    width: 100%;
    margin:0px auto;
    position:fixed;
    bottom:0px;
}

All properties are self-explanatory. Text-align makes the text center-aligned. Width is making this div .signature 100% wide on page. It is required to put the div with equal margins on both sides. Margin is saying put 0px margin on top & bottom sides and auto on both left & right side. Position makes it fixed on viewport/page. Bottom says keep 0px from bottom.

In body of page, use this code:

<?php
    foreach ($orders as $order) {
        ?>
        //<div class="order">order1 go here </div>
        //<div class="order">order2 go here </div>
        //<div class="order">order3 go here </div>
        //<div class="order">order4 go here </div>
        <?php
    } // for each ENDS
?>

<div class="signature">
      Authorized by <?php echo $who_authorized; ?> |
      Printed by <?php echo $who_printed; ?>
</div><!--//signature-->

It simply assigns whatever properties you defined in CSS Styling to signature div. Obviously you need to wrap this snippet into your logic, which decides when to echo/introduce the signature div. Also, $who_authorized & $who_printed needs to hold some value.

For any block bigger than 3 lines, I always come out (?>) of PHP parser/control and simply write HTML as desired. Then, when required, I again enter PHP (<?php)

If you want to go with include, you can omit the last 6 lines( starting from ?> & ending with <!--//signature--> from my code and simply put this line there.

include ("footer.php");
?>

This option also requires you to create a file named footer.php in the same directory and insert the following html code in it.

<div class="signature">
      Authorized by <?php echo $who_authorized; ?> |
      Printed by <?php echo $who_printed; ?>
</div><!--//signature-->
DavChana
  • 1,944
  • 17
  • 34
  • How would I need to format the code in footer.php to make it appear at the bottom of the printed page? – Bagellord Jul 09 '12 at 18:24
  • The method you gave me here isn't quite doing what I needed it to do. I can get it to repeat the footer for each invoice, I just can't get it to go on the bottom of the page. I guess I could just cheat and pad it with white space. – Bagellord Jul 09 '12 at 19:42
  • @Bagellord Could you post some relevant code in your question? Then we can find out the problem. – DavChana Jul 09 '12 at 23:01
  • I will in the morning when I get back to the office. – Bagellord Jul 10 '12 at 01:30
  • ` //orders go here ` – Bagellord Jul 10 '12 at 13:39
  • @Bagellord also provide some sample HTML output.. To explain how you use `.picklistCheck`, or `.signature`? – DavChana Jul 10 '12 at 14:11
  • picklistcheck is just a check mark to go on the form. This is actually my picking ticket/picklist code that does basically the same thing as the invoice, just less complicated. signature was just a bit of CSS from me trying on my own to format the signature at the bottom of each list. What would be the best way to show the html output? – Bagellord Jul 10 '12 at 14:37
-1

What format do your invoices have? You should create them as a PDF File to print them out. There you can try to define a footnote - based on the used php pdf library

Florian Brinker
  • 735
  • 7
  • 17
  • 1
    PDF isn't necessary for our purposes. But anyways, the format is customer information at the top and then the line items (goods ordered) and then the total, then white space. I need to place a signature line for who printed and authorized the invoice at the bottom of each invoice. An invoice can easily be more than 1 page as well. – Bagellord Jul 09 '12 at 18:29
-2

Create a footer.php file with the html you want to place in the footer.

Place this code where you want the footer to be placed on the invoice page:

<?php include 'footer.php'?>

To modify the footer, modify footer.php

Max Hudson
  • 9,961
  • 14
  • 57
  • 107
  • If this helps, you will be my new favorite person on the internet. I will test it out and report back. – Bagellord Jul 09 '12 at 13:54
  • 2
    Don't use a short code. Use: To ensure that your code is as future proof as possible. Edit: After reading the full question this won't even work. This solution will put the footer at the end of the webpage, not at the end of each printed page. – WhoaItsAFactorial Jul 09 '12 at 13:59