mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
A few more path fixes
This commit is contained in:
parent
e60bda0563
commit
95e2825716
|
@ -947,8 +947,7 @@ class AssetsController extends Controller
|
|||
return Redirect::route('hardware')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
}
|
||||
|
||||
// the asset is valid
|
||||
$destinationPath = config('app.private_uploads').'/imports/assets';
|
||||
$destinationPath = config('app.private_uploads').'/assets';
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
namespace App\Http\Controllers;
|
||||
|
||||
use Assets;
|
||||
|
||||
use Input;
|
||||
use Lang;
|
||||
use App\Models\License;
|
||||
|
@ -36,15 +35,16 @@ use Auth;
|
|||
|
||||
class LicensesController extends Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Show a list of all the licenses.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the licenses listing, which is generated in getDatatable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LicensesController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Show the page
|
||||
|
@ -53,15 +53,16 @@ class LicensesController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* License create.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
* Returns a form view that allows an admin to create a new licence.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see AccessoriesController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
// Show the page
|
||||
// $license_options = array('0' => 'Top Level') + License::lists('name', 'id');
|
||||
// Show the page
|
||||
|
||||
$depreciation_list = Helper::depreciationList();
|
||||
$supplier_list = Helper::suppliersList();
|
||||
$maintained_list = array('' => 'Maintained', '1' => 'Yes', '0' => 'No');
|
||||
|
@ -78,10 +79,14 @@ class LicensesController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* License create form processing.
|
||||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
* Validates and stores the license form data submitted from the new
|
||||
* license form.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LicensesController::getCreate() method that provides the form view
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
|
||||
|
@ -173,11 +178,14 @@ class LicensesController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* License update.
|
||||
*
|
||||
* @param int $licenseId
|
||||
* @return View
|
||||
*/
|
||||
* Returns a form with existing license data to allow an admin to
|
||||
* update license information.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $licenseId
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($licenseId = null)
|
||||
{
|
||||
// Check if the license exists
|
||||
|
@ -213,14 +221,18 @@ class LicensesController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* License update form processing page.
|
||||
*
|
||||
* @param int $licenseId
|
||||
* @return Redirect
|
||||
*/
|
||||
* Validates and stores the license form data submitted from the edit
|
||||
* license form.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LicensesController::getEdit() method that provides the form view
|
||||
* @since [v1.0]
|
||||
* @param int $licenseId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($licenseId = null)
|
||||
{
|
||||
// Check if the license exists
|
||||
// Check if the license exists
|
||||
if (is_null($license = License::find($licenseId))) {
|
||||
// Redirect to the blogs management page
|
||||
return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.does_not_exist'));
|
||||
|
@ -359,11 +371,14 @@ class LicensesController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete the given license.
|
||||
*
|
||||
* @param int $licenseId
|
||||
* @return Redirect
|
||||
*/
|
||||
* Checks to see whether the selected license can be deleted, and
|
||||
* if it can, marks it as deleted.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $licenseId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($licenseId)
|
||||
{
|
||||
// Check if the license exists
|
||||
|
@ -402,11 +417,19 @@ class LicensesController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Check out the asset to a person
|
||||
**/
|
||||
* Provides the form view for checking out a license to a user.
|
||||
* Here we pass the license seat ID instead of the license ID,
|
||||
* because licenses themselves are never checked out to anyone,
|
||||
* only the seats associated with them.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $seatId
|
||||
* @return View
|
||||
*/
|
||||
public function getCheckout($seatId)
|
||||
{
|
||||
// Check if the asset exists
|
||||
// Check if the license seat exists
|
||||
if (is_null($licenseseat = LicenseSeat::find($seatId))) {
|
||||
// Redirect to the asset management page with error
|
||||
return Redirect::to('admin/licenses')->with('error', Lang::get('admin/licenses/message.not_found'));
|
||||
|
@ -455,8 +478,14 @@ class LicensesController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Check out the asset to a person
|
||||
**/
|
||||
* Validates and stores the license checkout action.
|
||||
*
|
||||
* @todo Switch to using a FormRequest for validation here.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $seatId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCheckout($seatId)
|
||||
{
|
||||
|
||||
|
@ -604,8 +633,14 @@ class LicensesController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Check the license back into inventory
|
||||
**/
|
||||
* Makes the form view to check a license seat back into inventory.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $seatId
|
||||
* @param string $backto
|
||||
* @return View
|
||||
*/
|
||||
public function getCheckin($seatId = null, $backto = null)
|
||||
{
|
||||
// Check if the asset exists
|
||||
|
@ -622,8 +657,15 @@ class LicensesController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Check in the item so that it can be checked out again to someone else
|
||||
**/
|
||||
* Validates and stores the license checkin action.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LicensesController::getCheckin() method that provides the form view
|
||||
* @since [v1.0]
|
||||
* @param int $seatId
|
||||
* @param string $backto
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCheckin($seatId = null, $backto = null)
|
||||
{
|
||||
// Check if the asset exists
|
||||
|
@ -729,11 +771,13 @@ class LicensesController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the asset information to present to the asset view page
|
||||
* Makes the license detail page.
|
||||
*
|
||||
* @param int $licenseId
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $licenseId
|
||||
* @return View
|
||||
**/
|
||||
*/
|
||||
public function getView($licenseId = null)
|
||||
{
|
||||
|
||||
|
@ -767,7 +811,7 @@ class LicensesController extends Controller
|
|||
|
||||
// Show the page
|
||||
$license_options = array('0' => 'Top Level') + License::pluck('name', 'id')->toArray();
|
||||
$maintained_list = array('' => 'Maintained', '1' => 'Yes', '0' => 'No');
|
||||
$maintained_list = array('' => 'Maintained', '1' => 'Yes', '0' => 'No');
|
||||
$company_list = Helper::companyList();
|
||||
//clone the orig
|
||||
$license = clone $license_to_clone;
|
||||
|
@ -789,11 +833,14 @@ class LicensesController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Upload the file to the server
|
||||
* Validates and stores files associated with a license.
|
||||
*
|
||||
* @param int $licenseId
|
||||
* @return View
|
||||
**/
|
||||
* @todo Switch to using the AssetFileRequest form request validator.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $licenseId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postUpload($licenseId = null)
|
||||
{
|
||||
$license = License::find($licenseId);
|
||||
|
@ -852,9 +899,6 @@ class LicensesController extends Controller
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
// Prepare the error message
|
||||
$error = Lang::get('admin/licenses/message.does_not_exist', compact('id'));
|
||||
|
@ -866,12 +910,14 @@ class LicensesController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Delete the associated file
|
||||
* Deletes the selected license file.
|
||||
*
|
||||
* @param int $licenseId
|
||||
* @param int $fileId
|
||||
* @return View
|
||||
**/
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $licenseId
|
||||
* @param int $fileId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDeleteFile($licenseId = null, $fileId = null)
|
||||
{
|
||||
$license = License::find($licenseId);
|
||||
|
@ -905,12 +951,14 @@ class LicensesController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Display/download the uploaded file
|
||||
* Allows the selected file to be viewed.
|
||||
*
|
||||
* @param int $licenseId
|
||||
* @param int $fileId
|
||||
* @return View
|
||||
**/
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.4]
|
||||
* @param int $licenseId
|
||||
* @param int $fileId
|
||||
* @return Redirect
|
||||
*/
|
||||
public function displayFile($licenseId = null, $fileId = null)
|
||||
{
|
||||
|
||||
|
@ -924,7 +972,7 @@ class LicensesController extends Controller
|
|||
}
|
||||
|
||||
$log = Actionlog::find($fileId);
|
||||
$file = $log->get_src();
|
||||
$file = $log->get_src('licenses');
|
||||
return Response::download($file);
|
||||
} else {
|
||||
// Prepare the error message
|
||||
|
@ -935,6 +983,15 @@ class LicensesController extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates a JSON response to populate the licence index datatables.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LicensesController::getIndex() method that provides the view
|
||||
* @since [v1.0]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
$licenses = License::with('company');
|
||||
|
@ -981,6 +1038,19 @@ class LicensesController extends Controller
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the next free seat ID for checkout.
|
||||
*
|
||||
* @todo This is a dumb way to solve this problem.
|
||||
* Author should refactor. And go hide in a hole and
|
||||
* think about what she's done. And perhaps find a new
|
||||
* line of work. And get in the sea.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @since [v1.0]
|
||||
* @param int $licenseId
|
||||
* @return View
|
||||
*/
|
||||
public function getFreeLicense($licenseId)
|
||||
{
|
||||
// Check if the asset exists
|
||||
|
|
|
@ -26,12 +26,16 @@ use Symfony\Component\HttpFoundation\JsonResponse;
|
|||
|
||||
class LocationsController extends Controller
|
||||
{
|
||||
/**
|
||||
* Show a list of all the locations.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the locations listing, which is generated in getDatatable.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getDatatable() method that generates the JSON response
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
// Grab all the locations
|
||||
|
@ -43,10 +47,13 @@ class LocationsController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Location create.
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
* Returns a form view used to create a new location.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::postCreate() method that validates and stores the data
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getCreate()
|
||||
{
|
||||
$locations = \App\Models\Location::orderBy('name', 'ASC')->get();
|
||||
|
@ -62,10 +69,14 @@ class LocationsController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Location create form processing.
|
||||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
* Validates and stores a new location.
|
||||
*
|
||||
* @todo Check if a Form Request would work better here.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getCreate() method that makes the form
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postCreate()
|
||||
{
|
||||
|
||||
|
@ -89,7 +100,6 @@ class LocationsController extends Controller
|
|||
$location->zip = e(Input::get('zip'));
|
||||
$location->user_id = Auth::user()->id;
|
||||
|
||||
// Was the asset created?
|
||||
if ($location->save()) {
|
||||
// Redirect to the new location page
|
||||
return Redirect::to("admin/settings/locations")->with('success', Lang::get('admin/locations/message.create.success'));
|
||||
|
@ -99,37 +109,41 @@ class LocationsController extends Controller
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates and stores a new location created via the Create Asset form modal.
|
||||
*
|
||||
* @todo Check if a Form Request would work better here.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see AssetsController::getCreate() method that makes the form
|
||||
* @since [v1.0]
|
||||
* @return String JSON
|
||||
*/
|
||||
public function store()
|
||||
{
|
||||
|
||||
$new['currency']=Setting::first()->default_currency;
|
||||
|
||||
// create a new location instance
|
||||
// create a new location instance
|
||||
$location = new Location();
|
||||
|
||||
// Save the location data
|
||||
// Save the location data
|
||||
$location->name = e(Input::get('name'));
|
||||
// if (Input::get('parent_id')=='') {
|
||||
// $location->parent_id = null;
|
||||
// } else {
|
||||
// $location->parent_id = e(Input::get('parent_id'));
|
||||
// }
|
||||
$location->currency = Setting::first()->default_currency; //e(Input::get('currency'));
|
||||
$location->address = ''; //e(Input::get('address'));
|
||||
// $location->address2 = e(Input::get('address2'));
|
||||
// $location->address2 = e(Input::get('address2'));
|
||||
$location->city = e(Input::get('city'));
|
||||
$location->state = '';//e(Input::get('state'));
|
||||
$location->country = e(Input::get('country'));
|
||||
// $location->zip = e(Input::get('zip'));
|
||||
// $location->zip = e(Input::get('zip'));
|
||||
$location->user_id = Auth::user()->id;
|
||||
|
||||
// Was the location created?
|
||||
// Was the location created?
|
||||
if ($location->save()) {
|
||||
return JsonResponse::create($location);
|
||||
|
||||
}
|
||||
|
||||
// failure
|
||||
// failure
|
||||
$errors = $location->errors();
|
||||
return JsonResponse::create(["error" => "Failed validation: ".print_r($location->getErrors(), true)], 500);
|
||||
|
||||
|
@ -137,11 +151,14 @@ class LocationsController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Location update.
|
||||
*
|
||||
* @param int $locationId
|
||||
* @return View
|
||||
*/
|
||||
* Makes a form view to edit location information.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::postCreate() method that validates and stores
|
||||
* @param int $locationId
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getEdit($locationId = null)
|
||||
{
|
||||
// Check if the location exists
|
||||
|
@ -160,11 +177,14 @@ class LocationsController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Location update form processing page.
|
||||
*
|
||||
* @param int $locationId
|
||||
* @return Redirect
|
||||
*/
|
||||
* Validates and stores updated location data from edit form.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getEdit() method that makes the form view
|
||||
* @param int $locationId
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postEdit($locationId = null)
|
||||
{
|
||||
// Check if the location exists
|
||||
|
@ -173,7 +193,6 @@ class LocationsController extends Controller
|
|||
return Redirect::to('admin/settings/locations')->with('error', Lang::get('admin/locations/message.does_not_exist'));
|
||||
}
|
||||
|
||||
|
||||
// Update the location data
|
||||
$location->name = e(Input::get('name'));
|
||||
if (Input::get('parent_id')=='') {
|
||||
|
@ -201,11 +220,13 @@ class LocationsController extends Controller
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete the given location.
|
||||
*
|
||||
* @param int $locationId
|
||||
* @return Redirect
|
||||
*/
|
||||
* Validates and deletes selected location.
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $locationId
|
||||
* @since [v1.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getDelete($locationId)
|
||||
{
|
||||
// Check if the location exists
|
||||
|
@ -234,11 +255,16 @@ class LocationsController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Get the location page detail page
|
||||
* Returns a view that invokes the ajax tables which actually contains
|
||||
* the content for the locations detail page.
|
||||
*
|
||||
* @param int $locationID
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getDataViewUsers() method that returns JSON for location users
|
||||
* @see LocationsController::getDataViewAssets() method that returns JSON for location assets
|
||||
* @param int $locationId
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
**/
|
||||
*/
|
||||
public function getView($locationId = null)
|
||||
{
|
||||
$location = \App\Models\Location::find($locationId);
|
||||
|
@ -258,11 +284,13 @@ class LocationsController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Get the locations API information to present to the location view page
|
||||
* Returns the JSON response to populate the bootstrap tables on the locationa view.
|
||||
*
|
||||
* @param int $locationID
|
||||
* @return JSON
|
||||
**/
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getIndex() method that returns JSON for location index
|
||||
* @since [v1.0]
|
||||
* @return View
|
||||
*/
|
||||
public function getDatatable()
|
||||
{
|
||||
$locations = \App\Models\Location::select(array('locations.id','locations.name','locations.address','locations.address2','locations.city','locations.state','locations.zip','locations.country','locations.parent_id','locations.currency'))->with('assets');
|
||||
|
@ -333,11 +361,15 @@ class LocationsController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* Get the location user listing information to present to the location details page
|
||||
* Returns a JSON response that contains the users association with the
|
||||
* selected location, to be used by the location detail view.
|
||||
*
|
||||
* @param int $locationID
|
||||
* @return JSON
|
||||
**/
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getView() method that creates the display view
|
||||
* @param int $locationId
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function getDataViewUsers($locationID)
|
||||
{
|
||||
$location = \App\Models\Location::find($locationID);
|
||||
|
@ -358,12 +390,17 @@ class LocationsController extends Controller
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the location asset information to present to the location details page
|
||||
*
|
||||
* @param int $locationID
|
||||
* @return JSON
|
||||
**/
|
||||
/**
|
||||
* Returns a JSON response that contains the assets association with the
|
||||
* selected location, to be used by the location detail view.
|
||||
*
|
||||
* @todo This is broken for accessories and consumables.
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @see LocationsController::getView() method that creates the display view
|
||||
* @param int $locationId
|
||||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function getDataViewAssets($locationID)
|
||||
{
|
||||
$location = \App\Models\Location::find($locationID);
|
||||
|
|
|
@ -87,10 +87,10 @@ class Actionlog extends Model implements ICompanyableChild
|
|||
/**
|
||||
* Check if the file exists, and if it does, force a download
|
||||
**/
|
||||
public function get_src()
|
||||
public function get_src($type = 'assets')
|
||||
{
|
||||
|
||||
$file = storage_path() . '/app/private_uploads/' . $this->filename;
|
||||
$file = config('app.private_uploads') . '/' . $type . '/' . $this->filename;
|
||||
|
||||
return $file;
|
||||
|
||||
|
|
Loading…
Reference in a new issue