diff --git a/.gitignore b/.gitignore index 77016c6..a2c1fa7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,5 @@ -# ---> CodeIgniter -*/config/development -*/logs/log-*.php -!*/logs/index.html -*/cache/* -!*/cache/index.html -!*/cache/.htaccess - -user_guide_src/build/* -user_guide_src/cilexer/build/* -user_guide_src/cilexer/dist/* -user_guide_src/cilexer/pycilexer.egg-info/* - #codeigniter 3 -application/logs/* -!application/logs/index.html -!application/logs/.htaccess -/vendor/ + db_umkm2.sql application/config/database.php diff --git a/application/config/database.php.example b/application/config/database.php.example index c58c384..41f1b12 100644 --- a/application/config/database.php.example +++ b/application/config/database.php.example @@ -77,8 +77,8 @@ $db['default'] = array( 'dsn' => '', 'hostname' => 'localhost', 'username' => 'your_mysql_username', - 'password' => 'your_mysql_password', - 'database' => 'your_db_name', + 'password' => '', + 'database' => 'your_database_name', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, diff --git a/application/controllers/login.php b/application/controllers/login.php index 37a4081..c72ebf8 100644 --- a/application/controllers/login.php +++ b/application/controllers/login.php @@ -17,14 +17,18 @@ class Login extends CI_Controller { if($this->session->userdata('user_logged')->level=='admin'){ redirect(site_url('admin/dashboard')); } else { - redirect(site_url('dashboard')); + redirect(site_url('user/dashboard')); } } if($this->input->post()){ if($this->UserModel->doLogin()) { - redirect(site_url('admin/dashboard')); + if($this->UserModel->isPemilik()){ + redirect(site_url('user/dashboard')); + } else { + redirect(site_url('admin/dashboard')); + } } else { $data['error']="Username atau Password salah !"; $this->load->view('login',$data); diff --git a/application/controllers/user/Dashboard.php b/application/controllers/user/Dashboard.php new file mode 100644 index 0000000..54d496e --- /dev/null +++ b/application/controllers/user/Dashboard.php @@ -0,0 +1,40 @@ +load->model("UmkmModel"); + $this->load->model("UserModel"); + $this->load->model("KategoriModel"); + + if($this->UserModel->isNotLogin()) { + redirect(site_url('login')); + } elseif(!($this->UserModel->isPemilik())) { + redirect(site_url('admin/dashboard')); + } + + + } + + public function index() + { + if($this->input->get()){ + $get = $this->input->get(); + if(isset($get['pemilik'])){ + $data['del_pemilik']= $get['pemilik']; + } + $data['del_msg']= $get['del_msg']; + + } + + $data['user_logged'] = $this->session->userdata('user_logged'); + $data['data_umkm'] = $this->UmkmModel->getUmkmsByIdPemilik($data['user_logged']->id_user); + $this->load->view('user/dashboard',$data); + + } + + +} diff --git a/application/controllers/user/DetailUmkm.php b/application/controllers/user/DetailUmkm.php new file mode 100644 index 0000000..bb793b1 --- /dev/null +++ b/application/controllers/user/DetailUmkm.php @@ -0,0 +1,120 @@ +load->model("UserModel"); + $this->load->model("UmkmModel"); + $this->load->model("KategoriModel"); + $this->load->model("AbsensiModel"); + $this->load->model("AbsenModel"); + + if($this->UserModel->isNotLogin()) { + redirect(site_url('login')); + } elseif(!($this->UserModel->isPemilik())) { + redirect(site_url('admin/dashboard')); + } + + $get = $this->input->get(); + if($get['id_umkm']==NULL){ + redirect(site_url('user/dashboard')); + } + } + + public function index() + { + + $get = $this->input->get(); + + + $umkm = $this->UmkmModel->getUmkmsById($get['id_umkm']); + $pemilik = $this->UserModel->getUsersById($umkm->id_pemilik); + $daftarkategori = $this->KategoriModel->getKategori(); + + // var_dump($this->input->post());die(); + + if($this->input->post()){ + + $post = $this->input->post(); + if($this->AbsensiModel->update($post['id_absensi'])){ + redirect(site_url('user/detailumkm?id_umkm='.$umkm->id_umkm.'&msg=success')); + } else { + $data['msg']="error!"; + } + + + } + + $cekabsensiakhir = $this->AbsensiModel->getLatestSignedAbsensiCountByUmkmId($umkm->id_umkm); + + if($cekabsensiakhir > 0 ){ + $absensiakhir = $this->AbsensiModel->getLatestSignedAbsensiByUmkmId($umkm->id_umkm); + $aset = $absensiakhir->aset; + $karyawan_l = $absensiakhir->karyawan_l; + $karyawan_p = $absensiakhir->karyawan_p; + $data['listabsensi'] = $this->AbsensiModel->getSignedAbsensiByUmkmId($umkm->id_umkm); + } else { + $aset = $umkm->aset_awal; + $karyawan_l = $umkm->karyawan_l; + $karyawan_p = $umkm->karyawan_p; + $data['listabsensi'] = array(); + } + + + $data['omset'] = $umkm->omset_awal; + $data['karyawan_l'] = $karyawan_l; + $data['karyawan_p'] = $karyawan_p; + $data['aset'] = $aset; + $data['daftarkategori'] = $daftarkategori; + $data['umkm'] = $umkm; + $data['pemilik'] = $pemilik; + $data['user_logged'] = $this->session->userdata('user_logged'); + + if($this->AbsenModel->getCountActiveAbsen()>0){ + $data['data_absen'] = $this->AbsenModel->getActiveAbsen(); + if($data['data_absen']->bulan=='1'){ + $bulan = 'Januari'; + } elseif($data['data_absen']->bulan=='2'){ + $bulan = 'Februari'; + } elseif($data['data_absen']->bulan=='3'){ + $bulan = 'Maret'; + } elseif($data['data_absen']->bulan=='4'){ + $bulan = 'April'; + } elseif($data['data_absen']->bulan=='5'){ + $bulan = 'Mei'; + } elseif($data['data_absen']->bulan=='6'){ + $bulan = 'Juni'; + } elseif($data['data_absen']->bulan=='7'){ + $bulan = 'Juli'; + } elseif($data['data_absen']->bulan=='8'){ + $bulan = 'Agustus'; + } elseif($data['data_absen']->bulan=='9'){ + $bulan = 'September'; + } elseif($data['data_absen']->bulan=='10'){ + $bulan = 'Oktober'; + } elseif($data['data_absen']->bulan=='11'){ + $bulan = 'November'; + } elseif($data['data_absen']->bulan=='12'){ + $bulan = 'Desember'; + } + $data['bulan'] = $bulan; + + $data['active_absen'] = true; + + $data['absenisiaktif'] = $this->AbsensiModel->getAbsensiByAbsenIdAndUmkmId($umkm->id_umkm,$data['data_absen']->id_absen); + } else { + $data['data_absen'] = ''; + $data['active_absen'] = false; + } + + + $this->load->view('user/detailumkm',$data); + + } + + +} diff --git a/application/controllers/user/EditUmkm.php b/application/controllers/user/EditUmkm.php new file mode 100644 index 0000000..f7e73ea --- /dev/null +++ b/application/controllers/user/EditUmkm.php @@ -0,0 +1,84 @@ +load->model("UserModel"); + $this->load->model("UmkmModel"); + $this->load->model("KategoriModel"); + $this->load->model("KelurahanModel"); + $this->load->model("JenisModel"); + + if($this->UserModel->isNotLogin()) { + redirect(site_url('login')); + } elseif(!($this->UserModel->isPemilik())) { + redirect(site_url('admin/dashboard')); + } + + $get = $this->input->get(); + if($get['id_umkm']==NULL){ + redirect(site_url('user/dashboard')); + } + } + + public function index() + { + + $get = $this->input->get(); + $umkm = $this->UmkmModel->getUmkmsById($get['id_umkm']); + + + if($this->input->post()){ + + if(strlen($_FILES['foto_umkm']['tmp_name'])>0){ + $config['upload_path'] = './assets/images/umkm/'; + $config['allowed_types'] = 'jpg|jpeg|gif|png'; + $config['max_size'] = 100; + $config['max_width'] = 1024; + $config['max_height'] = 768; + $config['file_name'] = $umkm->id_umkm; + $config['overwrite'] = TRUE; + + $this->load->library('upload', $config); + + if ( ! $this->upload->do_upload('foto_umkm')){ + $data['error_upload'] = $this->upload->display_errors(); + } else { + $foto_lama = $umkm->foto_umkm; + $file = $this->upload->data(); + if($this->UmkmModel->userUpdate($umkm->id_umkm,$file['file_name'])){ + if($umkm->foto_umkm!=='umkm.png'){ + unlink('./assets/images/umkm/'.$foto_lama); + } + redirect(site_url('user/editumkm?id_umkm='.$umkm->id_umkm.'&msg=success')); + } else { + $data['msg']="error!"; + } + } + + } else{ + $foto_umkm = $umkm->foto_umkm; + if($this->UmkmModel->userUpdate($umkm->id_umkm,$foto_umkm)){ + redirect(site_url('user/editumkm?id_umkm='.$umkm->id_umkm.'&msg=success')); + } else { + $data['msg']="error!"; + } + } + } + + $daftarjenis = $this->JenisModel->getJenis(); + $data['daftarjenis'] = $daftarjenis; + $data['listkelurahan'] = $this->KelurahanModel->getKelurahan(); + $data['umkm'] = $umkm; + $data['user_logged'] = $this->session->userdata('user_logged'); + + $this->load->view('user/editumkm',$data); + + } + + +} diff --git a/application/controllers/user/HapusProduk.php b/application/controllers/user/HapusProduk.php new file mode 100644 index 0000000..2af4411 --- /dev/null +++ b/application/controllers/user/HapusProduk.php @@ -0,0 +1,50 @@ +load->model("UserModel"); + $this->load->model("UmkmModel"); + $this->load->model("AbsensiModel"); + $this->load->model("ProdukModel"); + + + if($this->UserModel->isNotLogin()) { + redirect(site_url('login')); + } elseif(!($this->UserModel->isPemilik())) { + redirect(site_url('admin/dashboard')); + } + + $get = $this->input->get(); + if($get['id_produk']==NULL){ + redirect(site_url('user/dashboard')); + } + } + + public function index() + { + + + $get = $this->input->get(); + $produk = $this->ProdukModel->getProdukById($get['id_produk']); + $id_umkm = $produk->id_umkm; + + if($produk->foto_produk!=='default.png'){ + unlink('./assets/images/produk/'.$produk->foto_produk); + } + $this->ProdukModel->delete($get['id_produk']); + redirect(site_url('user/produk?del_msg=success&id_umkm='.$id_umkm)); + + + + + $data['produk'] = $produk; + $data['user_logged'] = $this->session->userdata('user_logged'); + + } + + +} diff --git a/application/controllers/user/Produk.php b/application/controllers/user/Produk.php new file mode 100644 index 0000000..e1e4b11 --- /dev/null +++ b/application/controllers/user/Produk.php @@ -0,0 +1,87 @@ +load->model("UserModel"); + $this->load->model("UmkmModel"); + $this->load->model("KategoriModel"); + $this->load->model("AbsensiModel"); + $this->load->model("AbsenModel"); + $this->load->model("ProdukModel"); + + if($this->UserModel->isNotLogin()) { + redirect(site_url('login')); + } elseif(!($this->UserModel->isPemilik())) { + redirect(site_url('admin/dashboard')); + } + + + + + $get = $this->input->get(); + if($get['id_umkm']==NULL){ + redirect(site_url('user/dashboard')); + + } + } + + public function index() + { + + $get = $this->input->get(); + + if($this->input->get()){ + if(isset($get['del_msg'])){ + $data['del_msg']= $get['del_msg']; + } + + } + + $umkm = $this->UmkmModel->getUmkmsById($get['id_umkm']); + $pemilik = $this->UserModel->getUsersById($umkm->id_pemilik); + $daftarkategori = $this->KategoriModel->getKategori(); + $daftarproduk = $this->ProdukModel->getProdukByUmkmId($umkm->id_umkm); + + // var_dump($this->input->post());die(); + + + + $cekabsensiakhir = $this->AbsensiModel->getLatestSignedAbsensiCountByUmkmId($umkm->id_umkm); + + if($cekabsensiakhir > 0 ){ + $absensiakhir = $this->AbsensiModel->getLatestSignedAbsensiByUmkmId($umkm->id_umkm); + $aset = $absensiakhir->aset; + $karyawan_l = $absensiakhir->karyawan_l; + $karyawan_p = $absensiakhir->karyawan_p; + $data['listabsensi'] = $this->AbsensiModel->getSignedAbsensiByUmkmId($umkm->id_umkm); + } else { + $aset = $umkm->aset_awal; + $karyawan_l = $umkm->karyawan_l; + $karyawan_p = $umkm->karyawan_p; + $data['listabsensi'] = array(); + } + + + $data['omset'] = $umkm->omset_awal; + $data['karyawan_l'] = $karyawan_l; + $data['karyawan_p'] = $karyawan_p; + $data['aset'] = $aset; + $data['daftarkategori'] = $daftarkategori; + $data['daftarproduk'] = $daftarproduk; + $data['umkm'] = $umkm; + $data['pemilik'] = $pemilik; + $data['user_logged'] = $this->session->userdata('user_logged'); + + + + $this->load->view('user/produk',$data); + + } + + +} diff --git a/application/controllers/user/RiwayatAbsensi.php b/application/controllers/user/RiwayatAbsensi.php new file mode 100644 index 0000000..54ca882 --- /dev/null +++ b/application/controllers/user/RiwayatAbsensi.php @@ -0,0 +1,74 @@ +load->model("UserModel"); + $this->load->model("UmkmModel"); + $this->load->model("KategoriModel"); + $this->load->model("AbsensiModel"); + $this->load->model("AbsenModel"); + + if($this->UserModel->isNotLogin()) { + redirect(site_url('login')); + } elseif(!($this->UserModel->isPemilik())) { + redirect(site_url('admin/dashboard')); + } + + $get = $this->input->get(); + if($get['id_umkm']==NULL){ + redirect(site_url('user/dashboard')); + } + } + + public function index() + { + + $get = $this->input->get(); + + + $umkm = $this->UmkmModel->getUmkmsById($get['id_umkm']); + $pemilik = $this->UserModel->getUsersById($umkm->id_pemilik); + $daftarkategori = $this->KategoriModel->getKategori(); + + // var_dump($this->input->post());die(); + + + + $cekabsensiakhir = $this->AbsensiModel->getLatestSignedAbsensiCountByUmkmId($umkm->id_umkm); + + if($cekabsensiakhir > 0 ){ + $absensiakhir = $this->AbsensiModel->getLatestSignedAbsensiByUmkmId($umkm->id_umkm); + $aset = $absensiakhir->aset; + $karyawan_l = $absensiakhir->karyawan_l; + $karyawan_p = $absensiakhir->karyawan_p; + $data['listabsensi'] = $this->AbsensiModel->getSignedAbsensiByUmkmId($umkm->id_umkm); + } else { + $aset = $umkm->aset_awal; + $karyawan_l = $umkm->karyawan_l; + $karyawan_p = $umkm->karyawan_p; + $data['listabsensi'] = array(); + } + + + $data['omset'] = $umkm->omset_awal; + $data['karyawan_l'] = $karyawan_l; + $data['karyawan_p'] = $karyawan_p; + $data['aset'] = $aset; + $data['daftarkategori'] = $daftarkategori; + $data['umkm'] = $umkm; + $data['pemilik'] = $pemilik; + $data['user_logged'] = $this->session->userdata('user_logged'); + + + + $this->load->view('user/riwayatabsensi',$data); + + } + + +} diff --git a/application/controllers/user/TambahProduk.php b/application/controllers/user/TambahProduk.php new file mode 100644 index 0000000..8549440 --- /dev/null +++ b/application/controllers/user/TambahProduk.php @@ -0,0 +1,126 @@ +load->model("UserModel"); + $this->load->model("UmkmModel"); + $this->load->model("KategoriModel"); + $this->load->model("AbsensiModel"); + $this->load->model("AbsenModel"); + $this->load->model("ProdukModel"); + + if($this->UserModel->isNotLogin()) { + redirect(site_url('login')); + } elseif(!($this->UserModel->isPemilik())) { + redirect(site_url('admin/dashboard')); + } + + $get = $this->input->get(); + if($get['id_umkm']==NULL){ + redirect(site_url('user/dashboard')); + } + } + + public function index() + { + + $get = $this->input->get(); + + + $umkm = $this->UmkmModel->getUmkmsById($get['id_umkm']); + $pemilik = $this->UserModel->getUsersById($umkm->id_pemilik); + $daftarkategori = $this->KategoriModel->getKategori(); + + // var_dump($this->input->post());die(); + + if($this->input->post()){ + $post=$this->input->post(); + if($post['produk']!=='default'){ + if($this->ProdukModel->save($umkm->id_umkm)){ + + $current_produk = $this->ProdukModel->getLastProdukByIdUmkm($umkm->id_umkm); + + if(strlen($_FILES['foto_produk']['tmp_name'])>0){ + $config['upload_path'] = './assets/images/produk/'; + $config['allowed_types'] = 'jpg|jpeg|gif|png'; + $config['max_size'] = 100; + $config['max_width'] = 1024; + $config['max_height'] = 768; + $config['file_name'] = $current_produk->id_produk; + $config['overwrite'] = TRUE; + + $this->load->library('upload', $config); + + if ( ! $this->upload->do_upload('foto_produk')){ + $foto_produk = 'default.png'; + $this->ProdukModel->setFirstImage($current_produk->id_produk,$foto_produk); + $data['error_upload'] = $this->upload->display_errors(); + $data['msg']="success"; + } else { + $file = $this->upload->data(); + + if($this->ProdukModel->setFirstImage($current_produk->id_produk,$file['file_name'])){ + $data['msg']="success"; + } else { + $foto_produk = 'default.png'; + $this->ProdukModel->setFirstImage($current_produk->id_produk,$foto_produk); + $data['error_upload'] = 'gagal upload foto'; + $data['msg']="success"; + } + } + + } else { + $foto_produk = 'default.png'; + $this->ProdukModel->setFirstImage($current_produk->id_produk,$foto_produk); + $data['msg']="success"; + } + + } else { + $data['msg']="error!"; + } + } else { + $data['msg']="error!"; + } + + + } + + $cekabsensiakhir = $this->AbsensiModel->getLatestSignedAbsensiCountByUmkmId($umkm->id_umkm); + + if($cekabsensiakhir > 0 ){ + $absensiakhir = $this->AbsensiModel->getLatestSignedAbsensiByUmkmId($umkm->id_umkm); + $aset = $absensiakhir->aset; + $karyawan_l = $absensiakhir->karyawan_l; + $karyawan_p = $absensiakhir->karyawan_p; + $data['listabsensi'] = $this->AbsensiModel->getSignedAbsensiByUmkmId($umkm->id_umkm); + } else { + $aset = $umkm->aset_awal; + $karyawan_l = $umkm->karyawan_l; + $karyawan_p = $umkm->karyawan_p; + $data['listabsensi'] = array(); + } + + + $data['omset'] = $umkm->omset_awal; + $data['karyawan_l'] = $karyawan_l; + $data['karyawan_p'] = $karyawan_p; + $data['aset'] = $aset; + $data['daftarkategori'] = $daftarkategori; + $data['umkm'] = $umkm; + $data['pemilik'] = $pemilik; + $data['user_logged'] = $this->session->userdata('user_logged'); + + + + + $this->load->view('user/tambahproduk',$data); + + } + + +} diff --git a/application/models/AbsensiModel.php b/application/models/AbsensiModel.php index 51c14f7..b981db1 100644 --- a/application/models/AbsensiModel.php +++ b/application/models/AbsensiModel.php @@ -10,6 +10,22 @@ class AbsensiModel extends CI_Model return $absensi = $this->db->get($this->_table)->result(); } + public function getAbsensiByAbsenIdAndUmkmId($id_umkm,$id_absen){ + $this->db->where('id_absen', $id_absen); + $this->db->where('id_umkm', $id_umkm); + return $absensi = $this->db->get($this->_table)->row(); + } + + public function update($id_absensi){ + $post = $this->input->post(); + $this->aset = $post["aset"]; + $this->omset = $post["omset"]; + $this->karyawan_l = $post["karyawan_l"]; + $this->karyawan_p = $post["karyawan_p"]; + $this->signed = 1; + return $this->db->update($this->_table, $this, array('id_absensi' => $id_absensi)); + } + public function getLastMonthAbsensi($bulan,$tahun){ $bulan = $bulan-1; $this->db->where('bulan', $bulan); @@ -75,6 +91,7 @@ class AbsensiModel extends CI_Model public function getSignedAbsensiByUmkmId($id_umkm){ $this->db->where('signed', true); $this->db->where('id_umkm', $id_umkm); + $this->db->where('tahun', date('Y')); $this->db->order_by('bulan', 'DESC'); $this->db->order_by('tahun', 'DESC'); return $user = $this->db->get($this->_table)->result(); diff --git a/application/models/ProdukModel.php b/application/models/ProdukModel.php new file mode 100644 index 0000000..f64871d --- /dev/null +++ b/application/models/ProdukModel.php @@ -0,0 +1,47 @@ +input->post(); + $this->id_umkm = $id_umkm; + $this->produk = $post["produk"]; + $this->deskripsi = $post["deskripsi"]; + + $this->foto_produk = "default.png"; + return $this->db->insert($this->_table, $this); + } + + public function getProdukByUmkmId($id_umkm){ + $this->db->where('id_umkm', $id_umkm); + $this->db->order_by('produk', 'DESC'); + return $produk = $this->db->get($this->_table)->result(); + } + + public function getProdukById($id_produk){ + $this->db->where('id_produk', $id_produk); + return $produk = $this->db->get($this->_table)->row(); + } + + public function getLastProdukByIdUmkm($id_umkm){ + $this->db->where('id_umkm', $id_umkm); + $this->db->order_by('id_produk', 'DESC'); + return $umkm = $this->db->get($this->_table)->row(); + } + + public function setFirstImage($id_produk,$foto_produk) + { + $this->foto_produk = $foto_produk; + return $this->db->update($this->_table, $this, array('id_produk' => $id_produk)); + } + + public function delete($id_produk) + { + return $this->db->delete($this->_table, array("id_produk" => $id_produk)); + } + + +} \ No newline at end of file diff --git a/application/models/UmkmModel.php b/application/models/UmkmModel.php index 536a6d2..04fde85 100644 --- a/application/models/UmkmModel.php +++ b/application/models/UmkmModel.php @@ -66,6 +66,7 @@ class UmkmModel extends CI_Model public function getUmkmsByIdPemilik($id_pemilik){ $this->db->join('tb_kategori','tb_kategori.id_kategori = tb_umkm.id_kategori'); + $this->db->join('tb_jenis','tb_jenis.id_jenis = tb_umkm.id_jenis'); $this->db->where('id_pemilik', $id_pemilik); return $umkm = $this->db->get($this->_table)->result(); } @@ -127,6 +128,20 @@ class UmkmModel extends CI_Model return $this->db->update($this->_table, $this, array('id_umkm' => $id_umkm)); } + public function userUpdate($id_umkm,$foto_umkm) + { + $post = $this->input->post(); + $this->nama = $post["nama"]; + + + $this->id_jenis = $post["jenis"]; + + $this->telp = $post["telp"]; + $this->deskripsi = $post["deskripsi"]; + $this->foto_umkm = $foto_umkm; + return $this->db->update($this->_table, $this, array('id_umkm' => $id_umkm)); + } + public function delete($id_umkm) { return $this->db->delete($this->_table, array("id_umkm" => $id_umkm)); diff --git a/application/views/user/dashboard.php b/application/views/user/dashboard.php new file mode 100644 index 0000000..d6e25ac --- /dev/null +++ b/application/views/user/dashboard.php @@ -0,0 +1,197 @@ + + +
+ + + + + + + + + + + + + +No | +Nama Umkm | + +Kecamatan | +Kategori | +Opsi | + +
---|---|---|---|---|
+ | nama?> | + +kecamatan?> | + KategoriModel->getKategoriById($umkm->id_kategori); + ?> +kategori?> | ++ Detail + Edit + + | +