Home > CodeIgniter, PHP > CodeIgniter Tutorial: [Creating Accounting Application] Part 5 The Mainpage

CodeIgniter Tutorial: [Creating Accounting Application] Part 5 The Mainpage

Well I’m sorry, it’s been so long for this part to come.. I had been working very hard on some clients and don’t have enough time to write. Here’s what I had been done if you’re curious :) : http://maps.GpsTrackingIndonesia.com, www.SunberryCorp.com, www.mypushme.com, www.kulacak.com, www.web2trace.com, www.pushmeportal.com, … The fun is almost all of them was written with CodeIgniter :).

Ok, let’s start with the easiest one first. We will create a simple menu page that contains links to other modules on the system. We put it on the Mainpage controller class.

Look at the Mainpage.php controller file. There is a function on it named exactly the same with the filename: Mainpage(). This should be exactly the same including the case. This is the constructor or initialization function of the class. Each time the class is called or instantiate, this function is called automatically. We put some initialization lines inside it:

function Mainpage() 
{
     parent::Controller()
     $this->load->helper(‘url’);
}

The line parent::Controller() calls the constructor function of this class’s parent constructor which is the CodeIgniter’s Controller class so that it has all the properties and method of it’s parent.

Then, we load a helper library that contains helper functions related to URL handling such as site_url() to return the site’s URL that we are working on. Other functions on this helper are: anchor(), base_url(), uri_string(), etc. You can check it all on the user guide http://localhost/user_guide/helpers/url_helper.html.

Again, look at the Mainpage.php file. We added a new function called index(). This function is analogous to the index.html file in static web page. It’s called by default when we point our browser to the Mainpage controller, ie: http://localhost/index.php/Mainpage.

public function index()
{
    $this->load->view(‘header’);
    $this->load->view("main_menu");
    $this->load->view(‘footer’);
    return;
}

On the function, we load view files. Here we divide the view into 3 pieces: header, main_menu, and footer. They are basically just regular PHP files dealing with display templates. This will make us easier to manage the look of our application later.

All of the view files should be located under system/application/views folder on CodeIgniter file structure. So we need to create all of them:

The header.php view file, contains the opening HTML tags, HEAD, TITLE and start of BODY. Later we can add CSS link definition here:

<p><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<html>  
<head></p><p><title>Cashbook application</title>
</head>
<body>
</p>

 

The footer.php view file, just a closing BODY and HTML tag, but you can later add your copyright notice, timestamps, etc:  

 

</body>
</html>

And the main_menu.php view file. Here we write a list of links to modules that we are going to develop later:

<p><p>Cash Book</p>

<ul>

<li><?=anchor("Cashbook/addNew/receive","Cash Receive Entry")?>  
<li><?=anchor("Cashbook/addNew/out","Cash Out Entry") ?>

<li><?=anchor("Cashbook/viewReport","Cash Book Report")?>  
</ul> </p>
<p><p>Bank Book</p>  
<ul>

<li><?=anchor("Bankbook/addNew/receive","Bank Receive Entry");?>
<li><?=anchor("Bankbook/addNew/out","Bank Out Entry");?>
<li><?=anchor("Bankbook/viewReport","Bank Book Report");?>
</ul> </p>

<p><p>Manual Journal</p>  
<ul>
<li><?=anchor("Journal/addNew","Manual Journal Entry")?>
<li><?=anchor("Journal/viewReport","Manual Journal Report")?>
</ul> </p>
<p><p>Report</p>
<ul>  
<li><?=anchor("Mainpage/trialBalance","Trial Balance")?>

<li><?=anchor("Mainpage/balanceSheet","Balance Sheet")?>  
<li><?=anchor("Mainpage/profitLoss","Profit and Loss")?>

</ul> </p>

<p><p>Posting and COA</p>
<ul>
<li><?=anchor("Mainpage/doPosting","Post transaction")?>
<li><?=anchor("Coa/listCoa","Chart of Account Setting")?>
</ul></p>

As we can see above, we call a helper function anchor(). This function will create a standard HTML anchor link based on your local site URL. So for example, if we call it achor(“Mainpage/trialBalance”, “Trial Balance”) then it will return this string:

<a href=”http://localhost/Mainpage/trialBalance”> Trial Balance </a>

assumed that you have configured your site URL as http://localhost/ on the config.php file.

Now we can run our application by pointing the browser to http://localhost and it should return something like the following:

image

Congratulation!

Next we will begin to code the COA module.

  • Share/Bookmark
  1. Carlos
    May 5th, 2010 at 03:19 | #1

    Nice to see you back!!

    Thankyou :)

  2. Johnny
    May 19th, 2010 at 11:03 | #2

    kapan code the COA modulenya….udah gak sabaran nih….di tunggu ya…thanks u :)

  3. Ali
    May 20th, 2010 at 00:20 | #3

    Amazing…….Great Work….I am waiting for Part – 6….Please post it.I really impressed with your work.My email id is azoocoder@gmail.com.Plz email me ,I want to discuss u some points.

  4. June 2nd, 2010 at 15:51 | #4

    im waiting for your “Part 6 Coding, the and COA Module explain the application coding using CodeIgniter”. when can i expect it from you???

  5. Ali
    June 6th, 2010 at 00:55 | #5

    I m Waiting for Part-6.Please prepare it as soon as possible….I found this series is too informative and interesting.
    Thank you

  6. Azoo
    June 16th, 2010 at 15:10 | #6

    Excellent Work.Please keep it up.I am waiting for NEXT part.Upload it soon plz……..
    Thank u

  7. bembol
    June 22nd, 2010 at 03:41 | #7

    This is the best workflow I have ever seen. I really like the way you present the tutorials. Please upload the 6th part soon. Thank you so much!

  8. fitra
    July 1st, 2010 at 09:56 | #8

    kapan Modul coa nya nich …. please !!!!!!

  9. Azoo
    August 9th, 2010 at 21:35 | #9

    Still waiting for Part-6.Please upload it.

  10. Lee
    August 16th, 2010 at 23:38 | #10

    Great tutorials! I hope your schedule gets a little easier as I am eagerly awaiting the next part.

    I had a small problem with your main_menu.php file. At first none of the bullet points came up, only the menu headings. After a little digging around, I found that you are using short tags on the line items. All I had to do to fix this problem was go into the CI config file and change the line :
    $config['rewrite_short_tags'] = FALSE;
    to true.
    Keep up the great work!

    L

  11. Nuno
    August 25th, 2010 at 00:50 | #11

    Hi

    Fantastic work you’ve got here, really!
    Thanks for the enjoyable moment I had reading your posts.

    Hope you won’t leave this piece of art unfinished… we (the nerds from your fan club)’ll be watching you

    Peace

  12. DawsY
    August 28th, 2010 at 17:53 | #12

    hey should appreciate your work….!
    its all coz of u, noobs lik me can go ahead with CI.
    Thanks a lot for sharin.
    Keep up the good work

  13. August 29th, 2010 at 08:54 | #13

    Dawsy, more than happy I could help. Thanks

  14. August 29th, 2010 at 10:27 | #14

    Hey greetings from Caracas, Venezuela, i’m really enjoying this tutorial, please publish part 6th soon, i’m kind of php geek but i haven’t used a framework before so i want to be a Codeigniter Ninja. Thank you very much indeed. Over and out!
    Current CI level: NOOB

  15. August 29th, 2010 at 12:26 | #15

    Tony, greeting from Bandung, Indonesia! I’m really glad to finish the tutorial, but currently still have not enough time, doing some outsourcing projects. Will start to write it up bye the end of next month. Thanks a lot.

  16. September 26th, 2010 at 21:51 | #16

    Nice tutorials. I’m a CI noob and this tuts helps me alot! Thanks, bro. Still waiting for the next part :-)

  17. Danny
    December 22nd, 2010 at 15:34 | #17

    Impressive

  18. December 27th, 2010 at 07:05 | #18

    thank’s, a nice tutorials… . It’s someting new for me

  19. January 4th, 2011 at 23:13 | #19

    Mhhhhh……… pretty smart. Congrats. if i may request. Y dont u share the final product, coz u seem more busy lately . I realy wud love to see the final product. Being my first in CI.

    thanks.

  20. March 16th, 2011 at 00:46 | #20

    Nice Tutorial. Can I get step by step source code pleas?

    Waiting for next part.

    thanks in advance
    Mojam, WSS

  21. Bryce
    April 4th, 2011 at 17:52 | #21

    Hi

    Thanks os much for this tutorial.

    When will the next step be available?

    Thanks

    Regards
    Bryce

  22. May 4th, 2011 at 16:34 | #22

    I Appreciate your great work

    Please publish rest of the parts

    Thanks

  23. ooaat
    June 16th, 2011 at 16:54 | #23

    Shattered this tutorial has stopped as I really got so excited till i realised it stops here. Anyone completed this. I would love to check it out

  24. Azoo
    September 6th, 2011 at 23:10 | #24

    Please….please upload part 6.

  25. Michael
    January 18th, 2012 at 13:12 | #25

    I’m glad I read this entire article before I wasted my time doing the tutorial. Wouldn’t it be great if this person completed the entire application and then posted it on the site. The most important part of the application is missing.

  26. Michael
    January 18th, 2012 at 13:18 | #26

    On a positive note, I am glad to have read probably the best breakdown of a development project. Hope you will have time to complete the remaining 5 parts.

  1. February 19th, 2012 at 15:05 | #1
This site uses a Hackadelic PlugIn, Hackadelic SEO Table Of Contents 1.6.0.