Hello,
I need some help on completing my custom come, I have gone blank and nothing is fixing it.
I have the folling which works great calculating a date based on working days:
global $conn;
$str = "SELECT * FROM `holiday` order by `H_Date` desc";
$rs = db_query($str,$conn);
$holidayList = db_fetch_array($rs);
$j = $i = 0; //changed this to 0 or you were always starting one day ahead
$given_date = $data["F_Day"];
$tmp1 = strtotime($given_date); //worked out a timstamp to start with
while($i < 10)
{
$tmp2 = strtotime("+$j day", $tmp1);
$day = strftime("%A",$tmp2);
//echo strftime("%d-%m-%Y",$tmp2);
$tmp = strftime("%d-%m-%Y",$tmp2);
if(($day != "Sunday") && ($day != "Saturday" )&&(!in_array($tmp, $holidayList)))
{
$i = $i + 1;
$j = $j + 1;
}
else
{
$j = $j + 1;
}
}
$j = $j -1;
$newdate = strtotime("+$j day",$tmp1);
$working_days = strftime("%A, %d-%m-%Y",$newdate);
$value = $working_days;
I need to change the code so it give me diferent dates based on what data is contain in
other fields, but no matter what I do it is not working, can someone please help me fix it, it
driving me bananas. My IF and ELSE IF do not seem to be doing anything.
Here it is!!
global $conn;
$str = "SELECT * FROM `holiday` order by `H_Date` desc";
$rs = db_query($str,$conn);
$holidayList = db_fetch_array($rs);
$j = $i = 0; //changed this to 0 or you were always starting one day ahead
$given_date = $data["F_Day"];
$tmp1 = strtotime($given_date); //worked out a timstamp to start with
if (($value = $data["P_SentTo"] == "Trainer")){
($i < 7) ;}
elseif (($value = $data["P_SentTo"] == "Venue")){
($i < 5) ;}
elseif (($value=$data["Course_Type"] = "FF")&&($value = $data["P_SentTo"] == "Venue")){
($i < 15) ;}
{
$tmp2 = strtotime("+$j day", $tmp1);
$day = strftime("%A",$tmp2);
//echo strftime("%d-%m-%Y",$tmp2);
$tmp = strftime("%d-%m-%Y",$tmp2);
if(($day != "Sunday") && ($day != "Saturday" )&&(!in_array($tmp, $holidayList)))
{
$i = $i + 1;
$j = $j + 1;
}
else
{
$j = $j + 1;
}
}
$j = $j -1;
$newdate = strtotime("+$j day",$tmp1);
$working_days = strftime("%A, %d-%m-%Y",$newdate);
$value = $working_days
Anyone willing?
Thank you.