Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkin API does not support setting checkin date #10552

Closed
JonathonReinhart opened this issue Jan 24, 2022 · 2 comments · Fixed by #10640
Closed

checkin API does not support setting checkin date #10552

JonathonReinhart opened this issue Jan 24, 2022 · 2 comments · Fixed by #10640

Comments

@JonathonReinhart
Copy link
Contributor

JonathonReinhart commented Jan 24, 2022

Snipe-IT Version

v5.3.7

Problem

When checking in an asset via the web UI, the following form fields exist:

  • Asset Name
  • Status (required)
  • Location
  • Checkin Date (required; pre-filled to today's date)
  • Notes

However, the /hardware/:id/checkin API does not support all of these:

Solution

Api/AssetsController.checkin() should add fields which match the names used by the normal UI controller

  • checkin_at

Alternatives

None.

@JonathonReinhart JonathonReinhart changed the title checkin API does not support setting checkin date or asset name checkin API does not support setting checkin date Jan 24, 2022
@JonathonReinhart
Copy link
Contributor Author

I think it should be as easy as this, but I have not tried it yet:

diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php
index 3b37a2875..859ec89eb 100644
--- a/app/Http/Controllers/Api/AssetsController.php
+++ b/app/Http/Controllers/Api/AssetsController.php
@@ -844,8 +844,13 @@ class AssetsController extends Controller
             $asset->status_id =  $request->input('status_id');
         }
 
+        $checkin_at = null;
+        if($request->filled('checkin_at')){
+            $checkin_at = $request->input('checkin_at');
+        }
+
         if ($asset->save()) {
-            event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note')));
+            event(new CheckoutableCheckedIn($asset, $target, Auth::user(), $request->input('note'), $checkin_at));
 
             return response()->json(Helper::formatStandardApiResponse('success', ['asset'=> e($asset->asset_tag)], trans('admin/hardware/message.checkin.success')));
         }

@JonathonReinhart
Copy link
Contributor Author

I tested this out by adding the diff above, and confirmed it was being set properly (with a debug print). But now I can't see where the checkin date (CheckoutableCheckedIn::action_date) is actually used anywhere though:

Perhaps this worked previously but was broken?

Here's where it was originally added: #6733

cc @snipe @inietov @dmeltzer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant