Merge branch 'develop'

This commit is contained in:
snipe 2017-09-27 17:48:32 -07:00
commit 469a3fc608
17 changed files with 92 additions and 36 deletions

View file

@ -76,7 +76,7 @@ This project follows the [all-contributors](https://github.com/kentcdodds/all-co
### Contributing
Please see the documentation on [contributing and developing for Snipe-IT](https://snipe-it.readme.io/docs/contributing).
Please see the documentation on [contributing and developing for Snipe-IT](https://snipe-it.readme.io/docs/contributing-overview).
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.

View file

@ -73,7 +73,7 @@ class GroupsController extends Controller
{
$this->authorize('view', Group::class);
$group = Group::findOrFail($id);
return $group;
return (new GroupsTransformer)->transformGroup($group);
}

View file

@ -0,0 +1,15 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class RegisterController extends Controller
{
public function __construct()
{
$this->middleware('guest');
}
}

View file

@ -25,7 +25,7 @@ class ResetPasswordController extends Controller
*
* @var string
*/
protected $redirectTo = '/home';
protected $redirectTo = '/';
/**
* Create a new controller instance.

View file

@ -74,20 +74,20 @@ class ComponentsController extends Controller
* @since [v3.0]
* @return \Illuminate\Http\RedirectResponse
*/
public function store()
public function store(Request $request)
{
$this->authorize('create', Component::class);
$component = new Component();
$component->name = Input::get('name');
$component->category_id = Input::get('category_id');
$component->location_id = Input::get('location_id');
$component->company_id = Company::getIdForCurrentUser(Input::get('company_id'));
$component->order_number = Input::get('order_number');
$component->min_amt = Input::get('min_amt');
$component->serial = Input::get('serial');
$component->purchase_date = Input::get('purchase_date');
$component->purchase_cost = request('purchase_cost');
$component->qty = Input::get('qty');
$component->name = $request->input('name');
$component->category_id = $request->input('category_id');
$component->location_id = $request->input('location_id');
$component->company_id = Company::getIdForCurrentUser($request->input('company_id'));
$component->order_number = $request->input('order_number', null);
$component->min_amt = $request->input('min_amt', null);
$component->serial = $request->input('serial', null);
$component->purchase_date = $request->input('purchase_date', null);
$component->purchase_cost = $request->input('purchase_cost', null);
$component->qty = $request->input('qty');
$component->user_id = Auth::id();
if ($component->save()) {

View file

@ -37,19 +37,25 @@ class CustomFieldsetsController extends Controller
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]);
if ($cfset) {
$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]);
}
}
return view("custom_fields.fieldsets.view")->with("custom_fieldset", $cfset)->with("maxid", $maxid+1)->with("custom_fields_list", $custom_fields_list);
}
return view("custom_fields.fieldsets.view")->with("custom_fieldset", $cfset)->with("maxid", $maxid+1)->with("custom_fields_list", $custom_fields_list);
return redirect()->route("fields.index")->with("error", trans('admin/custom_fields/message.fieldset.does_not_exist'));
}
@ -133,16 +139,21 @@ class CustomFieldsetsController extends Controller
*/
public function destroy($id)
{
//
$fieldset = CustomFieldset::find($id);
$models = AssetModel::where("fieldset_id", "=", $id);
if ($models->count() == 0) {
$fieldset->delete();
return redirect()->route("fields.show")->with("success", trans('admin/custom_fields/message.fieldset.delete.success'));
} else {
return redirect()->route("fields.show")->with("error", trans('admin/custom_fields/message.fieldset.delete.in_use'));
if ($fieldset) {
$models = AssetModel::where("fieldset_id", "=", $id);
if ($models->count() == 0) {
$fieldset->delete();
return redirect()->route("fields.index")->with("success", trans('admin/custom_fields/message.fieldset.delete.success'));
} else {
return redirect()->route("fields.index")->with("error", trans('admin/custom_fields/message.fieldset.delete.in_use'));
}
}
return redirect()->route("fields.index")->with("error", trans('admin/custom_fields/message.fieldset.does_not_exist'));
}

View file

@ -338,7 +338,7 @@ class SettingsController extends Controller
$setting->email_format = $request->input('email_format');
$setting->username_format = $request->input('username_format');
$setting->require_accept_signature = $request->input('require_accept_signature');
if (config('app.lock_passwords')) {
if (!config('app.lock_passwords')) {
$setting->login_note = $request->input('login_note');
}

View file

@ -23,6 +23,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\CheckForSetup::class,
\Fideloper\Proxy\TrustProxies::class,
\App\Http\Middleware\CheckForDebug::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
];
/**

View file

@ -53,6 +53,7 @@ class ActionlogsTransformer
] : null,
'note' => e($actionlog->note),
'signature_file' => ($actionlog->accept_signature) ? $actionlog->accept_signature : null,
];

View file

@ -23,7 +23,7 @@ class GroupsTransformer
$array = [
'id' => (int) $group->id,
'name' => e($group->name),
'permissions' => $group->permissions,
'permissions' => json_decode($group->permissions),
'users_count' => (int) $group->users_count,
'created_at' => Helper::getFormattedDateObject($group->created_at, 'datetime'),
'updated_at' => Helper::getFormattedDateObject($group->updated_at, 'datetime'),

View file

@ -53,6 +53,7 @@ class Component extends SnipeModel
'name',
'purchase_cost',
'purchase_date',
'min_amt',
'qty',
];

View file

@ -77,6 +77,25 @@ class SnipeModel extends Model
return;
}
public function setMinAmtAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['min_amt'] = $value;
return;
}
public function setParentIdAttribute($value)
{
if ($value == '') {
$value = null;
}
$this->attributes['parent_id'] = $value;
return;
}
//
public function getDisplayNameAttribute()
{

View file

@ -59,7 +59,7 @@
<button class="btn btn-lg btn-primary btn-block">{{ trans('auth/general.login') }}</button>
</div>
<div class="col-md-12 col-sm-12 col-xs-12 text-right" style="padding-top: 10px;">
<a href="{{ url('/') }}/password/reset">{{ trans('auth/general.forgot_password') }}</a>
<a href="{{ route('password.request') }}">{{ trans('auth/general.forgot_password') }}</a>
</div>
</div> <!-- end login box -->

View file

@ -7,7 +7,8 @@
@stop
@section('header_right')
<a href="{{ route('groups.create') }}" class="btn btn-primary pull-right"> {{ trans('general.create') }}</a>
<a href="{{ route('groups.create') }}" class="btn btn-primary pull-right" style="margin-left: 10px;"> {{ trans('general.create') }}</a>
<a href="{{ route('settings.index') }}" class="btn btn-default pull-right">{{ trans('general.back') }}</a>
@stop
@ -32,7 +33,7 @@
<th data-switchable="true" data-sortable="false" data-field="id" data-visible="false">{{ trans('general.id') }}</th>
<th data-switchable="true" data-sortable="true" data-field="name" data-visible="true">{{ trans('admin/groups/table.name') }}</th>
<th data-switchable="true" data-sortable="false" data-field="users_count" data-visible="true">{{ trans('admin/groups/table.users') }}</th>
<th data-switchable="true" data-sortable="true" data-field="created_at" data-visible="true" data-formatter="createdAtFormatter">{{ trans('general.created_at') }}</th>
<th data-switchable="true" data-sortable="true" data-field="created_at" data-visible="true" data-formatter="dateDisplayFormatter">{{ trans('general.created_at') }}</th>
<th data-switchable="false" data-searchable="false" data-sortable="false" data-field="actions" data-formatter="groupsActionsFormatter">{{ trans('table.actions') }}</th>
</tr>
</thead>

View file

@ -603,6 +603,9 @@
<th class="col-sm-2" data-field="item" data-formatter="polymorphicItemFormatter">{{ trans('general.item') }}</th>
<th class="col-sm-2" data-field="target" data-formatter="polymorphicItemFormatter">{{ trans('general.target') }}</th>
<th class="col-sm-2" data-field="note">{{ trans('general.notes') }}</th>
@if ($snipeSettings->require_accept_signature=='1')
<th class="col-md-3" data-field="signature_file" data-formatter="imageFormatter">{{ trans('general.signature') }}</th>
@endif
</tr>
</thead>
</table>

View file

@ -358,7 +358,7 @@ $('.snipe-table').bootstrapTable({
function imageFormatter(value, row) {
if (value) {
return '<img src="' + value + '" style="max-height: {{ $snipeSettings->thumbnail_max_h }}px; width: auto;">';
return '<img src="' + value + '" style="max-height: {{ $snipeSettings->thumbnail_max_h }}px; width: auto;" data-toggle="lightbox" data-type="image">';
}
}

View file

@ -6,6 +6,10 @@
@parent
@stop
@section('header_right')
<a href="{{ route('settings.index') }}" class="btn btn-default pull-right">{{ trans('general.back') }}</a>
@stop
{{-- Page content --}}
@section('content')
@if (!config('app.lock_passwords'))