Fix loggable checkin (#2935)
* Log the user items are checked in from This restores functionality that was lost in the port to loggable. I'd still like to figure out a better term for the table, currently it says to, but I wonder if target is a better choice? * Fix display of remaining seats on license view
This commit is contained in:
parent
19592814d9
commit
55ccc000eb
5 changed files with 13 additions and 9 deletions
|
@ -427,8 +427,8 @@ class AccessoriesController extends Controller
|
||||||
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
return redirect()->to('admin/accessories')->with('error', trans('general.insufficient_permissions'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$logaction = $accessory->logCheckin(e(Input::get('note')));
|
|
||||||
$return_to = e($accessory_user->assigned_to);
|
$return_to = e($accessory_user->assigned_to);
|
||||||
|
$logaction = $accessory->logCheckin(User::find($return_to), e(Input::get('note')));
|
||||||
$admin_user = Auth::user();
|
$admin_user = Auth::user();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -670,8 +670,10 @@ class LicensesController extends Controller
|
||||||
// Ooops.. something went wrong
|
// Ooops.. something went wrong
|
||||||
return redirect()->back()->withInput()->withErrors($validator);
|
return redirect()->back()->withInput()->withErrors($validator);
|
||||||
}
|
}
|
||||||
$return_to = $licenseseat->assigned_to;
|
$return_to = User::find($licenseseat->assigned_to);
|
||||||
|
if (!$return_to) {
|
||||||
|
$return_to = Asset::find($licenseseat->asset_id);
|
||||||
|
}
|
||||||
// Update the asset data
|
// Update the asset data
|
||||||
$licenseseat->assigned_to = null;
|
$licenseseat->assigned_to = null;
|
||||||
$licenseseat->asset_id = null;
|
$licenseseat->asset_id = null;
|
||||||
|
@ -680,7 +682,7 @@ class LicensesController extends Controller
|
||||||
|
|
||||||
// Was the asset updated?
|
// Was the asset updated?
|
||||||
if ($licenseseat->save()) {
|
if ($licenseseat->save()) {
|
||||||
$licenseseat->logCheckin(e(Input::get('note')));
|
$licenseseat->logCheckin($return_to, e(Input::get('note')));
|
||||||
|
|
||||||
$settings = Setting::getSettings();
|
$settings = Setting::getSettings();
|
||||||
|
|
||||||
|
@ -720,7 +722,7 @@ class LicensesController extends Controller
|
||||||
|
|
||||||
|
|
||||||
if ($backto=='user') {
|
if ($backto=='user') {
|
||||||
return redirect()->to("admin/users/".$return_to.'/view')->with('success', trans('admin/licenses/message.checkin.success'));
|
return redirect()->to("admin/users/".$return_to->id.'/view')->with('success', trans('admin/licenses/message.checkin.success'));
|
||||||
} else {
|
} else {
|
||||||
return redirect()->to("admin/licenses/".$licenseseat->license_id."/view")->with('success', trans('admin/licenses/message.checkin.success'));
|
return redirect()->to("admin/licenses/".$licenseseat->license_id."/view")->with('success', trans('admin/licenses/message.checkin.success'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -217,7 +217,8 @@ class Asset extends Depreciable
|
||||||
$logaction->item_type = Asset::class;
|
$logaction->item_type = Asset::class;
|
||||||
$logaction->item_id = $this->id;
|
$logaction->item_id = $this->id;
|
||||||
$logaction->target_type = User::class;
|
$logaction->target_type = User::class;
|
||||||
$logaction->target_id = $this->assigned_to;
|
// On Checkin, this is the user that previously had the asset.
|
||||||
|
$logaction->target_id = $user->id;
|
||||||
$logaction->note = $note;
|
$logaction->note = $note;
|
||||||
$logaction->user_id = $admin->id;
|
$logaction->user_id = $admin->id;
|
||||||
if ($checkout_at!='') {
|
if ($checkout_at!='') {
|
||||||
|
@ -232,7 +233,6 @@ class Asset extends Depreciable
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Update the asset data to null, since it's being checked in
|
// Update the asset data to null, since it's being checked in
|
||||||
$logaction->target_id = '';
|
|
||||||
$logaction->location_id = null;
|
$logaction->location_id = null;
|
||||||
}
|
}
|
||||||
$logaction->user()->associate($admin);
|
$logaction->user()->associate($admin);
|
||||||
|
|
|
@ -170,7 +170,7 @@ class License extends Depreciable
|
||||||
public function remaincount()
|
public function remaincount()
|
||||||
{
|
{
|
||||||
$total = $this->licenseSeatsCount;
|
$total = $this->licenseSeatsCount;
|
||||||
$taken = $this->assigned_seats;
|
$taken = $this->assigned_seats_count;
|
||||||
$diff = ($total - $taken);
|
$diff = ($total - $taken);
|
||||||
return $diff;
|
return $diff;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,11 @@ trait Loggable
|
||||||
* @since [v3.4]
|
* @since [v3.4]
|
||||||
* @return \App\Models\Actionlog
|
* @return \App\Models\Actionlog
|
||||||
*/
|
*/
|
||||||
public function logCheckin($note)
|
public function logCheckin($target, $note)
|
||||||
{
|
{
|
||||||
$log = new Actionlog;
|
$log = new Actionlog;
|
||||||
|
$log->target_type = get_class($target);
|
||||||
|
$log->target_id = $target->id;
|
||||||
if (static::class == LicenseSeat::class) {
|
if (static::class == LicenseSeat::class) {
|
||||||
$log->item_type = License::class;
|
$log->item_type = License::class;
|
||||||
$log->item_id = $this->license_id;
|
$log->item_id = $this->license_id;
|
||||||
|
|
Loading…
Add table
Reference in a new issue