Thursday, 17 March 2016

Helper Codeignter Convert Number into Button

Simple helper for convert number into some word in PHP especially for codeignter framework,

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

  1. Number  One For Button Pending Status
  2. Number  Two For Button Pending Approve 1
  3. Number  Three For Button Pending Reject 1
  4. Number  Four For Button Pending Approve 2
  5. Number  Five For Button Pending Reject 2
  6. Number  Six  For Button Approve Admin
  7. 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




I'm 24 Being Suck Now & What Should I Do !

well during coding i search by random, open facebook, googling, etc then i found this article 

Is It Too Late?I am 24-years-old and feel like a complete failure who has wasted many, many years. What can I do to quickly get myself back on track?


it's like slap me after read answer from user in quora, i feel like what he asked in that forum.
  • No Motivation
  • No Goal
  • Being Flat
  • Hopeless
  • Full of Pain

i feel like lost after read all. but my mind give tolerance why this shit happen, and why no luck, even at this age i have no girlfriend ? oh poor me, i don't know why i blog my feeling now or just trying to pour all emotions in this blog.

My Current Job now is Web Developer create website honestly i'm not enjoy to much this job  but i will keep it till 2 years in this field, as indonesian i have some responsibility abpout my family but will not publish in here, i need something more than money i mean yes money can give comforts even fully of stressed i believe that theology.

Next month i will resign from  company but don't know how to start where should go, but i will give limitation time to find out where my soul / my passion should lead me, do i regret to take decision without new job ? first answer is yes but as long as i have hand and foot and brain to think i can go through this situation.

now after read this i feel like warm, feel free little bite lah. now my life begin in jakarta, i dont know will stay in IT or move to another department ?

hope this year all become easy for me, new job and will meet my future wife lah cause it's to hard with this age without girl friend. duh i too much (lebay) to write all shit in my mind in this blog, ah why i need Lord in this time, hey reader i hope you are doing great now, 



Sunday, 6 March 2016

Create Auto Increment without setting in PHPMYADMIN using CI

well may be the title make you hard to understand, let me give you example of my work, please see my images bellow with circle in that form

well logic is i select id from table order by desc limit 1 then in view i add with number 1 then i will look like autoincrement but it's not, here is my database screen shoot

then in view show up with number 10, so let me show my code,
cCONTROLLER
 $data = array(  
                //pro_employee_id auto increment  
                'id'=>$this->Karyawan_model->getlastid(),  
                );  
 $this->template->load('template', 'pro_employee_form',$data);  

MODEL
 function getlastid()  
      {  
        $this->db->from('pro_employee');  
     $this->db->order_by("pro_employee_id", "desc");  
     $this->db->limit('1');   
     return $this->db->get()->row();    
      }  

VIEW 
 <?php  
           $maxid = 0;  
     if ($id) {  
       $maxid = $id->pro_employee_id;   
     }   
           ;?>  
            <input type="text" class="form-control" name="pro_employee_id" id="pro_employee_id" value="<?php echo $maxid+1 ?>" readonly />  

hope you understand what i'm telling in here, thanks for visiting me,
Cheers


Friday, 4 March 2016

why you don't mastrubate or premature on it

Kalau ada orang bilang hidup itu butuh makan memang betul, tapi hidup yang buat menjadi hidup ada HARAPAN tapi entah kenapa kata harapan itu di nodai dengan kata-kata HARAPAN PALSU ini memberikan efek psikologi yang tenang terhadap orang yang berharap.

Kata "harapan" itu ibarat es kelapa muda yang di minum sehabis kecapean nyari alamat rumah gak ketemu-ketemu padahal sudah dilewati berkali-kali, kalau boleh sedikit mengartikannya Harapan itu adalah sesuatu yang di kejar dan membutuhkan waktu untuk wujudkan hal itu (please correct me)

Mungkin pernah dengar nasihat para rohaniawan kalau ada yang curhat respondnya adalah "Sabar, indah pada waktunya" jelas itu memberikan efek menenangkan kalau lagi ada masalah, tapi kalau di liat dari definisi di atas tentang menunggu sesuatu terjadi, ada hal yang unik yang mau gw diskusikan.

pertama gw mau diskusikan setuju kan definisi diatas ? kalau setuju kita lanjut, beberapa malam lalu sempet diskusi dengan teman tentang HARAPAN sehabis pulang kantor, tapi yang extrem adalah gw di ajak untuk berpikir ekstrem dan out the box. begini kira-kira kalimatnya

"If you have some hope that hard to get, forget it and let's move ! but if you think that your hope will be come true but it take so long, why you don't mastrubate or premature on it"

tapi ada caption kecil resiko di tanggung sendiri, kalau boleh gw kasih case ada 2 mamak-mamak yang lagi hamil prediksi dokter salah satu ada yang premature dan yang satu akan normal ? pertanyaan gw adalah apakah keduanya bisa yakin selamat dua-duanya, atau yang premature akan pasti gak selamat, well semua ada resiko nya masing-masing toh tapi kalau selamat dua-duanya siapa yang lebih dulu bisa melihat anaknya, jelas premature bukan, agak suliat seh untuk bahas elemen harapan ini karena banyak faktor di dalamnya,

Terus kenapa gw sudah berharap bakal nikah umur 27 sudah harus dapat mamaknya anak-anak tapi ternyata gw sudah masuk masa expired (fuck yeah) belum dapat-dapat (kita skip aja yang inilah ya)

yang menarik ada orang yang setia dan berharap akan satu point entah itu, pendidikan, cita-cita menaruh semuanya dalam kata harapan. Jatuh bangun lagi jatuh bangun lagi, kenapa dengan gw kita jatuh bukannya bangkit malah merubah rencana, duh do i too late about this ?

Hi Thanks for reading, hope you are still oke, i you think this good article please share lah ya, hitung-hitungan kalau ada cewek yang baca mau jadi mamaknya anak-anak (LOL)