Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('SYSPATH') OR die('No direct access allowed.');
- class Admin_Controller extends App_Controller {
- public function index(){}
- public function adduser()
- {
- $this->template->content->adduserform = new View('admin_adduserform');
- $this->template->content->adduserform->companies = ORM::factory('company')->select_list('id','name');
- if($_SERVER['REQUEST_METHOD'] == 'POST')
- {
- var_dump($_POST);
- echo $this->input->post('company');
- $this->user = ORM::factory('user', $this->input->post('username'));
- $this->user->username = $this->input->post('username');
- $this->user->email = $this->input->post('email');
- $this->user->password = $this->input->post('password');
- $this->user->company_id = $this->input->post('company');
- if ($this->user->username == 'admin')
- {
- $this->user->add(ORM::factory('role', array('name' => 'admin')));
- $this->user->add(ORM::factory('role', array('name' => 'login')));
- } else {
- $this->user->add(ORM::factory('role', array('name' => 'login')));
- }
- $this->user->save();
- }
- }
- public function addcompany()
- {
- $this->template->content->addcompanyform = new View('admin_addcompanyform');
- if($_SERVER['REQUEST_METHOD'] == 'POST')
- {
- var_dump($_POST);
- echo $this->input->post('company');
- $this->company = ORM::factory('company', $this->input->post('company'));
- $this->company->name = $this->input->post('company');
- $this->company->save();
- }
- }
- public function additem()
- {
- $this->template->content->additemform = new View('admin_additemform');
- $this->template->content->additemform->companies = ORM::factory('company')->select_list('id','name');
- if($_SERVER['REQUEST_METHOD'] == 'POST')
- {
- var_dump($_POST);
- $this->item = ORM::factory('item', $this->input->post('item'));
- $this->item->name = $this->input->post('item_name');
- $this->item->description = $this->input->post('item_description');
- $this->item->quantity = $this->input->post('item_quantity');
- $this->item->company_id = $this->input->post('item_company');
- $this->item->save();
- }
- }
- public function listusers()
- {
- $this->user = ORM::factory('user', $this->input->post('username'));
- $this->template->content->userlist = new View('userlist', array('users' => $this->user->find_all()));
- }
- public function listcompanies()
- {
- $this->company = ORM::factory('company')->find_all();
- $this->template->content->companylist = new View('companylist', array('companies' => $this->company));
- }
- public function listitems()
- {
- $this->item = ORM::factory('item')->find_all();
- $this->template->content->itemlist = new View('itemlist', array('items' => $this->item));
- }
- public function __construct() {
- parent::__construct();
- $this->template->content = new View('admin_content');
- $this->template->title = 'VINIX Inventory Admin Panel';
- if (!$this->auth->logged_in('admin'))
- {
- url::redirect('/user/login');
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement