Friday 29 January 2016

Full Calender Using Codeignter Which is Came from Database

Well this is my screen shot for you , please see the url so you can goes to file later on will be upload to dropbox












then in controller i use select data using where clause please see in controller
 public function date()  
   {  
     $this->db->select('*');  
     $this->db->from('cu_date_cuti');  
     $this->db->where('cu_date_cuti_id','1');  
     $query = $this->db->get();  
     foreach ($query->result_array() as $row)  
       {  
          $new_row['title']=htmlentities(stripslashes($row['cu_date_id']));  
          $new_row['start']=htmlentities(stripslashes($row['cu_date_date']));  
          $row_set[] = $new_row;   
       }  
     echo json_encode($row_set);  
   }  


when you need to echo date in full calender you need to convert data to be json, for more information fullcalender is here

file you can grab here

Note : This is bassically configuration and you need to be familiar with codeignter


Saturday 23 January 2016

Load All Varibales in every Controller Using Codeignter

This post for people know Codeignter been one year lah especially for me. This is about load same varibale each controller, please see script bellow

 <?php  
 defined('BASEPATH') OR exit('No direct script access allowed');  
 class Welcome extends CI_Controller {  
 public function read1()  
   {  
  $data['notif']=$this->Notif_model->get_all_notif(); //same varibale  
  }  
 public function read2()  
   {  
  $data['notif']=$this->Notif_model->get_all_notif(); //same varibale  
  }  
 public function read3()  
   {  
  $data['notif']=$this->Notif_model->get_all_notif(); //same varibale  
  }  
 }  

as you can see there are same varibale in every function, that's not clean code i guess !
so idecide to search about this issue then i found it
  1. GLOBAL VARIBALE
  2. EXTENDS CONTROLLER
after few hours digging on global varibale hard to learn then i leave it, focus on extends controller from stackoverflow here, yes stackoverflow is the best place to throw fuckin stress.

Then i make extends controller 
 <?php  
 defined('BASEPATH') OR exit('No direct script access allowed');  
 class AppKaryawan extends CI_Controller  
 {  
  /**  
  * @return void  
  **/  
  function __construct()  
  {  
  parent::__construct();  
  //load variable global  
  $this->data = array(  
       'notif' => $this->Notif_model->get_all_notif()  
     );  
  if (($this->session->userdata('cu_level') === 'Pegawai') or ($this->session->userdata('cu_level') === 'Manajer'))   
  {  
   return TRUE;  
  }  
  else  
  {  
   //show_404(); // OR   
   redirect('login');  
   return FALSE;  
  }  
  }  
 }  


Please see my extends above only for level Manajer, but ignore it lah it doesn't important. then let see the controller after extends controller this is will change like this
 public function read1()  
   {  
  $data = $this->data;   
  }  
 public function read2()  
   {  
  $data = $this->data;   
  }  
 public function read3()  
   {  
  $data = $this->data;   
  }   

Please compare the controller, yes the second controller is really lite bite clean but after think and quit some minute it tottally same, wtf ! cause each function should write the $data, how can i make it more clean, i'm open disscuss guys !

if you any trick please throw the code so people will understanding, so i will reblog it again to make more clean, Thanks for visiting me !

Happy Weekend 

Thursday 21 January 2016

Validations Input Type File Using Jquery

well honestly this is my simple demo about validations in modal bootsrap, but this very bassic for validations input type file in modal bootsrap using jquery.

You can adapot this style to yours !


  1. I give value in input type file by giving id 
  2. Then check it using if then execute every condition
Here is simple demo made for you out there

See the Pen Check input type file empty por not by Freddy Sidauruk (@sidaurukfreddy) on CodePen.


Thanks for visiting Me !

Get One Field in Codeignter

Get one field in Codeignter when we need to extract it in view or controller

here is controller
and here is model
Thanks for visiting me !

you can grab database is here

Tuesday 19 January 2016

COUNT DIFFRENT 2 DATE IN MYSQL USING CODEIGNTER

now i'm working on about date and time and will give you short tutorial about count diffrent date between two dates, well i'm fun using codeignter then spend some hours i found some blog intresting and help me a lot

check this out the authtoor tell how to count 2 date, so i change it to CODEIGNTER

first go to your and create datediff_helper.php
 <?php  
 // Set timezone  
  date_default_timezone_set("UTC");  
  // Time format is UNIX timestamp or  
  // PHP strtotime compatible strings  
  function dateDiff($time1, $time2, $precision = 6) {  
   // If not numeric then convert texts to unix timestamps  
   if (!is_int($time1)) {  
    $time1 = strtotime($time1);  
   }  
   if (!is_int($time2)) {  
    $time2 = strtotime($time2);  
   }  
   // If time1 is bigger than time2  
   // Then swap time1 and time2  
   if ($time1 > $time2) {  
    $ttime = $time1;  
    $time1 = $time2;  
    $time2 = $ttime;  
   }  
   // Set up intervals and diffs arrays  
   $intervals = array('year','month','day','hour','minute','second');  
   $diffs = array();  
   // Loop thru all intervals  
   foreach ($intervals as $interval) {  
    // Create temp time from time1 and interval  
    $ttime = strtotime('+1 ' . $interval, $time1);  
    // Set initial values  
    $add = 1;  
    $looped = 0;  
    // Loop until temp time is smaller than time2  
    while ($time2 >= $ttime) {  
     // Create new temp time from time1 and interval  
     $add++;  
     $ttime = strtotime("+" . $add . " " . $interval, $time1);  
     $looped++;  
    }  
    $time1 = strtotime("+" . $looped . " " . $interval, $time1);  
    $diffs[$interval] = $looped;  
   }  
   $count = 0;  
   $times = array();  
   // Loop thru all diffs  
   foreach ($diffs as $interval => $value) {  
    // Break if we have needed precission  
    if ($count >= $precision) {  
     break;  
    }  
    // Add value and interval  
    // if value is bigger than 0  
    if ($value > 0) {  
     // Add s if value is not 1  
     if ($value != 1) {  
      $interval .= "s";  
     }  
     // Add value and interval to times array  
     $times[] = $value . " " . $interval;  
     $count++;  
    }  
   }  
   // Return string with times  
   return implode(", ", $times);  
  }  
 ?>  




Then goes to autoload.php
 $autoload['helper'] = array('datediff');  


Then this is the controller
 <?php  
 if (!defined('BASEPATH'))  
   exit('No direct script access allowed');  
 class Login extends CI_Controller  
 {  
   function __construct()  
   {  
     parent::__construct();  
    }  
   public function index()  
   {  
      $this->template->load('template', 'login');  
   }  
 public function diffdate()  
   {  
     echo dateDiff('00:57:42','07:30:00');  
   }  
 }  
 </textare>  


The results here








You can grab helper is here




Change date MySQL to indonesia date using moment.js

as long as you develop cms you need to modif everything you need based on your requirements, locale and languange to make your users know why and how it came be,

Last posting about change date from database to view using codeignter, now i'm going to give tutorial about change date from database to view using moment.js  

Here is simple demo

See the Pen OMOGXg by Freddy Sidauruk (@sidaurukfreddy) on CodePen.

Thanks for visiting me, please feel free to comment !

Sunday 17 January 2016

Change format date in mysql to indonesian format

 well quick tutorial about change date mysql to indonesia date using codeignter, well copy paste this script bellow, give it name tgl_indonesia_helper.php put inside helper folder

 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');  
 if ( ! function_exists('tgl_indo'))  
 {  
  function tgl_indo($tgl)  
  {  
  $ubah = gmdate($tgl, time()+60*60*8);  
  $pecah = explode("-",$ubah);  
  $tanggal = $pecah[2];  
  $bulan = bulan($pecah[1]);  
  $tahun = $pecah[0];  
  return $tanggal.'-'.$bulan.'-'.$tahun;  
  }  
 }  
 if ( ! function_exists('bulan'))  
 {  
  function bulan($bln)  
  {  
  switch ($bln)  
  {  
   case 1:  
   return "Januari";  
   break;  
   case 2:  
   return "Februari";  
   break;  
   case 3:  
   return "Maret";  
   break;  
   case 4:  
   return "April";  
   break;  
   case 5:  
   return "Mei";  
   break;  
   case 6:  
   return "Juni";  
   break;  
   case 7:  
   return "Juli";  
   break;  
   case 8:  
   return "Agustus";  
   break;  
   case 9:  
   return "September";  
   break;  
   case 10:  
   return "October";  
   break;  
   case 11:  
   return "November";  
   break;  
   case 12:  
   return "Desember";  
   break;  
  }  
  }  
 }  


then don't forget to load in load helper in autoload.php like this

 $autoload['helper'] = array('tgl_indonesia');  


Then goes to your controller welcome copy and paste this
 <?php  
 defined('BASEPATH') OR exit('No direct script access allowed');  
 class Welcome extends CI_Controller {  
  public function index()  
  {  
   echo tgl_indo ('2016-02-11');   
  //$this->load->view('welcome_message');  
  }  
 }  


 then this the results,


Thanks for reading me !

Tuesday 12 January 2016

Jiwa yang terperangkap

Ungkapan perasaan yang mengalir dari dalam hati itu ibarat aliran sungai yang jernih, bunyinya saja terasa menyegarkan hati dan pikiran, pernah tidak kau merasakan hal itu ? 

jujur saja aku pernah beberapa kali, ku pikir itu hanya ada dalam cerita dongeng  anak orang kaya pengiring tidur, kuakui masih terlalu kolot untuk menikmati hidup  mengharuskan point-point dimana semua orang yang tidak punya atau bahkan butuh waktu lama untuk mencapai hal itu atau aku yang sudah memenjarakan dan memvonis bahwa hidup bahagia dan enak itu harus selalu dengan materi ah ternyata cerita cewek matre aja yang ada, cowok matre pun ada eh jangan terlalu terburu-buru untuk memberi label “Cowok Matre” aku terlalu obsesi untuk menjadi orang yang selalu serba lebih, apakah ini sebuah syndrome yang perlu di obati kurasa tidak hanya saja aku terlalu amat terobsesi akan hal itu,

sampai aku lupa bersyukur untuk kaki yang masih bias berjalan, lidah yang masih bisa merasakan bagaimana nikmatnya kopi, mata yang masih bisa melihat bagaimana Tuhan menciptakan wanita yang sexy dan cantik.

Perasaan yang tulus dari hati itu bisa di rasakan apakah itu hanya buatan semata untuk terlihat pada orang “Hei buddy I’m really happy to be who am I” tapi ternyata di dalam hati menyimpan begitu banyak luka, kepahitan, kekecewaan, amarah dan itu tersusun dengan rapi bahkan enak untuk di lihat,,pernah lihat rak buku yang disusun rapi bahkan sampai penuh pun terlihat rapi seperti itu lah kira-kira keadaannya.


 Damn ! ternyata aku terperangkap dalam jiwa sangat menyedihkan butuh cinta yang tulus untuk menurunkan semua benda-benda itu satu persatu tapi terlalu lama satu-satu bisakah ini diturunkan semua, sudah terlalu lama mereka disitu ingin ku cepat taruh bunga, tanaman rumahan dan hewan-hewan kecil supaya ada kehidupan disana dan benar-benar tulus yang keluar dari dalam hati ini.
Sebentar kalian jangan terlalu cepat menilai bahwa cerita ini tentang  merindukan pasangan bukan jelas bukan, saya tegaskan sekali lagi. Ini adalah kerinduan dalam hati yang benar-benar ingin di penuhi hal-hal indah dan enak di denger bagi siapa yang ngobrol dengan ku atau paling minimal gak takut untuk di pinjamin duit, wtf !

Menikmati hidup itu sebenarnya tidak terlalu sulit, sebenarnya itu lho tapi kenyataan sulit.  Kita oh maaf lebih baik menggunakan subject aku, aku ulangi kembali ya, sebenarnya aku tahu bagaimana menikmati dan belajar bersyukur, sebenarnya cuma terbuka dan mencintai diri sendiri as simple as that but the important things is God become the center in life no matter your religion always put Lord in the center.

Ketika kita aku melakukan hal itu ada perubahan kecil yang ku amati, ntah kenapa mudah sekali senyum bahkan kamar mandi kosan masih ada beberapa butir-butir rudal tempur  teman sekosan yang tersisa pun dengan senang hati ku kirim segera menyusul temannya didalam.

untuk menjadikan Tuhan prioritas dalam hidup kita ku susah, jujur saja susah L  semua butuh proses untuk mengerti lagi atau minimal ada batasan untuk trial and error supaya mengerti kenapa harus begini dan begitu,





Wednesday 6 January 2016

Get current time using jquery event onclick

Hello qucik tutorial get current time using jquery by event on click, here is demo

See the Pen OMpgEr by Freddy Sidauruk (@sidaurukfreddy) on CodePen.

Thanks for visiting me