As long as you develop project you need some helper if you already know CI, now i'm going to create Tutorial about convert number into some words using codeignter
here is my helper about it, give it name convert_status_helper.php
<?php
'Pending',
2=> 'Approve 1',
3=> 'Reject 1',
4=> 'Approve 2',
5=> 'Reject 2',
6=> 'Approve Admin',
7=> 'Reject Admin',
*/
if ( ! function_exists('test_method'))
{
function convert_to_colour($var = '')
{
if ($var=='1')
{
echo "<div class="external-event bg-green">
Pending</div>
";
}
else if ($var=='2')
{
echo "<div class="external-event bg-yellow">
Approve 1</div>
";
}
else if ($var=='3')
{
echo "<div class="external-event bg-black">
Reject 1</div>
";
}
else if ($var=='4')
{
echo "<div class="external-event bg-aqua">
Approve 2</div>
";
}
else if ($var=='5')
{
echo "<div class="external-event bg-black">
Reject 2</div>
";
}
else if ($var=='6')
{
echo "<div class="external-event bg-red">
Approve Admin</div>
";
}
else if ($var=='7')
{
echo "<div class="external-event bg-black">
Reject Admin</div>
";
}
else
{
echo "<div class="external-event bg-black">
Pending</div>
";
}
}
}
?>
in that helper convert number into button but if you need convert to words you can change it, open autoload we need autoload this helper like this
$autoload['helper'] = array('convert_status');
then i put in controller login and this is my controller
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Login extends CI_Controller
{
function __construct()
{
parent::__construct();
}
public function index()
{
$this->load->view('login');
}
}
and in your view you just need
<?php echo convert_to_colour('1') ?>
this helper help me alot when show status in multiple controller then i just call by conver_to_colour so this is my deisgn based on number
- Number One For Button Pending Status
- Number Two For Button Pending Approve 1
- Number Three For Button Pending Reject 1
- Number Four For Button Pending Approve 2
- Number Five For Button Pending Reject 2
- Number Six For Button Approve Admin
- Number Seven For Button Reject Admin
in your view don't forget to use bootsrap framework, cause i use it tomake button become pretty
then this is my screen shot with status 1
Hope you understand lah what i'm talking about, thanks