409 posts
  • Has been part of the Envato Community for over 4 years
  • Sells items exclusively on Envato Market
  • Located in India
Dhruv says

Hello,

I am writing a invoice script, but don’t know how to go about this.

I have two tables i..e “invoice” and “invoice_items”

Here’s the table structure for invoice_items with demo content

id | invoiceid | title | qty | amount

1 | 1 | this is a new invoice item | 2 | 299

2 | 1 | this is another item | 1 | 399

3 | 1 | this is another item for invoice 1 | 1 | 600

4 | 2 | invoice 2 item | 1 | 600

What i want to do is

1. display all the invoice items related to invoiceid 1 – DONE

2. display total price for each invoice item (qty * amount) – DONE

3. Display grand total : i don’t know how to do this…(ran our of ideas)

So, can anyone help me out and guide me in the right direction??

186 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
Artillegence says

I suggest you to first learn php and MySql , you can find good tutorials of nettuts :)

409 posts
  • Has been part of the Envato Community for over 4 years
  • Sells items exclusively on Envato Market
  • Located in India
Dhruv says

Well, i know both php and mysql, i just don’t know how to go about this..,

I mean first i have to loop through all invoice_items table, after that i have to select invoice_items with invoiceid 1, after doing this i have to multiply amount with qty and then display all these data

At the end, i have to add all the amount i..e total price (in this case 3) and display it as grand total.

BTW , I know i can / will find goood tutorials at nettuts :D

409 posts
  • Has been part of the Envato Community for over 4 years
  • Sells items exclusively on Envato Market
  • Located in India
Dhruv says

@5thSenseLabs

I see you are releasing an Invoice Management Application by next week,

Even i am planning to launch my Application by next week (max 2 weeks), so you can be sure of some competition :) (atleast a little.)

186 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
Artillegence says

I hav been working on my application for 3 weeks now, should be releasing this weekend.. :P .. as far as the table is concerned, I think you are confused about how to work with invoice items in the table, for that just create a column invoice_item add the items separated by example comma, use php explode function to work with them… no need for 2 tables

409 posts
  • Has been part of the Envato Community for over 4 years
  • Sells items exclusively on Envato Market
  • Located in India
Dhruv says

This is exactly(sort of) what i was looking for earlier.., but i will use it now.

Can you post some screenshots or demo of your app??? :D

186 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
Artillegence says

sure here it is … http://twitpic.com/25utz5 , it has invoice, client, project, estimate and events management 8-)

409 posts
  • Has been part of the Envato Community for over 4 years
  • Sells items exclusively on Envato Market
  • Located in India
Dhruv says

Looks Great. Have you made use of jquery/ajax or not?

499 posts
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
  • Located in Canada
+2 more
TutelageSystems says
I hav been working on my application for 3 weeks now, should be releasing this weekend.. :P .. as far as the table is concerned, I think you are confused about how to work with invoice items in the table, for that just create a column invoice_item add the items separated by example comma, use php explode function to work with them… no need for 2 tables

Or instead of explode you could also use serialize / unserialize.

Not to take over the thread or anything have either of you checked out Invoice Bubble?

Back on track, so you say you have two tables. You could do this in php or MySQL.

PHP

I haven’t tested this, and it isn’t fully completed or anything but just helping along the tracks.
// grab invoice
$invoice = $Invoices->get(1);  // Invoice Class returns Invoice Information for Invoice 1
$invoice_items = $Invoices->getItems(1); // Same as above
// Both of these return an Array
$grand_total = 0;

foreach($invoice_items as $item)
{
  $grand_total += ($item['qty'] * $item['amount'];)
}
The other way you can do this is using SQL to create a column
select title, qty, amount, (qty * amount) as total from invoice_items where invoiceid = 1
186 posts
  • Has been part of the Envato Community for over 4 years
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
Artillegence says

@dhruv yup jQuery interface ... and @TutelageSystems serialize is also a good solution nice one buddy ;) , not much of use in my app so didnt mentioned it :P

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by