Creating a timesheet for work using PHP MySQL [closed] - php

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am trying to create a time-sheet for my work. I don't know if getting myself into a lot of work by doing this as I am quiet new to PHP and MYSQL but I do have a good understanding/knowledge
of the two. I want the below fields in my database.
Job
weekPeriod ------A list of weeks Monday > Sunday
dateWorked ------List Of dates in the form coming from a database e.g. 1/1/2011
startTime ------List of times from 12:00am>11:00pm 30 min intervals e.g. 11:30-12:30
endTime ------List of times from 12:00am>11:00pm 30 min intervals e.g. 11:30-12:30
totalHours ------Automated
amount ------Automated based on dayWorked
comments ------Any messages here
I want to be able to fill in some drop down boxes through a form that will then submit all information to my database.
I want the script to know that if the date worked is on a Weekday Mon-Fri e.g. my rate of pay is 30.00ph On a sat it is 35.00ph and on a Sunday it is 40ph
I then want to create a page where i select a particular week and see how many hours i worked and how much i earn and so on.
Please let me know if there is such a program already established or if this is something that requires a bit of time and if I could do it being new to PHP and MYSQL

Try this it is great what you are looking for:-
phpcollab

I made exactly the same program, but build on the facebook platform. Some things that you might want to consider are:
Shift start time
Shift end time
Paid Breaks
Unpaid Breaks
Overtime
Calculate break entitlements for overtime
Different rates of pay
DST
What happens if you finish early?
When are you pay periods, and what time of day does it cut off (mine was at 3am!)
The key thing you need to do is set down your rules currently in place at work. E.G if you do over time, what do you get paid. Would this mean you are entitled to another break, is it paid? What happens when the clocks change?
Concentrate on getting the program logic to work out the correct pay for different scenarios. I would use arrays to imitate form input. Once you've got it working then build the interface.
In your database all you need is
- Job
- Start time (date/timestamp)
- End time (date/timestamp)
- Comments (text/varchar)
Then in a seperate table
- Week number (UID)
- Start Date (date/timestamp)
- End Date (date/timestamp)
Everything else can be calculated easily and doesn't really need to be stored. This means your logic can be updated much more easy if you calculate it when you do your lookups.
I would look up the following function:
http://php.net/manual/en/book.datetime.php

This works very well for me. It's in an advanced stage of development. http://www.simpleinvoices.org/
But if you want to use this project as practice to gain comfort with php/mysql, it would be a fairly straightforward learning project.

Related

PHP - Updating data yearly. -Process advice-

I have made an employee management system as such, and it calcualtes leave days. Although I am trying to work out how to make the leave days update yearly according to the staffs starting date.
I think I know how I will do this easily. Except it will involve the software being open on that date.
How would I account for each day, without the software having to be open?
Heres the process i was thinking:
-Loop through array of staff data and determine if starting date matches current date.
-If it matches then add an ammount of days to their leave days
I know this is very basic, and it has some flaws. Here are the flaws i am thinking:
-If the page were to be refreshed, or page opened again then it would add x2 of the staff days.
-Also, if the software was not to be opened on this day then the staff would not get the added leave days.
How would I get around this issues? I feel like it should be an easy thing, but I cant think on how to do it properly.
Any help would be greatly appreciated,
Create your php script I'll call it leavetime.php
Then if you have c-panel on your server, there is a thing called cron, in there you can select the time to call it. typically it will be something like this for the command
usr/bin/php -q locationof/leavetime.php
https://www.youtube.com/watch?v=ZAbefcWLxrw
As for the actual php code to do this, it's to broad a topic to cover in a single question.

How to apply a ranking algorithm using PHP/MySQL? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm working on an algorithm that gives a score to some messages posted on a website. This score will be used to rank all the messages. If, for one message, the score is high, this message will be ranked above the other messages (that have a lower score) and vice versa. The parameters for this algorithm are the number of upvotes/downvotes and the number of seconds gone by since the message was posted.
I want to display the millions of messages on a webpage using PHP and MySQL. Of course I will use a paging system. Since one of the parameters for the algorithm is the number of seconds gone by since the message was posted, this score will change over the time. But I will need to update it. The only way for me to update the score of each message is to update it automatically with PHP when the client asks for the messages to be displayed, then call them with a MySQL request like that : SELECT * FROM messages ORDER BY score.
But because there are millions of messages, it would take a lot of time to update everything each time someone wants to see some messages.
How do I implement this in PHP ?
So basically, I'm asking how to rank messages (using a score) without having to calculate the score of each message before I call them (because it would take a lot of time) + because I'm gonna be using a paging system, only 20 or 30 messages will be selected at a time from the database.
Thank you very much
Create a field which holds miliseconds since 1970 when a post is created. then use the following:
select milisecondsSince1970 as t,votes as v,* from messages order by (v-a*(t-t0))
where:
"a" is your personal factor for giving desired weight to "t".
t0 is miliseocnds from an exact date which you consider it as
start date rather than 1970.
This solution just works for you question as the criterion of score is "time". In other huge calculations , a periodic update on scores is suggestd.
Updating in real time will be difficult, and expensive in terms of performance. But I have suggestion - you can use a MySQL events scheduler to schedule JOB at regular intervals may be every half hour depending upon DB size. Running batch script as cron job on regular intervals may also work but direct Event execution in MySQL is better choice.
Since rank is calculated based on age of post and votes, so a stored procedure will work.
Other solution, I recommend - run update query to calculate rank on result set as data in shown in paginated form.

Creating an advanced admin/staff rota [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I know this place is for uploading code that may need some help although I hope you won't mind helping as I'm not sure where to really start with this code. You are the experts and I am a novice requiring help with future coding. If there is a section aimed at this kind of thing, I will be happy to repost.
Here is the situation:
I am starting work on an advanced admin backend panel for my staff, an idea I currently have is to use a MySQLi database to create the staff rota, to be displayed in a simple calendar like table on the aPanel.
Now, the advanced part is the staff member will be able to click "Clock In" or "Clock Out" during the times/days they are issued on the rota.
The system will NOT let the staff member Clock In, unless they are on the rota for that time of day. I will then have access to a management section of the panel allowing me to view the amount of hours the staff member has been clocked in for for if they have missed days, or are late, etc... And pay them for recorded clocked in hours.
Maybe some added features would be that they are clocked out automatically at the end of their shift or the system would record overtime and such?
I have no idea how I would go about creating such system or if it is actually possible so if anybody may have any advice/tips/examples for such idea I would appreciate any help!
All the best!
Your system will necessarily consist of several parts:
Database Store - Houses all necessary information for the system, Staff Schedules, Timeclock Entries, User Information, etc. Sounds like you already have this mostly in place, though it may need some tweaking for your purposes.
Staff Assignment / Admin Interface - System to allow administrators or those with appropriate access to assign schedules to Staff, add new Staff to the system, etc.
Timeclock Frontend - Staff would use this to login to view their schedules, and clock in/out.
(Possibly) Automated Monitoring System - If you wanted the system to automatically monitor active Staff, and clock them out when their schedule is up, you'll need a recurring task, a script that runs every X minutes and clocks out those Staff required.
This isn't a quick and simple project, but it's not very complicated either. The major pitfall you'll need to avoid is the temptation to just code the whole thing yourself. It may seem like a good idea at first, you only need a few hard-coded pages, right? Trust me, though, that process always ends in major headaches later on. Find a Framework that you can base your application on. It's a bit more to learn, but you'll be able to focus more on building your application, and less re-inventing the wheel.
For PHP, I strongly recommend Symfony. It uses Doctrine for it's ORM, which will make it much easier to handle data interactions, and Twig Templating, which is far superior to mixing PHP/HTML directly. Symfony has decent documentation, and a number of tutorials. (And an active Stack Overflow tag.)
Regardless of the choice you make, the best thing to do is choose a framework to base your application on, it'll make all the numerous little design decisions much easier. (And less error-prone for any widely used framework.)
Your individual questions are a little too vague to answer directly without a system around them. I'll try to give some general advice for them, though.
I am starting work on an advanced admin backend panel for my staff, an idea I currently have is to use a MySQLi database to create the staff rota, to be displayed in a simple calendar like table on the aPanel.
You might want to take a look at Full Calendar, a nice customizable JS calendar.
Now, the advanced part is the staff member will be able to click "Clock In" or "Clock Out" during the times/days they are issued on the rota.
When the employee logs in to the application, the application will load the schedule for that employee. If they have a current (or shortly upcoming) assignment, display a Clock In form. The Clock In form, on submit, will change the Employee status to Clocked In, and insert a timestamp into the Timeclock Logs associated with the Employee. If the employee is currently Clocked In, instead display a Clock Out form (possibly with shift notes), that does much the same thing, only switching the status to Clocked Out.
The system will NOT let the staff member Clock In, unless they are on the rota for that time of day.
It's fairly easy to check these sort of things after the Clock In form is submitted. If they aren't supposed to Clock In yet, throw an error. (Note, never assume that the pre-submission validations are sufficient. I.e., don't rely on the fact that the Clock-In form will only show up when the Employee can Clock In.
I will then have access to a management section of the panel allowing me to view the amount of hours the staff member has been clocked in for for if they have missed days, or are late, etc... And pay them for recorded clocked in hours.
In the admin section, you can create a report by getting all the Timeclock logs for a given employee for a given date range, total the hours worked, and compare to the expected schedule.
Maybe some added features would be that they are clocked out automatically at the end of their shift or the system would record overtime and such?
Have a script that runs every X minutes (lower times will have greater resolution, but consume more resources) as a scheduled task on your server, checking every Clocked In employee, and Clocking Out those who should no longer be Clocked In. If you're using Symfony, I'd recommend creating a Custom Console Command for the job.
That's hopefully enough to get you started. Please feel free to come back with any more specific issues that you may run into.

Getting PHP to run once on a specific date [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've looked into this, and I've found out about Cron jobs - but the thing is that it only has to run once ever.
Background:
My users can create something that expires - and they choose when it expires.
One of my solutions: Maybe I don't have to expire it on that day - whenever someone requests that thing, then I can check whether or not it has already expired, and if it has, then I can change that thing accordingly.
Why it wouldn't work: I'd also like to send an email out when that thing expires.
Thanks for any help!
You could save a time-stamp together with the user item, that you call expire for example
then you could run a cron job that removes all items that has passed the expired time.
if($item.expire < time())
{
// Item has expired, remove it
}
You can set up a cron job that runs a script which compares the date with the expriation date. If It is equal to the expiration date, send a mail, else do nothing.
If you re on MYSQL you could use events. I ve used them successfully on expiring sessions.
You could choose to have kind of "runner" that checks for available jobs to run at the specific time and runs them.
Then you can create a cronjob that fires the runner.
Cron jobs are what you're looking for, you just have to find a way to run the task only once.
https://stackoverflow.com/a/5473841/2055152
Try this out to execute a command on 30th March 2011 at midnight:
0 0 30 3 ? 2011 /command
This answer offers a simple solution. If you want users to create their own events with PHP, just convert their desired date to the cron format. Just be careful on what you allow them to launch!

Job planification: looking for UI design to make my own

I'm developping an admin panel with ExtJS.
I've almost finished it except one thing: I need the "partner" who logs in to be able to configure when he/she works.
I'm like re-inventing the wheel, but thanks to ExtJS and my structure this won't be a problem.
The actual problem is about UI design:
I want to make very simple so that it's possible to enter very simple values like "I'm working each working days from 8 to 12 then 14 to 18"
I want to make it more configurable and be able to precise "I'm on vacation from july,1st until august,31th"
I want to make it even more configurable and be able to precise "the month of january, I'm working every single day from 8 to 20 non-stop".
I was looking for some inspiration with Microsoft Scheduler but to be honest, a basic user will never ever (ever x 87) be able to use such a UI to configure when he/she works
Same for unix cronjob. From my point of view, this is very hard to understand from a basic user's point of view.
So my question is: do you know where I could find some inspiration for this? And maybe if there are some Php components well written out there to handle such things...
Here's the way I did it: a "list" of rows that contains:
start hour
end hour
start date
end date
and a list of associated days.
This way it's possible to configure any kind of scenarii, even though it requires a bit of thinking, because you do not have to enter it a "natural" way (= you usually think first days of week you work, the hours and maybe the start/end days = it's the opposite of my configuration).

Categories