The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(287) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/printthread.php(287) : eval()'d code 2 errorHandler->error
/printthread.php 287 eval
/printthread.php 117 printthread_multipage



UserSpice
Need a point in the right direction - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: General (https://userspice.com/forums/forumdisplay.php?fid=20)
+--- Forum: New to UserSpice? (https://userspice.com/forums/forumdisplay.php?fid=22)
+--- Thread: Need a point in the right direction (/showthread.php?tid=348)

Pages: 1 2 3


Need a point in the right direction - mudmin - 11-20-2016

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





Need a point in the right direction - mudmin - 11-20-2016

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


Need a point in the right direction - sandrews - 11-21-2016

I think Hastebin hates me, not showing anything but the blue screen. Did I take too long and it expired lol?


Need a point in the right direction - mudmin - 11-21-2016

I have no idea what happened there. Here's the second one that shows the number of clicks etc...

http://pastebin.com/Smm3UmyS


Need a point in the right direction - sandrews - 11-22-2016

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


Need a point in the right direction - mudmin - 11-22-2016

Awesome! Glad it worked. Let me know if there's anything else you get stuck on. I love a challenge from time to time!


Need a point in the right direction - sandrews - 11-22-2016

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>";


Need a point in the right direction - mudmin - 11-22-2016

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.


Need a point in the right direction - sandrews - 11-23-2016

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.


Need a point in the right direction - sandrews - 11-24-2016

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.