51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
|
|
|
class HapusProduk extends CI_Controller {
|
|
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->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');
|
|
|
|
}
|
|
|
|
|
|
}
|