 Okay, hopefully you watched the first video in this little series. If not, there's hopefully I put an annotation up on the screen. And this is software that I wrote, mainly with the goal of calling overtime for firefighters because that's my day job, but I'm sure there's other areas that this can be used in. And today, previous video, I should give you a walkthrough. Today I'm going to show you how to install and get at least the database set up. And then in the next video, I'll probably walkthrough more of the code. So go to GitHub, my username is metalx1000, so github.com forward slash metalx1000. Click on my repositories here and find the one labeled overtime list. We'll go ahead and we'll click on that. And now you can download the zip file here. I'm going to recommend getting this HTTPS URL and using GitHub to get clone it. But whatever you find easier, if you've never used it before, the download zip might be easier. Using Git might be a little bit easier if you want to update it later on. Then in your shell, go to wherever your web server is set up, that type Git clone. And I will paste in the address, the URL that we just got, and it will clone down the whole project. It is really, really small. And as you saw, it took a couple of seconds. And it looks like it's 55 kilobytes. So very small. And so for this project, as I just said, you'll need a web server. I'm running Apache. And you'll use MySQL database is what it's using, as well as PHP for the server-side scripts. So those are three things you want to have installed. Also optional is PHP MyAdmin is what I suggest for maintaining your databases. And we're going to have a little look at that right now. So again, those are all in your repositories, whatever distro you're using. Use the package manager to get that stuff, get it up and running if you don't already have it up and running. Now I've logged into my PHP admin here. And just for testing purposes, I set the default username and password to root and root. Obviously, you wouldn't want that on your live machine. You want to use something a little different. So now we need to create a database. Now we can manually do this in here, according to my script, although you can change it. The database name will be overtime and it'll be two tables in there, overtime list and overtime log. Again, you can create those. Each one of those tables will have six entries in them. The entries will be ID, PID, name, rank, phone number. And then the last one will either be update, updated or date. So you can go through and create all of that. And I can walk you through that. I was nice. I made a script that already does this for you. So let's go in here real quick. And as you can see, we downloaded our script and it's inside a folder called overtime list. We'll go in there, we'll list out our files here. And there's this one called credentials. That's the first one you want to go into. So I'm going to use Vim as my text editor, but use whatever text editor you prefer. And I'm going to edit the credentials. Localhost will probably be your server unless you're connecting to a remote server, which normally you'll be connecting to a local server, localhost, if you're running a web server like this. Now you'll change your username and password right here. Again, I have mine set to default as root just for this tutorial. That's what it's going to say by default when you download the code. But you'll want to delete here and put in your actual username and password that has the proper permissions for creating tables and databases. So that's all you have to do in there. There's a script in here called connect. We'll have a quick look at that, which will use that credential script, but also set your database to overtime. And this will be basically in the head of all your connections. But what we want to do is we need to create that stuff. And I did create a PHP script called createDB PHP. So let's create DBB. We're going to look at it first here. It's kind of long, but real quick, just so you can see, it's loading up that credential. So it's loading up the local host and username and password. It's connecting. We'll check to make sure it connected properly. And that's going to create a database called overtime. Again, you can do this all manually if you wanted to. Here it's going to give you whether it was successful or if there was an error. Then we're going to load up our connect PHP and our tables PHP. There's two tables working with. The tables PHP will generate variables for you, table and table two. And here we're going to create those tables. And as I said, there's going to be a table called, our entry called ID, PID, name, rank, phone, and update in our first table. It will try to create those. And if not, it will give you an error message. And we will also create our second table here, which also has an ID, PID, name, rank, phone, but last entry will be a date entry. And again, it will try to generate that and give you a message of whether it was successful or not. So that's a quick look at it. How do you run it? It's really, really simple. Like I said, you have your web server set up. We're going to go to wherever your web server is. For me, it's local host, middle x1000 here. And again, overtime list. So here we are looking at the same code we were just looking at in the shell. There's one called create DB. We'll click on that. And look, it says database created successfully, table overtime list created. And the second one should actually say table overtime log created successfully. That's something I need to change in the code. It still creates the table properly. It's just giving the output wrong. So now if we go back into PHP My Admin and we click on databases, you can see that the overtime database now exists. So it did it all for you. So all you had to do is click on that in your browser. Obviously you're going to want to password protect some of these files so that you'll have access to them. And it created two tables here. The first table here, the overtime list. We can look at its structure right here. And you can see again that it has those entries we talked about. The ID one is an integer and it's an auto incrementing. PID is going to be a randomly generated individual number. Similar to this ID and I call it PID. It's just another individual ID that you can generate with your code on the go. And again, we have the user's name, their rank. Because again, over time you may be calling people for firefighter over time, driver over time, lieutenant over time, different positions. So you want to have that. My code right now doesn't really filter through that. That's something you would implement yourself based on your ranking, but should be very simple to add. Their phone number and then updated is going to be a UNIX timestamp. And this is how we rotate the list. So every time the button is clicked, it timestamps that with the new time, which will be a higher number than the old time, because the UNIX timestamp is the number of seconds since January 1st, 1970, I believe. So continuously grow every second and move that person to the bottom of the list when their name is clicked. Going back to here and clicking on our other table, this is our ongoing log. And the only real difference between here is besides the fact that it's not just updating each entry, it's actually adding an entry each time, is that it's structured. The last one, as you can see, it's a little bit bigger. I made it 100 characters, which is probably overkill a little bit, but it's going to be an actual date stamp just to keep things simple. It's going to say actually Saturday, November 5th, 2014, at 12 p.m. Eastern Standard Time or whatever. It's going to give you all that information. So it's a little bit bigger. So now that we have that, what we want to do, I'll give you an example here. Well, we can go in here and through PHP My Admin. Let me go back here to our databases over time and I'll click on our list here. There's no one in our list right now. So if we were actually go to our list, like if we were to go back here and click calls, nothing's showing up because no one's on our list. So let's go ahead and add people to our list. So we'll say insert. We'll leave the ID blank. It's going to automatically generate that. PID, we're going to give it a random number. So I'm just going to, you know, you're actually going to probably use some sort of script input in a lot of the information here, but we'll say here, John Smith for the name rank, I'll say firefighter. I'm just going to put everybody in as a firefighter because again, just an example here. 555, 555, dash 5555, updated leave it blank. Again, it was a UNIX timestamp right now where it will be blank. And as you click on their names or rotate them through the list, you can sort people through the actual interface when the time comes. Again, for the PID, we'll give it a random, whatever for their name. I'll just say Peter Parker rank. Again, I'll say firefighter, phone number this. I'll say 555, 555, 555, 556, whatever, and leave the updated blank. And we'll click go. And it has added those two entries. If we go to browse, you can now see those entries added. And we'll go back to our call list and hit F5 to refresh there the names. Now you notice again, right now the updated is a null number. If I click on the first entry there and I refresh this page, you can see that now there's an entry in there. If I click the next name now and refresh in here, you can see there's a timestamp. So each time I click it, it's going to update that number. It's going to be a higher number based on the date and time. So just to speed things along, there's another little script that I put into our code here if we go back to our shell. So if you just want to test out the program, you don't want to enter in all your employees, which can actually, hopefully you have some sort of contact list you can import it from. If we list out here, there is a test SH. Now you're going to want to modify one variable in it because right now I'm local host, but everything's in a folder called metalx1000. So you might want to change that if it's in your root folder, just remove that part. Besides that, this will generate random fake people for you. So I'll just say, I'll run it like that. Gave me some output telling me what it entered. If we come back here and I refresh this page, you can see that people have been added in. If I go to the call time list and refresh here, you can see a random name and number has been added in. So you can run this script a couple of times, this test bash script. And now again, if we come in here and refresh, you can see that we just generated a bunch of fake names and phone numbers in our database for testing. So if you want to test this out before we actually implement it and take the time of entering everyone's numbers. And again, we can click through the list here and that'll actually cancel or not zero everybody out, but give everybody a unique, well, sometimes unique. Again, it's based on seconds if I click the same name within a second, it's gonna give it the same name there. But that is getting it all set up. You're good to go. In the next video, we'll actually look at some of the other scripts and actually go into details on how they work. That way you can modify it. Again, I know where I live, there's different fire departments and each of them do things different, especially their overtime lists are all work different ways. And so, although this program is pretty much fully functional, you'll probably have to tweak it based on your rules, regulations, and or contract. So I'll give you an overview of the code so that you can understand how it works and modify it for your use. So that'll be in the next video. And hopefully I've remembered to put some annotations on the screen to that next video and probably hopefully an annotation for the full playlist for this software here so you can view it. I thank you for watching. Again, my website is filmsbychrist.com. That's Chris the K. There should be a link in the description. Go ahead and check that out. If you like this video, be sure to like, subscribe, and share. I truly appreciate it. And as always, have a great day.