Updatecol and Date Filter Range

Do you need the range filter and the updatecol at the same time?
If not you can copy your list, use one for filtering and the other one (date element without filter) with the updatecol plugin.
 
Yes I do need them at the same time and it's quite critical to have the functionality. I think I found a complicated path forward. I determined I couldn't drop the range filter because I'm doing things that depend on the range like this for other processes:

Code:
//Capture the Filter Array (Date Range of element 402)
$EventDateFilter = FabrikHelperElement::filterValue(402);
$PreRangeFrom = $EventDateFilter[0];
$PreRangeTo = $EventDateFilter[1];

So I created a new (hidden) date element 'event_date_update_col' and I modified the update_col plugin to be able to update this elements and not the 'event_date' field (which has a range filter). I then added the following code to the Post_Eval section of the plugin:

Code:
$db = JFactory::getDBO();
$ids = JRequest::getVar( 'ids', array(), 'method', 'array' );
$rowids = implode(', ', $ids);
foreach ($ids AS $id) {  
  $row = $model->getRow($id);
  $ID_event_date = $row->event_schedule___event_date;
  $ID_event_date_update_col = $row->event_schedule___event_date_update_col;
    $UpdateQuery="
    UPDATE event_schedule
    SET event_date = event_date_update_col
    WHERE '$ID_event_date' != '$ID_event_date_update_col'
    AND '$ID_event_date_update_col' > '1980-01-01 01:01:01'
    AND event_id IN ($rowids);
    ";
                
        $db->setQuery($UpdateQuery);
        $count++;
        $db->execute();
        }

So after the update_col plugin is used, the query checks for values in the 'event_date_update_col' and copy's them over to 'event_date'. Seems to be working :)
 
Yup, that's pretty much what I would have done.

Note that JRequest is deprecated, you should use the input class instead ...

Code:
$app = JFactory::getApplication();
$ids = $app->input->get('ids', array(), 'array');

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top