diff --git a/app/controllers/account/ViewAssetsController.php b/app/controllers/account/ViewAssetsController.php
index 47325811867a..b9098a62d97f 100755
--- a/app/controllers/account/ViewAssetsController.php
+++ b/app/controllers/account/ViewAssetsController.php
@@ -8,6 +8,8 @@
use Location;
use View;
use Asset;
+use Actionlog;
+use Lang;
class ViewAssetsController extends AuthorizedController
{
@@ -55,6 +57,53 @@ public function getRequestAsset($assetId = null) {
}
+
+
+
+ // Get the acceptance screen
+ public function getAcceptAsset($assetId = null) {
+
+ // Check if the asset exists
+ if (is_null($asset = Asset::find($assetId))) {
+ // Redirect to the asset management page
+ return Redirect::to('account')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
+ }
+
+ return View::make('frontend/account/accept-asset', compact('asset'));
+
+
+
+
+ }
+
+ // Save the acceptance
+ public function postAcceptAsset($assetId = null) {
+
+ // Check if the asset exists
+ if (is_null($asset = Asset::find($assetId))) {
+ // Redirect to the asset management page
+ return Redirect::to('account')->with('error', Lang::get('admin/hardware/message.does_not_exist'));
+ }
+
+ $user = Sentry::getUser();
+
+
+ $logaction = new Actionlog();
+ $logaction->asset_id = $assetId;
+ $logaction->checkedout_to = $asset->assigned_to;
+ $logaction->asset_type = 'hardware';
+ $logaction->note = e(Input::get('note'));
+ $logaction->user_id = $user->id;
+ $logaction->accepted_at = date("Y-m-d h:i:s");
+ $log = $logaction->logaction('accepted');
+
+ return Redirect::to('account/view-assets')->with('success', 'You have successfully accept this asset.');
+
+
+
+
+ }
+
}
diff --git a/app/controllers/admin/AssetsController.php b/app/controllers/admin/AssetsController.php
index 675a73ded014..581d5a978f2c 100755
--- a/app/controllers/admin/AssetsController.php
+++ b/app/controllers/admin/AssetsController.php
@@ -21,6 +21,7 @@
use Config;
use Location;
use Log;
+use Mail;
use BaconQrCode\Renderer\Image as QrImage;
@@ -432,7 +433,7 @@ public function postCheckout($assetId)
// Check if the user exists
- if (is_null($assigned_to = User::find($assigned_to))) {
+ if (is_null($user = User::find($assigned_to))) {
// Redirect to the asset management page with error
return Redirect::to('hardware')->with('error', Lang::get('admin/hardware/message.user_does_not_exist'));
}
@@ -446,10 +447,23 @@ public function postCheckout($assetId)
$logaction->asset_id = $asset->id;
$logaction->checkedout_to = $asset->assigned_to;
$logaction->asset_type = 'hardware';
- $logaction->location_id = $assigned_to->location_id;
+ $logaction->location_id = $user->location_id;
$logaction->user_id = Sentry::getUser()->id;
$logaction->note = e(Input::get('note'));
$log = $logaction->logaction('checkout');
+
+ $data['asset_id'] = $asset->id;
+ $data['eula'] = $asset->getEula();
+ $data['first_name'] = $user->first_name;
+
+
+ if ($asset->requireAcceptance()=='1') {
+
+ Mail::send('emails.accept-asset', $data, function ($m) use ($user) {
+ $m->to($user->email, $user->first_name . ' ' . $user->last_name);
+ $m->subject('Confirm asset delivery');
+ });
+ }
// Redirect to the new asset page
return Redirect::to("hardware")->with('success', Lang::get('admin/hardware/message.checkout.success'));
@@ -866,6 +880,8 @@ public function postBulkSave($assets = null)
return Redirect::to("hardware");
}
-
-
+
+
+
+
}
diff --git a/app/controllers/admin/CategoriesController.php b/app/controllers/admin/CategoriesController.php
index 0ead4401780c..89e4bdd8882a 100755
--- a/app/controllers/admin/CategoriesController.php
+++ b/app/controllers/admin/CategoriesController.php
@@ -63,8 +63,11 @@ public function postCreate()
else{
// Update the category data
- $category->name = e(Input::get('name'));
- $category->user_id = Sentry::getId();
+ $category->name = e(Input::get('name'));
+ $category->eula_text = e(Input::get('eula_text'));
+ $category->use_default_eula = e(Input::get('use_default_eula', '1'));
+ $category->require_acceptance = e(Input::get('require_acceptance', '0'));
+ $category->user_id = Sentry::getId();
// Was the asset created?
if($category->save()) {
@@ -133,6 +136,9 @@ public function postEdit($categoryId = null)
// Update the category data
$category->name = e(Input::get('name'));
+ $category->eula_text = e(Input::get('eula_text'));
+ $category->use_default_eula = e(Input::get('use_default_eula', '1'));
+ $category->require_acceptance = e(Input::get('require_acceptance', '0'));
// Was the asset created?
if($category->save()) {
diff --git a/app/controllers/admin/SettingsController.php b/app/controllers/admin/SettingsController.php
index 4498f9f42823..a3a70abd0205 100755
--- a/app/controllers/admin/SettingsController.php
+++ b/app/controllers/admin/SettingsController.php
@@ -110,6 +110,7 @@ public function postEdit()
$setting->alert_email = e(Input::get('alert_email'));
$setting->alerts_enabled = e(Input::get('alerts_enabled', '0'));
$setting->header_color = e(Input::get('header_color'));
+ $setting->default_eula_text = e(Input::get('default_eula_text'));
// Was the asset updated?
diff --git a/app/controllers/admin/UsersController.php b/app/controllers/admin/UsersController.php
index b59e87825986..5f1fcfa4e228 100755
--- a/app/controllers/admin/UsersController.php
+++ b/app/controllers/admin/UsersController.php
@@ -732,6 +732,7 @@ public function postImport()
return Redirect::route('users')->with('duplicates',$duplicates)->with('success', 'Success');
}
+
diff --git a/app/database/migrations/2015_02_25_022931_add_eula_fields.php b/app/database/migrations/2015_02_25_022931_add_eula_fields.php
new file mode 100644
index 000000000000..36d53d54cc0f
--- /dev/null
+++ b/app/database/migrations/2015_02_25_022931_add_eula_fields.php
@@ -0,0 +1,69 @@
+longText('default_eula_text');
+ });
+
+ Schema::table('categories', function ($table) {
+ $table->longText('eula_text');
+ $table->boolean('use_default_eula')->default(0);
+ $table->boolean('require_acceptance')->default(0);
+ });
+
+ Schema::table('asset_logs', function ($table) {
+ $table->dateTime('requested_at')->nullable()->default(NULL);
+ $table->dateTime('accepted_at')->nullable()->default(NULL);
+ });
+
+
+ Schema::create('requested_assets', function ($table) {
+ $table->increments('id');
+ $table->integer('asset_id')->default(NULL);
+ $table->integer('user_id')->default(NULL);
+ $table->dateTime('accepted_at')->nullable()->default(NULL);
+ $table->dateTime('denied_at')->nullable()->default(NULL);
+ $table->string('notes')->default(NULL);
+ $table->timestamps();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ //
+ Schema::table('settings', function ($table) {
+ $table->dropColumn('default_eula_text');
+ });
+
+ Schema::table('categories', function ($table) {
+ $table->dropColumn('eula_text');
+ $table->dropColumn('use_default_eula');
+ $table->dropColumn('require_acceptance');
+ });
+
+ Schema::table('asset_logs', function ($table) {
+ $table->dropColumn('requested_at');
+ $table->dropColumn('accepted_at');
+ });
+
+ Schema::drop('requested_assets');
+ }
+
+}
diff --git a/app/database/seeds/CategoriesSeeder.php b/app/database/seeds/CategoriesSeeder.php
index 0aae16f614bd..6c4cdaa9ebd8 100755
--- a/app/database/seeds/CategoriesSeeder.php
+++ b/app/database/seeds/CategoriesSeeder.php
@@ -12,6 +12,8 @@ public function run()
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'user_id' => 1,
+ 'use_default_eula' = 0;
+ 'require_acceptance' = 0;
'deleted_at' => NULL,
);
@@ -21,6 +23,8 @@ public function run()
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'user_id' => 1,
+ 'use_default_eula' = 0;
+ 'require_acceptance' = 0;
'deleted_at' => NULL,
);
@@ -30,6 +34,8 @@ public function run()
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'user_id' => 1,
+ 'use_default_eula' = 0;
+ 'require_acceptance' = 0;
'deleted_at' => NULL,
);
@@ -39,6 +45,8 @@ public function run()
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'user_id' => 1,
+ 'use_default_eula' = 0;
+ 'require_acceptance' = 0;
'deleted_at' => NULL,
);
@@ -48,6 +56,8 @@ public function run()
'created_at' => $date->modify('-10 day'),
'updated_at' => $date->modify('-3 day'),
'user_id' => 1,
+ 'use_default_eula' = 0;
+ 'require_acceptance' = 0;
'deleted_at' => NULL,
);
diff --git a/app/lang/en/admin/categories/general.php b/app/lang/en/admin/categories/general.php
index 88c6a63c46c9..3d50e3d083b2 100755
--- a/app/lang/en/admin/categories/general.php
+++ b/app/lang/en/admin/categories/general.php
@@ -6,6 +6,12 @@
'asset_categories' => 'Asset Categories',
'category_name' => 'Category Name',
'create' => 'Create Category',
+ 'eula_text' => 'Category EULA',
+ 'eula_text_help' => 'This field allows you to customize your EULAs for specific types of assets. If you only have one EULA for all of your assets, you can check the box below to use the primary default.',
+ 'require_acceptance' => 'Require users to confirm acceptance of assets in this category.',
+ 'no_default_eula' => 'No primary default EULA found. Add one in Settings.',
'update' => 'Update Category',
+ 'use_default_eula' => 'Use the primary default EULA instead.',
+ 'use_default_eula_disabled' => 'Use the primary default EULA instead. No primary default EULA is set. Please add one in Settings.',
);
diff --git a/app/lang/en/admin/categories/table.php b/app/lang/en/admin/categories/table.php
index 6fdcd1149ac1..a3ee96ae7f0c 100755
--- a/app/lang/en/admin/categories/table.php
+++ b/app/lang/en/admin/categories/table.php
@@ -1,9 +1,10 @@
'ID',
- 'parent' => 'Parent',
- 'title' => 'Asset Category Name',
+ 'eula_text' => 'EULA',
+ 'id' => 'ID',
+ 'parent' => 'Parent',
+ 'require_acceptance' => 'Acceptance',
+ 'title' => 'Asset Category Name',
);
diff --git a/app/lang/en/admin/settings/general.php b/app/lang/en/admin/settings/general.php
index 35c1b85a7684..27a72d090ce3 100755
--- a/app/lang/en/admin/settings/general.php
+++ b/app/lang/en/admin/settings/general.php
@@ -5,7 +5,9 @@
'alerts_enabled' => 'Alerts enabled',
'auto_increment_assets' => 'Generate auto-incrementing asset IDs',
'auto_increment_prefix' => 'Prefix (optional)',
- 'auti_incrementing_help' => 'Enable auto-incrementing asset IDs first to set this',
+ 'auto_incrementing_help' => 'Enable auto-incrementing asset IDs first to set this',
+ 'default_eula_text' => 'Default EULA',
+ 'default_eula_help_text' => 'You can also associate custom EULAs to specific asset categories.',
'display_asset_name' => 'Display Asset Name',
'display_checkout_date' => 'Display Checkout Date',
'display_eol' => 'Display EOL in table view',
diff --git a/app/models/Asset.php b/app/models/Asset.php
index ede68e2422d6..0fb953b018b0 100755
--- a/app/models/Asset.php
+++ b/app/models/Asset.php
@@ -203,6 +203,25 @@ public static function autoincrement_asset()
return false;
}
}
+
+ public function requireAcceptance() {
+ return $this->model->category->require_acceptance;
+ }
+
+ public function getEula() {
+
+ if ($this->model->category->eula_text) {
+ return $this->model->category->eula_text;
+ } elseif (Setting::getSettings()->default_eula_text) {
+ return Setting::getSettings()->default_eula_text;
+ } else {
+ return null;
+ }
+
+ }
+
+
+
/**
diff --git a/app/routes.php b/app/routes.php
index e78f2cb01761..36c3637e9cfa 100755
--- a/app/routes.php
+++ b/app/routes.php
@@ -245,7 +245,7 @@
# Account Activation
Route::get('activate/{activationCode}', array('as' => 'activate', 'uses' => 'AuthController@getActivate'));
-
+
# Forgot Password
Route::get('forgot-password', array('as' => 'forgot-password', 'uses' => 'AuthController@getForgotPassword'));
Route::post('forgot-password', 'AuthController@postForgotPassword');
@@ -270,9 +270,7 @@
Route::group(array('prefix' => 'account', 'before' => 'auth', 'namespace' => 'Controllers\Account'), function () {
- # Account Dashboard
- Route::get('/', array('as' => 'account', 'uses' => 'DashboardController@getIndex'));
-
+
# Profile
Route::get('profile', array('as' => 'profile', 'uses' => 'ProfileController@getIndex'));
Route::post('profile', 'ProfileController@postIndex');
@@ -287,10 +285,17 @@
# Change Email
Route::get('change-email', array('as' => 'change-email', 'uses' => 'ChangeEmailController@getIndex'));
Route::post('change-email', 'ChangeEmailController@postIndex');
+
+ # Accept Asset
+ Route::get('accept-asset/{assetId}', array('as' => 'account/accept-assets', 'uses' => 'ViewAssetsController@getAcceptAsset'));
+ Route::post('accept-asset/{assetId}', array('as' => 'account/asset-accepted', 'uses' => 'ViewAssetsController@postAcceptAsset'));
# Profile
Route::get('requestable-assets', array('as' => 'requestable-assets', 'uses' => 'ViewAssetsController@getRequestableIndex'));
Route::get('request-asset/{assetId}', array('as' => 'account/request-asset', 'uses' => 'ViewAssetsController@getRequestAsset'));
+
+ # Account Dashboard
+ Route::get('/', array('as' => 'account', 'uses' => 'DashboardController@getIndex'));
});
diff --git a/app/views/backend/categories/edit.blade.php b/app/views/backend/categories/edit.blade.php
index e6afc73d9d0e..7e2b2086897b 100755
--- a/app/views/backend/categories/edit.blade.php
+++ b/app/views/backend/categories/edit.blade.php
@@ -37,17 +37,56 @@
@lang('admin/categories/general.eula_text_help')
+ {{ $errors->first('eula_text', ':message') }} +@lang('admin/settings/general.default_eula_help_text')
+ +Hello {{{ $first_name }}},
+ +A new asset has been checked out to you. Please read the terms of use below, and click on the link at the bottom to confirm that you read and agree to the terms of use, and have received the asset.
+ +{{ nl2br(e($eula)) }}
+ +I have read and agree to the terms of use, and have received this item.
+ +{{{ Setting::getSettings()->site_name }}}
+@stop diff --git a/app/views/frontend/account/accept-asset.blade.php b/app/views/frontend/account/accept-asset.blade.php new file mode 100644 index 000000000000..6f7e36d2d4a3 --- /dev/null +++ b/app/views/frontend/account/accept-asset.blade.php @@ -0,0 +1,41 @@ +@extends('backend/layouts/default') + +{{-- Page title --}} +@section('title') + +@parent +@stop + +{{-- Page content --}} +@section('content') + + +