-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Improve License Editing to add or delete seats #160
Conversation
This fixes issue #125 |
Improve License Editing to add or delete seats
Nice work, @exula! Thanks! Moving forward, I'd like to move more of this logic into the model instead of the controller (fat models, skinny controllers), but your code looks good and it fixes a legitimate bug, so I'm going to merge this request and we can refactor later. |
Great, that makes total sense. Anything else in the future I hack at i'll keep that in mind. |
When I changed a license to a smaller number in the history it shows i removed x number of seats but it only removes one from the license. eg 10 - 9 should be 1 but I got 9 |
Not sure I understand. If you changed it from 10 to 9, it would only take off one license seat. |
i changed from 10 to 1 and was left with 9 |
I'll take a look at this tomorrow when I get a chance. I probably totally screwed up my first commit. |
@madd15 and to clarify, you had no users assigned to those 9, right? So they should be available for removal. |
correct |
Thanks - looking into it now. Apologies for the trouble. |
I think I see what's happening. The number of seats in the licenses table is updating, but the number of records in the license seats isn't decreasing accordingly. |
I think I got it with d1499de (and bef5170 because I'm a dumbass). @exula - simple mistake to make. When you use So in this kind of circumstance, where you're not re-retrieving that array of objects within the loop itself and you just want to iterate through the loop, So @madd15 - this issue should be resolved with the latest on |
@snipe That makes perfect sense. Bonehead mistake on my part. |
👍 |
Works like a charm |
@madd15 - sweet, thanks for the quick reply! |
Now when i set the seats to a higher number i get this error; $logaction->checkedout_to = NULL; is the line that errors ErrorException |
Balls. Sorry about that. I had to change that to NULL for mysql strict mode. It's not happening for me, but I'll check again. |
Oh FFS. Bad copy+paste. I'm an idiot and should not be allowed to write code. |
What line is that on, can you tell? I can't find that block of text in the Licenses controller. |
Its on line 246 |
Hmm... https://github.com/snipe/snipe-it/blob/develop/app/controllers/admin/LicensesController.php - I don't see that there. |
:/ ok the error has changed now Illuminate \ Database \ QueryException |
Did you run the DB migrations? |
i thought i had but i will do it again |
Ok I'm a noob and its now working after migration |
Haha - excellent. I'd rather have you be a noob than me be a crappy coder. :P |
Haha :P |
Is it wrong that i'm glad the second half of problems here weren't my fault? ;) |
Nope |
LOL not at all, @exula |
If the number of seats change for license this goes through and only deletes seats which are not assigned to a user.
If there are no available seats to delete it returns an error message (which looks like was already in the lang file)
Adding seats is easy and it just does it.
I've logged the deletion and addition of seats along the way.
** This is my first real pull request, I appreciate any help in making it better.