The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need a point in the right direction
#11
Ok. I'm at a computer. I made a new userspice 4.1.8c install and made a file in the root folder called pizza.php

I created a new db table called clicks with 4 columns
id -int(11)
user_id -int(11)
username -varchar(255)
timein - datetime

I'm just going to make a simple checkin button that updates the db just to get you going. I tested this one and it works. I didn't use functions...I just made a form. I'm not sure what the 4 buttons are supposed to do, but this should definitely point you in the right direction. Again, for example purposes, this file goes in the root of your project and should be named pizza.php
http://hastebin.com/obayoriyat.xml


  Reply
#12
Here's a slightly more advanced version that counts check ins and in a super basic format, echoes back every time a user has checked in...
http://hastebin.com/odobiburuv.xml
  Reply
#13
I think Hastebin hates me, not showing anything but the blue screen. Did I take too long and it expired lol?
  Reply
#14
I have no idea what happened there. Here's the second one that shows the number of clicks etc...

http://pastebin.com/Smm3UmyS
  Reply
#15
Y'all are awesome, it's working Big Grin I now have it logging timestamps in two different tables (for logging purposes), as well as updating a boolean for being on break or not and displaying the users "on break" so that everyone can see who is actually on break. Thank you so much for helping lay the ground work for this, it's pretty damn cool and the more I play with it, the more I understand the $user->data() awesomeness.

I feel like I can take it from here and run with it now Big Grin
  Reply
#16
Awesome! Glad it worked. Let me know if there's anything else you get stuck on. I love a challenge from time to time!
  Reply
#17
Well I'm making a bunch of progress, and am working on the logic now for it (to avoid clicking the same function more than once) and I am comfortable on figure that out tomorrow...but my OCD is getting to me again on another piece.

So I'm just trying to set a condition that changes some verbiage depending on how many results are returned. I have it half ass working, just not fully...

As of right now, if it finds no results, I get - "There is 0 person on break right now." <----- This bothers me. I just want it to say "There is no one on break right now."
If there's one person on break, I get - "There is 1 person on break right now.
Shawn"
If there's more than one person on break, I get - "There are 2 people on break right now.
Shawn
test"

I know I'm derping this up somewhere simple, but every form of >,<,<=,=>,== I try with any number just keeps failing. It'll fix one os the issues, then break another lol.

$breaksQ = $db->query("SELECT * FROM users WHERE on_break = 1");
$breaks = $breaksQ->results();
$countbreaks = $breaksQ->count();
if ($countbreaks <= 1) {
?>
<h3>There is <?=$countbreaks?> person on break right now.</h3>
<? foreach ($breaks as $b){
echo $b->fname;
echo "<br>";
}
}
elseif ($countbreaks >= 2) {
?>
<h3>There are <?=$countbreaks?> people on break right now.</h3>
<? foreach ($breaks as $b) {
echo $b->fname;
echo "<br>";
}
}
else {
echo "<h3>There is no one on break right now.</h3>";
  Reply
#18
I think this is what you're looking for...
http://pastebin.com/d6rR3KcU

Also of note, that weird things happen sometimes when you use <? instead of <?php.

You are fine doing <?= instead of <?php echo though.
  Reply
#19
Wow I feel dumb lol....of all the combinations I tried, that is one I did not -_-

Thanks again lol....glad I picked your framework to build this on; the support/help I've gotten so far has been great. I think I have learned enough in the past week or so to continue developing on this to include generating reports and start adding other features for the front-end of it.
  Reply
#20
Okay....last time I think haha

Trying to get it to where it won't update the DB again if you already have the boolean set as 1.

$db->query("UPDATE users SET on_break = CASE WHEN on_break = 0 THEN 1, ELSE 0 END WHERE id = ?",array($user->data()->id));

This actually ends up doing nothing as far as setting the on_break flag or not in the DB. I've tried if/thens wrapped around the $_POST['break_out]' but those don't seem to actually be able to pull the results correctly and I'm not getting anywhere there either. I tried doing a $db->query("SELECT * FROM users WHERE on_break = 1") where it saved the query as a variable, and then did if statements using if (is_bool === true) but, that wasn't working either.

Full code can be found at http://pastebin.com/nY5L3pbd if it helps clarify anything.

Basically I just don't want people to be able to continue clicking a button that they've already clicked.
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)