<?php include_once("class/class.MySQL.php");
$db	=new MySQL();
if($_POST['act'])
{

////////////////////////////////////////activity plan date genarate////////////////////
$HTML='';
 $todat=date("Y-m-d",strtotime($_POST['too']));
 $frmdat= date("Y-m-d",strtotime($_POST['frmm']));

$cur_dats=date("Y-m-d");

 $cov_dat_to=strtotime($todat);
 $cov_dat_curr=strtotime($cur_dats);
 

 
/*if( $cov_dat_to >= $cov_dat_curr  ){
	$todat= date("Y-m-d"); 
}else{
	 $todat=date("Y-m-d",strtotime($_POST['too']));
}
*/
function getAllDatesBetweenTwoDates($strDateFrom,$strDateTo)
{
    $aryRange=array();

    $iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2),     substr($strDateFrom,8,2),substr($strDateFrom,0,4));
    $iDateTo=mktime(1,0,0,substr($strDateTo,5,2),     substr($strDateTo,8,2),substr($strDateTo,0,4));

    if ($iDateTo>=$iDateFrom)
    {
        array_push($aryRange,date('Y-m-d',$iDateFrom)); // first entry
        while ($iDateFrom<$iDateTo)
        {
            $iDateFrom+=86400; // add 24 hours
            array_push($aryRange,date('Y-m-d',$iDateFrom));
        }
    }
    return $aryRange;
}

$fromDate = $frmdat;
$toDate = $todat;

$dateArray = getAllDatesBetweenTwoDates($fromDate, $toDate);

   // print_r($dateArray);
$HTML.='<select name="daily_wrk_dat[]" id="daily_wrk_dat" class="dj" style="width:135px;"><option value="">Select Date</option>';
foreach($dateArray as $dats)
{

$HTML.='<option value="'.$dats.'" selected="selected">'.date("d-m-Y",strtotime($dats)).'</option>';
}

$HTML.='</select>';
echo $HTML;

////////////////////////////////////////activity plan date genarate////////////////////
}
else
{

//////////////////////////////////////////activity done date genarate////////////////////

$HTML='';
 $todat=date("Y-m-d",strtotime($_POST['too']));
 $frmdat= date("Y-m-d",strtotime($_POST['frmm']));

$cur_dats=date("Y-m-d");

 $cov_dat_to=strtotime($todat);
 $cov_dat_curr=strtotime($cur_dats);
 

 
if( $cov_dat_to >= $cov_dat_curr  ){
	$todat= date("Y-m-d"); 
}else{
	 $todat=date("Y-m-d",strtotime($_POST['too']));
}

function getAllDatesBetweenTwoDates($strDateFrom,$strDateTo)
{
    $aryRange=array();

    $iDateFrom=mktime(1,0,0,substr($strDateFrom,5,2),     substr($strDateFrom,8,2),substr($strDateFrom,0,4));
    $iDateTo=mktime(1,0,0,substr($strDateTo,5,2),     substr($strDateTo,8,2),substr($strDateTo,0,4));

    if ($iDateTo>=$iDateFrom)
    {
        array_push($aryRange,date('Y-m-d',$iDateFrom)); // first entry
        while ($iDateFrom<$iDateTo)
        {
            $iDateFrom+=86400; // add 24 hours
            array_push($aryRange,date('Y-m-d',$iDateFrom));
        }
    }
    return $aryRange;
}

$fromDate = $frmdat;
$toDate = $todat;

$dateArray = getAllDatesBetweenTwoDates($fromDate, $toDate);

   // print_r($dateArray);
$HTML.='<select name="daily_wrk_dat[]" id="daily_wrk_dat" class="dj" style="width:135px;"><option value="">Select Date</option>';
foreach($dateArray as $dats)
{

$HTML.='<option value="'.$dats.'" selected="selected">'.date("d-m-Y",strtotime($dats)).'</option>';
}

$HTML.='</select>';
echo $HTML;
}

//////////////////////////////////////////activity done date genarate////////////////////
?>