<?php

defined('BASEPATH') OR exit('No direct script access allowed');

class Store_controller extends CI_Controller {

    public function __construct() {
        parent::__construct();
        // Your own constructor code
        $this->load->model('business_model');
        $this->load->model('store_model');
        
        if ($this->session->userdata('role') == '') {
            redirect('logout');
        }
    }

    public function business_stores() {
        if($this->session->userdata('role')=='' || $this->session->userdata('role')=='Sh-Users'){
            $this->load->view('login_view');
        } else {
            //storemanager,hr,reception...user serial
            checkroles(0, 0, 0);

            $data['nav'] = 'my_business';
            $data['subnav'] = 'business_stores';

            $data['stores'] = $this->store_model->get_business_stores();

            $this->load->view('includes/header', $data);
            $this->load->view('setting/business_stores_view');
            $this->load->view('includes/footer');
        }
    }

    public function edit_store() {
        $result = $this->store_model->edit_store();
        echo (json_encode($result));
        die;
    }

    public function update_store() {

        $result = $this->store_model->update_store();
        echo('success|' . $result);
    }
    
    public function add_store() {

        $result = $this->store_model->add_store();
        echo('success|' . $result);
    }


}
