Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:snipe/snipe-it into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
uberbrady committed Nov 18, 2013
2 parents 8f86ec9 + 3d5dcf7 commit 90c4dfe
Show file tree
Hide file tree
Showing 17 changed files with 438 additions and 440 deletions.
127 changes: 63 additions & 64 deletions app/controllers/admin/AssetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,49 +53,49 @@ public function getCreate()
*/
public function postCreate()
{
// Declare the rules for the form validation
$rules = array(
'name' => 'required|min:3',
'asset_tag' => 'required|min:3|unique:assets',
'model_id' => 'required',
'serial' => 'required|min:3',
);

// Create a new validator instance from our validation rules
$validator = Validator::make(Input::all(), $rules);

// If validation fails, we'll exit the operation now.
if ($validator->fails())
{
// Ooops.. something went wrong
return Redirect::back()->withInput()->withErrors($validator);
}

// Create a new asset
$asset = new Asset;
// get the POST data
$new = Input::all();

// Save the asset data
$asset->name = e(Input::get('name'));
$asset->serial = e(Input::get('serial'));
$asset->model_id = e(Input::get('model_id'));
$asset->purchase_date = e(Input::get('purchase_date'));
$asset->purchase_cost = e(Input::get('purchase_cost'));
$asset->order_number = e(Input::get('order_number'));
$asset->notes = e(Input::get('notes'));
$asset->asset_tag = e(Input::get('asset_tag'));
$asset->user_id = Sentry::getId();
$asset->physical = '1';
// create a new model instance
$asset = new Asset();

// attempt validation
if ($asset->validate($new))
{

// Was the asset created?
if($asset->save())
// Save the asset data
$asset->name = e(Input::get('name'));
$asset->serial = e(Input::get('serial'));
$asset->model_id = e(Input::get('model_id'));
$asset->purchase_date = e(Input::get('purchase_date'));
$asset->purchase_cost = e(Input::get('purchase_cost'));
$asset->order_number = e(Input::get('order_number'));
$asset->notes = e(Input::get('notes'));
$asset->asset_tag = e(Input::get('asset_tag'));
$asset->user_id = Sentry::getId();
$asset->physical = '1';


// Was the asset created?
if($asset->save())
{
// Redirect to the asset listing page
return Redirect::to("admin")->with('success', Lang::get('admin/assets/message.create.success'));
}
}
else
{
// Redirect to the asset listing page
return Redirect::to("admin")->with('success', Lang::get('admin/assets/message.create.success'));
// failure
$errors = $asset->errors();
return Redirect::back()->withInput()->withErrors($errors);
}


// Redirect to the asset create page with an error
return Redirect::to('assets/create')->with('error', Lang::get('admin/assets/message.create.error'));


}

/**
Expand Down Expand Up @@ -137,45 +137,44 @@ public function postEdit($assetId = null)
return Redirect::to('admin')->with('error', Lang::get('admin/assets/message.does_not_exist'));
}

// Declare the rules for the form validation
$rules = array(
'name' => 'required|min:3',
'asset_tag' => 'required|min:3',
'model_id' => 'required',
'serial' => 'required|min:3',
);
// get the POST data
$new = Input::all();

// Create a new validator instance from our validation rules
$validator = Validator::make(Input::all(), $rules);

// If validation fails, we'll exit the operation now.
if ($validator->fails())
// attempt validation
if ($asset->validate($new))
{
// Ooops.. something went wrong
return Redirect::back()->withInput()->withErrors($validator);
}
// Update the asset data
$asset->name = e(Input::get('name'));
$asset->serial = e(Input::get('serial'));
$asset->model_id = e(Input::get('model_id'));
$asset->purchase_date = e(Input::get('purchase_date'));
$asset->purchase_cost = e(Input::get('purchase_cost'));
$asset->order_number = e(Input::get('order_number'));
$asset->asset_tag = e(Input::get('asset_tag'));
$asset->notes = e(Input::get('notes'));
$asset->physical = '1';

// Was the asset created?
if($asset->save())
{
// Redirect to the asset listing page
return Redirect::to("admin")->with('success', Lang::get('admin/assets/message.update.success'));
}

// Update the asset data
$asset->name = e(Input::get('name'));
$asset->serial = e(Input::get('serial'));
$asset->model_id = e(Input::get('model_id'));
$asset->purchase_date = e(Input::get('purchase_date'));
$asset->purchase_cost = e(Input::get('purchase_cost'));
$asset->order_number = e(Input::get('order_number'));
$asset->asset_tag = e(Input::get('asset_tag'));
$asset->notes = e(Input::get('notes'));
$asset->physical = '1';


// Was the asset updated?
if($asset->save())
}
else
{
// Redirect to the new asset page
return Redirect::to("assets/$assetId/edit")->with('success', Lang::get('admin/assets/message.update.success'));

// Did not validate
$errors = $asset->errors();
return Redirect::back()->withInput()->withErrors($errors);
}


// Redirect to the asset management page with error
return Redirect::to("assets/$assetId/edit")->with('error', Lang::get('admin/assets/message.update.error'));

}

/**
Expand Down
85 changes: 44 additions & 41 deletions app/controllers/admin/CategoriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,38 +49,40 @@ public function getCreate()
*/
public function postCreate()
{
// Declare the rules for the form validation
$rules = array(
'name' => 'required|min:3',
);

// Create a new validator instance from our validation rules
$validator = Validator::make(Input::all(), $rules);
// get the POST data
$new = Input::all();

// If validation fails, we'll exit the operation now.
if ($validator->fails())
{
// Ooops.. something went wrong
return Redirect::back()->withInput()->withErrors($validator);
}

// Create a new category
$category = new Category;
// create a new model instance
$category = new Category();

// Update the category data
$category->name = e(Input::get('name'));
$category->parent = e(Input::get('parent'));
$category->user_id = Sentry::getId();
// attempt validation
if ($category->validate($new))
{

// Was the category created?
if($category->save())
// Update the category data
$category->name = e(Input::get('name'));
$category->parent = e(Input::get('parent'));
$category->user_id = Sentry::getId();

// Was the asset created?
if($category->save())
{
// Redirect to the new category page
return Redirect::to("admin/settings/categories")->with('success', Lang::get('admin/categories/message.create.success'));
}
}
else
{
// Redirect to the new category page
return Redirect::to("admin/settings/categories")->with('success', Lang::get('admin/categories/message.create.success'));
// failure
$errors = $category->errors();
return Redirect::back()->withInput()->withErrors($errors);
}

// Redirect to the category create page
return Redirect::to('admin/settings/categories/create')->with('error', Lang::get('admin/categories/message.create.error'));


}

/**
Expand Down Expand Up @@ -121,34 +123,35 @@ public function postEdit($categoryId = null)
return Redirect::to('admin/categories')->with('error', Lang::get('admin/categories/message.does_not_exist'));
}

// Declare the rules for the form validation
$rules = array(
'name' => 'required|min:3',
);

// Create a new validator instance from our validation rules
$validator = Validator::make(Input::all(), $rules);
// get the POST data
$new = Input::all();

// If validation fails, we'll exit the operation now.
if ($validator->fails())
// attempt validation
if ($category->validate($new))
{
// Ooops.. something went wrong
return Redirect::back()->withInput()->withErrors($validator);
}

// Update the category data
$category->name = e(Input::get('name'));
$category->parent = e(Input::get('parent'));
// Update the category data
$category->name = e(Input::get('name'));
$category->parent = e(Input::get('parent'));

// Was the category updated?
if($category->save())
// Was the asset created?
if($category->save())
{
// Redirect to the new category page
return Redirect::to("admin/settings/categories")->with('success', Lang::get('admin/categories/message.update.success'));
}
}
else
{
// Redirect to the new category page
return Redirect::to("admin/settings/categories/$categoryId/edit")->with('success', Lang::get('admin/categories/message.update.success'));
// failure
$errors = $category->errors();
return Redirect::back()->withInput()->withErrors($errors);
}

// Redirect to the category management page
return Redirect::to("admin/settings/categories/$categoryID/edit")->with('error', Lang::get('admin/categories/message.update.error'));

}

/**
Expand Down
Loading

0 comments on commit 90c4dfe

Please sign in to comment.