I have a calendar that I am currently working on, everything is working great. Essentially when an event is added to the calendar it checks to see how many days the event is for. This works and it places it on the calendar, however, I don't want the events to span over the weekends and have found no way to do this in full calendar.js. So in my model on the backend I want to add 2 days to each event when requesting from the database for each increment of 5 days. Business hours are mon-fri. Sat-sun closed. So if event is 4 days no value added, however if is 6 days event would now be 8 and if 11 days it would now be 15 days etc. I have started to build a if elseif php statement to accommodate this, however is there a faster way in php to do the math of increments of 5.
$endDate = project['endDate']; //is my variable from database
So shared below is what I had been doing, but it is obviously a lot of coding there must be a better way
$endDate = 12 //number of days of tasks summed from the DB;
if ($endDate <= 5) {
$endDate = $endDate
} else if ($endDate > 5 && $endDate <= 10){
$endDate = $endDate + 2;
} else if ($endDate > 10 && $endDate <= 15){
$endDate = $endDate + 4; // would currently stop here
} else if ($endDate > 15 && $endDate <= 20){
$endDate = $endDate + 6;
} else if ($endDate > 20 && $endDate <= 25){
$endDate = $endDate + 8;
} else if {.........// continue this, must be a better way as I have to goto 100000....
Aucun commentaire:
Enregistrer un commentaire