Skip to content

A free open source IT asset/license management system

Merge remote-tracking branch 'origin/master' into develop

snipe5fded57ec62d
diff --cc app/Console/Commands/LdapSync.php
index 0601c7b0c4,d80e672845..19694569f9
--- a/app/Console/Commands/LdapSync.php
+++ b/app/Console/Commands/LdapSync.php
@@@ -167,32 -166,35 +167,33 @@@ class LdapSync extends Comman
}
/* Create user account entries in Snipe-IT */
- $tmp_pass = substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, 20);
+ $tmp_pass = substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'), 0, 20);
$pass = bcrypt($tmp_pass);
- for ($i = 0; $i < $results["count"]; $i++) {
- if (empty($ldap_result_active_flag) || $results[$i][$ldap_result_active_flag][0] == "TRUE") {
-
- $item = array();
- $item["username"] = isset($results[$i][$ldap_result_username][0]) ? $results[$i][$ldap_result_username][0] : "";
- $item["employee_number"] = isset($results[$i][$ldap_result_emp_num][0]) ? $results[$i][$ldap_result_emp_num][0] : "";
- $item["lastname"] = isset($results[$i][$ldap_result_last_name][0]) ? $results[$i][$ldap_result_last_name][0] : "";
- $item["firstname"] = isset($results[$i][$ldap_result_first_name][0]) ? $results[$i][$ldap_result_first_name][0] : "";
- $item["email"] = isset($results[$i][$ldap_result_email][0]) ? $results[$i][$ldap_result_email][0] : "" ;
- $item["ldap_location_override"] = isset($results[$i]["ldap_location_override"]) ? $results[$i]["ldap_location_override"]:"";
- $item["location_id"] = isset($results[$i]["location_id"]) ? $results[$i]["location_id"]:"";
- $item["telephone"] = isset($results[$i][$ldap_result_phone][0]) ? $results[$i][$ldap_result_phone][0] : "";
- $item["jobtitle"] = isset($results[$i][$ldap_result_jobtitle][0]) ? $results[$i][$ldap_result_jobtitle][0] : "";
- $item["country"] = isset($results[$i][$ldap_result_country][0]) ? $results[$i][$ldap_result_country][0] : "";
- $item["department"] = isset($results[$i][$ldap_result_dept][0]) ? $results[$i][$ldap_result_dept][0] : "";
-
+ for ($i = 0; $i < $results['count']; $i++) {
+ if (empty($ldap_result_active_flag) || $results[$i][$ldap_result_active_flag][0] == 'TRUE') {
+ $item = [];
+ $item['username'] = isset($results[$i][$ldap_result_username][0]) ? $results[$i][$ldap_result_username][0] : '';
+ $item['employee_number'] = isset($results[$i][$ldap_result_emp_num][0]) ? $results[$i][$ldap_result_emp_num][0] : '';
+ $item['lastname'] = isset($results[$i][$ldap_result_last_name][0]) ? $results[$i][$ldap_result_last_name][0] : '';
+ $item['firstname'] = isset($results[$i][$ldap_result_first_name][0]) ? $results[$i][$ldap_result_first_name][0] : '';
+ $item['email'] = isset($results[$i][$ldap_result_email][0]) ? $results[$i][$ldap_result_email][0] : '';
+ $item['ldap_location_override'] = isset($results[$i]['ldap_location_override']) ? $results[$i]['ldap_location_override'] : '';
+ $item['location_id'] = isset($results[$i]['location_id']) ? $results[$i]['location_id'] : '';
+ $item['telephone'] = isset($results[$i][$ldap_result_phone][0]) ? $results[$i][$ldap_result_phone][0] : '';
+ $item['jobtitle'] = isset($results[$i][$ldap_result_jobtitle][0]) ? $results[$i][$ldap_result_jobtitle][0] : '';
+ $item['country'] = isset($results[$i][$ldap_result_country][0]) ? $results[$i][$ldap_result_country][0] : '';
+ $item['department'] = isset($results[$i][$ldap_result_dept][0]) ? $results[$i][$ldap_result_dept][0] : '';
$department = Department::firstOrCreate([
- 'name' => $item["department"],
+ 'name' => $item['department'],
]);
+
- $user = User::where('username', $item["username"])->first();
+ $user = User::where('username', $item['username'])->first();
if ($user) {
// Updating an existing user.
- $item["createorupdate"] = 'updated';
+ $item['createorupdate'] = 'updated';
} else {
// Creating a new user.
$user = new User;
diff --cc app/Http/Controllers/Api/AssetsController.php
index cc04207b88,80a9109ba8..aacff45918
--- a/app/Http/Controllers/Api/AssetsController.php
+++ b/app/Http/Controllers/Api/AssetsController.php
@@@ -118,13 -119,12 +118,13 @@@ class AssetsController extends Controll
->with('location', 'assetstatus', 'company', 'defaultLoc','assignedTo',
'model.category', 'model.manufacturer', 'model.fieldset','supplier'); //it might be tempting to add 'assetlog' here, but don't. It blows up update-heavy users.
-
+
- if($filter_non_deprecable_assets) {
+ if ($filter_non_deprecable_assets) {
$non_deprecable_models = AssetModel::select('id')->whereNotNull('depreciation_id')->get();
+
$assets->InModelList($non_deprecable_models->toArray());
}
-
+
// These are used by the API to query against specific ID numbers.
// They are also used by the individual searches on detail pages like
// locations, etc.
diff --cc app/Http/Controllers/ProfileController.php
index e55dbe0709,dcdd805ed3..14f9ba81c0
--- a/app/Http/Controllers/ProfileController.php
+++ b/app/Http/Controllers/ProfileController.php
@@@ -60,10 -59,11 +60,11 @@@ class ProfileController extends Control
$user->two_factor_optin = $request->input('two_factor_optin', '0');
}
- if (Gate::allows('self.edit_location') && (!config('app.lock_passwords'))) {
- $user->location_id = $request->input('location_id');
+ if (Gate::allows('self.edit_location') && (! config('app.lock_passwords'))) {
+ $user->location_id = $request->input('location_id');
}
+
if ($request->input('avatar_delete') == 1) {
$user->avatar = null;
}
@@@ -178,16 -180,21 +181,17 @@@
$validator->errors()->add('password', trans('validation.disallow_same_pwd_as_user_fields'));
}
}
-
-
-
-
});
- if (!$validator->fails()) {
+ if (! $validator->fails()) {
$user->password = Hash::make($request->input('password'));
$user->save();
-
return redirect()->route('account.password.index')->with('success', 'Password updated!');
- }
+ }
return redirect()->back()->withInput()->withErrors($validator);
+
+
}
/**
diff --cc app/Importer/ItemImporter.php
index 7b4fc36643,27b21a431b..3188a46052
--- a/app/Importer/ItemImporter.php
+++ b/app/Importer/ItemImporter.php
@@@ -284,13 -267,11 +284,12 @@@ class ItemImporter extends Importe
$category->user_id = $this->user_id;
if ($category->save()) {
- $this->log('Category ' . $asset_category . ' was created');
+ $this->log('Category '.$asset_category.' was created');
+
return $category->id;
}
--
- $this->logError($category, 'Category "'.$asset_category.'"');
+ $this->logError($category, 'Category "'. $asset_category. '"');
+
return null;
}
@@@ -379,8 -357,7 +378,7 @@@
return $status->id;
}
- $this->logError($status, 'Status "'. $asset_statuslabel_name . '"');
+ $this->logError($status, 'Status "'.$asset_statuslabel_name.'"');
-
return null;
}
diff --cc app/Importer/UserImporter.php
index cb3a3fdb5d,13d163b4c1..940c758f34
--- a/app/Importer/UserImporter.php
+++ b/app/Importer/UserImporter.php
@@@ -144,10 -145,8 +145,9 @@@ class UserImporter extends ItemImporte
$this->logError($department, 'Department');
return null;
}
-
- public function sendWelcome($send = true) {
+
-
+ public function sendWelcome($send = true)
+ {
$this->send_welcome = $send;
}
}
diff --cc app/Models/Asset.php
index 49f2ca1ff3,a1e94b4510..82c6d97120
--- a/app/Models/Asset.php
+++ b/app/Models/Asset.php
@@@ -259,12 -248,13 +259,12 @@@ class Asset extends Depreciabl
// The asset status is not archived and is deployable
if (($this->assetstatus) && ($this->assetstatus->archived == '0')
- && ($this->assetstatus->deployable == '1'))
+ && ($this->assetstatus->deployable == '1'))
{
-
return true;
- }
+
+ }
}
-
return false;
}
@@@ -675,7 -665,9 +678,9 @@@
*/
public static function getExpiringWarrantee($days = 30)
{
+ $days = (is_null($days)) ? 30 : $days;
+
- return Asset::where('archived', '=', '0')
+ return self::where('archived', '=', '0')
->whereNotNull('warranty_months')
->whereNotNull('purchase_date')
->whereNull('deleted_at')
@@@ -1316,9 -1306,10 +1321,10 @@@
{
return $query->where(function ($query) use ($filter) {
foreach ($filter as $key => $search_val) {
+
- $fieldname = str_replace('custom_fields.','', $key) ;
+ $fieldname = str_replace('custom_fields.', '', $key);
- if ($fieldname =='asset_tag') {
+ if ($fieldname == 'asset_tag') {
$query->where('assets.asset_tag', 'LIKE', '%'.$search_val.'%');
}
@@@ -1447,13 -1437,12 +1453,14 @@@
* - snipe
*
*/
+
if (($fieldname!='category') && ($fieldname!='model_number') && ($fieldname!='rtd_location') && ($fieldname!='location') && ($fieldname!='supplier')
- && ($fieldname!='status_label') && ($fieldname!='model') && ($fieldname!='company') && ($fieldname!='manufacturer')) {
- $query->orWhere('assets.'.$fieldname, 'LIKE', '%' . $search_val . '%');
+ && ($fieldname!='status_label') && ($fieldname!='assigned_to') && ($fieldname!='model') && ($fieldname!='company') && ($fieldname!='manufacturer')) {
+ $query->where('assets.'.$fieldname, 'LIKE', '%' . $search_val . '%');
}
+
+ }
});
diff --cc app/Models/License.php
index c25e8366b7,37a0e8d411..bcdcf3128e
--- a/app/Models/License.php
+++ b/app/Models/License.php
@@@ -592,9 -579,10 +593,10 @@@ class License extends Depreciabl
*/
public function supplier()
{
- return $this->belongsTo('\App\Models\Supplier', 'supplier_id');
+ return $this->belongsTo(\App\Models\Supplier::class, 'supplier_id');
}
+
/**
* Gets the next available free seat - used by
* the API to populate next_seat
@@@ -638,12 -627,15 +640,14 @@@
*/
public static function getExpiringLicenses($days = 60)
{
+ $days = (is_null($days)) ? 60 : $days;
+
- return License::whereNotNull('expiration_date')
+ return self::whereNotNull('expiration_date')
->whereNull('deleted_at')
->whereRaw(DB::raw('DATE_SUB(`expiration_date`,INTERVAL '.$days.' DAY) <= DATE(NOW()) '))
- ->where('expiration_date', '>', date("Y-m-d"))
+ ->where('expiration_date', '>', date('Y-m-d'))
->orderBy('expiration_date', 'ASC')
->get();
-
}
/**
diff --cc resources/assets/js/components/importer/importer-file.vue
index 13425e884b,f208a84079..b363b51a93
--- a/resources/assets/js/components/importer/importer-file.vue
+++ b/resources/assets/js/components/importer/importer-file.vue
@@@ -184,8 -182,8 +184,9 @@@
{id: 'address', text: 'Address' },
{id: 'city', text: 'City' },
{id: 'state', text: 'State' },
+ {id: 'zip', text: 'ZIP' },
{id: 'country', text: 'Country' },
+ {id: 'zip', text: 'ZIP' },
],
customFields: this.customFields,
diff --cc resources/views/depreciations/edit.blade.php
index 54696a3acc,26adbb4559..7c7e309cd0
--- a/resources/views/depreciations/edit.blade.php
+++ b/resources/views/depreciations/edit.blade.php
@@@ -15,12 -15,14 +15,13 @@@
<label for="months" class="col-md-3 control-label">
{{ trans('admin/depreciations/general.number_of_months') }}
</label>
- <div class="col-md-7{{ (\App\Helpers\Helper::checkIfRequired($item, 'months')) ? ' required' : '' }}">
+ <div class="col-md-7 col-sm-12 {{ (Helper::checkIfRequired($item, 'months')) ? ' required' : '' }}">
- <input class="form-control" type="text" name="months" aria-label="months" id="months" value="{{ Request::old('months', $item->months) }}" style="width: 80px;"{!! (Helper::checkIfRequired($item, 'months')) ? ' data-validation="required" required' : '' !!} />
- {!! $errors->first('months', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
+ <div class="col-md-7" style="padding-left:0px">
+ <input class="form-control" type="text" name="months" id="months" value="{{ Request::old('months', $item->months) }}" style="width: 80px;"{!! (\App\Helpers\Helper::checkIfRequired($item, 'months')) ? ' data-validation="required" required' : '' !!} />
+ {!! $errors->first('months', '<span class="alert-msg" aria-hidden="true"><i class="fa fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
- </div>
-
</div>
+
<!-- Depreciation Minimum -->
<div class="form-group {{ $errors->has('depreciation_min') ? ' has-error' : '' }}">
<label for="depreciation_min" class="col-md-3 control-label">