Date compare in scheduling emplooyee job |
Hello.
The situation example in this: Our company has 100 employees. We assign some employees to do job in several days. A and B and C given job in Oktober 5 to Oktober 9, and it is inputted and recorded in the system.
So if someone input A and B to do another job in October 8 to October 10,, the system will reject and gives warning that A and B already have the job in Oktober 5 to Oktober 9. Is there any CI function that deal with date to avoid problem like that ? Date comparison? Date between in? What logic to solve that problem? I use CI 3 and mysql.
Thank you.
Try to get the record from the database first using their ID that's if it is stored in the database.
PHP Code: // Get users record by their id Something like that. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Hi, I don't see how do you have this problem, I asume that you have 2 entities, workers and Jobs, the relation is several to several. So it gives birth to a new entity, jobs_x_workers; the fields of this new table are job_id, worker_id, (this two combined are usually the primary key, but you should add an jxw_id just in case the jobs where to be repeated), start_date and end_day. Since the record will be alway different, it can't fail. You shouldn't have warnings. What's the current structure of your DB??
Because, in my office, sometimes the job admin forget that a worker is already in the job. Example is Mr. John already in job in Sept 5-sept 8, because the job admin forget, he will give another job to mr John in sept 7-8,,,so the usage of this website sistem is to prevent that happens, so when in happen, the detail will show that Mr.Jhon is already in job from 5 Sept to 8 Sept,,,please choose another employee to do this job.
This might help:
Fetching records between two date ranges What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Did you tried the between and between. Something like this:
$query = "SELECT * FROM job_x_worker WHERE worker_id =". $id ." AND start_date BETEWEEN ". $date1 ." AND ". $date2 ." OR end_date BETWEEN ". $date1 ." AND ". $date2 ." "; $this->db->query($query); |
Welcome Guest, Not a member yet? Register Sign In |