CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Implementing Invoice

Print topic Send  topic

Author Message
ruhtra


Posts: 30
Posted: 04/22/2010, 8:41 PM

I have an invoice working as desktop application. I need to develop web Invoice now and it should look as much the same as desktop screen as possible. That means, I would like the see all 3 sections in place: Header (with Vendor and customer Info), Items, Footer (with totals). I did some testing but wasn't very succesful. My majo problem seem to be updating Invoice Header information, which holds a Vendor info, as well as InvoiceTotal, and the first should be places on top, while the second after InvoiceItems, and I do not see how can I have this done.

I know, by hand coding everything is possible, however I'm just a beginer with PHP, so I cannot do really advanced coding (at least for now).

What is the best method to implement it ?

Arthur
View profile  Send private message
andy


Posts: 183
Posted: 04/23/2010, 4:29 AM

The difficulty you will come up against is that it is very difficult to submit multiple forms/editable grids on one page in series.
When you update your invoice you want to ensure that the invoice header, line items and totals are all updated together.
What you can do is have the invoice header record as an editable record form.
Have the line items in a read-only report with edit... and new... links to a separate page for editing the line items, which in turn returns the user with the updated line item values to the calling page.
You can do your aggregation of totals in the footer band of the grid.
That is my recommendation (after a lot of experimenting in this field).

Otherwise you will have to do a lot of custom coding using ajax dbupdate and you are likely to run into a lot of problems with validation, synching and page refreshes. Save yourself the hastle.

If you keep one page per editable form (but add as many read-only grids/reports with links to their own edit pages), you will play to the strengths of CodeCharge Studio and be able to take advantage of all of its validation and scripting options.

Good luck
_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
ruhtra


Posts: 30
Posted: 04/23/2010, 6:20 AM

that makes sense, but there are few places I still don't know how to resolve.First question is how to split InvoiceHeader so I can have top portion with fields for CustomerName etc. on the top, then have the other portion (ie. InvoiceTotal, Tax etc.) on the bottom, below InvoiceDetail lines ? Of course those Totals are calculated based on InvoiceDetail lines so no user entry is necessary ).
Is there any working example available how to do this ?

Thanks - Arthur
View profile  Send private message
Waspman

Posts: 948
Posted: 04/23/2010, 8:15 AM

Are reports no good for this?
_________________
http://www.waspmedia.co.uk
View profile  Send private message
Waspman

Posts: 948
Posted: 04/23/2010, 8:18 AM

So are you entering the data into the invoice on screen?

or are you simply building the invoice from data already entered?


_________________
http://www.waspmedia.co.uk
View profile  Send private message
ruhtra


Posts: 30
Posted: 04/23/2010, 8:59 AM

to wnswer this I have to say both cases are true, but for now I need to create a full invoice either through deskop OR/AND web application. Desktop application is pretty much set up, so the dB structure is (tough I can made adjustments if necessary). I haven't tried anything with the reports yet (I though reports are read only and if so how can I edit InvoiceItems?).

Arthur
View profile  Send private message
ruhtra


Posts: 30
Posted: 04/23/2010, 9:01 AM

still asking for an examples..
Arthur
View profile  Send private message
Waspman

Posts: 948
Posted: 04/23/2010, 9:07 AM

so you want add data directly to the invoice on screen in the correct layout?
_________________
http://www.waspmedia.co.uk
View profile  Send private message
Waspman

Posts: 948
Posted: 04/23/2010, 9:16 AM

I'd do it in stages - enter customer details move on - enter items move on etc. Then at the end you can present the invoice as a pdf to print etc.

You create a unique ID to start with set to a session and pass it on. You create a nice progress bar that you can use to navigate back to the previous elements if you want to change them etc.

The main thing will be your db scheme - Invoice log - Customer details - whether you will call the items from another table or add them at build time etc
_________________
http://www.waspmedia.co.uk
View profile  Send private message
Waspman

Posts: 948
Posted: 04/23/2010, 9:36 AM

Use panels and the stages can be on the same page?
_________________
http://www.waspmedia.co.uk
View profile  Send private message
ruhtra


Posts: 30
Posted: 04/23/2010, 11:52 AM

are you talking about Panels or Tabs ?
any examples ?
View profile  Send private message
GeorgeS

Posts: 206
Posted: 04/23/2010, 12:07 PM

Arthur,
what you are intending to do may not be a simple task of creating a couple of pages with some coding.

I just finished a PHP website for reselling electronic RF components with the whole admin section for processing RFQs and Orders from customers, Quotations from vendors, combining them into Quotes for customers, generating HTML and PDF Quotes for emailing, Converting them into Purchase Orders and Invoices (PDF & HTML) with flexible discounts or markups.

If you need a really helpful advice or even if you'd want to hire some programmers here to help you started you must create a very detailed and illustrated Work-flow description of the whole process.

Without it it would be very hard to point you to the right direction.



_________________
GeorgeS
View profile  Send private message
robertmann

Posts: 109
Posted: 04/23/2010, 12:21 PM

I think the ReportBuilder should do this and CCS includes some examples.
_________________
Robert
View profile  Send private message
robertmann

Posts: 109
Posted: 04/23/2010, 12:25 PM

http://examples.codecharge.com/

Order Detail Report example
Simple Report example
And Timesheet Report example with complex calculations

_________________
Robert
View profile  Send private message
Waspman

Posts: 948
Posted: 04/23/2010, 12:29 PM

Quote ruhtra:
are you talking about Panels or Tabs ?
any examples ?


Panels, but like I said it doesn't have to be if you prefer separate pages.

There are loads of ways to solve this issue. You must be clear about what you want and how you want to achieve it. However, I find it better not to think in 2D terms, just cos you fill in an invoice in a paper format doesn't mean it has to like that in your app.

This is a very simple job in CCS you just gota think outside the box. If you need any help let me know ;-)
_________________
http://www.waspmedia.co.uk
View profile  Send private message
ruhtra


Posts: 30
Posted: 04/26/2010, 5:43 PM

ok, so far no one has answered the part of my question asking about Invoice footer. I would like to present Invoice totals at the bottom (or if not possible on another Tab). How would I advance user to the NEXT Tab (i.e. by clicking NEXT button) ??

I'm trying to figure out the proces flow here so let's see if I understand it correctly (because I see it must be handled completely differend from what I developed for the desktop app).

PAGE-1
1. I have a header with rhe RECORD type form to enter Vendor info, InvoiceNumber etc
2. Once this is entered user submits for by clicking INSERT button and then is returned to the same page
3. On this same page I place a REPORT GRID which displays the items for the invoice, Here the query must select all records from the InvoiceItems WHERE InvoiceHeader.InvoiceID=InvoiceItem.InvoiceID
4. On this same REPORT GRID I change one of the coluns to LINK type and call InvoiceItem_Maint (PAGE-2) passing InvoiceHeader.InvoiceID as parameter

PAGE-2
5. Upon opening (BeforeShow event) I assign

InvoiceItem.InvoiceID=InvoiceHeader.InvoiceID
then user fill the blanks and clicks INSERT item

6. User is eturned to the PAGE-1 (which shows 1 item added)

Now in this scenario several questions arrise:
- after all InvoiceItems are added, I need to have a button to store InvoiceTotals, so how would I handle that ?
- because InvoiceID is autoincremented its value is saved when I save the form, so I do I pass this value to InvoiceItem.InvoiceID (when adding new record) ?


Arthur



View profile  Send private message
Waspman

Posts: 948
Posted: 04/27/2010, 12:36 AM

Not sure about your method but I’ll have a stab at the logic

So you want the page in three sections

Header? – the area where you enter the vendor info

The body – the area where you add the items

The footer – where you add it all up?


So your header is a record form for your vendor data but you must create the invoiceID, there’s some nice functions on here to do that. Once created save it as a session variable.

The body is an editable grid(?) where you can add all your items(?) and as you submit this form you can add the invoiceID from the session. In the before show of this form you can save the various numeric fields to session variables which you then show, and use to calculate values for labels in the footer.
I would also use a custom SQL script to store/update the totals in the master Invoice record, if needed?


Am I close?


Personally I’d select the vendor from previously entered data and the items would be also be drawn from an existing table where I could add all the stuff like cost and tax etc
:-) :-)
_________________
http://www.waspmedia.co.uk
View profile  Send private message
andy


Posts: 183
Posted: 04/27/2010, 6:00 AM

Hi Arthur

You've pretty much got the work flow from your last post.
One change I would make would be to create an invoice_new page and an invoice_edit page.
Invoice_new just has invoice header record and is Insert only (NOT update or delete)
Invoice_edit has invoice header record (no insert, but update and delete form actions) and below that your report WHERE InvoiceHeader.InvoiceID=InvoiceItem.InvoiceID

At the foot of your report you can aggregate totals (total invoice amount) and Total sales tax/vat etc. but of course these values are created on the fly and are not stored.

To answer your last questions:
Quote :
Now in this scenario several questions arrise:
- after all InvoiceItems are added, I need to have a button to store InvoiceTotals, so how would I handle that ?
- because InvoiceID is autoincremented its value is saved when I save the form, so I do I pass this value to InvoiceItem.InvoiceID (when adding new record) ?

On the invoice header Record AfterUpdate event, include custom code to total all amounts in the related invoice line items and write them to a field either in your invoice header (e.g. NetTotal) or to write the totals to a separate table (depends on your db structure).
Alternatively, assuming you have say a NetTotal field in your invoice header table, include this NetTotal field in your Invoice Record form and do the custom code totalling of related invoice lineitem totals in the Record's BeforeShow event. So when the page opens it adds up the totals and aggregates them for you on your form. SImilarly when you return from editing a lineitem, it magically updates the NetTotal.

In response to your second question, in the Invoice Record's BeforeShow event get the invoiceID and pass it to a session variable.
Then when you open your invoiceItem form to insert a new record set the default value of the InvoiceItem.invoiceID (foreign key) to the session variable. Tada!

If you want any help with code examples, give me a shout.
_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
ruhtra


Posts: 30
Posted: 04/27/2010, 7:24 AM

Quote :
In response to your second question, in the Invoice Record's BeforeShow event get the invoiceID and pass it to a session variable.
Then when you open your invoiceItem form to insert a new record set the default value of the InvoiceItem.invoiceID (foreign key) to the session variable. Tada!

If you want any help with code examples, give me a shout.

this sounds right for editing existing Invoice, but when I add NewInvoice this might not work simply because BeforeShow Event doesn;t have the Invoice number until you save it, so my question was pretty much related to adding new Invoice (not editing existing one).

Arthur
View profile  Send private message
Waspman

Posts: 948
Posted: 04/27/2010, 8:21 AM

I wouldn't rely on the autonumber, create your own ID?
_________________
http://www.waspmedia.co.uk
View profile  Send private message
andy


Posts: 183
Posted: 04/27/2010, 8:58 AM

When you create a new invoice send the user to the invoice_new page which only contains the invoice header Record (insert only allowed).
When the user has entered all the invoice header information and submits the record, the primary key, unique, autoincrement value is automatically created at database level.
Then redirect the user to the invoice_edit page containing the above invoice header record AND the report/grid/editable grid with the invoice line items.

To redirect the user using the correct newly added primary key use something along the lines of the following code in the Record's AfterInsert event:

global $DBConnection1;    
global $Redirect;    
  
//If new record, get the latest id and redirect using this id in the url  
if (!CCGetFromGet("invoice_id",0)) {      
     $LastID = CCDLookUp("last_insert_id()","invoice","",$DBConnection1);      
	 CCSetSession("session_invoice_id", $LastID);   
     if (strpos($Redirect,"?") == false ) {      
        $Redirect = $Redirect."?invoice_id=".$LastID;      
     } else if (substr($Redirect,-1) == "?" ) {      
         $Redirect = $Redirect."invoice_id=".$LastID;      
         } else {      
           $Redirect = $Redirect."&invoice_id=".$LastID;      
        }      
  }     

Hope that helps
_________________
Andy

RAD tools for rich UI controls:
http://www.koolphptools.com
View profile  Send private message
Waspman

Posts: 948
Posted: 04/27/2010, 9:11 AM

Last_insert ID? - Only one user at a time then?
_________________
http://www.waspmedia.co.uk
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.