Advertisement
Guest User

Untitled

a guest
May 15th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.72 KB | None | 0 0
  1. <?php defined('SYSPATH') OR die('No direct access allowed.');
  2.  
  3. class Admin_Controller extends App_Controller {
  4.  
  5.         public function index(){}
  6.  
  7.         public function adduser()
  8.         {
  9.             $this->template->content->adduserform = new View('admin_adduserform');
  10.             $this->template->content->adduserform->companies = ORM::factory('company')->select_list('id','name');
  11.  
  12.             if($_SERVER['REQUEST_METHOD'] == 'POST')
  13.             {
  14.                 var_dump($_POST);
  15.                 echo $this->input->post('company');
  16.                 $this->user = ORM::factory('user', $this->input->post('username'));
  17.                 $this->user->username = $this->input->post('username');
  18.                 $this->user->email = $this->input->post('email');
  19.                 $this->user->password = $this->input->post('password');
  20.                 $this->user->company_id = $this->input->post('company');
  21.  
  22.                 if ($this->user->username == 'admin')
  23.                 {
  24.                     $this->user->add(ORM::factory('role', array('name' => 'admin')));
  25.                     $this->user->add(ORM::factory('role', array('name' => 'login')));
  26.                 } else {
  27.                     $this->user->add(ORM::factory('role', array('name' => 'login')));
  28.                 }
  29.  
  30.                 $this->user->save();
  31.             }
  32.         }
  33.  
  34.         public function addcompany()
  35.         {
  36.             $this->template->content->addcompanyform = new View('admin_addcompanyform');
  37.            
  38.  
  39.             if($_SERVER['REQUEST_METHOD'] == 'POST')
  40.             {
  41.                 var_dump($_POST);
  42.                 echo $this->input->post('company');
  43.                 $this->company = ORM::factory('company', $this->input->post('company'));
  44.                 $this->company->name = $this->input->post('company');
  45.                 $this->company->save();
  46.             }
  47.         }
  48.         public function additem()
  49.         {
  50.             $this->template->content->additemform = new View('admin_additemform');
  51.             $this->template->content->additemform->companies = ORM::factory('company')->select_list('id','name');
  52.  
  53.             if($_SERVER['REQUEST_METHOD'] == 'POST')
  54.             {
  55.                 var_dump($_POST);
  56.                 $this->item = ORM::factory('item', $this->input->post('item'));
  57.                 $this->item->name = $this->input->post('item_name');
  58.                 $this->item->description = $this->input->post('item_description');
  59.                 $this->item->quantity = $this->input->post('item_quantity');
  60.                 $this->item->company_id = $this->input->post('item_company');
  61.                 $this->item->save();
  62.             }
  63.  
  64.         }
  65.         public function listusers()
  66.         {
  67.             $this->user = ORM::factory('user', $this->input->post('username'));
  68.             $this->template->content->userlist = new View('userlist', array('users' => $this->user->find_all()));
  69.         }
  70.  
  71.         public function listcompanies()
  72.         {
  73.             $this->company = ORM::factory('company')->find_all();
  74.             $this->template->content->companylist = new View('companylist', array('companies' => $this->company));
  75.         }
  76.  
  77.         public function listitems()
  78.         {
  79.             $this->item = ORM::factory('item')->find_all();
  80.             $this->template->content->itemlist = new View('itemlist', array('items' => $this->item));
  81.         }
  82.  
  83.         public function  __construct() {
  84.             parent::__construct();
  85.             $this->template->content = new View('admin_content');
  86.             $this->template->title = 'VINIX Inventory Admin Panel';
  87.             if (!$this->auth->logged_in('admin'))
  88.             {
  89.                  url::redirect('/user/login');
  90.             }
  91.         }
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement