Add initial support for multiple companies

You can find screenshots and other files
related to the feature on Dropbox here:
https://www.dropbox.com/sh/wugnzqepwgzwlnh/AAAwNWA5hIKrP0y2VTu-LMHHa?dl=0

https://github.com/snipe/snipe-it/issues/23
This commit is contained in:
Abdullah Alansari
2015-11-07 14:40:48 +03:00
parent c1961c0e40
commit 6bf2a2875f
39 changed files with 822 additions and 65 deletions
@@ -8,6 +8,7 @@ use Setting;
use DB;
use Sentry;
use Consumable;
use Company;
use Str;
use Validator;
use View;
@@ -41,7 +42,12 @@ class ConsumablesController extends AdminController
{
// Show the page
$category_list = array('' => '') + DB::table('categories')->where('category_type','=','consumable')->whereNull('deleted_at')->orderBy('name','ASC')->lists('name', 'id');
return View::make('backend/consumables/edit')->with('consumable',new Consumable)->with('category_list',$category_list);
$company_list = Company::getSelectList();
return View::make('backend/consumables/edit')
->with('consumable', new Consumable)
->with('category_list', $category_list)
->with('company_list', $company_list);
}
@@ -68,6 +74,7 @@ class ConsumablesController extends AdminController
// Update the consumable data
$consumable->name = e(Input::get('name'));
$consumable->category_id = e(Input::get('category_id'));
$consumable->company_id = e(Input::get('company_id'));
$consumable->order_number = e(Input::get('order_number'));
if (e(Input::get('purchase_date')) == '') {
@@ -113,7 +120,11 @@ class ConsumablesController extends AdminController
}
$category_list = array('' => '') + DB::table('categories')->where('category_type','=','consumable')->whereNull('deleted_at')->orderBy('name','ASC')->lists('name', 'id');
return View::make('backend/consumables/edit', compact('consumable'))->with('category_list',$category_list);
$company_list = Company::getSelectList();
return View::make('backend/consumables/edit', compact('consumable'))
->with('category_list', $category_list)
->with('company_list', $company_list);
}
@@ -150,6 +161,7 @@ class ConsumablesController extends AdminController
// Update the consumable data
$consumable->name = e(Input::get('name'));
$consumable->category_id = e(Input::get('category_id'));
$consumable->company_id = e(Input::get('company_id'));
$consumable->order_number = e(Input::get('order_number'));
if (e(Input::get('purchase_date')) == '') {
@@ -365,8 +377,9 @@ class ConsumablesController extends AdminController
public function getDatatable()
{
$consumables = Consumable::select(array('id','name','qty'))
->whereNull('deleted_at');
$consumables = Consumable::select(array('id','name','qty', 'company_id'))
->whereNull('deleted_at')
->with('company');
if (Input::has('search')) {
$consumables = $consumables->TextSearch(Input::get('search'));
@@ -397,13 +410,15 @@ class ConsumablesController extends AdminController
foreach($consumables as $consumable) {
$actions = '<a href="'.route('checkout/consumable', $consumable->id).'" style="margin-right:5px;" class="btn btn-info btn-sm" '.(($consumable->numRemaining() > 0 ) ? '' : ' disabled').'>'.Lang::get('general.checkout').'</a><a href="'.route('update/consumable', $consumable->id).'" class="btn btn-warning btn-sm" style="margin-right:5px;"><i class="fa fa-pencil icon-white"></i></a><a data-html="false" class="btn delete-asset btn-danger btn-sm" data-toggle="modal" href="'.route('delete/consumable', $consumable->id).'" data-content="'.Lang::get('admin/consumables/message.delete.confirm').'" data-title="'.Lang::get('general.delete').' '.htmlspecialchars($consumable->name).'?" onClick="return false;"><i class="fa fa-trash icon-white"></i></a>';
$company = $consumable->company;
$rows[] = array(
'id' => $consumable->id,
'id' => $consumable->id,
'name' => link_to('admin/consumables/'.$consumable->id.'/view', $consumable->name),
'qty' => $consumable->qty,
'numRemaining' => $consumable->numRemaining(),
'actions' => $actions
'actions' => $actions,
'companyName' => is_null($company) ? '' : e($company->name)
);
}