mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Small phpcbf cleanup
This commit is contained in:
parent
fd805bde50
commit
51ceaedfaf
|
@ -70,11 +70,11 @@ class LdapSync extends Command
|
|||
$results = Ldap::findLdapUsers();
|
||||
|
||||
if ($this->option('location')!='') {
|
||||
$location = Location::where('name','=',$this->option('location'))->first();
|
||||
$location = Location::where('name', '=', $this->option('location'))->first();
|
||||
LOG::debug('Location name '.$this->option('location').' passed');
|
||||
LOG::debug('Importing to '.$location->name.' ('.$location->id.')');
|
||||
} elseif ($this->option('location_id')!='') {
|
||||
$location = Location::where('id','=',$this->option('location_id'))->first();
|
||||
$location = Location::where('id', '=', $this->option('location_id'))->first();
|
||||
LOG::debug('Location ID '.$this->option('location_id').' passed');
|
||||
LOG::debug('Importing to '.$location->name.' ('.$location->id.')');
|
||||
} else {
|
||||
|
@ -146,7 +146,7 @@ class LdapSync extends Command
|
|||
if ($this->option('summary')) {
|
||||
for ($x = 0; $x < count($summary); $x++) {
|
||||
if ($summary[$x]['status']=='error') {
|
||||
$this->error('ERROR: '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].' was not imported: '.$summary[$x]['note'] );
|
||||
$this->error('ERROR: '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].' was not imported: '.$summary[$x]['note']);
|
||||
} else {
|
||||
$this->info('User '.$summary[$x]['firstname'].' '.$summary[$x]['lastname'].' (username: '.$summary[$x]['username'].' was '.strtoupper($summary[$x]['createorupdate']).'.');
|
||||
}
|
||||
|
@ -159,6 +159,4 @@ class LdapSync extends Command
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -125,12 +125,12 @@ class ObjectImportCommand extends Command
|
|||
}
|
||||
public function progress($count)
|
||||
{
|
||||
if(!$this->bar) {
|
||||
if (!$this->bar) {
|
||||
$this->bar = $this->output->createProgressBar($count);
|
||||
}
|
||||
static $index =0;
|
||||
$index++;
|
||||
if($index < $count) {
|
||||
if ($index < $count) {
|
||||
$this->bar->advance();
|
||||
} else {
|
||||
$this->bar->finish();
|
||||
|
|
|
@ -42,7 +42,7 @@ class Versioning extends Command
|
|||
{
|
||||
|
||||
$versionFile = 'config/version.php';
|
||||
$hash_version = str_replace("\n",'',shell_exec('git describe --tags'));
|
||||
$hash_version = str_replace("\n", '', shell_exec('git describe --tags'));
|
||||
|
||||
$version = explode('-', $hash_version);
|
||||
|
||||
|
@ -52,18 +52,19 @@ class Versioning extends Command
|
|||
'build_version' => $version[1],
|
||||
'hash_version' => $version[2],
|
||||
'full_hash' => $hash_version),
|
||||
true);
|
||||
true
|
||||
);
|
||||
|
||||
|
||||
// Construct our file content
|
||||
$content = <<<CON
|
||||
$content = <<<CON
|
||||
<?php
|
||||
return $array;
|
||||
CON;
|
||||
|
||||
// And finally write the file and output the current version
|
||||
\File::put($versionFile, $content);
|
||||
$this->line('Setting version: '. config('version.app_version').' build '.config('version.build_version').' ('.config('version.hash_version').')');
|
||||
\File::put($versionFile, $content);
|
||||
$this->line('Setting version: '. config('version.app_version').' build '.config('version.build_version').' ('.config('version.hash_version').')');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,20 +46,20 @@ class Handler extends ExceptionHandler
|
|||
public function render($request, Exception $e)
|
||||
{
|
||||
if ($e instanceof \Illuminate\Session\TokenMismatchException) {
|
||||
return redirect()->back()->with('error', trans('general.token_expired'));
|
||||
return redirect()->back()->with('error', trans('general.token_expired'));
|
||||
}
|
||||
|
||||
if ($this->isHttpException($e)) {
|
||||
|
||||
$statusCode = $e->getStatusCode();
|
||||
$statusCode = $e->getStatusCode();
|
||||
|
||||
switch ($statusCode) {
|
||||
switch ($statusCode) {
|
||||
|
||||
case '404':
|
||||
return response()->view('layouts/basic', [
|
||||
case '404':
|
||||
return response()->view('layouts/basic', [
|
||||
'content' => view('errors/404')
|
||||
]);
|
||||
}
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return parent::render($request, $e);
|
||||
|
|
|
@ -31,7 +31,8 @@ class Helper
|
|||
* @since [v2.0]
|
||||
* @return String
|
||||
*/
|
||||
public static function parseEscapedMarkedown($str) {
|
||||
public static function parseEscapedMarkedown($str)
|
||||
{
|
||||
$Parsedown = new \Parsedown();
|
||||
|
||||
if ($str) {
|
||||
|
@ -173,8 +174,9 @@ class Helper
|
|||
$categories = Category::orderBy('name', 'asc')
|
||||
->whereNull('deleted_at')
|
||||
->orderBy('name', 'asc');
|
||||
if(!empty($category_type))
|
||||
if (!empty($category_type)) {
|
||||
$categories = $categories->where('category_type', '=', $category_type);
|
||||
}
|
||||
$category_list = array('' => trans('general.select_category')) + $categories->pluck('name', 'id')->toArray();
|
||||
return $category_list;
|
||||
}
|
||||
|
@ -309,7 +311,7 @@ class Helper
|
|||
{
|
||||
$users_list = array( '' => trans('general.select_user')) +
|
||||
Company::scopeCompanyables(User::where('deleted_at', '=', null))
|
||||
->where('show_in_list','=',1)
|
||||
->where('show_in_list', '=', 1)
|
||||
->orderBy('last_name', 'asc')
|
||||
->orderBy('first_name', 'asc')->get()
|
||||
->pluck('complete_name', 'id')->toArray();
|
||||
|
@ -554,7 +556,7 @@ class Helper
|
|||
if ($permission[$x]['display'] === true) {
|
||||
|
||||
if ($selected_arr) {
|
||||
if (array_key_exists($permission_name,$selected_arr)) {
|
||||
if (array_key_exists($permission_name, $selected_arr)) {
|
||||
$permissions_arr[$permission_name] = $selected_arr[$permission_name];
|
||||
} else {
|
||||
$permissions_arr[$permission_name] = '0';
|
||||
|
@ -585,7 +587,8 @@ class Helper
|
|||
* @since [v3.0]
|
||||
* @return boolean
|
||||
*/
|
||||
public static function checkIfRequired($class, $field) {
|
||||
public static function checkIfRequired($class, $field)
|
||||
{
|
||||
$rules = $class::rules();
|
||||
foreach ($rules as $rule_name => $rule) {
|
||||
if ($rule_name == $field) {
|
||||
|
@ -612,7 +615,7 @@ class Helper
|
|||
*/
|
||||
public static function array_smart_fetch(array $array, $key, $default = '')
|
||||
{
|
||||
array_change_key_case($array, CASE_LOWER);
|
||||
array_change_key_case($array, CASE_LOWER);
|
||||
return array_key_exists(strtolower($key), array_change_key_case($array)) ? e(trim($array[ $key ])) : $default;
|
||||
}
|
||||
|
||||
|
@ -647,7 +650,8 @@ class Helper
|
|||
* @param String $string
|
||||
* @return string
|
||||
*/
|
||||
public static function gracefulDecrypt(CustomField $field, $string) {
|
||||
public static function gracefulDecrypt(CustomField $field, $string)
|
||||
{
|
||||
|
||||
if ($field->isFieldDecryptable($string)) {
|
||||
|
||||
|
@ -675,7 +679,8 @@ class Helper
|
|||
* @param $array array
|
||||
* @return Array
|
||||
*/
|
||||
public static function stripTagsFromJSON(Array $array) {
|
||||
public static function stripTagsFromJSON(array $array)
|
||||
{
|
||||
|
||||
foreach ($array as $key => $value) {
|
||||
$clean_value = strip_tags($value);
|
||||
|
@ -699,7 +704,7 @@ class Helper
|
|||
public static function generateDatatableButton($type, $route, $enabled = true, $message = null, $itemName = null)
|
||||
{
|
||||
$disabledString = $enabled ? '' : 'disabled';
|
||||
switch($type) {
|
||||
switch ($type) {
|
||||
case 'checkout':
|
||||
return '<a href="' . $route . '" style="margin-right:5px;" class="btn btn-info btn-sm ' . $disabledString . '">' . trans('general.checkout') . '</a>';
|
||||
case 'checkin':
|
||||
|
@ -714,5 +719,4 @@ class Helper
|
|||
return '<a href="'.$route.'" class="btn btn-warning btn-sm ' . $disabledString . '"><i class="fa fa-recycle icon-white"></i></a>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class AssetMaintenancesController extends Controller
|
|||
*/
|
||||
public function getDatatable(Request $request)
|
||||
{
|
||||
$maintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company','admin');
|
||||
$maintenances = AssetMaintenance::with('asset', 'supplier', 'asset.company', 'admin');
|
||||
|
||||
if (Input::has('search')) {
|
||||
$maintenances = $maintenances->TextSearch(e($request->input('search')));
|
||||
|
@ -107,12 +107,12 @@ class AssetMaintenancesController extends Controller
|
|||
if (Gate::allows('update', Asset::class)) {
|
||||
$actions .= Helper::generateDatatableButton('edit', route('maintenances.edit', $maintenance->id));
|
||||
$actions .= Helper::generateDatatableButton(
|
||||
'delete',
|
||||
route('maintenances.destroy', $maintenance->id),
|
||||
$enabled = true,
|
||||
trans('admin/asset_maintenances/message.delete.confirm'),
|
||||
$maintenance->title
|
||||
);
|
||||
'delete',
|
||||
route('maintenances.destroy', $maintenance->id),
|
||||
$enabled = true,
|
||||
trans('admin/asset_maintenances/message.delete.confirm'),
|
||||
$maintenance->title
|
||||
);
|
||||
}
|
||||
|
||||
if (($maintenance->cost) && (isset($maintenance->asset)) && ($maintenance->asset->assetloc) && ($maintenance->asset->assetloc->currency!='')) {
|
||||
|
|
|
@ -418,7 +418,7 @@ class AssetModelsController extends Controller
|
|||
if (Input::has('search')) {
|
||||
$assets = $assets->TextSearch(e($request->input('search')));
|
||||
}
|
||||
$offset = request('offset',0);
|
||||
$offset = request('offset', 0);
|
||||
$limit = request('limit', 50);
|
||||
|
||||
|
||||
|
|
|
@ -156,7 +156,7 @@ class AssetsController extends Controller
|
|||
$asset->archived = '0';
|
||||
$asset->physical = '1';
|
||||
$asset->depreciate = '0';
|
||||
$asset->status_id = request('status_id',0);
|
||||
$asset->status_id = request('status_id', 0);
|
||||
$asset->warranty_months = request('warranty_months', null);
|
||||
$asset->purchase_cost = Helper::ParseFloat(Input::get('purchase_cost'));
|
||||
$asset->purchase_date = request('purchase_date', null);
|
||||
|
@ -784,7 +784,7 @@ class AssetsController extends Controller
|
|||
|
||||
// We use hardware instead of asset in the url
|
||||
$redirectTo = "hardware";
|
||||
switch(request('import-type')) {
|
||||
switch (request('import-type')) {
|
||||
case "asset":
|
||||
$redirectTo = "hardware.index";
|
||||
break;
|
||||
|
@ -819,7 +819,7 @@ class AssetsController extends Controller
|
|||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
|
||||
}
|
||||
|
||||
$this->authorize('create',$asset_to_clone);
|
||||
$this->authorize('create', $asset_to_clone);
|
||||
|
||||
$asset = clone $asset_to_clone;
|
||||
$asset->id = null;
|
||||
|
@ -882,7 +882,7 @@ class AssetsController extends Controller
|
|||
$status['success'] = array();
|
||||
|
||||
|
||||
foreach($results as $row) {
|
||||
foreach ($results as $row) {
|
||||
|
||||
if (is_array($row)) {
|
||||
|
||||
|
@ -899,37 +899,37 @@ class AssetsController extends Controller
|
|||
$item[$asset_tag][$batch_counter]['name'] = Helper::array_smart_fetch($row, "name");
|
||||
$item[$asset_tag][$batch_counter]['email'] = Helper::array_smart_fetch($row, "email");
|
||||
|
||||
if ($asset = Asset::where('asset_tag','=',$asset_tag)->first()) {
|
||||
if ($asset = Asset::where('asset_tag', '=', $asset_tag)->first()) {
|
||||
|
||||
$item[$asset_tag][$batch_counter]['asset_id'] = $asset->id;
|
||||
|
||||
$base_username = User::generateFormattedNameFromFullName(Setting::getSettings()->username_format,$item[$asset_tag][$batch_counter]['name']);
|
||||
$user = User::where('username','=',$base_username['username']);
|
||||
$base_username = User::generateFormattedNameFromFullName(Setting::getSettings()->username_format, $item[$asset_tag][$batch_counter]['name']);
|
||||
$user = User::where('username', '=', $base_username['username']);
|
||||
$user_query = ' on username '.$base_username['username'];
|
||||
|
||||
if ($request->input('match_firstnamelastname')=='1') {
|
||||
$firstnamedotlastname = User::generateFormattedNameFromFullName('firstname.lastname',$item[$asset_tag][$batch_counter]['name']);
|
||||
$firstnamedotlastname = User::generateFormattedNameFromFullName('firstname.lastname', $item[$asset_tag][$batch_counter]['name']);
|
||||
$item[$asset_tag][$batch_counter]['username'][] = $firstnamedotlastname['username'];
|
||||
$user->orWhere('username','=',$firstnamedotlastname['username']);
|
||||
$user->orWhere('username', '=', $firstnamedotlastname['username']);
|
||||
$user_query .= ', or on username '.$firstnamedotlastname['username'];
|
||||
}
|
||||
|
||||
if ($request->input('match_flastname')=='1') {
|
||||
$flastname = User::generateFormattedNameFromFullName('filastname',$item[$asset_tag][$batch_counter]['name']);
|
||||
$flastname = User::generateFormattedNameFromFullName('filastname', $item[$asset_tag][$batch_counter]['name']);
|
||||
$item[$asset_tag][$batch_counter]['username'][] = $flastname['username'];
|
||||
$user->orWhere('username','=',$flastname['username']);
|
||||
$user->orWhere('username', '=', $flastname['username']);
|
||||
$user_query .= ', or on username '.$flastname['username'];
|
||||
}
|
||||
if ($request->input('match_firstname')=='1') {
|
||||
$firstname = User::generateFormattedNameFromFullName('firstname',$item[$asset_tag][$batch_counter]['name']);
|
||||
$firstname = User::generateFormattedNameFromFullName('firstname', $item[$asset_tag][$batch_counter]['name']);
|
||||
$item[$asset_tag][$batch_counter]['username'][] = $firstname['username'];
|
||||
$user->orWhere('username','=',$firstname['username']);
|
||||
$user->orWhere('username', '=', $firstname['username']);
|
||||
$user_query .= ', or on username '.$firstname['username'];
|
||||
}
|
||||
if ($request->input('match_email')=='1') {
|
||||
if ($item[$asset_tag][$batch_counter]['email']=='') {
|
||||
$item[$asset_tag][$batch_counter]['username'][] = $user_email = User::generateEmailFromFullName($item[$asset_tag][$batch_counter]['name']);
|
||||
$user->orWhere('username','=',$user_email);
|
||||
$user->orWhere('username', '=', $user_email);
|
||||
$user_query .= ', or on username '.$user_email;
|
||||
}
|
||||
}
|
||||
|
@ -948,8 +948,7 @@ class AssetsController extends Controller
|
|||
'target_type' => User::class,
|
||||
'created_at' => $item[$asset_tag][$batch_counter]['checkout_date'],
|
||||
'action_type' => 'checkout',
|
||||
)
|
||||
);
|
||||
));
|
||||
|
||||
$asset->assigned_to = $user->id;
|
||||
|
||||
|
@ -974,13 +973,13 @@ class AssetsController extends Controller
|
|||
// Loop through and backfill the checkins
|
||||
foreach ($item as $key => $asset_batch) {
|
||||
$total_in_batch = count($asset_batch);
|
||||
for($x = 0; $x < $total_in_batch; $x++) {
|
||||
for ($x = 0; $x < $total_in_batch; $x++) {
|
||||
$next = $x + 1;
|
||||
|
||||
// Only do this if a matching user was found
|
||||
if ((array_key_exists('checkedout_to',$asset_batch[$x])) && ($asset_batch[$x]['checkedout_to']!='')) {
|
||||
if ((array_key_exists('checkedout_to', $asset_batch[$x])) && ($asset_batch[$x]['checkedout_to']!='')) {
|
||||
|
||||
if (($total_in_batch > 1) && ($x < $total_in_batch) && (array_key_exists($next,$asset_batch))) {
|
||||
if (($total_in_batch > 1) && ($x < $total_in_batch) && (array_key_exists($next, $asset_batch))) {
|
||||
$checkin_date = Carbon::parse($asset_batch[$next]['checkout_date'])->subDay(1)->format('Y-m-d H:i:s');
|
||||
$asset_batch[$x]['real_checkin'] = $checkin_date;
|
||||
|
||||
|
@ -992,13 +991,12 @@ class AssetsController extends Controller
|
|||
'target_id' => null,
|
||||
'created_at' => $checkin_date,
|
||||
'action_type' => 'checkin'
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return View::make('hardware/history')->with('status',$status);
|
||||
return View::make('hardware/history')->with('status', $status);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1152,12 +1150,14 @@ class AssetsController extends Controller
|
|||
// Create labels
|
||||
if (Input::get('bulk_actions')=='labels') {
|
||||
$count = 0;
|
||||
return View::make('hardware/labels')->with('assets', Asset::find($asset_ids))->with('settings', Setting::getSettings())->with('count', $count)->with('settings',
|
||||
Setting::getSettings());
|
||||
return View::make('hardware/labels')->with('assets', Asset::find($asset_ids))->with('settings', Setting::getSettings())->with('count', $count)->with(
|
||||
'settings',
|
||||
Setting::getSettings()
|
||||
);
|
||||
} elseif (Input::get('bulk_actions')=='delete') {
|
||||
$assets = Asset::with('assigneduser', 'assetloc')->find($asset_ids);
|
||||
$assets->each(function($asset) {
|
||||
$this->authorize('delete',$asset);
|
||||
$assets->each(function ($asset) {
|
||||
$this->authorize('delete', $asset);
|
||||
});
|
||||
return View::make('hardware/bulk-delete')->with('assets', $assets);
|
||||
// Bulk edit
|
||||
|
@ -1168,8 +1168,10 @@ class AssetsController extends Controller
|
|||
->with('statuslabel_list', Helper::statusLabelList())
|
||||
->with('location_list', Helper::locationsList())
|
||||
->with('models_list', Helper::modelList())
|
||||
->with('companies_list',
|
||||
array('' => '') + array('clear' => trans('general.remove_company')) + Helper::companyList());
|
||||
->with(
|
||||
'companies_list',
|
||||
array('' => '') + array('clear' => trans('general.remove_company')) + Helper::companyList()
|
||||
);
|
||||
}
|
||||
}
|
||||
return redirect()->back()->with('error', 'No action selected');
|
||||
|
@ -1347,7 +1349,7 @@ class AssetsController extends Controller
|
|||
}
|
||||
|
||||
if ($request->has('status_id')) {
|
||||
$assets->where('status_id','=', e($request->get('status_id')));
|
||||
$assets->where('status_id', '=', e($request->get('status_id')));
|
||||
}
|
||||
|
||||
$allowed_columns = [
|
||||
|
@ -1429,60 +1431,58 @@ class AssetsController extends Controller
|
|||
return $data;
|
||||
}
|
||||
|
||||
public function getBulkCheckout()
|
||||
{
|
||||
public function getBulkCheckout()
|
||||
{
|
||||
$this->authorize('checkout', Asset::class);
|
||||
// Filter out assets that are not deployable.
|
||||
$assets_list = Company::scopeCompanyables(Asset::RTD()->get(), 'assets.company_id')->pluck('detailed_name', 'id')->toArray();
|
||||
return View::make('hardware/bulk-checkout')
|
||||
->with('users_list', Helper::usersList())
|
||||
->with('assets_list', $assets_list);
|
||||
}
|
||||
// Filter out assets that are not deployable.
|
||||
$assets_list = Company::scopeCompanyables(Asset::RTD()->get(), 'assets.company_id')->pluck('detailed_name', 'id')->toArray();
|
||||
return View::make('hardware/bulk-checkout')
|
||||
->with('users_list', Helper::usersList())
|
||||
->with('assets_list', $assets_list);
|
||||
}
|
||||
|
||||
public function postBulkCheckout(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
"assigned_to" => 'required'
|
||||
]);
|
||||
public function postBulkCheckout(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
"assigned_to" => 'required'
|
||||
]);
|
||||
|
||||
$user = User::find(e(Input::get('assigned_to')));
|
||||
$admin = Auth::user();
|
||||
$user = User::find(e(Input::get('assigned_to')));
|
||||
$admin = Auth::user();
|
||||
|
||||
$asset_ids = array_filter(Input::get('selected_assets'));
|
||||
$asset_ids = array_filter(Input::get('selected_assets'));
|
||||
|
||||
if ((Input::has('checkout_at')) && (Input::get('checkout_at')!= date("Y-m-d"))) {
|
||||
$checkout_at = e(Input::get('checkout_at'));
|
||||
} else {
|
||||
$checkout_at = date("Y-m-d H:i:s");
|
||||
}
|
||||
if ((Input::has('checkout_at')) && (Input::get('checkout_at')!= date("Y-m-d"))) {
|
||||
$checkout_at = e(Input::get('checkout_at'));
|
||||
} else {
|
||||
$checkout_at = date("Y-m-d H:i:s");
|
||||
}
|
||||
|
||||
if (Input::has('expected_checkin')) {
|
||||
$expected_checkin = e(Input::get('expected_checkin'));
|
||||
} else {
|
||||
$expected_checkin = '';
|
||||
}
|
||||
if (Input::has('expected_checkin')) {
|
||||
$expected_checkin = e(Input::get('expected_checkin'));
|
||||
} else {
|
||||
$expected_checkin = '';
|
||||
}
|
||||
|
||||
$errors = [];
|
||||
DB::transaction(function() use ($user, $admin, $checkout_at, $expected_checkin, $errors, $asset_ids)
|
||||
{
|
||||
foreach($asset_ids as $asset_id)
|
||||
{
|
||||
$asset = Asset::find($asset_id);
|
||||
$this->authorize('checkout', $asset);
|
||||
$error = $asset->checkOutToUser($user, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), null);
|
||||
$errors = [];
|
||||
DB::transaction(function () use ($user, $admin, $checkout_at, $expected_checkin, $errors, $asset_ids) {
|
||||
|
||||
if($error) {
|
||||
array_merge_recursive($errors, $asset->getErrors()->toArray());
|
||||
}
|
||||
}
|
||||
});
|
||||
foreach ($asset_ids as $asset_id) {
|
||||
$asset = Asset::find($asset_id);
|
||||
$this->authorize('checkout', $asset);
|
||||
$error = $asset->checkOutToUser($user, $admin, $checkout_at, $expected_checkin, e(Input::get('note')), null);
|
||||
|
||||
if (!$errors) {
|
||||
// Redirect to the new asset page
|
||||
return redirect()->to("hardware")->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
if ($error) {
|
||||
array_merge_recursive($errors, $asset->getErrors()->toArray());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!$errors) {
|
||||
// Redirect to the new asset page
|
||||
return redirect()->to("hardware")->with('success', trans('admin/hardware/message.checkout.success'));
|
||||
}
|
||||
// Redirect to the asset management page with error
|
||||
return redirect()->to("hardware/bulk-checkout")->with('error', trans('admin/hardware/message.checkout.error'))->withErrors($errors);
|
||||
}
|
||||
|
||||
return redirect()->to("hardware/bulk-checkout")->with('error', trans('admin/hardware/message.checkout.error'))->withErrors($errors);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,8 @@ class ForgotPasswordController extends Controller
|
|||
* Overriding method "getEmailSubject()" from trait "use ResetsPasswords"
|
||||
* @return string
|
||||
*/
|
||||
public function getEmailSubject(){
|
||||
public function getEmailSubject()
|
||||
{
|
||||
return property_exists($this, 'subject') ? $this->subject : \Lang::get('mail.reset_link');
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,6 @@ use Log;
|
|||
use View;
|
||||
use PragmaRX\Google2FA\Google2FA;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This controller handles authentication for the user, including local
|
||||
* database users and LDAP users.
|
||||
|
@ -65,7 +63,7 @@ class LoginController extends Controller
|
|||
{
|
||||
LOG::debug("Binding user to LDAP.");
|
||||
$ldap_user = Ldap::findAndBindUserLdap($request->input('username'), $request->input('password'));
|
||||
if(!$ldap_user) {
|
||||
if (!$ldap_user) {
|
||||
LOG::debug("LDAP user ".$request->input('username')." not found in LDAP or could not bind");
|
||||
throw new \Exception("Could not find user in LDAP directory");
|
||||
} else {
|
||||
|
@ -73,7 +71,7 @@ class LoginController extends Controller
|
|||
}
|
||||
|
||||
// Check if the user already exists in the database and was imported via LDAP
|
||||
$user = User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->where('ldap_import','=',1)->first();
|
||||
$user = User::where('username', '=', Input::get('username'))->whereNull('deleted_at')->where('ldap_import', '=', 1)->first();
|
||||
LOG::debug("Local auth lookup complete");
|
||||
|
||||
// The user does not exist in the database. Try to get them from LDAP.
|
||||
|
@ -135,8 +133,8 @@ class LoginController extends Controller
|
|||
if (Setting::getSettings()->ldap_enabled=='1') {
|
||||
LOG::debug("LDAP is enabled.");
|
||||
try {
|
||||
$user = $this->login_via_ldap($request);
|
||||
Auth::login($user, true);
|
||||
$user = $this->login_via_ldap($request);
|
||||
Auth::login($user, true);
|
||||
|
||||
// If the user was unable to login via LDAP, log the error and let them fall through to
|
||||
// local authentication.
|
||||
|
@ -146,20 +144,20 @@ class LoginController extends Controller
|
|||
}
|
||||
|
||||
// If the user wasn't authenticated via LDAP, skip to local auth
|
||||
if(!$user) {
|
||||
LOG::debug("Authenticating user against database.");
|
||||
if (!$user) {
|
||||
LOG::debug("Authenticating user against database.");
|
||||
// Try to log the user in
|
||||
if (!Auth::attempt(Input::only('username', 'password'), Input::get('remember-me', 0))) {
|
||||
if (!Auth::attempt(Input::only('username', 'password'), Input::get('remember-me', 0))) {
|
||||
|
||||
if (!$lockedOut) {
|
||||
$this->incrementLoginAttempts($request);
|
||||
}
|
||||
if (!$lockedOut) {
|
||||
$this->incrementLoginAttempts($request);
|
||||
}
|
||||
|
||||
LOG::debug("Local authentication failed.");
|
||||
return redirect()->back()->withInput()->with('error', trans('auth/message.account_not_found'));
|
||||
} else {
|
||||
LOG::debug("Local authentication failed.");
|
||||
return redirect()->back()->withInput()->with('error', trans('auth/message.account_not_found'));
|
||||
} else {
|
||||
$this->clearLoginAttempts($request);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the page we were before
|
||||
|
@ -200,7 +198,7 @@ class LoginController extends Controller
|
|||
$user->two_factor_secret
|
||||
);
|
||||
|
||||
return View::make('auth.two_factor_enroll')->with('google2fa_url',$google2fa_url);
|
||||
return View::make('auth.two_factor_enroll')->with('google2fa_url', $google2fa_url);
|
||||
|
||||
}
|
||||
|
||||
|
@ -210,7 +208,8 @@ class LoginController extends Controller
|
|||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
public function getTwoFactorAuth() {
|
||||
public function getTwoFactorAuth()
|
||||
{
|
||||
return View::make('auth.two_factor');
|
||||
}
|
||||
|
||||
|
@ -219,7 +218,8 @@ class LoginController extends Controller
|
|||
*
|
||||
* @return Redirect
|
||||
*/
|
||||
public function postTwoFactorAuth(Request $request) {
|
||||
public function postTwoFactorAuth(Request $request)
|
||||
{
|
||||
|
||||
if (!Auth::check()) {
|
||||
return redirect()->route('login')->with('error', 'You must be logged in.');
|
||||
|
@ -290,7 +290,7 @@ class LoginController extends Controller
|
|||
|
||||
$minutes = round($seconds / 60);
|
||||
|
||||
$message = \Lang::get('auth/message.throttle',['minutes' => $minutes]);
|
||||
$message = \Lang::get('auth/message.throttle', ['minutes' => $minutes]);
|
||||
|
||||
return redirect()->back()
|
||||
->withInput($request->only($this->username(), 'remember'))
|
||||
|
@ -310,8 +310,9 @@ class LoginController extends Controller
|
|||
$maxLoginAttempts = config('auth.throttle.max_attempts');
|
||||
|
||||
return $this->limiter()->tooManyAttempts(
|
||||
$this->throttleKey($request), $maxLoginAttempts, $lockoutTime
|
||||
$this->throttleKey($request),
|
||||
$maxLoginAttempts,
|
||||
$lockoutTime
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -264,7 +264,7 @@ class ComponentsController extends Controller
|
|||
$this->authorize('checkout', $component);
|
||||
|
||||
$max_to_checkout = $component->numRemaining();
|
||||
$validator = Validator::make($request->all(),[
|
||||
$validator = Validator::make($request->all(), [
|
||||
"asset_id" => "required",
|
||||
"assigned_qty" => "required|numeric|between:1,$max_to_checkout"
|
||||
]);
|
||||
|
|
|
@ -114,7 +114,7 @@ class CustomFieldsController extends Controller
|
|||
$field = CustomField::find($field_id);
|
||||
|
||||
if ($field->fieldset()->detach($fieldset_id)) {
|
||||
return redirect()->route('fieldsets.show',['fieldset' => $fieldset_id])->with("success", trans('admin/custom_fields/message.field.delete.success'));
|
||||
return redirect()->route('fieldsets.show', ['fieldset' => $fieldset_id])->with("success", trans('admin/custom_fields/message.field.delete.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withErrors(['message' => "Field is in-use"]);
|
||||
|
|
|
@ -34,24 +34,24 @@ class CustomFieldsetsController extends Controller
|
|||
* @since [v1.8]
|
||||
* @return View
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$cfset = CustomFieldset::with('fields')->where('id','=',$id)->orderBy('id','ASC')->first();
|
||||
$custom_fields_list = ["" => "Add New Field to Fieldset"] + CustomField::pluck("name", "id")->toArray();
|
||||
public function show($id)
|
||||
{
|
||||
$cfset = CustomFieldset::with('fields')->where('id', '=', $id)->orderBy('id', 'ASC')->first();
|
||||
$custom_fields_list = ["" => "Add New Field to Fieldset"] + CustomField::pluck("name", "id")->toArray();
|
||||
|
||||
$maxid = 0;
|
||||
foreach ($cfset->fields() as $field) {
|
||||
if ($field->pivot->order > $maxid) {
|
||||
$maxid=$field->pivot->order;
|
||||
}
|
||||
if (isset($custom_fields_list[$field->id])) {
|
||||
unset($custom_fields_list[$field->id]);
|
||||
}
|
||||
$maxid = 0;
|
||||
foreach ($cfset->fields() as $field) {
|
||||
if ($field->pivot->order > $maxid) {
|
||||
$maxid=$field->pivot->order;
|
||||
}
|
||||
if (isset($custom_fields_list[$field->id])) {
|
||||
unset($custom_fields_list[$field->id]);
|
||||
}
|
||||
|
||||
return View::make("custom_fields.fieldset")->with("custom_fieldset", $cfset)->with("maxid", $maxid+1)->with("custom_fields_list", $custom_fields_list);
|
||||
}
|
||||
|
||||
return View::make("custom_fields.fieldset")->with("custom_fieldset", $cfset)->with("maxid", $maxid+1)->with("custom_fields_list", $custom_fields_list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a view with a form for creating a new custom fieldset.
|
||||
|
@ -80,7 +80,7 @@ class CustomFieldsetsController extends Controller
|
|||
[
|
||||
"name" => e($request->get("name")),
|
||||
"user_id" => Auth::user()->id]
|
||||
);
|
||||
);
|
||||
|
||||
$validator = Validator::make(Input::all(), $cfset->rules);
|
||||
if ($validator->passes()) {
|
||||
|
@ -169,5 +169,4 @@ class CustomFieldsetsController extends Controller
|
|||
|
||||
return redirect()->route("fieldsets.show", [$id])->with("success", trans('admin/custom_fields/message.field.create.assoc_success'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ class ManufacturersController extends Controller
|
|||
'accessories.category',
|
||||
'accessories.manufacturer',
|
||||
'accessories.users'
|
||||
);
|
||||
);
|
||||
$accessories = $manufacturer->accessories();
|
||||
|
||||
if ($request->has('search')) {
|
||||
|
|
|
@ -117,11 +117,11 @@ class ReportsController extends Controller
|
|||
|
||||
$customfields = CustomField::get();
|
||||
|
||||
$response = new StreamedResponse(function() use ($customfields) {
|
||||
$response = new StreamedResponse(function () use ($customfields) {
|
||||
// Open output stream
|
||||
$handle = fopen('php://output', 'w');
|
||||
|
||||
Asset::with('assigneduser', 'assetloc','defaultLoc','assigneduser.userloc','model','supplier','assetstatus','model.manufacturer')->orderBy('created_at', 'DESC')->chunk(500, function($assets) use($handle, $customfields) {
|
||||
Asset::with('assigneduser', 'assetloc', 'defaultLoc', 'assigneduser.userloc', 'model', 'supplier', 'assetstatus', 'model.manufacturer')->orderBy('created_at', 'DESC')->chunk(500, function ($assets) use ($handle, $customfields) {
|
||||
$headers=[
|
||||
trans('general.company'),
|
||||
trans('admin/hardware/table.asset_tag'),
|
||||
|
@ -140,7 +140,7 @@ class ReportsController extends Controller
|
|||
trans('admin/hardware/table.location'),
|
||||
trans('general.notes'),
|
||||
];
|
||||
foreach($customfields as $field) {
|
||||
foreach ($customfields as $field) {
|
||||
$headers[]=$field->name;
|
||||
}
|
||||
fputcsv($handle, $headers);
|
||||
|
@ -166,7 +166,7 @@ class ReportsController extends Controller
|
|||
e($asset->assigneduser->userloc->name) : ( ($asset->defaultLoc!='') ? e($asset->defaultLoc->name) : ''),
|
||||
($asset->notes) ? e($asset->notes) : '',
|
||||
];
|
||||
foreach($customfields as $field) {
|
||||
foreach ($customfields as $field) {
|
||||
$values[]=$asset->{$field->db_column_name()};
|
||||
}
|
||||
fputcsv($handle, $values);
|
||||
|
@ -339,7 +339,7 @@ class ReportsController extends Controller
|
|||
foreach ($activitylogs as $activity) {
|
||||
|
||||
if (($activity->item) && ($activity->itemType()=="asset")) {
|
||||
$activity_item = '<a href="'.route('hardware.show', $activity->item_id).'">'.e($activity->item->asset_tag).' - '. e($activity->item->present()->name()).'</a>';
|
||||
$activity_item = '<a href="'.route('hardware.show', $activity->item_id).'">'.e($activity->item->asset_tag).' - '. e($activity->item->present()->name()).'</a>';
|
||||
$item_type = 'asset';
|
||||
} elseif ($activity->item) {
|
||||
$activity_item = '<a href="' . route($activity->parseItemRoute().'.show', $activity->item_id) . '">' . e($activity->item->name) . '</a>';
|
||||
|
@ -353,14 +353,14 @@ class ReportsController extends Controller
|
|||
if (($activity->user) && ($activity->action_type=="uploaded") && ($activity->itemType()=="user")) {
|
||||
$activity_target = '<a href="'.route('users.show', $activity->target_id).'">'.$activity->user->present()->fullName().'</a>';
|
||||
} elseif ($activity->target_type === "App\Models\Asset") {
|
||||
if($activity->target) {
|
||||
if ($activity->target) {
|
||||
$activity_target = '<a href="'.route('hardware.show', $activity->target_id).'">'.$activity->target->present()->name().'</a>';
|
||||
} else {
|
||||
$activity_target = "";
|
||||
}
|
||||
} elseif ( $activity->target_type === "App\Models\User") {
|
||||
if($activity->target) {
|
||||
$activity_target = '<a href="'.route('users.show', $activity->target_id).'">'.$activity->target->present()->fullName().'</a>';
|
||||
} elseif ($activity->target_type === "App\Models\User") {
|
||||
if ($activity->target) {
|
||||
$activity_target = '<a href="'.route('users.show', $activity->target_id).'">'.$activity->target->present()->fullName().'</a>';
|
||||
} else {
|
||||
$activity_target = '';
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ class ReportsController extends Controller
|
|||
$activity_target = '';
|
||||
}
|
||||
} else {
|
||||
if($activity->target) {
|
||||
if ($activity->target) {
|
||||
$activity_target = $activity->target->id;
|
||||
} else {
|
||||
$activity_target = "";
|
||||
|
@ -385,7 +385,7 @@ class ReportsController extends Controller
|
|||
$rows[] = array(
|
||||
'icon' => '<i class="'.$activity->parseItemIcon().'"></i>',
|
||||
'created_at' => date("M d, Y g:iA", strtotime($activity->created_at)),
|
||||
'action_type' => strtolower(trans('general.'.str_replace(' ','_',$activity->action_type))),
|
||||
'action_type' => strtolower(trans('general.'.str_replace(' ', '_', $activity->action_type))),
|
||||
'admin' => $activity->user ? (string) link_to_route('users.show', $activity->user->present()->fullName(), [$activity->user_id]) : '',
|
||||
'target' => $activity_target,
|
||||
'item' => $activity_item,
|
||||
|
@ -492,7 +492,7 @@ class ReportsController extends Controller
|
|||
*/
|
||||
public function postCustom()
|
||||
{
|
||||
$assets = Asset::orderBy('created_at', 'DESC')->with('company','assigneduser', 'assetloc','defaultLoc','assigneduser.userloc','model','supplier','assetstatus','model.manufacturer')->get();
|
||||
$assets = Asset::orderBy('created_at', 'DESC')->with('company', 'assigneduser', 'assetloc', 'defaultLoc', 'assigneduser.userloc', 'model', 'supplier', 'assetstatus', 'model.manufacturer')->get();
|
||||
$customfields = CustomField::get();
|
||||
|
||||
$rows = [ ];
|
||||
|
|
|
@ -21,7 +21,6 @@ use App\Models\User;
|
|||
use App\Http\Requests\SetupUserRequest;
|
||||
use App\Http\Requests\ImageUploadRequest;
|
||||
|
||||
|
||||
/**
|
||||
* This controller handles all actions related to Settings for
|
||||
* the Snipe-IT Asset Management application.
|
||||
|
@ -58,7 +57,7 @@ class SettingsController extends Controller
|
|||
|
||||
$host = $_SERVER['SERVER_NAME'];
|
||||
if (($protocol === 'http://' && $_SERVER['SERVER_PORT'] != '80') || ($protocol === 'https://' && $_SERVER['SERVER_PORT'] != '443')) {
|
||||
$host .= ':' . $_SERVER['SERVER_PORT'];
|
||||
$host .= ':' . $_SERVER['SERVER_PORT'];
|
||||
}
|
||||
$pageURL = $protocol . $host . $_SERVER['REQUEST_URI'];
|
||||
|
||||
|
@ -443,7 +442,8 @@ class SettingsController extends Controller
|
|||
}
|
||||
|
||||
|
||||
public function getLdapTest() {
|
||||
public function getLdapTest()
|
||||
{
|
||||
|
||||
try {
|
||||
$connection = Ldap::connectToLdap();
|
||||
|
|
|
@ -207,7 +207,7 @@ class StatuslabelsController extends Controller
|
|||
$statuslabel->pending = $statustype['pending'];
|
||||
$statuslabel->archived = $statustype['archived'];
|
||||
$statuslabel->color = Input::get('color');
|
||||
$statuslabel->show_in_nav = Input::get('show_in_nav',0);
|
||||
$statuslabel->show_in_nav = Input::get('show_in_nav', 0);
|
||||
|
||||
|
||||
// Was the asset created?
|
||||
|
|
|
@ -200,8 +200,10 @@ class SuppliersController extends Controller
|
|||
// Delete the supplier
|
||||
$supplier->delete();
|
||||
// Redirect to the suppliers management page
|
||||
return redirect()->route('suppliers.index')->with('success',
|
||||
trans('admin/suppliers/message.delete.success'));
|
||||
return redirect()->route('suppliers.index')->with(
|
||||
'success',
|
||||
trans('admin/suppliers/message.delete.success')
|
||||
);
|
||||
}
|
||||
// Redirect to the asset management page
|
||||
return redirect()->route('suppliers.index')->with('error', trans('admin/suppliers/message.assoc_users'));
|
||||
|
|
|
@ -217,13 +217,14 @@ class UsersController extends Controller
|
|||
* @internal param int $id
|
||||
*/
|
||||
|
||||
private function filterDisplayable($permissions) {
|
||||
private function filterDisplayable($permissions)
|
||||
{
|
||||
$output = null;
|
||||
foreach($permissions as $key=>$permission) {
|
||||
$output[$key] = array_filter($permission, function($p) {
|
||||
foreach ($permissions as $key => $permission) {
|
||||
$output[$key] = array_filter($permission, function ($p) {
|
||||
return $p['display'] === true;
|
||||
});
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
@ -308,7 +309,7 @@ class UsersController extends Controller
|
|||
if ($request->has('password')) {
|
||||
$user->password = bcrypt($request->input('password'));
|
||||
}
|
||||
if ( $request->has('username')) {
|
||||
if ($request->has('username')) {
|
||||
$user->username = e($request->input('username'));
|
||||
}
|
||||
$user->email = e($request->input('email'));
|
||||
|
@ -334,7 +335,7 @@ class UsersController extends Controller
|
|||
if (!Auth::user()->isSuperUser()) {
|
||||
unset($permissions_array['superuser']);
|
||||
$permissions_array['superuser'] = $orig_superuser;
|
||||
}
|
||||
}
|
||||
|
||||
$user->permissions = json_encode($permissions_array);
|
||||
|
||||
|
@ -550,7 +551,7 @@ class UsersController extends Controller
|
|||
*/
|
||||
public function show($userId = null)
|
||||
{
|
||||
if(!$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($userId)) {
|
||||
if (!$user = User::with('assets', 'assets.model', 'consumables', 'accessories', 'licenses', 'userloc')->withTrashed()->find($userId)) {
|
||||
$error = trans('admin/users/message.user_not_found', compact('id'));
|
||||
// Redirect to the user management page
|
||||
return redirect()->route('users.index')->with('error', $error);
|
||||
|
@ -815,7 +816,7 @@ class UsersController extends Controller
|
|||
'users.company_id',
|
||||
'users.deleted_at',
|
||||
'users.activated'
|
||||
])->with('manager', 'groups', 'userloc', 'company','throttle');
|
||||
])->with('manager', 'groups', 'userloc', 'company', 'throttle');
|
||||
$users = Company::scopeCompanyables($users);
|
||||
|
||||
switch ($status) {
|
||||
|
@ -1036,13 +1037,13 @@ class UsersController extends Controller
|
|||
try {
|
||||
$ldapconn = Ldap::connectToLdap();
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->withInput()->with('error',$e->getMessage());
|
||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
Ldap::bindAdminToLdap($ldapconn);
|
||||
} catch (\Exception $e) {
|
||||
return redirect()->back()->withInput()->with('error',$e->getMessage());
|
||||
return redirect()->back()->withInput()->with('error', $e->getMessage());
|
||||
}
|
||||
|
||||
$summary = array();
|
||||
|
@ -1128,11 +1129,11 @@ class UsersController extends Controller
|
|||
$this->authorize('view', User::class);
|
||||
\Debugbar::disable();
|
||||
|
||||
$response = new StreamedResponse(function() {
|
||||
$response = new StreamedResponse(function () {
|
||||
// Open output stream
|
||||
$handle = fopen('php://output', 'w');
|
||||
|
||||
User::with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company','throttle')->orderBy('created_at', 'DESC')->chunk(500, function($users) use($handle) {
|
||||
User::with('assets', 'accessories', 'consumables', 'licenses', 'manager', 'groups', 'userloc', 'company', 'throttle')->orderBy('created_at', 'DESC')->chunk(500, function ($users) use ($handle) {
|
||||
$headers=[
|
||||
// strtolower to prevent Excel from trying to open it as a SYLK file
|
||||
strtolower(trans('general.id')),
|
||||
|
|
|
@ -315,7 +315,7 @@ class ViewAssetsController extends Controller
|
|||
} elseif (!Company::isCurrentUserHasAccess($item)) {
|
||||
return redirect()->route('requestable-assets')->with('error', trans('general.insufficient_permissions'));
|
||||
} else {
|
||||
return View::make('account/accept-asset', compact('item'))->with('findlog', $findlog)->with('item',$item);
|
||||
return View::make('account/accept-asset', compact('item'))->with('findlog', $findlog)->with('item', $item);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class CheckForDebug
|
|||
view()->share('debug_in_production', false);
|
||||
|
||||
if (((Auth::check() && (Auth::user()->isSuperUser()))) && (app()->environment()=='production') && (config('app.warn_debug')===true) && (config('app.debug')===true)) {
|
||||
view()->share('debug_in_production', true);
|
||||
view()->share('debug_in_production', true);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
namespace App\Importer;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Accessory;
|
||||
|
||||
|
@ -41,7 +40,7 @@ class AccessoryImporter extends ItemImporter
|
|||
$accessory = $this->accessories->search(function ($key) {
|
||||
return strcasecmp($key->name, $this->item['item_name']) == 0;
|
||||
});
|
||||
if($accessory) {
|
||||
if ($accessory) {
|
||||
$editingAccessory = true;
|
||||
if (!$this->updating) {
|
||||
$this->log('A matching Accessory ' . $this->item["item_name"] . ' already exists. ');
|
||||
|
@ -101,7 +100,7 @@ class AccessoryImporter extends ItemImporter
|
|||
// $this->comment('Accessory ' . $this->item["item_name"] . ' was created');
|
||||
|
||||
} else {
|
||||
$this->jsonError($accessory,'Accessory', $accessory->getErrors()) ;
|
||||
$this->jsonError($accessory, 'Accessory', $accessory->getErrors()) ;
|
||||
}
|
||||
} else {
|
||||
$this->log('TEST RUN - Accessory ' . $this->item["item_name"] . ' not created');
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
namespace App\Importer;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Asset;
|
||||
use App\Models\Category;
|
||||
|
@ -52,7 +51,7 @@ class AssetImporter extends ItemImporter
|
|||
$asset = $this->assets->search(function ($key) {
|
||||
return strcasecmp($key->asset_tag, $this->item['asset_tag']) == 0;
|
||||
});
|
||||
if($asset) {
|
||||
if ($asset) {
|
||||
$editingAsset = true;
|
||||
if (!$this->updating) {
|
||||
$this->log('A matching Asset ' . $this->item['asset_tag'] . ' already exists');
|
||||
|
@ -91,7 +90,7 @@ class AssetImporter extends ItemImporter
|
|||
|
||||
if (isset($this->item["status_label"])) {
|
||||
$status_id = $this->item["status_label"]->id;
|
||||
} else if (!$editingAsset) {
|
||||
} elseif (!$editingAsset) {
|
||||
// Assume if we are editing, we already have a status and can ignore.
|
||||
$this->log("No status field found, defaulting to first status.");
|
||||
$status_id = $this->status_labels->first()->id;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
namespace App\Importer;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Consumable;
|
||||
|
||||
|
@ -41,7 +40,7 @@ class ConsumableImporter extends ItemImporter
|
|||
$consumable = $this->consumables->search(function ($key) {
|
||||
return strcasecmp($key->name, $this->item['item_name']) == 0;
|
||||
});
|
||||
if($consumable) {
|
||||
if ($consumable) {
|
||||
$editingConsumable = true;
|
||||
if (!$this->updating) {
|
||||
$this->log('A matching Consumable ' . $this->item["item_name"] . ' already exists. ');
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
namespace App\Importer;
|
||||
|
||||
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
|
@ -69,15 +68,17 @@ abstract class Importer
|
|||
* @param bool $updating
|
||||
* @param null $usernameFormat
|
||||
*/
|
||||
function __construct(string $filename,
|
||||
$logCallback,
|
||||
$progressCallback,
|
||||
$errorCallback,
|
||||
$testRun = false,
|
||||
$user_id = -1,
|
||||
$updating = false,
|
||||
$usernameFormat = null)
|
||||
{
|
||||
function __construct(
|
||||
string $filename,
|
||||
$logCallback,
|
||||
$progressCallback,
|
||||
$errorCallback,
|
||||
$testRun = false,
|
||||
$user_id = -1,
|
||||
$updating = false,
|
||||
$usernameFormat = null
|
||||
) {
|
||||
|
||||
$this->filename = $filename;
|
||||
$this->csv = Reader::createFromPath($filename);
|
||||
$this->csv->setNewLine('\r\n');
|
||||
|
@ -85,7 +86,7 @@ abstract class Importer
|
|||
ini_set("auto_detect_line_endings", '1');
|
||||
}
|
||||
$this->testRun = $testRun;
|
||||
if($user_id == -1) {
|
||||
if ($user_id == -1) {
|
||||
$user_id = Auth::id();
|
||||
}
|
||||
$this->user_id = $user_id;
|
||||
|
@ -193,11 +194,13 @@ abstract class Importer
|
|||
return array_key_exists($index_name, $array) ? e(trim($array[$index_name])) : '';
|
||||
}
|
||||
|
||||
protected function log($string) {
|
||||
protected function log($string)
|
||||
{
|
||||
call_user_func($this->logCallback, $string);
|
||||
}
|
||||
|
||||
protected function jsonError($item, $field, $errorString) {
|
||||
protected function jsonError($item, $field, $errorString)
|
||||
{
|
||||
call_user_func($this->errorCallback, $item, $field, $errorString);
|
||||
}
|
||||
|
||||
|
@ -276,7 +279,7 @@ abstract class Importer
|
|||
if ($user->save()) {
|
||||
$this->log('User '.$first_name.' created');
|
||||
} else {
|
||||
$this->jsonError($user,'User "' . $first_name . '"', $user->getErrors());
|
||||
$this->jsonError($user, 'User "' . $first_name . '"', $user->getErrors());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Importer;
|
||||
|
||||
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Category;
|
||||
use App\Models\Company;
|
||||
|
@ -91,7 +90,7 @@ class ItemImporter extends Importer
|
|||
});
|
||||
// We need strict compare here because the index returned above can be 0.
|
||||
// This casts to false and causes false positives
|
||||
if(($asset_model !== false) && !$editingModel) {
|
||||
if (($asset_model !== false) && !$editingModel) {
|
||||
return $this->asset_models[$asset_model];
|
||||
} else {
|
||||
$this->log("No Matching Model, Creating a new one");
|
||||
|
@ -116,7 +115,7 @@ class ItemImporter extends Importer
|
|||
$this->log('Asset Model ' . $asset_model_name . ' with model number ' . $asset_modelNumber . ' was created');
|
||||
return $asset_model;
|
||||
} else {
|
||||
$this->jsonError($asset_model,'Asset Model "' . $asset_model_name . '"', $asset_model->getErrors());
|
||||
$this->jsonError($asset_model, 'Asset Model "' . $asset_model_name . '"', $asset_model->getErrors());
|
||||
$this->log('Asset Model "' . $asset_model_name . '"' . $asset_model->getErrors());
|
||||
return $asset_model;
|
||||
}
|
||||
|
@ -186,12 +185,12 @@ class ItemImporter extends Importer
|
|||
*/
|
||||
public function createOrFetchCompany($asset_company_name)
|
||||
{
|
||||
$company = $this->companies->search(function ($key) use($asset_company_name) {
|
||||
$company = $this->companies->search(function ($key) use ($asset_company_name) {
|
||||
return strcasecmp($key->name, $asset_company_name) == 0;
|
||||
});
|
||||
// We need strict compare here because the index returned above can be 0.
|
||||
// This casts to false and causes false positives
|
||||
if($company !== false) {
|
||||
if ($company !== false) {
|
||||
$this->log('A matching Company ' . $asset_company_name . ' already exists');
|
||||
return $this->companies[$company];
|
||||
}
|
||||
|
@ -225,7 +224,7 @@ class ItemImporter extends Importer
|
|||
if (empty($asset_statuslabel_name)) {
|
||||
return null;
|
||||
}
|
||||
$status = $this->status_labels->search(function ($key) use($asset_statuslabel_name) {
|
||||
$status = $this->status_labels->search(function ($key) use ($asset_statuslabel_name) {
|
||||
return strcasecmp($key->name, $asset_statuslabel_name) == 0;
|
||||
});
|
||||
// We need strict compare here because the index returned above can be 0.
|
||||
|
@ -248,7 +247,7 @@ class ItemImporter extends Importer
|
|||
$this->log('Status ' . $asset_statuslabel_name . ' was created');
|
||||
return $status;
|
||||
} else {
|
||||
$this->jsonError($status,'Status "'. $asset_statuslabel_name . '"', $status->getErrors());
|
||||
$this->jsonError($status, 'Status "'. $asset_statuslabel_name . '"', $status->getErrors());
|
||||
return $status;
|
||||
}
|
||||
} else {
|
||||
|
@ -272,7 +271,7 @@ class ItemImporter extends Importer
|
|||
if (empty($item_manufacturer)) {
|
||||
$item_manufacturer='Unknown';
|
||||
}
|
||||
$manufacturer = $this->manufacturers->search(function ($key) use($item_manufacturer) {
|
||||
$manufacturer = $this->manufacturers->search(function ($key) use ($item_manufacturer) {
|
||||
return strcasecmp($key->name, $item_manufacturer) == 0;
|
||||
});
|
||||
// We need strict compare here because the index returned above can be 0.
|
||||
|
@ -317,7 +316,7 @@ class ItemImporter extends Importer
|
|||
$this->log('No location given, so none created.');
|
||||
return null;
|
||||
}
|
||||
$location = $this->locations->search(function ($key) use($asset_location) {
|
||||
$location = $this->locations->search(function ($key) use ($asset_location) {
|
||||
return strcasecmp($key->name, $asset_location) == 0;
|
||||
});
|
||||
// We need strict compare here because the index returned above can be 0.
|
||||
|
@ -366,7 +365,7 @@ class ItemImporter extends Importer
|
|||
$item_supplier='Unknown';
|
||||
}
|
||||
|
||||
$supplier = $this->suppliers->search(function ($key) use($item_supplier) {
|
||||
$supplier = $this->suppliers->search(function ($key) use ($item_supplier) {
|
||||
return strcasecmp($key->name, $item_supplier) == 0;
|
||||
});
|
||||
// We need strict compare here because the index returned above can be 0.
|
||||
|
@ -394,6 +393,4 @@ class ItemImporter extends Importer
|
|||
return $supplier;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -26,15 +26,15 @@ class Actionlog extends Model
|
|||
public static function boot()
|
||||
{
|
||||
parent::boot();
|
||||
static::creating( function (Actionlog $actionlog) {
|
||||
static::creating(function (Actionlog $actionlog) {
|
||||
// If the admin is a superadmin, let's see if the target instead has a company.
|
||||
if (Auth::user() && Auth::user()->isSuperUser()) {
|
||||
if ($actionlog->target) {
|
||||
$actionlog->company_id = $actionlog->target->company_id;
|
||||
} else if ($actionlog->item) {
|
||||
} elseif ($actionlog->item) {
|
||||
$actionlog->company_id = $actionlog->item->company_id;
|
||||
}
|
||||
} else if (Auth::user() && Auth::user()->company) {
|
||||
} elseif (Auth::user() && Auth::user()->company) {
|
||||
$actionlog->company_id = Auth::user()->company_id;
|
||||
}
|
||||
});
|
||||
|
@ -45,27 +45,29 @@ class Actionlog extends Model
|
|||
return $this->morphTo('item')->withTrashed();
|
||||
}
|
||||
|
||||
public function company() {
|
||||
return $this->hasMany('\App\Models\Company', 'id','company_id');
|
||||
public function company()
|
||||
{
|
||||
return $this->hasMany('\App\Models\Company', 'id', 'company_id');
|
||||
}
|
||||
|
||||
public function itemType()
|
||||
{
|
||||
|
||||
if($this->item_type == AssetModel::class) {
|
||||
if ($this->item_type == AssetModel::class) {
|
||||
return "model";
|
||||
}
|
||||
return camel_case(class_basename($this->item_type));
|
||||
}
|
||||
|
||||
public function parseItemRoute() {
|
||||
public function parseItemRoute()
|
||||
{
|
||||
if ($this->itemType() == "asset") {
|
||||
$itemroute = 'assets';
|
||||
} elseif ($this->itemType() == "accessory") {
|
||||
$itemroute = 'accessories';
|
||||
} elseif ($this->itemType()=="consumable") {
|
||||
$itemroute = 'consumables';
|
||||
} elseif ($this->itemType()=="license"){
|
||||
} elseif ($this->itemType()=="license") {
|
||||
$itemroute = 'licenses';
|
||||
} elseif ($this->itemType()=="component") {
|
||||
$itemroute = 'components';
|
||||
|
@ -77,14 +79,15 @@ class Actionlog extends Model
|
|||
}
|
||||
|
||||
|
||||
public function parseItemIcon() {
|
||||
public function parseItemIcon()
|
||||
{
|
||||
if ($this->itemType() == "asset") {
|
||||
$itemicon = 'fa fa-barcode';
|
||||
} elseif ($this->itemType() == "accessory") {
|
||||
$itemicon = 'fa fa-keyboard-o';
|
||||
} elseif ($this->itemType()=="consumable") {
|
||||
$itemicon = 'fa fa-tint';
|
||||
} elseif ($this->itemType()=="license"){
|
||||
} elseif ($this->itemType()=="license") {
|
||||
$itemicon = 'fa fa-floppy-o';
|
||||
} elseif ($this->itemType()=="component") {
|
||||
$itemicon = 'fa fa-hdd-o';
|
||||
|
|
|
@ -74,7 +74,7 @@ class Asset extends Depreciable
|
|||
|
||||
public function availableForCheckout()
|
||||
{
|
||||
return (
|
||||
return (
|
||||
empty($this->assigned_to) &&
|
||||
$this->assetstatus->deployable == 1 &&
|
||||
empty($this->deleted_at)
|
||||
|
@ -105,7 +105,7 @@ class Asset extends Depreciable
|
|||
|
||||
$this->assigneduser()->associate($user);
|
||||
|
||||
if($name != null) {
|
||||
if ($name != null) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
|
@ -359,7 +359,7 @@ class Asset extends Depreciable
|
|||
->max('id');
|
||||
|
||||
if ($settings->zerofill_count > 0) {
|
||||
return $settings->auto_increment_prefix.Asset::zerofill(($asset_tag + 1),$settings->zerofill_count);
|
||||
return $settings->auto_increment_prefix.Asset::zerofill(($asset_tag + 1), $settings->zerofill_count);
|
||||
}
|
||||
return $settings->auto_increment_prefix.($asset_tag + 1);
|
||||
} else {
|
||||
|
@ -368,7 +368,7 @@ class Asset extends Depreciable
|
|||
}
|
||||
|
||||
|
||||
public static function zerofill ($num, $zerofill = 3)
|
||||
public static function zerofill($num, $zerofill = 3)
|
||||
{
|
||||
return str_pad($num, $zerofill, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
|||
|
||||
public function setIsWarrantyAttribute($value)
|
||||
{
|
||||
if($value == '') {
|
||||
if ($value == '') {
|
||||
$value = 0;
|
||||
}
|
||||
$this->attributes['is_warranty'] = $value;
|
||||
|
@ -70,7 +70,7 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
|||
public function setCostAttribute($value)
|
||||
{
|
||||
$value = Helper::ParseFloat($value);
|
||||
if($value == '0.0') {
|
||||
if ($value == '0.0') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['cost'] = $value;
|
||||
|
@ -81,7 +81,7 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
|||
*/
|
||||
public function setNotesAttribute($value)
|
||||
{
|
||||
if($value == '') {
|
||||
if ($value == '') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['notes'] = $value;
|
||||
|
@ -92,7 +92,7 @@ class AssetMaintenance extends Model implements ICompanyableChild
|
|||
*/
|
||||
public function setCompletionDateAttribute($value)
|
||||
{
|
||||
if($value == '' || $value == "0000-00-00") {
|
||||
if ($value == '' || $value == "0000-00-00") {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['completion_date'] = $value;
|
||||
|
|
|
@ -41,7 +41,8 @@ class AssetModel extends SnipeModel
|
|||
protected $injectUniqueIdentifier = true;
|
||||
use ValidatingTrait;
|
||||
|
||||
public function setEolAttribute($value) {
|
||||
public function setEolAttribute($value)
|
||||
{
|
||||
if ($value == '') {
|
||||
$value = 0;
|
||||
}
|
||||
|
|
|
@ -164,26 +164,32 @@ final class Company extends SnipeModel
|
|||
}
|
||||
}
|
||||
|
||||
public function users() {
|
||||
public function users()
|
||||
{
|
||||
return $this->hasMany(User::class);
|
||||
}
|
||||
|
||||
public function assets() {
|
||||
public function assets()
|
||||
{
|
||||
return $this->hasMany(Asset::class);
|
||||
}
|
||||
|
||||
public function licenses() {
|
||||
public function licenses()
|
||||
{
|
||||
return $this->hasMany(License::class);
|
||||
}
|
||||
public function accessories() {
|
||||
public function accessories()
|
||||
{
|
||||
return $this->hasMany(Accessory::class);
|
||||
}
|
||||
|
||||
public function consumables() {
|
||||
public function consumables()
|
||||
{
|
||||
return $this->hasMany(Consumable::class);
|
||||
}
|
||||
|
||||
public function components() {
|
||||
public function components()
|
||||
{
|
||||
return $this->hasMany(Component::class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class CustomField extends Model
|
|||
{
|
||||
self::creating(function ($custom_field) {
|
||||
|
||||
if (Schema::hasColumn(CustomField::$table_name,$custom_field->db_column_name())) {
|
||||
if (Schema::hasColumn(CustomField::$table_name, $custom_field->db_column_name())) {
|
||||
//field already exists when making a new custom field; fail.
|
||||
return false;
|
||||
}
|
||||
|
@ -50,20 +50,20 @@ class CustomField extends Model
|
|||
|
||||
self::updating(function ($custom_field) {
|
||||
if ($custom_field->isDirty("name")) {
|
||||
if (Schema::hasColumn(CustomField::$table_name,$custom_field->db_column_name())) {
|
||||
if (Schema::hasColumn(CustomField::$table_name, $custom_field->db_column_name())) {
|
||||
//field already exists when renaming a custom field
|
||||
return false;
|
||||
}
|
||||
return Schema::table(CustomField::$table_name, function ($table) use ($custom_field) {
|
||||
$table->renameColumn(self::name_to_db_name($custom_field->getOriginal("name")),$custom_field->db_column_name());
|
||||
$table->renameColumn(self::name_to_db_name($custom_field->getOriginal("name")), $custom_field->db_column_name());
|
||||
});
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
self::deleting(function ($custom_field) {
|
||||
return Schema::table(CustomField::$table_name,function ($table) use ($custom_field) {
|
||||
$table->dropColumn(self::name_to_db_name($custom_field->getOriginal("name")));
|
||||
return Schema::table(CustomField::$table_name, function ($table) use ($custom_field) {
|
||||
$table->dropColumn(self::name_to_db_name($custom_field->getOriginal("name")));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -122,7 +122,8 @@ class CustomField extends Model
|
|||
* @since [v3.4]
|
||||
* @return Array
|
||||
*/
|
||||
public function formatFieldValuesAsArray() {
|
||||
public function formatFieldValuesAsArray()
|
||||
{
|
||||
$arr = preg_split("/\\r\\n|\\r|\\n/", $this->field_values);
|
||||
|
||||
$result[''] = 'Select '.strtolower($this->format);
|
||||
|
@ -130,7 +131,7 @@ class CustomField extends Model
|
|||
for ($x = 0; $x < count($arr); $x++) {
|
||||
$arr_parts = explode('|', $arr[$x]);
|
||||
if ($arr_parts[0]!='') {
|
||||
if (key_exists('1',$arr_parts)) {
|
||||
if (key_exists('1', $arr_parts)) {
|
||||
$result[$arr_parts[0]] = $arr_parts[1];
|
||||
} else {
|
||||
$result[$arr_parts[0]] = $arr_parts[0];
|
||||
|
@ -143,14 +144,11 @@ class CustomField extends Model
|
|||
return $result;
|
||||
}
|
||||
|
||||
public function isFieldDecryptable($string) {
|
||||
public function isFieldDecryptable($string)
|
||||
{
|
||||
if (($this->field_encrypted=='1') && ($string!='')) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -34,9 +34,7 @@ class CustomFieldset extends Model
|
|||
$rule = [];
|
||||
|
||||
if (($field->field_encrypted!='1') ||
|
||||
(($field->field_encrypted =='1') && (Gate::allows('admin')) ))
|
||||
{
|
||||
|
||||
(($field->field_encrypted =='1') && (Gate::allows('admin')) )) {
|
||||
if ($field->pivot->required) {
|
||||
$rule[]="required";
|
||||
}
|
||||
|
@ -47,5 +45,4 @@ class CustomFieldset extends Model
|
|||
}
|
||||
return $rules;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ use Exception;
|
|||
use Input;
|
||||
use Log;
|
||||
|
||||
|
||||
class Ldap extends Model
|
||||
{
|
||||
|
||||
|
@ -36,8 +35,8 @@ class Ldap extends Model
|
|||
}
|
||||
|
||||
// If the user specifies where CA Certs are, make sure to use them
|
||||
if(env("LDAPTLS_CACERT")) {
|
||||
putenv("LDAPTLS_CACERT=".env("LDAPTLS_CACERT"));
|
||||
if (env("LDAPTLS_CACERT")) {
|
||||
putenv("LDAPTLS_CACERT=".env("LDAPTLS_CACERT"));
|
||||
}
|
||||
|
||||
$connection = @ldap_connect($ldap_host);
|
||||
|
@ -78,13 +77,10 @@ class Ldap extends Model
|
|||
$ldap_username_field = $settings->ldap_username_field;
|
||||
$baseDn = $settings->ldap_basedn;
|
||||
|
||||
if ($settings->is_ad =='1')
|
||||
{
|
||||
|
||||
// Check if they are using the userprincipalname for the username field.
|
||||
if ($settings->is_ad =='1') {
|
||||
// Check if they are using the userprincipalname for the username field.
|
||||
// If they are, we can skip building the UPN to authenticate against AD
|
||||
if ($ldap_username_field=='userprincipalname')
|
||||
{
|
||||
if ($ldap_username_field=='userprincipalname') {
|
||||
$userDn = $username;
|
||||
} else {
|
||||
// In case they haven't added an AD domain
|
||||
|
@ -238,7 +234,8 @@ class Ldap extends Model
|
|||
* @param $ldapatttibutes
|
||||
* @return array|bool
|
||||
*/
|
||||
static function findLdapUsers() {
|
||||
static function findLdapUsers()
|
||||
{
|
||||
|
||||
$ldapconn = Ldap::connectToLdap();
|
||||
$ldap_bind = Ldap::bindAdminToLdap($ldapconn);
|
||||
|
@ -291,8 +288,4 @@ class Ldap extends Model
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class License extends Depreciable
|
|||
|
||||
public function setExpirationDateAttribute($value)
|
||||
{
|
||||
if($value == '' || $value == '0000-00-00') {
|
||||
if ($value == '' || $value == '0000-00-00') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['expiration_date'] = $value;
|
||||
|
@ -43,7 +43,7 @@ class License extends Depreciable
|
|||
|
||||
public function setTerminationDateAttribute($value)
|
||||
{
|
||||
if($value == '' || $value == '0000-00-00') {
|
||||
if ($value == '' || $value == '0000-00-00') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['termination_date'] = $value;
|
||||
|
@ -261,8 +261,8 @@ class License extends Depreciable
|
|||
->orWhereHas('manufacturer', function ($query) use ($search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->where('manufacturers.name', 'LIKE', '%'.$search.'%');
|
||||
});
|
||||
})
|
||||
});
|
||||
})
|
||||
->orWhereHas('company', function ($query) use ($search) {
|
||||
$query->where(function ($query) use ($search) {
|
||||
$query->where('companies.name', 'LIKE', '%'.$search.'%');
|
||||
|
|
|
@ -47,7 +47,7 @@ trait Loggable
|
|||
if (!is_null($this->asset_id) || isset($target)) {
|
||||
$log->target_type = Asset::class;
|
||||
$log->target_id = $this->asset_id;
|
||||
} else if (!is_null($this->assigned_to)) {
|
||||
} elseif (!is_null($this->assigned_to)) {
|
||||
$log->target_type = User::class;
|
||||
$log->target_id = $this->assigned_to;
|
||||
}
|
||||
|
|
|
@ -51,11 +51,11 @@ class Setting extends Model
|
|||
{
|
||||
static $static_cache = null;
|
||||
|
||||
if (!$static_cache) {
|
||||
if (Schema::hasTable('settings')) {
|
||||
$static_cache = Setting::first();
|
||||
}
|
||||
if (!$static_cache) {
|
||||
if (Schema::hasTable('settings')) {
|
||||
$static_cache = Setting::first();
|
||||
}
|
||||
}
|
||||
|
||||
return $static_cache;
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ class SnipeModel extends Model
|
|||
// Setters that are appropriate across multiple models.
|
||||
public function setPurchaseDateAttribute($value)
|
||||
{
|
||||
if($value == '') {
|
||||
if ($value == '') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['purchase_date'] = $value;
|
||||
|
@ -22,7 +22,7 @@ class SnipeModel extends Model
|
|||
public function setPurchaseCostAttribute($value)
|
||||
{
|
||||
$value = Helper::ParseFloat($value);
|
||||
if($value == '0.0') {
|
||||
if ($value == '0.0') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['purchase_cost'] = $value;
|
||||
|
@ -30,7 +30,7 @@ class SnipeModel extends Model
|
|||
|
||||
public function setLocationIdAttribute($value)
|
||||
{
|
||||
if($value == '') {
|
||||
if ($value == '') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['location_id'] = $value;
|
||||
|
@ -38,7 +38,7 @@ class SnipeModel extends Model
|
|||
|
||||
public function setCategoryIdAttribute($value)
|
||||
{
|
||||
if($value == '') {
|
||||
if ($value == '') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['category_id'] = $value;
|
||||
|
@ -46,7 +46,7 @@ class SnipeModel extends Model
|
|||
|
||||
public function setSupplierIdAttribute($value)
|
||||
{
|
||||
if($value == '') {
|
||||
if ($value == '') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['supplier_id'] = $value;
|
||||
|
@ -54,7 +54,7 @@ class SnipeModel extends Model
|
|||
|
||||
public function setDepreciationIdAttribute($value)
|
||||
{
|
||||
if($value == '') {
|
||||
if ($value == '') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['depreciation_id'] = $value;
|
||||
|
@ -62,7 +62,7 @@ class SnipeModel extends Model
|
|||
|
||||
public function setManufacturerIdAttribute($value)
|
||||
{
|
||||
if($value == '') {
|
||||
if ($value == '') {
|
||||
$value = null;
|
||||
}
|
||||
$this->attributes['manufacturer_id'] = $value;
|
||||
|
|
|
@ -277,7 +277,8 @@ class User extends SnipeModel implements AuthenticatableContract, CanResetPasswo
|
|||
->orWhere('username', '=', $user_email);
|
||||
}
|
||||
|
||||
public static function generateEmailFromFullName($name) {
|
||||
public static function generateEmailFromFullName($name)
|
||||
{
|
||||
$username = User::generateFormattedNameFromFullName(Setting::getSettings()->email_format, $name);
|
||||
return $username['username'].'@'.Setting::getSettings()->email_domain;
|
||||
}
|
||||
|
|
|
@ -37,12 +37,11 @@ class CheckinNotification extends Notification
|
|||
public function via($notifiable)
|
||||
{
|
||||
$notifyBy = [];
|
||||
if(Setting::getSettings()->slack_endpoint) {
|
||||
if (Setting::getSettings()->slack_endpoint) {
|
||||
$notifyBy[] = 'slack';
|
||||
}
|
||||
$item = $this->params['item'];
|
||||
if (
|
||||
(method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1'))
|
||||
if ((method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1'))
|
||||
|| (method_exists($item, 'getEula') && ($item->getEula()))
|
||||
) {
|
||||
$notifyBy[] = 'mail';
|
||||
|
@ -63,7 +62,7 @@ class CheckinNotification extends Notification
|
|||
];
|
||||
array_key_exists('note', $this->params) && $fields['Notes'] = $this->params['note'];
|
||||
|
||||
$attachment->title($item->name, $item->present()->viewUrl() )
|
||||
$attachment->title($item->name, $item->present()->viewUrl())
|
||||
->fields($fields);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -38,13 +38,12 @@ class CheckoutNotification extends Notification
|
|||
public function via($notifiable)
|
||||
{
|
||||
$notifyBy = [];
|
||||
if(Setting::getSettings()->slack_endpoint) {
|
||||
if (Setting::getSettings()->slack_endpoint) {
|
||||
$notifyBy[] = 'slack';
|
||||
}
|
||||
$item = $this->params['item'];
|
||||
|
||||
if (
|
||||
(method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1'))
|
||||
if ((method_exists($item, 'requireAcceptance') && ($item->requireAcceptance()=='1'))
|
||||
|| (method_exists($item, 'getEula') && ($item->getEula()))
|
||||
) {
|
||||
$notifyBy[] = 'mail';
|
||||
|
@ -68,7 +67,7 @@ class CheckoutNotification extends Notification
|
|||
];
|
||||
array_key_exists('note', $this->params) && $fields['Notes'] = $this->params['note'];
|
||||
|
||||
$attachment->title($item->name, $item->present()->viewUrl() )
|
||||
$attachment->title($item->name, $item->present()->viewUrl())
|
||||
->fields($fields);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class AssetPolicy
|
|||
return $user->hasAccess('assets.view');
|
||||
}
|
||||
|
||||
public function viewRequestable(User $user, Asset $asset=null)
|
||||
public function viewRequestable(User $user, Asset $asset = null)
|
||||
{
|
||||
return $user->hasAccess('assets.view.requestable');
|
||||
}
|
||||
|
@ -77,5 +77,4 @@ class AssetPolicy
|
|||
{
|
||||
return $user->hasAccess('assets.edit');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class UserPolicy
|
|||
*/
|
||||
public function delete(User $user, User $targetUser = null)
|
||||
{
|
||||
if($targetUser) {
|
||||
if ($targetUser) {
|
||||
//We can't delete ourselves.
|
||||
if ($user->id == $targetUser->id) {
|
||||
return false;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
|
@ -133,7 +132,7 @@ class AccessoryPresenter extends Presenter
|
|||
$results = [];
|
||||
$results['name'] = $this->nameUrl();
|
||||
$results['category'] = '';
|
||||
if($this->model->category) {
|
||||
if ($this->model->category) {
|
||||
$results['category'] = $this->model->category->present()->nameUrl();
|
||||
}
|
||||
$results['model_number'] = $this->model_number;
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
|
||||
/**
|
||||
|
@ -48,7 +47,7 @@ class AssetModelPresenter extends Presenter
|
|||
$results['model_number'] = $this->model_number;
|
||||
$results['numassets'] = $this->assets()->count();
|
||||
$results['depreciation'] = trans('general.no_depreciation');
|
||||
if(($depreciation = $this->model->depreciation) and $depreciation->id > 0) {
|
||||
if (($depreciation = $this->model->depreciation) and $depreciation->id > 0) {
|
||||
$results['depreciation'] = $depreciation->name.' ('.$depreciation->months.')';
|
||||
}
|
||||
$results['category'] = $this->categoryUrl();
|
||||
|
@ -76,7 +75,7 @@ class AssetModelPresenter extends Presenter
|
|||
|
||||
public function eolText()
|
||||
{
|
||||
if($this->eol) {
|
||||
if ($this->eol) {
|
||||
return $this->eol.' '.trans('general.months');
|
||||
}
|
||||
return '';
|
||||
|
@ -101,7 +100,7 @@ class AssetModelPresenter extends Presenter
|
|||
*/
|
||||
public function nameUrl()
|
||||
{
|
||||
return (string) link_to_route('models.show',$this->name, $this->id);
|
||||
return (string) link_to_route('models.show', $this->name, $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,7 +109,7 @@ class AssetModelPresenter extends Presenter
|
|||
*/
|
||||
public function imageUrl()
|
||||
{
|
||||
if(!empty($this->image)) {
|
||||
if (!empty($this->image)) {
|
||||
return '<img src="' . url('/') . '/uploads/models/' . $this->image . '" height=50 width=50>';
|
||||
}
|
||||
return '';
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
namespace App\Presenters;
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\SnipeModel;
|
||||
use DateTime;
|
||||
|
@ -10,7 +11,6 @@ use Illuminate\Support\Facades\Gate;
|
|||
* @package App\Presenters
|
||||
*/
|
||||
class AssetPresenter extends Presenter
|
||||
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -48,18 +48,21 @@ class AssetPresenter extends Presenter
|
|||
|
||||
$actions .= '</div>';
|
||||
|
||||
if (($this->model->availableForCheckout()))
|
||||
{
|
||||
if (($this->model->availableForCheckout())) {
|
||||
if (Gate::allows('checkout', $this->model)) {
|
||||
$inout = '<a href="' . route('checkout/hardware',
|
||||
$this->model->id) . '" class="btn btn-info btn-sm" title="Checkout this asset to a user" data-toggle="tooltip">' . trans('general.checkout') . '</a>';
|
||||
$inout = '<a href="' . route(
|
||||
'checkout/hardware',
|
||||
$this->model->id
|
||||
) . '" class="btn btn-info btn-sm" title="Checkout this asset to a user" data-toggle="tooltip">' . trans('general.checkout') . '</a>';
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!empty($this->model->assigned_to)) {
|
||||
if (Gate::allows('checkin', $this->model)) {
|
||||
$inout = '<a href="' . route('checkin/hardware',
|
||||
$this->model->id) . '" class="btn btn-primary btn-sm" title="Checkin this asset" data-toggle="tooltip">' . trans('general.checkin') . '</a>';
|
||||
$inout = '<a href="' . route(
|
||||
'checkin/hardware',
|
||||
$this->model->id
|
||||
) . '" class="btn btn-primary btn-sm" title="Checkin this asset" data-toggle="tooltip">' . trans('general.checkin') . '</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -80,16 +83,16 @@ class AssetPresenter extends Presenter
|
|||
|
||||
$results['status_label'] = '';
|
||||
$results['assigned_to'] = '';
|
||||
if($assigned = $this->model->assigneduser) {
|
||||
if ($assigned = $this->model->assigneduser) {
|
||||
$results['status_label'] = 'Deployed';
|
||||
$results['assigned_to'] = (string) link_to_route('users.show', $assigned->present()->fullName(), $this->assigned_to );
|
||||
} else if($this->model->assetstatus) {
|
||||
$results['assigned_to'] = (string) link_to_route('users.show', $assigned->present()->fullName(), $this->assigned_to);
|
||||
} elseif ($this->model->assetstatus) {
|
||||
$results['status_label'] = $this->model->assetstatus->name;
|
||||
}
|
||||
$results['location'] = '';
|
||||
if (isset($assigned) and !empty($assignedLoc = $assigned->userloc)) {
|
||||
$results['location'] = $assignedLoc->present()->nameUrl();
|
||||
} else if (!empty($this->model->defaultLoc)) {
|
||||
} elseif (!empty($this->model->defaultLoc)) {
|
||||
$results['location'] = $this->model->defaultLoc->present()->nameUrl();
|
||||
}
|
||||
|
||||
|
@ -98,14 +101,14 @@ class AssetPresenter extends Presenter
|
|||
$results['purchase_date'] = $this->purchase_date ?: '';
|
||||
$results['notes'] = $this->notes;
|
||||
$results['order_number'] = '';
|
||||
if(!empty($this->order_number)) {
|
||||
if (!empty($this->order_number)) {
|
||||
$results['order_number'] = link_to_route('hardware.index', $this->order_number, ['order_number' => $this->order_number]);
|
||||
}
|
||||
|
||||
$results['last_checkout'] = $this->last_checkout ?: '';
|
||||
$results['expected_checkin'] = $this->expected_checkin ?: '';
|
||||
$results['created_at'] = '';
|
||||
if(!empty($this->created_at)) {
|
||||
if (!empty($this->created_at)) {
|
||||
$results['created_at'] = $this->created_at->format('F j, Y h:iA');
|
||||
}
|
||||
$results['companyName'] = $this->companyUrl();
|
||||
|
@ -162,7 +165,7 @@ class AssetPresenter extends Presenter
|
|||
|
||||
public function modelUrl()
|
||||
{
|
||||
if($this->model->model) {
|
||||
if ($this->model->model) {
|
||||
return $this->model->model->present()->nameUrl();
|
||||
}
|
||||
return '';
|
||||
|
@ -175,13 +178,13 @@ class AssetPresenter extends Presenter
|
|||
public function imageUrl()
|
||||
{
|
||||
$imagePath = '';
|
||||
if($this->image && !empty($this->image)) {
|
||||
if ($this->image && !empty($this->image)) {
|
||||
$imagePath = $this->image;
|
||||
} else if ($this->model && !empty($this->model->image)) {
|
||||
} elseif ($this->model && !empty($this->model->image)) {
|
||||
$imagePath = $this->model->image;
|
||||
}
|
||||
$url = config('app.url');
|
||||
if(!empty($imagePath)) {
|
||||
if (!empty($imagePath)) {
|
||||
$imagePath = "<img src='{$url}/uploads/assets/{$imagePath}' height=50 width=50>";
|
||||
}
|
||||
return $imagePath;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
/**
|
||||
* Class CompanyPresenter
|
||||
* @package App\Presenters
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
|
||||
/**
|
||||
|
@ -48,7 +47,7 @@ class ManufacturerPresenter extends Presenter
|
|||
*/
|
||||
public function nameUrl()
|
||||
{
|
||||
return (string) link_to_route('manufacturers.show', $this->name, $this->id);
|
||||
return (string) link_to_route('manufacturers.show', $this->name, $this->id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Models\SnipeModel;
|
||||
|
||||
abstract class Presenter
|
||||
|
@ -27,11 +26,11 @@ abstract class Presenter
|
|||
{
|
||||
$model = $this->model;
|
||||
// Category of Asset belongs to model.
|
||||
if($model->model) {
|
||||
if ($model->model) {
|
||||
$model = $this->model->model;
|
||||
}
|
||||
|
||||
if($model->category) {
|
||||
if ($model->category) {
|
||||
return $model->category->present()->nameUrl();
|
||||
}
|
||||
return '';
|
||||
|
@ -56,7 +55,7 @@ abstract class Presenter
|
|||
{
|
||||
$model = $this->model;
|
||||
// Category of Asset belongs to model.
|
||||
if($model->model) {
|
||||
if ($model->model) {
|
||||
$model = $this->model->model;
|
||||
}
|
||||
|
||||
|
@ -68,7 +67,7 @@ abstract class Presenter
|
|||
|
||||
public function __get($property)
|
||||
{
|
||||
if( method_exists($this, $property)) {
|
||||
if (method_exists($this, $property)) {
|
||||
return $this->{$property}();
|
||||
}
|
||||
|
||||
|
@ -79,5 +78,4 @@ abstract class Presenter
|
|||
{
|
||||
return $this->model->$method($args);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace App\Presenters;
|
||||
|
||||
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
@ -38,8 +37,8 @@ class UserPresenter extends Presenter
|
|||
$actions .= link_to_route(
|
||||
'unsuspend/user',
|
||||
'<span class="fa fa-clock-o"></span>"',
|
||||
$this->id,
|
||||
['class' => 'btn btn-default btn-sm']
|
||||
$this->id,
|
||||
['class' => 'btn btn-default btn-sm']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ use Illuminate\Support\ServiceProvider;
|
|||
use DB;
|
||||
use Log;
|
||||
|
||||
|
||||
/**
|
||||
* This service provider handles a few custom validation rules.
|
||||
*
|
||||
|
@ -27,12 +26,11 @@ class AppServiceProvider extends ServiceProvider
|
|||
{
|
||||
|
||||
// Email array validator
|
||||
Validator::extend('email_array', function($attribute, $value, $parameters, $validator) {
|
||||
$value = str_replace(' ','',$value);
|
||||
Validator::extend('email_array', function ($attribute, $value, $parameters, $validator) {
|
||||
$value = str_replace(' ', '', $value);
|
||||
$array = explode(',', $value);
|
||||
|
||||
foreach($array as $email) //loop over values
|
||||
{
|
||||
foreach ($array as $email) { //loop over values
|
||||
$email_to_validate['alert_email'][]=$email;
|
||||
}
|
||||
|
||||
|
@ -41,7 +39,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
'alert_email.*'=>trans('validation.email_array')
|
||||
);
|
||||
|
||||
$validator = Validator::make($email_to_validate,$rules,$messages);
|
||||
$validator = Validator::make($email_to_validate, $rules, $messages);
|
||||
|
||||
if ($validator->passes()) {
|
||||
return true;
|
||||
|
@ -54,9 +52,9 @@ class AppServiceProvider extends ServiceProvider
|
|||
// Unique only if undeleted
|
||||
// This works around the use case where multiple deleted items have the same unique attribute.
|
||||
// (I think this is a bug in Laravel's validator?)
|
||||
Validator::extend('unique_undeleted', function($attribute, $value, $parameters, $validator) {
|
||||
Validator::extend('unique_undeleted', function ($attribute, $value, $parameters, $validator) {
|
||||
|
||||
$count = DB::table($parameters[0])->select('id')->where($attribute,'=',$value)->whereNull('deleted_at')->where('id','!=',$parameters[1])->count();
|
||||
$count = DB::table($parameters[0])->select('id')->where($attribute, '=', $value)->whereNull('deleted_at')->where('id', '!=', $parameters[1])->count();
|
||||
|
||||
if ($count < 1) {
|
||||
return true;
|
||||
|
@ -91,7 +89,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
}
|
||||
}
|
||||
|
||||
foreach($monolog->getHandlers() as $handler) {
|
||||
foreach ($monolog->getHandlers() as $handler) {
|
||||
$handler->setLevel($log_level);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class MacroServiceProvider extends ServiceProvider {
|
||||
class MacroServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* Bootstrap the application services.
|
||||
|
@ -12,9 +13,9 @@ class MacroServiceProvider extends ServiceProvider {
|
|||
public function boot()
|
||||
{
|
||||
// require base_path() . '/resources/macros/community_types.php';
|
||||
foreach(glob(base_path('resources/macros/*.php')) as $filename) {
|
||||
require_once($filename);
|
||||
}
|
||||
foreach (glob(base_path('resources/macros/*.php')) as $filename) {
|
||||
require_once($filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -27,5 +28,4 @@ class MacroServiceProvider extends ServiceProvider {
|
|||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ use Carbon\Carbon;
|
|||
<div class="row">
|
||||
<div class="col-md-3 col-sm-3" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
|
||||
<strong>{{ trans('admin/asset_maintenances/form.start_date') }}: </strong>
|
||||
<?php $startDate = Carbon::parse($assetMaintenance->start_date); ?>
|
||||
<?php $startDate = Carbon::parse($assetMaintenance->start_date); ?>
|
||||
{{ $startDate->toDateString() }}
|
||||
</div>
|
||||
<div class="col-md-3 col-sm-3" style="padding-bottom: 10px; margin-left: 15px; word-wrap: break-word;">
|
||||
|
|
|
@ -51,9 +51,9 @@
|
|||
<?php $model=$item->model; ?>
|
||||
@endif
|
||||
@if (Input::old('model_id'))
|
||||
<?php $model=\App\Models\AssetModel::find(Input::old('model_id')); ?>
|
||||
<?php $model=\App\Models\AssetModel::find(Input::old('model_id')); ?>
|
||||
@elseif (isset($selected_model))
|
||||
<?php $model=$selected_model; ?>
|
||||
<?php $model=$selected_model; ?>
|
||||
@endif
|
||||
@if (isset($model) && $model)
|
||||
@include("models/custom_fields_form",["model" => $model])
|
||||
|
@ -84,12 +84,12 @@
|
|||
@include ('partials.forms.edit.purchase_date')
|
||||
@include ('partials.forms.edit.supplier')
|
||||
@include ('partials.forms.edit.order_number')
|
||||
<?php
|
||||
$currency_type=null;
|
||||
if ($item->id && $item->assetloc) {
|
||||
$currency_type = $item->assetloc->currency;
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
$currency_type=null;
|
||||
if ($item->id && $item->assetloc) {
|
||||
$currency_type = $item->assetloc->currency;
|
||||
}
|
||||
?>
|
||||
@include ('partials.forms.edit.purchase_cost', ['currency_type' => $currency_type])
|
||||
@include ('partials.forms.edit.warranty')
|
||||
@include ('partials.forms.edit.notes')
|
||||
|
|
|
@ -521,7 +521,7 @@
|
|||
<a href="{{ route('users.show', $assetMaintenance->admin->id) }}">{{ $assetMaintenance->admin->present()->fullName() }}</a>
|
||||
@endif
|
||||
</td>
|
||||
<?php $totalCost += $assetMaintenance->cost; ?>
|
||||
<?php $totalCost += $assetMaintenance->cost; ?>
|
||||
@can('update', \App\Models\Asset::class)
|
||||
<td>
|
||||
<a href="{{ route('maintenances.edit', $assetMaintenance->id) }}" class="btn btn-warning btn-sm"><i class="fa fa-pencil icon-white"></i></a>
|
||||
|
|
|
@ -414,7 +414,7 @@
|
|||
<a href="{{ url('hardware') }}">@lang('general.list_all')</a>
|
||||
</li>
|
||||
|
||||
<?php $status_navs = \App\Models\Statuslabel::where('show_in_nav','=',1)->get(); ?>
|
||||
<?php $status_navs = \App\Models\Statuslabel::where('show_in_nav', '=', 1)->get(); ?>
|
||||
@if (count($status_navs) > 0)
|
||||
<li class="divider"> </li>
|
||||
@foreach ($status_navs as $status_nav)
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
@endcan
|
||||
</td>
|
||||
</tr>
|
||||
<?php $count++; ?>
|
||||
<?php $count++; ?>
|
||||
@endforeach
|
||||
@endif
|
||||
</tbody>
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
if ($errormessage) {
|
||||
$errormessage=preg_replace('/ snipeit /', '', $errormessage);
|
||||
print('<span class="alert-msg"><i class="fa fa-times"></i> '.$errormessage.'</span>');
|
||||
}
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<?php
|
||||
$totalDays = 0;
|
||||
$totalCost = 0;
|
||||
?>
|
||||
?>
|
||||
@foreach ($assetMaintenances as $assetMaintenance)
|
||||
<tr>
|
||||
<td>{{ is_null($assetMaintenance->asset->company) ? '' : $assetMaintenance->asset->company->name }}</td>
|
||||
|
@ -65,10 +65,10 @@
|
|||
{{ number_format($assetMaintenance->cost,2) }}
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
$totalDays += $assetMaintenanceTime;
|
||||
$totalCost += floatval($assetMaintenance->cost);
|
||||
?>
|
||||
<?php
|
||||
$totalDays += $assetMaintenanceTime;
|
||||
$totalCost += floatval($assetMaintenance->cost);
|
||||
?>
|
||||
@endforeach
|
||||
</tbody>
|
||||
<tfoot>
|
||||
|
|
|
@ -198,7 +198,7 @@
|
|||
<td>{{ $improvement->completion_date }}</td>
|
||||
<td>{{ $improvement->is_warranty ? trans('admin/asset_maintenances/message.warranty') : trans('admin/asset_maintenances/message.not_warranty') }}</td>
|
||||
<td>{{ sprintf( trans( 'general.currency' ) . '%01.2f', $improvement->cost) }}</td>
|
||||
<?php $totalCost += $improvement->cost; ?>
|
||||
<?php $totalCost += $improvement->cost; ?>
|
||||
<td><a href="{{ route('maintenances.edit', $improvement->id) }}" class="btn btn-warning"><i class="fa fa-pencil icon-white"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -108,16 +108,16 @@ $style = [
|
|||
<tr>
|
||||
<td align="center">
|
||||
<?php
|
||||
switch ($level) {
|
||||
case 'success':
|
||||
$actionColor = 'button--green';
|
||||
break;
|
||||
case 'error':
|
||||
$actionColor = 'button--red';
|
||||
break;
|
||||
default:
|
||||
$actionColor = 'button--blue';
|
||||
}
|
||||
switch ($level) {
|
||||
case 'success':
|
||||
$actionColor = 'button--green';
|
||||
break;
|
||||
case 'error':
|
||||
$actionColor = 'button--red';
|
||||
break;
|
||||
default:
|
||||
$actionColor = 'button--blue';
|
||||
}
|
||||
?>
|
||||
|
||||
<a href="{{ $actionUrl }}"
|
||||
|
|
Loading…
Reference in a new issue