Hi,

I tried to add Office Hours in the views' filter and I am not having much luck at the moment.

- Office Hours: Day filter is working fine (i can select day)
- Office Hours: Start Hours Filter is not working at all... When I tried to add it's giving me an error message:
"Fatal Error: Call to undefined function _create_hours_arr() in *************/includes/mass_times_handler_filter_hours.inc on line 107""
I did try to uncommented this and another error message displayed.
warning: Invalid argument supplied for foreach() in ******/includes/form.inc on line 1434.
and no time displayed at all.

- Office Hours: End hours filter is not working as well
I got this error message:
Error: handler for node_data_field_oh > field_oh_endhours doesn't exist!

Has anyone managed to make exposed filter working for either start time or end time? I just need one to work :)

Please help and thank you.

Comments

HippoOnDiet’s picture

I think I have managed to fix this error myself, not sure if it's working or not as I haven't tried to put some nodes to try.

Anyway here is what I do:
I updated $opt on /includes/mass_times_handler_filter_hours.inc on line 107 to

$opt = array(0 => t('12:00 AM'), 100 => t('1:00 AM'), 200 => t('2:00 AM'), 300 => t('3:00 AM'), 400 => t('4:00 AM'), 500 => t('5:00 AM'), 600 => t('6:00 AM'), 700 => t('7:00 AM'), 800 => t('8:00 AM'), 900 => t('9:00 AM'), 1000 => t('10:00 AM'), 1100 => t('11:00 AM'), 1200 => t('12:00 PM'), 1300 => t('1:00 PM'), 1400 => t('2:00 PM'), 1500 => t('3:00 PM'), 1600 => t('4:00 PM'), 1700 => t('5:00 PM'), 1800 => t('6:00 PM'), 1900 => t('7:00 PM'), 2000 => t('8:00 PM'), 2100 => t('9:00 PM'), 2200 => t('10:00 PM'), 2300 => t('11:00 PM') );

$opt is being used as options operator by other functions, therefore we need to declare $opt.

So when I do try to exposed my hours I can select the time and I didn't get any error message.

Please let me know if this is working well or not.

HippoOnDiet’s picture

double post :( something wrong with the posting.

HippoOnDiet’s picture

triple post

HippoOnDiet’s picture

Issue tags: +exposed, +day, +office hours

Hi Guys,

I am now having issue with exposed day filter.

When I select 'any' it will display all the nodes.
But when I filter it to Tuesday, no nodes displayed even though I have a node that is open on Tuesday.

When I check the SQL, I don't think it's right as well.

SELECT node.nid AS nid FROM d6_node node  
LEFT JOIN d6_content_type_office_hours node_data_field_test_masstimes_value_0 ON node.vid = node_data_field_test_masstimes_value_0.vid AND node_data_field_test_masstimes_value_0.field_test_masstimes_day = '2' 

WHERE (node.type in ('office_hours')) 
AND (node_data_field_test_masstimes_value_0.field_test_masstimes_day in ('0')) //this last bit should be 2 as well instead of 0

I did try to open the handler_filter_day.inc and I found out of I change %s with number 1, 2, 3 and so on

  function query() {
   if (empty($this->value)) {
      return;
    }
    $this->ensure_my_table();
    $placeholder = !empty($this->definition['numeric']) ? '%d' : "'%s'"; //change this %s to anything and it will change Where clause

    $replace = array_fill(0, sizeof($this->value), $placeholder);
    $in = ' (' . implode(", ", $replace) . ')';

    // We use array_values() because the checkboxes keep keys and that can cause
    // array addition problems.
    $this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field " . $this->operator . $in, array_keys($this->value));
  }

then the Where condition in SQL will follow what we change on %s.
WHERE (node.type in ('office_hours')) AND (node_data_field_test_masstimes_value_0.field_test_masstimes_day in ('1, 2, 3, and so on'))

Unfortunately I am not really good with coding, therefore any hand to help to fix this issue is much appreciated...

kansaj’s picture

try to change to this

// We use array_values() because the checkboxes keep keys and that can cause
    // array addition problems.
    $this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field " . $this->operator . $in, array_values($this->value));
johnv’s picture

Status: Active » Postponed (maintainer needs more info)

@HippoOnDiet, any luck/progress on this?

johnv’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (won't fix)

Even in D7-version, Views integration is not working fine.
See #1364096: Add Views 3 integration: fields, filter criteria, sort criteria, ... [D7]
I'm closing this D6-issue now, since it is not maintained anymore. Patchess are always welcome!