• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

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