date element : PHP Allow date function problem

mahmoodee

Member
Hello ,
In my form there are : date field (rtable___date) and databasejoin element (rtable___cname) .
I am using PHP Allow date function in date element and I am using databasejoin element (rtable___cname) as Watch element , so calendar dates have populated based on (rtable___cname) element value.
It work fine , but there is problem :
1- before select value form databasejoin , the calendar show all dates . I want to disable all dates until the user select value from databasejoin element .
2- after the user choose a value from databasejoin element and the calendar populated correctly , then if you save the form and edit again , you will see all dates again and you must choose another databasejoin value to populate the calendar again .

So , on the form load the ajax request not work and the date calendar element show all dates .
How I can solve this problem , I do'not want the user see all dates and select from them.
thank you .

this is the php code which I have used , with databasejoin element (rtable___cname) as Watch element
Code:
$myDb = JFactory::getDbo();
$input = JFactory::getApplication()->input;
$myQuery = $myDb->getQuery(true);
$id = JArrayHelper::getValue($data, 'rtable___cname_raw', 0);
$id = $input->get('v', $id);
$myQuery
    ->select ('DATE(date)')
    ->from('class')
    ->where('name = ' . (int) $id);
$myDb->setQuery($myQuery);
$bookedDates = $myDb->loadColumn();
$begin = new DateTime();
$end = new DateTime("+3 month");


$interval = DateInterval::createFromDateString('1 day');
$period = new DatePeriod($begin, $interval, $end);

$myAllowedDates = array();

foreach( $period as $dt ) {
  $thisDate = $dt->format("Y-m-d");
   
   $ff= date('N',strtotime($thisDate));
 
  
    if (in_array($thisDate, $bookedDates)) {
    $myAllowedDates[] = $thisDate . '|allowedDate1';
    }
}
return $myAllowedDates;
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top