Job planification: looking for UI design to make my own - php

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).

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.

Listening To Timestamps in Database Laravel

I have been having some trouble finding a way to add a Laravel listener to a database. Basically, I have a database full of posts, and if a user hasn't updated a for 3 months, I want to send them an email reminding them to do it.
I have looked at laravel events, which may work. I also had the idea of running a continuous loop that checks if a timestamp has passed the 3 months mark, but that seems inefficient. What would be the best way to implement this feature?
Just run a cron task once a day to look for users that have not posted in over 3 months. There's no need to be any fancier than that, no?

calendar Question with PHP, reading your computer calendar

So I am really stumped because I have basic ideas but I am looking for some of your expertise.
What I am trying to do: I want to basically write an app using Twilio which you dont really need to know about because that is another issue. What that app does is call on a php file in my web host and "triggers the php code"
What I need help with here is how can I keep record in php of the calendar of the week for my computer. What I mean by that is if someone like an admin has a specific code that I have written for them, and that code runs automatically all week, but a specific week they dont want that code to run, instead they want a different code to run that week. How can I use php to find when a week has ended or keep track of the week using that calendar in bottom right of your computer screen so that my program will know after an admin wants a different code run from the usual code that the week is over no need to run that admin irregular code any more go back to your usual automated running code.
If you still dont know what I am talking. I will try to explain more. Think of 2 separate codes. One Custom and the other automated. The automated runs all the time automatically. But one day the admin chooses for that week he doesnt want to follow the regular shcedule of running the automated code as usual, instead for that week he would like to run the custom code and after the week is over go back to running the automated code as usual.
I hope that makes it more clear. I know that in PHP gives the date. But I really need expert opinion on how to do this.
Generally for something like this, I'd generate a "nextrun_datetime" for each and every script/user combination. By default it would have a repeat interval, in your case, 7 days.
If a user doesn't want to run it this week, they can "push" it out N days and the normal update interval would apply afterwards. To get the one-time shot, I'd allow an update interval of 0 or -1 to denote that.
With this sort of thing, whenever a script is updated (or saved, run, rescheduled), you can calculate the next date if there is one. From there, it's a relatively simple cron job that should check the last N minutes for any scripts to be run.
Unless your client machines are running on a completely different calendar than the server, why bother with wondering what the client's date is? Unless the client and server are in different time zones, the client date is going to be the same as the server date, except for a few hours around midnight.
As well, why depend on the client to trigger the server-side code? If this is a regularly occuring thing, use cron or whatever's available on the server to run the code automatically. If an admin wants to override WHICH code gets run, then you can provide an interface to change what's executed. Click a button on a site and a flag is set somewhere that tells the timed job to run script B instead of script A.
I've done something similar. Based on the day (e.g. monday, sunday) I would do something different in php.
this is how I did it:
$today = date('w');
if ($today== 0){
//its sunday
exec('rmdir C:\myApp\oldLogs');
}
else{
echo '1 -> monday, 2-> tuesday etc...'
}
you can also make a date from a string for example
$date = strtotime("8 days ago 14:00");
/*
or "Monday next week", "+1 week 2 days 4 hours 2 seconds","yesterday noon","10 September 2000" etc...
*/

Handling Reoccurring Events in PHP/MySQL

Example
7.30pm, second Monday each month
or
7.30pm, first & third Thursday each month.
Basically I want a upcoming events list for the next month.
How do I handle reoccurring events in PHP/MySQL?
Assuming a linux like environment: Have a cron job execute your php script.
I think cron has a pretty flexible way of recording schedules for repeating tasks, it might be worth diving into how it works (it is open source).
I also found this class for parsing crontab entries - http://www.phpclasses.org/browse/package/2568.html - I can't vouch for how good the code is, it's quite old (but crontab doesn't change much). The example given uses a MySQL database to store the tasks, so it might be worth at least looking at for ideas.

suggestion regarding my "question of the week" project

I am going to start on a new project for my school. I have to create a "question of the week" forum, where the members can post questions and their questions could then be voted by other members. The best question of that week will be discussed the week after, and the posting of the questions will take place again.
I am going to use MySQL as database, with backend in php.
Does anyone have some examples of something that I could use? Also, how will I be able to see a week in my project? I mean, how am I going to decide that a week has passed? I can not figure that out.
Do let me know about your suggestions.
Thank you!
Best
Zeeshan
Pick a handful of the free php / mysql
forum software programs. These
should be a good starting point;
phpBB, Vanilla, SMF, BBpress.
Install
and configure each of them, and
figure out which one makes most sense
to you in terms of ease of use, ease
of customisation, etc.
You may find
that these forums have enough
features to achieve what you are
after without any extra effort, but
if not, then start customising!
To see a weeks worth of data, you would create a database query that would view only the current weeks questions posts. The algorith would look like:
Get current day
From the current day, find the last day of the week (you have to decide what you consider the last day of the week)
Subtract 7 days from the last day of the week
Write you query
SELECT * FROM questions WHERE postdate >= #7DaysFromLastDayOfWeek
Hope that helps and makes sense.
If you don't want to go the trouble of hosting your own solution (even if it is the implementation of a existing application), google have an application called Moderator which you can either use standalone or embed into another web page - not sure if this is suitable?

Categories