diff --git a/.gitignore b/.gitignore index 78622e2004b5..28be8d7ff55b 100755 --- a/.gitignore +++ b/.gitignore @@ -1,15 +1,16 @@ -/bootstrap/compiled.php -/vendor -composer.phar .DS_Store +/app/config/*/app.php +/app/config/*/database.php +/app/config/*/mail.php /app/config/database.php /app/config/mail.php /app/database/*.sqlite +/app/storage/debugbar/ +/app/storage/logs/* /app/storage/meta/services.json -/app/config/*/mail.php -/app/config/*/database.php -/app/config/*/app.php -public/packages/* +/app/storage/uploads/* /app/storage/views/* -/app/storage/logs/* -/app/storage/debugbar/ \ No newline at end of file +/bootstrap/compiled.php +/vendor +composer.phar +public/packages/* diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php index 867422987360..0bc983f2a652 100644 --- a/app/controllers/admin/AssetsController.php +++ b/app/controllers/admin/AssetsController.php @@ -4,6 +4,7 @@ use Input; use Lang; use Asset; +use FileUpload; use Supplier; use Statuslabel; use User; @@ -172,6 +173,8 @@ public function postCreate() // get the POST data $new = Input::all(); + $file = Input::file('file'); + // create a new model instance $asset = new Asset(); @@ -225,8 +228,44 @@ public function postCreate() // Was the asset created? if($asset->save()) { + $assetid = $asset->id; + + if ($file) { + + // Make the directory if it doesn't exist + if (!file_exists(storage_path().'/uploads/assets/asset-'.$assetid)) { + mkdir(storage_path().'/uploads/assets/asset-'.$assetid, 0755, true); + } + + // Strip out spaces in filenames and upload + $cleaner_name = str_replace(" ",'-',Input::file('file')->getClientOriginalName()); + $upload_success = Input::file('file')->move(storage_path().'/uploads/assets/asset-'.$assetid, $cleaner_name); + + if( $upload_success) { + + $uploadfile = new FileUpload(); + $uploadfile->asset_id = $assetid; + $uploadfile->filename = $cleaner_name; + $uploadfile->created_at = date("Y-m-d H:i:s"); + $uploadfile->user_id = Sentry::getUser()->id; + $uploadfile->filenotes = e(Input::get('note')); + $uploadfile->save(); + + $logaction = new Actionlog(); + $logaction->asset_id = $assetid; + $logaction->asset_type = 'file'; + $logaction->user_id = Sentry::getUser()->id; + $logaction->note = $cleaner_name; + $log = $logaction->logaction('uploaded'); + + + } + + } + + // Redirect to the asset listing page - return Redirect::to("hardware")->with('success', Lang::get('admin/hardware/message.create.success')); + return Redirect::to("hardware/$assetid/view")->with('success', Lang::get('admin/hardware/message.create.success')); } } else { // failure @@ -533,6 +572,7 @@ public function getView($assetId = null) if (isset($asset->id)) { $settings = Setting::getSettings(); + $files = $asset->assetfiles(); $qr_code = (object) array( 'display' => $settings->qr_code == '1', diff --git a/app/lang/en/admin/hardware/form.php b/app/lang/en/admin/hardware/form.php index df7c737b2938..baaa043b5af3 100644 --- a/app/lang/en/admin/hardware/form.php +++ b/app/lang/en/admin/hardware/form.php @@ -14,6 +14,7 @@ 'expires' => 'Expires', 'fully_depreciated' => 'Fully Depreciated', 'help_checkout' => 'If you wish to assign this asset immediately, you should select "Ready to Deploy" from the status list above, or unexpected things may happen. ', + 'help_upload' => 'You can use this to upload purchase orders, invoices, etc.', 'manufacturer' => 'Manufacturer', 'model' => 'Model', 'months' => 'months', @@ -27,6 +28,7 @@ 'supplier' => 'Supplier', 'tag' => 'Asset Tag', 'update' => 'Asset Update', + 'upload_files' => 'Upload Files', 'warranty' => 'Warranty', 'years' => 'years', ) diff --git a/app/lang/en/general.php b/app/lang/en/general.php index f882ae4e1384..0c49993fb606 100755 --- a/app/lang/en/general.php +++ b/app/lang/en/general.php @@ -35,8 +35,10 @@ 'editprofile' => 'Edit Profile', 'eol' => 'EOL', 'first_name' => 'First Name', + 'files' => 'Uploaded Files', 'groups' => 'Groups', 'history_for' => 'History for', + 'history' => 'History', 'id' => 'ID', 'last_name' => 'Last Name', 'license' => 'License', diff --git a/app/lang/en/table.php b/app/lang/en/table.php index 0622f57c13e3..e8b0f228700a 100755 --- a/app/lang/en/table.php +++ b/app/lang/en/table.php @@ -2,6 +2,7 @@ return array( - 'actions' => 'Actions' + 'actions' => 'Actions', + 'action' => 'Action' ); diff --git a/app/lang/en/validation.php b/app/lang/en/validation.php index 4c6e269dedd7..2bb816ca1ebf 100755 --- a/app/lang/en/validation.php +++ b/app/lang/en/validation.php @@ -33,6 +33,7 @@ "digits_between" => "The :attribute must be between :min and :max digits.", "email" => "The :attribute format is invalid.", "exists" => "The selected :attribute is invalid.", + "file" => "The :attribute is not a valid filetype.", "image" => "The :attribute must be an image.", "in" => "The selected :attribute is invalid.", "integer" => "The :attribute must be an integer.", diff --git a/app/models/Asset.php b/app/models/Asset.php index d21da3cfebe9..bb0a64070d55 100644 --- a/app/models/Asset.php +++ b/app/models/Asset.php @@ -5,13 +5,14 @@ class Asset extends Elegant protected $table = 'assets'; protected $softDelete = true; protected $rules = array( - 'name' => 'alpha_space', - 'asset_tag' => 'required|alpha_space|min:3|unique:assets', - 'model_id' => 'required', - 'serial' => 'alpha_dash|min:3|unique:assets', + 'name' => 'alpha_space', + 'asset_tag' => 'required|alpha_space|min:3|unique:assets', + 'model_id' => 'required', + 'serial' => 'alpha_dash|min:3|unique:assets', 'warranty_months' => 'integer', - 'note' => 'alpha_space', - 'notes' => 'alpha_space', + 'note' => 'alpha_space', + 'notes' => 'alpha_space', + 'file' => 'mimes:doc,docx,jpeg,jpg,gif,png,pdf,xls,tiff', ); @@ -66,7 +67,7 @@ public function assetloc() */ public function assetlog() { - return $this->hasMany('Actionlog','asset_id')->where('asset_type','=','hardware')->orderBy('added_on', 'desc')->withTrashed(); + return $this->hasMany('Actionlog','asset_id')->orderBy('added_on', 'desc')->withTrashed(); } /** @@ -169,6 +170,11 @@ public function supplier() return $this->belongsTo('Supplier','supplier_id'); } + public function assetfiles() + { + return $this->hasMany('FileUpload', 'asset_id'); + } + public function months_until_eol() { $today = date("Y-m-d"); diff --git a/app/storage/uploads/.gitkeep b/app/storage/uploads/.gitkeep new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/app/views/backend/hardware/edit.blade.php b/app/views/backend/hardware/edit.blade.php index 93acce94fadb..26c98404664d 100755 --- a/app/views/backend/hardware/edit.blade.php +++ b/app/views/backend/hardware/edit.blade.php @@ -31,7 +31,7 @@
-
+ @@ -155,8 +155,21 @@ {{ $errors->first('assigned_to', ' :message') }}
+ + +
+ +
+ +

@lang('admin/hardware/form.help_upload')

+ {{ $errors->first('assigned_to', ' :message') }} +
+
@endif + +
diff --git a/app/views/backend/hardware/view.blade.php b/app/views/backend/hardware/view.blade.php index 16b990018639..352ea1c1e68f 100644 --- a/app/views/backend/hardware/view.blade.php +++ b/app/views/backend/hardware/view.blade.php @@ -133,7 +133,7 @@ -
Software Assigned to {{{ $asset->name }}}
+
Software Assigned

@if (count($asset->licenses) > 0) @@ -164,13 +164,44 @@
@endif - + +
@lang('general.files')
+ @if (count($asset->assetfiles) > 0) + + + + + + + + + + + + + @for ($i = 0; $i < count($asset->assetfiles); $i++) + + + + + + + @endfor + + +
@lang('general.date')@lang('general.name')@lang('general.admin')@lang('general.notes')
{{{ $asset->assetfiles[$i]->created_at }}}{{{ $asset->assetfiles[$i]->filename }}}{{{ $asset->assetfiles[$i]->adminuser->fullName() }}}{{{ $asset->assetfiles[$i]->notes }}}
+ @endif + + + + + +
@lang('general.history')
- - + @@ -181,14 +212,10 @@ @if (count($asset->assetlog) > 0) @foreach ($asset->assetlog as $log) - @@ -200,14 +227,14 @@ @endif @endforeach @endif -
@lang('general.date')@lang('general.date') @lang('general.admin') @lang('table.action') @lang('general.user')
- @if ((isset($log->checkedout_to)) && ($log->checkedout_to == $asset->assigned_to)) - - @endif - {{{ $log->added_on }}} - @if (isset($log->user_id)) {{{ $log->adminlog->fullName() }}} + @if (isset($log->user_id)) + {{{ $log->adminlog->fullName() }}} @endif {{ $log->action_type }} - @if ($log->note) {{{ $log->note }}} + @if ($log->note) + {{{ $log->note }}} @endif
{{ $asset->created_at }} @if ($asset->adminuser->id) {{{ $asset->adminuser->fullName() }}} @@ -223,6 +250,10 @@
+ + + +