![]() |
Date compare in scheduling emplooyee job - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Date compare in scheduling emplooyee job (/showthread.php?tid=77469) |
Date compare in scheduling emplooyee job - kelapamuda - 09-05-2020 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.
RE: Date compare in scheduling emplooyee job - InsiteFX - 09-05-2020 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. RE: Date compare in scheduling emplooyee job - Omar Crespo - 09-08-2020 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?? RE: Date compare in scheduling emplooyee job - kelapamuda - 09-08-2020 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. RE: Date compare in scheduling emplooyee job - InsiteFX - 09-09-2020 This might help: Fetching records between two date ranges RE: Date compare in scheduling emplooyee job - Omar Crespo - 09-09-2020 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); |