Forms and Templates

Print forms for invoices, orders, quotations and financial reports can be customized by you by editing form templates. There are three type of templates:

Type 1: HTML Templates

HTML templates are easier to modify because it of wide spread knowledge of html. Only basic html knowledge is required to edit html templates.

Attach:templates1.jpg

Type 2: Latex Templates

Latex templates are bit complex to understand and modify but offer complete control over printed invoice, order or quotation forms. See below for basic introduction to latex.

Attach:templates3.jpg

Type 3: Text Templates. Used only with Point-of-Sale interface

Text templates are used only for Point-of-Sale receipts printing. These templates allow you to print on 40 character receipt printers.

Attach:templates4.jpg

1. Editing Templates

Templates can be edit through sql-ledger. When you click on a template, it is displayed with 'Edit' button at the end of the template. Clicking the 'Edit' button will open the template in a text box where it can be edited and saved.

Attach:templates2.jpg

2. Template Variables

Sql-ledger replaces actual data into templates using variables which we call template variables. Template variables are enclosed within <% and %>.

Here are some template variables to give you an idea of these:

<%name%>
<%address1%>
<%address2%>
<%city%>
<%state%>
<%zipcode%>
<%country%>
<%contact%>

<%invnumber%>
<%invdate%>
<%duedate%>
<%ordnumber%>
<%employee%>
<%shippingpoint%>
<%shipvia%>

<%runningnumber%>
<%number%>
<%description%>
<%deliverydate%>
<%qty%>
<%unit%>
<%sellprice%>
<%discountrate%>
<%linetotal%>

The best way to view all these template variables and understand their usage is by going through existing templates.

3. Template Control Structure

Template processing engine in sql-ledger allows simple if statement and loops. Example of these are described below:

* 'if' conditions to print a column data conditionally:

          <%if contact%>
          <br><%contact%>
          <br>
          <%end contact%>

          <%if taxincluded%>
          <th colspan=7 align=right>Total</th>
          <td colspan=2 align=right><%invtotal%></td>
          <%end taxincluded%>

          <%if not taxincluded%>
          <th colspan=7 align=right>Subtotal</th>
          <td colspan=2 align=right><%subtotal%></td>
          <%end taxincluded%>

        <%if paid%>
        <tr>
          <th colspan=7 align=right>Paid</th>
          <td colspan=2 align=right>- <%paid%></td>
        </tr>
        <%end paid%>
  • 'for' loop to print all lines on an invoice:
        <%foreach number%>
        <tr valign=top>
          <td align=right><%runningnumber%>.</td>
          <td><%number%></td>
          <td><%description%></td>
          <td><%deliverydate%></td>
          <td align=right><%qty%></td>
          <td><%unit%></td>
          <td align=right><%sellprice%></td>
          <td align=right><%discountrate%></td>
          <td align=right><%linetotal%></td>
        </tr>
        <%end number%>

        <%foreach tax%>
        <tr>
          <th colspan=7 align=right><%taxdescription%> on <%taxbase%> @ <%taxrate%> %</th>
          <td colspan=2 align=right><%tax%></td>
        </tr>
        <%end tax%>

4. An Introduction to Latex

Latex is a complete collection of software tools to create high quaility print documents. Latex templates are used in SQL-Ledger to create high quality print forms like invoices, purhcase orders etc.

Latex is included with Redhat distributions (rpm -qa | grep tetex). For FreeBSD, you can install the teTex port from /usr/ports/print/teTeX.

Latex migh seem overwhelming to a new comer but it is really a simple toolkit to use for customizing the SQL-Ledger templates. In this very short introduction of Latex, we shall go through the basic document format and its use in SQL-Ledger.

Hello world!

1. Create a text file (hello.tex) in your home folder with following text:

    \documentclass[a4paper,11pt]{article}
    \begin{document}
    Hello world!
    \end{document}

2. Compile this tex file into dvi file and use xdvi to view it:

    latex hello.tex
    xdvi hello.dvi
You can also convert it to pdf:
    pdflatex hello.tex
    xpdf hello.pdf

Structure of a Latex Document

Latex commands start with a backslash (\). Parameters can follow the command. Optional parameters are enclosed in [] while mandatory ones are enclosed in {}. {} can also be used to terminated a command mixed within some text (to make it easier to understand the command for the compiler). Special characters in latex (#, $, %, ^, &, _, {, }, ~) are escaped with \ except for the \ character itself (because
is used to break a line). To use literal backslash (\) use can use special command $\backslash$.

Single line comments start with % while multi-line comments can be enclosed between \begin{comment} and \end{comment} structure.

Every latex document starts with \documentclass with parameters ([a4paper,11pt]{article}) following it

 
forms.txt · Last modified: 2010/05/06 12:05 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki