Simple Invoices logo
    • CommentAuthorseesaw
    • CommentTimeFeb 2nd 2008 edited
     permalink
    Is it possible to place a query in the template to check if a payment has been received for the invoice and if so change the background image to something like this.

    • CommentAuthorseesaw
    • CommentTimeFeb 3rd 2008 edited
     permalink
    I added the following code to template.tpl but it didn't work, any ideas anyone?

    <?php

    if ($invoice.owing == 0.00)
    $bgimg = "paid.gif";
    else
    $bgimg = "";
    ?>
    <body background:url("$bgimg");
    background-repeat:no-repeat; background-position:center; background-attachment:fixed;
    • CommentAuthorjustin
    • CommentTimeFeb 4th 2008 edited
     permalink
    hey

    in the .tpl files you need to use the smarty php syntax

    ie
    {php}
    if ($invoice.owing == 0.00)
    $bgimg = "paid.gif";
    else
    $bgimg = "";
    {/php}


    have not tested the above but something similar should work

    Cheers

    Justin
    • CommentAuthorseesaw
    • CommentTimeMar 30th 2008 edited
     permalink
    Finally got it worked out.

    For anyone who would like this feature

    Save the paid.gif file above to your server and edit the path in the code below.

    Then edit your style.css file and add the following:-

    [code].rec {background-image:

    url("path-to-paid.gif"); background-repeat: no-repeat;

    background-position: 50% 20%; }[/code]



    Now edit your template.tpl file and add the following:-

    [code]{if $invoice.owing == 0 }<div class="rec">{/if}[/code]

    Hope this can be of use to someone else, I think it adds a nice touch and customers can tell at a glance that the invoice is paid.


    Regards
    Chris
    • CommentAuthorseesaw
    • CommentTimeMar 30th 2008 edited
     permalink
    It adds the stamp to all receipts/invoices or quotes that have a zero amount owing.

    This could be taken a step further with stamps for "Overdue" - "Now Due" etc.
    • CommentAuthorsgrayban
    • CommentTimeMar 30th 2008 edited
     permalink
    [quote=seesaw]
    Finally got it worked out.

    For anyone who would like this feature

    Save the paid.gif file above to your server and edit the path in the code below.

    Then edit your style.css file and add the following:-

    [code].rec {background-image:

    url("path-to-paid.gif"); background-repeat: no-repeat;

    background-position: 50% 20%; }[/code]



    Now edit your template.tpl file and add the following:-

    [code]{if $invoice.owing == 0 }<div class="rec">{/if}[/code]

    Hope this can be of use to someone else, I think it adds a nice touch and customers can tell at a glance that the invoice is paid.


    Regards
    Chris
    [/quote]

    Add this were? I tried and nothing showed up.
    • CommentAuthorjustin
    • CommentTimeMar 30th 2008 edited
     permalink
    did you create a file for the paid symbol?

    if so you just got to make sure you put in the correct path in url("path-to-paid.gif");

    also try using firebug in firefox to debug issue - most likely a path issue

    let us know how you go

    Cheers

    Justin
    • CommentAuthorsgrayban
    • CommentTimeMar 30th 2008 edited
     permalink
    more specific -- which template.tpl -- there are a few. And the image path is correct.
    • CommentAuthorjustin
    • CommentTimeMar 30th 2008 edited
     permalink
    if your using the default invoice template then its templates/invoices/default/template.tpl

    cheers

    justin
    • CommentAuthorsgrayban
    • CommentTimeMar 30th 2008 edited
     permalink
    ok tried that one - no go
    • CommentAuthorjustin
    • CommentTimeMar 30th 2008 edited
     permalink
    hmm

    i haven't actually tried this mod so not 100% sure

    Chris, can you lend a hand with this one?

    Cheers

    Justin
    • CommentAuthorseesaw
    • CommentTimeMar 31st 2008 edited
     permalink
    [quote=sgrayban]
    more specific -- which template.tpl -- there are a few. And the image path is correct.
    [/quote]

    I'm using a custom invoice template which is a slightly modded copy of default.

    I put the

    [code]{if $invoice.owing == 0 }<div class="rec">{/if}[/code]

    after the summary section.


    In your style.css make sure you have the DOT before REC like this[code].rec[/code]

    Make sure you're using the style.css and template.tpl from the same template folder - sorry if it's stating the obvious :roll:

    Try viewing your image path in a browser - my image is in the root of my public_html and the path is the full url.

    I'm also using Firefox. I just tried using IETab and it works fine.

    Make sure that your invoice has nothing owing - it won't display the stamp if it has an amount owing. :shock:

    Chris
    • CommentAuthorsgrayban
    • CommentTimeMar 31st 2008 edited
     permalink
    Ok to point out a few things in hopes that you don't take them wrong.

    First you don't have a closing [code]</div>[/code] which breaks html code.

    Second as a coder of many years you don't give arbitrary patch code and not give any instructions. For instance a normal patch file ends in .diff and contains special codes that tell patch what lines to look for. If it didn't have that then patch would fail.

    So if you are going to offer a custom hack likes this it is better to write it up so that even the most basic newbie could follow them.

    Now after numerous times of trying to get this to work it still doesn't and I am no newbie at php or smarty code. So I have to say this hack is worthless without more info.

    Sorry if that hurts your feelings but I am looking out for the next person that comes along and tries this out and has the same issues.
    • CommentAuthorsgrayban
    • CommentTimeMar 31st 2008 edited
     permalink
    OK using the default template this is what I did to get this working.

    Edit [b]templates/invoices/default/template.tpl[/b]

    change your [code]<body>[/code] tag to

    [code]
    {if $invoice.owing == 0.00 }
    <body class="rec">
    {else}
    <body>
    {/if}
    [/code]

    The add the style sheet code:
    [code]
    .rec {
    background-image: url("/url-path-to/paid.gif");
    background-repeat: no-repeat;
    background-position: 50% 20%;
    }
    [/code]

    To [b]templates/invoices/default/style.css[/b]

    You will see this if you click on "[b]Print Preview[/b]" in the top menu bar for the paid invoice you are viewing.
    • CommentAuthorsgrayban
    • CommentTimeMar 31st 2008 edited
     permalink
    It will also show up in any exported document as well so that you or your client won't try to re-pay it again.
    • CommentAuthorseesaw
    • CommentTimeMar 31st 2008 edited
     permalink
    Scott

    Sorry if the instructions weren't set out properly, but I am a complete newbie to coding (this is the first time I have used PHP/Smarty) and I've only just got this to work myself after 2 months of trying diferent things. As far as I was concerned, the only additions I made to make this work looked pretty straight-forward just as I posted them.

    I certainly haven't taken it the wrong way, but it might be worth getting an overview of the skill level involved before you make judgments.

    I wouldn't know where to start when it comes to "writing up a patch", I just posted something that I thought others might be able to use - after all of the work I put into it.

    Chris
    • CommentAuthorsgrayban
    • CommentTimeMar 31st 2008 edited
     permalink
    Like I said -- I didn't want you to take it wrong. I have no idea what your skills are, that's why I pointed out what needed to be done.

    It's all good :) No worries mate.

    BTW nice hack too.
    • CommentAuthorseesaw
    • CommentTimeMar 31st 2008 edited
     permalink
    I didn't take it wrong, just don't have much of a clue as to what I'm doing.

    Thanks for alterations, can't understand why it worked for me but not you. Whatever makes it more accessible to everyone is all good.

    Chris
    • CommentAuthorjustin
    • CommentTimeApr 1st 2008 edited
     permalink
    Thanks guys for getting this sorted out

    one thing to note: when you export to xls/doc it uses the 'export' template rather than the default one

    reason : images and css stuff doesn't come through into excel/word so using a very basic template for all xls/doc requests

    Cheers

    Justin
    • CommentAuthorsgrayban
    • CommentTimeApr 1st 2008 edited
     permalink
    Ahh ok -- the doc and ods I never checked but it does show up in the PDF out put.

    I'll work out a hack for the doc and ods then.
    • CommentAuthorjustin
    • CommentTimeApr 1st 2008 edited
     permalink
    maybe just print in bold up the top PAID or similar
    • CommentAuthorsgrayban
    • CommentTimeApr 1st 2008 edited
     permalink
    Yes that is what I was thinking.
    • CommentAuthorseesaw
    • CommentTimeApr 11th 2008 edited
     permalink
    Just a quick note to add to this.

    If you print from IE and want the Paid Stamp printed too, you ned to turn on Background Printing. Go to Tools - Internet Options - Advanced - Print background colors and images.

    In Firefox, goto File - Page Setup - Print Background (Colors and images)
    • CommentAuthorjustin
    • CommentTimeApr 12th 2008 edited
     permalink
    Thanks Chris,

    been wondering how to enable background printing

    Cheers

    Justin