Re: Views filter rooms by occupacy

Jamie Holly <[email protected]> Mon, 19 Jan 2015 10:07:24 -0500
Newsgroups gmane.comp.php.drupal.support
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============6291478501002772698==
Content-Type: multipart/alternative;
	boundary="------------010003070703090506050001"

This is a multi-part message in MIME format.
--------------010003070703090506050001
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: quoted-printable

How are you associating the rooms content type to the reservations one?=20
If you're using entity reference, then you would want to create a=20
relationship with the reservations content type through that reference=20
field. Make sure you don't check "require this relationship" then add a=20
filter so that the related node (reservations) nid is NULL.

The other option is in a custom module, using hook_views_query_alter.=20
Load the reserved room nids, through a normal DB query, then add a NOT=20
IN condition to the list of nids. Here's the documentation on that hook:

https://api.drupal.org/api/views/views.api.php/function/hook_views_query_=
alter/7

Jamie Holly
http://hollyit.net

On 1/19/2015 9:37 AM, Llu=EDs Forns wrote:
> I have a site with 2 content types: rooms and reservations. I want to=20
> list all the rooms without a reservation for an interval, and also for=20
> services, capacity, ....
>
> I tried creating a view with a PHP filter to check free rooms, but=20
> then if the page lists 10 rooms, sometimes there are 7, 2, or 0;=20
> because the filter lists the 10 rooms and after remove the occupied one=
s.
>
> I have tried to create a "subview" filter to select nodes "not in=20
> (view of occupied rooms); but I haven't find a way to do so.
>
> Any idea of how to accomplish this?
>
> thanks
> --=20
> *Ser freak no =E9s imprescindible per ser inform=E0tic, per=F2 ajuda.
>
>


--------------010003070703090506050001
Content-Type: text/html; charset=windows-1252
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta content=3D"text/html; charset=3Dwindows-1252"
      http-equiv=3D"Content-Type">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">How are you associating the rooms
      content type to the reservations one? If you're using entity
      reference, then you would want to create a relationship with the
      reservations content type through that reference field. Make sure
      you don't check "require this relationship" then add a filter so
      that the related node (reservations) nid is NULL. <br>
      <br>
      The other option is in a custom module, using
      hook_views_query_alter. Load the reserved room nids, through a
      normal DB query, then add a NOT IN condition to the list of nids.
      Here's the documentation on that hook:<br>
      <br>
<a class=3D"moz-txt-link-freetext" href=3D"https://api.drupal.org/api/vie=
ws/views.api.php/function/hook_views_query_alter/7">https://api.drupal.or=
g/api/views/views.api.php/function/hook_views_query_alter/7</a><br>
      <br>
      <pre class=3D"moz-signature" cols=3D"72">Jamie Holly
<a class=3D"moz-txt-link-freetext" href=3D"http://hollyit.net">http://hol=
lyit.net</a></pre>
      On 1/19/2015 9:37 AM, Llu=EDs Forns wrote:<br>
    </div>
    <blockquote
cite=3D"mid:[email protected]=
l.com"
      type=3D"cite">
      <div dir=3D"ltr">
        <div>I have a site with 2 content types: rooms and reservations.
          I want to list all the rooms without a reservation for an
          interval, and also for services, capacity, ....<br>
        </div>
        <div><br>
        </div>
        <div>I tried creating a view with a PHP filter to check free
          rooms, but then if the page lists 10 rooms, sometimes there
          are 7, 2, or 0; because the filter lists the 10 rooms and
          after remove the occupied ones.<br clear=3D"all">
          <div><br>
          </div>
          <div>I have tried to create a "subview" filter to select nodes
            "not in (view of occupied rooms); but I haven't find a way
            to do so.</div>
          <div><br>
          </div>
          <div>Any idea of how to accomplish this?</div>
          <div><br>
          </div>
          <div>thanks</div>
          -- <br>
          <div class=3D"gmail_signature">*Ser freak no =E9s imprescindibl=
e
            per ser inform=E0tic, per=F2 ajuda.<br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class=3D"mimeAttachmentHeader"></fieldset>
      <br>
    </blockquote>
    <br>
  </body>
</html>

--------------010003070703090506050001--

--===============6291478501002772698==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-- 
[ Drupal support list | http://lists.drupal.org/ ]
--===============6291478501002772698==--