policybot/application/controllers/Menu.php

52 lines
1.1 KiB
PHP
Raw Permalink Normal View History

2021-11-30 10:56:55 +00:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Menu extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('Menu_model');
}
function list_menu()
{
if($this->session->userdata('id')==""){redirect('admin/login');}
$data['men']=$this->Menu_model->list_menu();
$this->load->view('admin/menu/list',$data);
}
function update_menu()
{
if($this->session->userdata('id')==""){redirect('admin/login');}
if($this->input->post('add'))
{
$checkhide=$this->input->post('checkhide');
$pri_id=$this->input->post('pri_id');
foreach($pri_id as $key=>$val)
{
$PID=$pri_id[$key];
$VAL=$checkhide[$key];
$table="menu";
$where=array("id"=>$PID);
$rvalue=array("status"=>$VAL);
$result=$this->commonsql_model->updateTable($table,$where,$rvalue);
}
if($result)
{
$this->session->set_userdata('suc','successfully Updated');
redirect('admin/cmenu');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('admin/cmenu');
}
}
}
}
?>