<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Wizard_tambah_akun extends CI_Controller{

  public function __construct()
  {
    parent::__construct();
    //Codeigniter : Write Less Do More
  }

  function index()
  {
    $this->load->model('wizard_m');

    if($this->session->has_userdata('id_departemen_kedep')) {
      $this->session->unset_userdata('id_departemen_kedep');
    }
    $this->session->unset_userdata('kepala_departemen_next');
    $data['departemen'] = $this->wizard_m->total_departemen();
    $data['total_kedep'] = $this->wizard_m->total_karyawan_level(2);
    $data['total_staff'] = $this->wizard_m->total_karyawan_level(3);
    $this->load->view('wizard/header');
    $this->load->view('wizard/tambah_akun/main', $data);
  }

  function tambah()
  {
    $this->load->view('wizard/header');
    $this->load->view('wizard/tambah_akun/tambah');
    $this->load->view('wizard/footer');
  }

  function pilih() {
    $kepala_departemen = $this->input->get('kepala_departemen');
    $staff = $this->input->get('staff');
    if($kepala_departemen == "ya") {
      if($staff == "ya") {
        $this->session->set_userdata('kepala_departemen_next', 'wizard.akun.staff.tambah');
        $this->session->set_userdata('id_departemen_kedep', true);
      } else {
        $this->session->set_userdata('kepala_departemen_next', 'wizard.berhasil');
      }
      redirect(route('wizard.akun.kepala_departemen.tambah'));
    } else {
      if($staff == "ya") {
        redirect(route('wizard.akun.staff.tambah'));
      } else {
        redirect(route('wizard.selesai'));
      }
    }
  }
}
