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

class Canteen extends MY_Controller
{

    public $data = array();


    function __construct()
    {
        parent::__construct();
        $this->load->model('Canteen_Model', 'canteen', true);
    }

    public function index($school_id = null)
    {
        // check_permission(VIEW);
        $this->data['records'] = $this->canteen->get_canteen_detail_list($school_id);
      
        $this->data['schools'] = $this->schools;
        // $this->data['list'] = TRUE;
      
        $this->layout->title($this->lang->line('manage_canteen') . ' | ' . SMS);
        $this->load->layout->view('academic/canteen/index', $this->data);
    }
    // public function index()
    // {
    //     $data['records'] = $this->canteen->get_all_data();
    //     $this->load->layout->view('academic/canteen/index', $data);
    // }

      public function delete($id)
    {
        $this->canteen->delete_canteen_record($id);

        // Redirect to a page after deletion (adjust the URL)
        redirect('academic/canteen/index');
    }

    public function add()
    {

        $data = array(
            // 'name' => $this->input->post('name'),
            'school_name' => $this->input->post('school_id'),
            'student_name' => $this->input->post('name'),
            'date' => $this->input->post('date'),
            // 'canteen_user_id' => $this->input->post('canteen_user_id'),
            'canteen_operator' => $this->input->post('canteen_operator_name'),
            // 'wallet_balance' => $this->input->post('wallet_balance'),
            'amount_charged' => $this->input->post('amount_charged')

        );

        $this->canteen->insert('canteen', $data);

        redirect('academic/canteen/index');
    }
}
