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-->