168 lines
6.1 KiB
PHP
168 lines
6.1 KiB
PHP
<?php
|
|
//-------------ID pasien = 18
|
|
|
|
class Ps_pasien extends CI_Controller {
|
|
|
|
//-----------start variables for check action access----------//
|
|
public $vartambah = null;
|
|
public $varedit = null;
|
|
public $vardelete = null;
|
|
public $varview = null;
|
|
//-----------start variables for check action access----------//
|
|
|
|
function __construct(){
|
|
parent::__construct();
|
|
$this->check_isvalidated();
|
|
$this->load->helper(array('form', 'date'));
|
|
}
|
|
private function check_isvalidated(){
|
|
if(! $this->session->userdata('validated')){
|
|
redirect('index.php/login');
|
|
}
|
|
|
|
//--------------start check access this form page-------------//
|
|
$this->db->where('mum_tipeuser_id', $this->session->userdata('s_FK_TipeUser'));
|
|
$this->db->where('mum_menu_id', '18');
|
|
$cekMenu = $this->db->get('master_user_menu');
|
|
$rowcount = $cekMenu->num_rows();
|
|
if($rowcount==0){
|
|
redirect('index.php');
|
|
}else{
|
|
foreach ($cekMenu->result() as $cm)
|
|
{
|
|
$this->vartambah=$cm->mum_tambah;
|
|
$this->varedit=$cm->mum_ubah;
|
|
$this->vardelete=$cm->mum_hapus;
|
|
$this->varview=$cm->mum_lihat;
|
|
}
|
|
}
|
|
//--------------end check access this form page-------------//
|
|
}
|
|
|
|
public function index($error = NULL) {
|
|
$data['title'] = 'Data Pasien';
|
|
$data['main_content'] = 'pasien/v_pasien';
|
|
$data['error']=$error;
|
|
|
|
$this->load->model('m_pasien');
|
|
$ppdata = $this->m_pasien->index();
|
|
$this->load->vars('mp', $ppdata);
|
|
|
|
$this->load->view('includes/template', $data);
|
|
}
|
|
|
|
//fungsi untuk menampilkan form edit data dengan data terpilih
|
|
public function edit($id) {
|
|
//----start validate page edit-------//
|
|
if($this->varedit==null){redirect('index.php/ps_pasien');}
|
|
//----end validate page edit---------//
|
|
$data['title'] = 'Edit Pasien';
|
|
$data['actionform'] = 'prosesedit';
|
|
$data['main_content'] = 'pasien/form_pasien';
|
|
|
|
$this->load->model('m_pasien');
|
|
$ppdata = $this->m_pasien->edit($id);
|
|
$this->load->vars('mp', $ppdata);
|
|
|
|
$this->load->model('m_klinik');
|
|
$klinik = $this->m_klinik->index();
|
|
$this->load->vars('mk', $klinik);
|
|
|
|
$this->load->view('includes/template', $data);
|
|
}
|
|
|
|
//funsi untuk memproses update data
|
|
public function prosesedit() {
|
|
//----start validate page edit-------//
|
|
if($this->varedit==null){redirect('index.php/ps_pasien');}
|
|
//----end validate page edit---------//
|
|
$id = $this->input->post('id');
|
|
|
|
$this->load->helper('form');
|
|
$this->load->helper('url');
|
|
// $this->load->library('form_validation');
|
|
// $this->form_validation->set_rules('klinik','Klinik','required');
|
|
// $this->form_validation->set_rules('shift','Shift Periksa','required');
|
|
// $this->form_validation->set_rules('pembayaran','Jenis Pembayaran','required');
|
|
//
|
|
// if($this->form_validation->run()==FALSE){
|
|
// $data['title'] = 'Edit Pasien';
|
|
// $data['actionform'] = 'prosesedit';
|
|
// $data['main_content'] = 'pasien/form_pasien';
|
|
//
|
|
// $this->load->model('m_pasien');
|
|
// $ppdata = $this->m_pasien->edit($id);
|
|
// $this->load->vars('mp', $ppdata);
|
|
//
|
|
// $this->load->model('m_klinik');
|
|
// $klinik = $this->m_klinik->index();
|
|
// $this->load->vars('mk', $klinik);
|
|
//
|
|
// $this->load->view('includes/template', $data);
|
|
// }
|
|
// else{
|
|
$this->session->set_flashdata('message', 'Anda berhasil mengedit Pasien');
|
|
$this->load->model('m_pasien');
|
|
$this->m_pasien->prosesedit();
|
|
redirect('index.php/ps_pasien');
|
|
// }
|
|
}
|
|
|
|
//fungsi untuk menampilkan form view data dengan data terpilih
|
|
public function view($id) {
|
|
//----start validate page view-------//
|
|
if($this->varview==null){redirect('index.php/ps_pasien');}
|
|
//----end validate page view---------//
|
|
$data['title'] = 'View Pasien';
|
|
$data['actionform'] = 'prosesview';
|
|
$data['main_content'] = 'pasien/form_pasien';
|
|
|
|
$this->load->model('m_pasien');
|
|
$ppdata = $this->m_pasien->edit($id);
|
|
$this->load->vars('mp', $ppdata);
|
|
|
|
$this->load->model('m_klinik');
|
|
$klinik = $this->m_klinik->index();
|
|
$this->load->vars('mk', $klinik);
|
|
|
|
$this->load->view('includes/template', $data);
|
|
}
|
|
|
|
//fungsi untuk delete
|
|
// function delete($id) {
|
|
// //----start validate page delete-------//
|
|
// if($this->vardelete==null){redirect('index.php/ps_pasien');}
|
|
// //----end validate page delete---------//
|
|
// $this->session->set_flashdata('message', 'Anda berhasil menghapus pasien');
|
|
// $this->load->model('m_paien');
|
|
// $this->m_paien->delete($id);
|
|
// redirect('index.php/ps_pasien');
|
|
// }
|
|
|
|
function datashift(){
|
|
$idk = $this->input->post('idklinik');
|
|
$jumshift;
|
|
$jamshift;
|
|
//---------------------start get data klinik--------------//
|
|
$this->db->where('mk_id', $idk);
|
|
$query_kl = $this->db->get('master_klinik');
|
|
foreach ($query_kl->result() as $datklinik ){
|
|
$jumshift=$datklinik->mk_shift;
|
|
$jamshift=$datklinik->mk_jam_shift;
|
|
}
|
|
//---------------------end get data klinik--------------//
|
|
|
|
$pecahjamshift = explode("|",$jamshift);
|
|
$numpecah = 0;
|
|
|
|
for($i=1;$i<=$jumshift;$i++){
|
|
$data[] = ['datashift'=>"<option value='$i'>Shift $i ± Mulai Pukul $pecahjamshift[$numpecah] </option>"];
|
|
$numpecah++;
|
|
|
|
}
|
|
echo json_encode($data);
|
|
}
|
|
|
|
}
|
|
|
|
?>
|