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

This commit is contained in:
snipe 2016-06-21 10:06:29 -07:00
commit 9c5965a8c5
11 changed files with 57 additions and 31 deletions

View file

@ -1,4 +1,4 @@
[![Build Status](https://travis-ci.org/snipe/snipe-it.svg?branch=develop)](https://travis-ci.org/snipe/snipe-it) [![Stories in Ready](https://badge.waffle.io/snipe/snipe-it.png?label=ready+for+dev&title=Ready+for+development)](http://waffle.io/snipe/snipe-it) [![Maintenance](https://img.shields.io/maintenance/yes/2016.svg)]() [![Crowdin](https://d322cqt584bo4o.cloudfront.net/snipe-it/localized.png)](https://crowdin.com/project/snipe-it) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/snipe/snipe-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Docker Pulls](https://img.shields.io/docker/pulls/snipe/snipe-it.svg)](https://hub.docker.com/r/snipe/snipe-it/) [![Twitter Follow](https://img.shields.io/twitter/follow/snipeyhead.svg?style=social)](https://twitter.com/snipeyhead) [![Zenhub](https://raw.githubusercontent.com/ZenHubIO/support/master/zenhub-badge.png)](https://zenhub.io) [![Build Status](https://travis-ci.org/snipe/snipe-it.svg?branch=develop)](https://travis-ci.org/snipe/snipe-it) [![Stories in Ready](https://badge.waffle.io/snipe/snipe-it.png?label=ready+for+dev&title=Ready+for+development)](http://waffle.io/snipe/snipe-it) [![Maintenance](https://img.shields.io/maintenance/yes/2016.svg)]() [![Crowdin](https://d322cqt584bo4o.cloudfront.net/snipe-it/localized.png)](https://crowdin.com/project/snipe-it) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/snipe/snipe-it?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Docker Pulls](https://img.shields.io/docker/pulls/snipe/snipe-it.svg)](https://hub.docker.com/r/snipe/snipe-it/) [![Twitter Follow](https://img.shields.io/twitter/follow/snipeyhead.svg?style=social)](https://twitter.com/snipeyhead) [![Zenhub](https://raw.githubusercontent.com/ZenHubIO/support/master/zenhub-badge.png)](https://zenhub.io) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/553ce52037fc43ea99149785afcfe641)](https://www.codacy.com/app/snipe/snipe-it?utm_source=github.com&utm_medium=referral&utm_content=snipe/snipe-it&utm_campaign=Badge_Grade)
## Snipe-IT - Open Source Asset Management System ## Snipe-IT - Open Source Asset Management System

View file

@ -103,8 +103,10 @@ class ObjectImportCommand extends Command {
$this->accessories = Accessory::All(['name']); $this->accessories = Accessory::All(['name']);
$this->consumables = Consumable::All(['name']); $this->consumables = Consumable::All(['name']);
$this->customfields = CustomField::All(['name']); $this->customfields = CustomField::All(['name']);
$bar = NULL;
$bar = $this->output->createProgressBar(count($newarray)); if(!$this->option('web-importer')) {
$bar = $this->output->createProgressBar(count($newarray));
}
// Loop through the records // Loop through the records
DB::transaction(function() use (&$newarray, $bar){ DB::transaction(function() use (&$newarray, $bar){
Model::unguard(); Model::unguard();
@ -180,12 +182,16 @@ class ObjectImportCommand extends Command {
break; break;
} }
$bar->advance(); if(!$this->option('web-importer')) {
$bar->advance();
}
$this->log('------------- Action Summary ----------------'); $this->log('------------- Action Summary ----------------');
} }
}); });
$bar->finish(); if(!$this->option('web-importer')) {
$bar->finish();
}
$this->log('====================================='); $this->log('=====================================');
@ -321,7 +327,7 @@ class ObjectImportCommand extends Command {
$asset_model->manufacturer_id = $manufacturer->id; $asset_model->manufacturer_id = $manufacturer->id;
$asset_model->modelno = $asset_modelno; $asset_model->modelno = $asset_modelno;
$asset_model->category_id = $category->id; $asset_model->category_id = $category->id;
$asset_model->user_id = 1; $asset_model->user_id = $this->option('user_id');
if(!$this->option('testrun')) { if(!$this->option('testrun')) {
@ -367,7 +373,7 @@ class ObjectImportCommand extends Command {
$category->name = $asset_category; $category->name = $asset_category;
$category->category_type = $item_type; $category->category_type = $item_type;
$category->user_id = 1; $category->user_id = $this->option('user_id');
if(!$this->option('testrun')) { if(!$this->option('testrun')) {
@ -491,7 +497,7 @@ class ObjectImportCommand extends Command {
$manufacturer = new Manufacturer(); $manufacturer = new Manufacturer();
$manufacturer->name = $asset_mfgr; $manufacturer->name = $asset_mfgr;
$manufacturer->user_id = 1; $manufacturer->user_id = $this->option('user_id');
if (!$this->option('testrun')) { if (!$this->option('testrun')) {
if ($manufacturer->save()) { if ($manufacturer->save()) {
@ -538,7 +544,7 @@ class ObjectImportCommand extends Command {
$location->city = ''; $location->city = '';
$location->state = ''; $location->state = '';
$location->country = ''; $location->country = '';
$location->user_id = 1; $location->user_id = $this->option('user_id');
if (!$this->option('testrun')) { if (!$this->option('testrun')) {
if ($location->save()) { if ($location->save()) {
@ -584,7 +590,7 @@ class ObjectImportCommand extends Command {
$supplier = new Supplier(); $supplier = new Supplier();
$supplier->name = $supplier_name; $supplier->name = $supplier_name;
$supplier->user_id = 1; $supplier->user_id = $this->option('user_id');
if(!$this->option('testrun')) { if(!$this->option('testrun')) {
if ($supplier->save()) { if ($supplier->save()) {
@ -721,6 +727,7 @@ class ObjectImportCommand extends Command {
$this->log('Serial No: '.$asset_serial); $this->log('Serial No: '.$asset_serial);
$this->log('Asset Tag: '.$asset_tag); $this->log('Asset Tag: '.$asset_tag);
$this->log('Notes: '.$item["notes"]); $this->log('Notes: '.$item["notes"]);
$this->log('Warranty Months: ' . $asset_warranty_months);
foreach ($this->assets as $tempasset) { foreach ($this->assets as $tempasset) {
if (strcasecmp($tempasset->asset_tag, $asset_tag ) == 0 ) { if (strcasecmp($tempasset->asset_tag, $asset_tag ) == 0 ) {
@ -747,9 +754,11 @@ class ObjectImportCommand extends Command {
$asset->purchase_date = NULL; $asset->purchase_date = NULL;
} }
foreach ($item['custom_fields'] as $custom_field => $val) { if( array_key_exists('custom_fields', $item)) {
$asset->{$custom_field} = $val; foreach ($item['custom_fields'] as $custom_field => $val) {
} $asset->{$custom_field} = $val;
}
}
if (!empty($item["purchase_cost"])) { if (!empty($item["purchase_cost"])) {
//TODO How to generalize this for not USD? //TODO How to generalize this for not USD?
@ -761,6 +770,7 @@ class ObjectImportCommand extends Command {
} }
$asset->serial = $asset_serial; $asset->serial = $asset_serial;
$asset->asset_tag = $asset_tag; $asset->asset_tag = $asset_tag;
$asset->warranty_months = $asset_warranty_months;
if($asset_model) if($asset_model)
$asset->model_id = $asset_model->id; $asset->model_id = $asset_model->id;
@ -768,7 +778,7 @@ class ObjectImportCommand extends Command {
$asset->assigned_to = $item["user"]->id; $asset->assigned_to = $item["user"]->id;
if($item["location"]) if($item["location"])
$asset->rtd_location_id = $item["location"]->id; $asset->rtd_location_id = $item["location"]->id;
$asset->user_id = 1; $asset->user_id = $this->option('user_id');
$this->log("status_id: " . $status_id); $this->log("status_id: " . $status_id);
$asset->status_id = $status_id; $asset->status_id = $status_id;
if($item["company"]) if($item["company"])
@ -827,7 +837,7 @@ class ObjectImportCommand extends Command {
} }
if($item["location"]) if($item["location"])
$accessory->location_id = $item["location"]->id; $accessory->location_id = $item["location"]->id;
$accessory->user_id = 1; $accessory->user_id = $this->option('user_id');
if($item["company"]) if($item["company"])
$accessory->company_id = $item["company"]->id; $accessory->company_id = $item["company"]->id;
$accessory->order_number = $item["order_number"]; $accessory->order_number = $item["order_number"];
@ -893,7 +903,7 @@ class ObjectImportCommand extends Command {
$consumable->purchase_cost = 0.00; $consumable->purchase_cost = 0.00;
} }
$consumable->location_id = $item["location"]->id; $consumable->location_id = $item["location"]->id;
$consumable->user_id = 1; // TODO: What user_id should we use for imports? $consumable->user_id = $this->option('user_id');
$consumable->company_id = $item["company"]->id; $consumable->company_id = $item["company"]->id;
$consumable->order_number = $item["order_number"]; $consumable->order_number = $item["order_number"];
$consumable->category_id = $item["category"]->id; $consumable->category_id = $item["category"]->id;
@ -950,7 +960,8 @@ class ObjectImportCommand extends Command {
array('testrun', null, InputOption::VALUE_NONE, 'If set, will parse and output data without adding to database', null), array('testrun', null, InputOption::VALUE_NONE, 'If set, will parse and output data without adding to database', null),
array('logfile', null, InputOption::VALUE_REQUIRED, 'The path to log output to. storage/logs/importer.log by default', storage_path('logs/importer.log') ), array('logfile', null, InputOption::VALUE_REQUIRED, 'The path to log output to. storage/logs/importer.log by default', storage_path('logs/importer.log') ),
array('item-type', null, InputOption::VALUE_REQUIRED, 'Item Type To import. Valid Options are Asset, Consumable, Or Accessory', 'Asset'), array('item-type', null, InputOption::VALUE_REQUIRED, 'Item Type To import. Valid Options are Asset, Consumable, Or Accessory', 'Asset'),
array('web-importer', null, InputOption::VALUE_NONE, 'Internal: packages output for use with the web importer') array('web-importer', null, InputOption::VALUE_NONE, 'Internal: packages output for use with the web importer'),
array('user_id', null, InputOption::VALUE_REQUIRED, 'ID of user creating items', 1)
); );
} }

View file

@ -878,15 +878,17 @@ class AssetsController extends Controller
['filename'=> config('app.private_uploads').'/imports/assets/'.$filename, ['filename'=> config('app.private_uploads').'/imports/assets/'.$filename,
'--email_format'=>'firstname.lastname', '--email_format'=>'firstname.lastname',
'--username_format'=>'firstname.lastname', '--username_format'=>'firstname.lastname',
'--web-importer' => true '--web-importer' => true,
'--user_id' => Auth::user()->id
]); ]);
$display_output = Artisan::output(); $display_output = Artisan::output();
$file = config('app.private_uploads').'/imports/assets/'.str_replace('.csv', '', $filename).'-output-'.date("Y-m-d-his").'.txt'; $file = config('app.private_uploads').'/imports/assets/'.str_replace('.csv', '', $filename).'-output-'.date("Y-m-d-his").'.txt';
file_put_contents($file, $display_output); file_put_contents($file, $display_output);
if( $return === 0) //Success if( $return === 0) //Success
return redirect()->to('hardware')->with('success', trans('admin/hardware/message.import.success')); return redirect()->to('hardware')->with('success', trans('admin/hardware/message.import.success'));
else if( $return === 1) // Failure else if( $return === 1) { // Failure
return redirect()->back()->with('import_errors', json_decode($display_output))->with('error', trans('admin/hardware/message.import.error')); return redirect()->back()->with('import_errors', json_decode($display_output))->with('error', trans('admin/hardware/message.import.error'));
}
dd("Shouldn't be here"); dd("Shouldn't be here");
} }

View file

@ -6,7 +6,7 @@ use Closure;
use Config; use Config;
use Route; use Route;
use Gate; use Gate;
use Log;
class CheckPermissions class CheckPermissions
{ {

View file

@ -15,6 +15,7 @@ class AssetMaintenance extends Model implements ICompanyableChild
{ {
use SoftDeletes; use SoftDeletes;
use CompanyableChildTrait; use CompanyableChildTrait;
use ValidatingTrait;
protected $dates = [ 'deleted_at' ]; protected $dates = [ 'deleted_at' ];

View file

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

View file

@ -46,7 +46,7 @@
<label for="asset_id" class="col-md-3 control-label">{{ trans('admin/hardware/form.checkout_to') }} <label for="asset_id" class="col-md-3 control-label">{{ trans('admin/hardware/form.checkout_to') }}
<i class='icon-asterisk'></i></label> <i class='icon-asterisk'></i></label>
<div class="col-md-9"> <div class="col-md-9">
{{ Form::select('asset_id', $assets_list , Input::old('asset_id', $component->asset_id), array('class'=>'select2', 'style'=>'min-width:100%')) }} {{ Form::select('asset_id', $assets_list , Input::old('asset_id', $component->asset_id), array('class'=>'select2', 'style'=>'width:100%')) }}
{!! $errors->first('asset_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!} {!! $errors->first('asset_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
</div> </div>
</div> </div>

View file

@ -68,10 +68,10 @@
</label> </label>
<div class="col-md-7 col-sm-10"> <div class="col-md-7 col-sm-10">
@if (isset($selected_model)) @if (isset($selected_model))
{{ Form::select('model_id', $model_list , $selected_model->id, array('class'=>'select2 model', 'style'=>'min-width:100%','id' =>'model_select_id')) }} {{ Form::select('model_id', $model_list , $selected_model->id, array('class'=>'select2 model', 'style'=>'width:100%','id' =>'model_select_id')) }}
@else @else
{{ Form::select('model_id', $model_list , Input::old('model_id', $asset->model_id), array('class'=>'select2 model', 'style'=>'min-width:100%','id' =>'model_select_id')) }} {{ Form::select('model_id', $model_list , Input::old('model_id', $asset->model_id), array('class'=>'select2 model', 'style'=>'width:100%','id' =>'model_select_id')) }}
@endif @endif
<!-- onclick="return dependency('model')" --> <!-- onclick="return dependency('model')" -->
@ -158,7 +158,7 @@
<div class="col-md-3 control-label">{{ Form::label('company_id', trans('general.company')) }}</div> <div class="col-md-3 control-label">{{ Form::label('company_id', trans('general.company')) }}</div>
<div class="col-md-7 col-sm-12"> <div class="col-md-7 col-sm-12">
{{ Form::select('company_id', $company_list , Input::old('company_id', $asset->company_id), {{ Form::select('company_id', $company_list , Input::old('company_id', $asset->company_id),
['class'=>'select2', 'style'=>'min-width:100%']) }} ['class'=>'select2', 'style'=>'width:100%']) }}
{!! $errors->first('company_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!} {!! $errors->first('company_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
</div> </div>
</div> </div>
@ -181,7 +181,7 @@
<div class="form-group {{ $errors->has('supplier_id') ? ' has-error' : '' }}"> <div class="form-group {{ $errors->has('supplier_id') ? ' has-error' : '' }}">
<label for="supplier_id" class="col-md-3 control-label">{{ trans('admin/hardware/form.supplier') }}</label> <label for="supplier_id" class="col-md-3 control-label">{{ trans('admin/hardware/form.supplier') }}</label>
<div class="col-md-7 col-sm-11"> <div class="col-md-7 col-sm-11">
{{ Form::select('supplier_id', $supplier_list , Input::old('supplier_id', $asset->supplier_id), array('class'=>'select2', 'style'=>'min-width:100%','id'=>'supplier_select_id')) }} {{ Form::select('supplier_id', $supplier_list , Input::old('supplier_id', $asset->supplier_id), array('class'=>'select2', 'style'=>'width:100%','id'=>'supplier_select_id')) }}
{!! $errors->first('supplier_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!} {!! $errors->first('supplier_id', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
</div> </div>

View file

@ -9,7 +9,7 @@
<?php <?php
$settings->labels_width = $settings->labels_width - $settings->labels_display_sgutter; $settings->labels_width = $settings->labels_width - $settings->labels_display_sgutter;
$settings->labels_height = $settings->labels_height - $settings->labels_display_sgutter; $settings->labels_height = $settings->labels_height - $settings->labels_display_bgutter;
$qr_size = ($settings->labels_height - .25); $qr_size = ($settings->labels_height - .25);
$qr_txt_size = $settings->labels_width - $qr_size - $settings->labels_display_sgutter - .1; $qr_txt_size = $settings->labels_width - $qr_size - $settings->labels_display_sgutter - .1;
?> ?>
@ -49,6 +49,11 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
img.barcode {
display: block;
margin-left: auto;
margin-right: auto;
}
.qr_text { .qr_text {
width: {{ $qr_txt_size }}in; width: {{ $qr_txt_size }}in;
@ -88,6 +93,9 @@
} }
} }
@if (\App\Models\Setting::getSettings()->custom_css)
{{ \App\Models\Setting::getSettings()->show_custom_css() }}
@endif
</style> </style>

View file

@ -560,7 +560,11 @@
<script> <script>
$(function () { $(function () {
//Initialize Select2 Elements //Initialize Select2 Elements
$(".select2").select2(); var iOS = /iPhone|iPad|iPod/.test(navigator.userAgent) && !window.MSStream;
if(!iOS)
{
$(".select2").select2();
}
$('.datepicker').datepicker(); $('.datepicker').datepicker();
}); });

View file

@ -470,19 +470,19 @@
</div> </div>
<div class="col-md-3 form-group"> <div class="col-md-3 form-group">
<div class="input-group"> <div class="input-group">
{{ Form::text('labels_display_bgutter', Input::old('labels_display_bgutter', $setting->labels_display_bgutter), array('class' => 'form-control')) }} {{ Form::text('labels_display_sgutter', Input::old('labels_display_sgutter', $setting->labels_display_sgutter), array('class' => 'form-control')) }}
<div class="input-group-addon">{{ trans('admin/settings/general.horizontal') }}</div> <div class="input-group-addon">{{ trans('admin/settings/general.horizontal') }}</div>
</div> </div>
</div> </div>
<div class="col-md-3 form-group" style="margin-left: 10px"> <div class="col-md-3 form-group" style="margin-left: 10px">
<div class="input-group"> <div class="input-group">
{{ Form::text('labels_display_sgutter', Input::old('labels_display_sgutter', $setting->labels_display_sgutter), array('class' => 'form-control')) }} {{ Form::text('labels_display_bgutter', Input::old('labels_display_bgutter', $setting->labels_display_bgutter), array('class' => 'form-control')) }}
<div class="input-group-addon">{{ trans('admin/settings/general.vertical') }}</div> <div class="input-group-addon">{{ trans('admin/settings/general.vertical') }}</div>
</div> </div>
</div> </div>
<div class="col-md-9 col-md-offset-3"> <div class="col-md-9 col-md-offset-3">
{!! $errors->first('labels_display_bgutter', '<span class="alert-msg">:message</span>') !!}
{!! $errors->first('labels_display_sgutter', '<span class="alert-msg">:message</span>') !!} {!! $errors->first('labels_display_sgutter', '<span class="alert-msg">:message</span>') !!}
{!! $errors->first('labels_display_bgutter', '<span class="alert-msg">:message</span>') !!}
</div> </div>
</div> </div>