drop procedure sp_populate_dates;

CREATE PROCEDURE sp_populate_dates(form_date VARCHAR(10), to_date  VARCHAR(10))
begin
declare i INT; 

set @i = -1;


INsert into staff_attendance(date, staff_id, staff_attendance_type_id, InTime, outTime)
select distinct  dates.date, a.id, 2, '11:00', '20:00' from staff a, (

SELECT DATE(ADDDATE(form_date, INTERVAL @i:=@i+1 DAY)) AS date 
FROM staff
HAVING 
@i < DATEDIFF(to_date,form_date) 
) dates
where a.is_active = 1;

end;