Re: Views filter rooms by occupacy
LluĂs Forns <[email protected]> Mon, 19 Jan 2015 17:48:43 +0100
| Newsgroups | gmane.comp.php.drupal.support |
|---|---|
| Message-ID | <CAGTZhB5UH6VRE4PDEammv2dpwJi6S7+2vK-kZbN5Ca-u=eMOtA@mail.gmail.com> |
--===============0871928555905181422== Content-Type: multipart/alternative; boundary=e89a8f64335696fc1d050d04197e --e89a8f64335696fc1d050d04197e Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable I think the way shoud be adding a filter for NID where: nid NOT IN (custom PHP) AND use custom php to select all nids with bookings for those days (loading a view) 2015-01-19 17:46 GMT+01:00 Llu=C3=ADs Forns <[email protected]>: > Not working; nearly solved this using: > [other filters] > AND > [ > filter_start_date > booking_end_date > OR > filter_end_date<booking_start_date > OR > booking_nid IS NULL > ] > > But nearly all rooms appear because they have previous bookings outside > the interval. > > > 2015-01-19 16:52 GMT+01:00 Steve Kessler <[email protected]>: > >> If you require the relationship it should fix that. >> >> On Monday, January 19, 2015, Llu=C3=ADs Forns <[email protected]> wrote: >> >>> I was trying to make it without coding a new module; the steps and the >>> result are: >>> >>> 1. created a join, which is no required >>> I can list all the rooms with the nid of bookings (if avaliable). >>> 2. Created a filter per dates: >>> only rooms with bookings for that night are available >>> 3. Filter for NULL related booking nid >>> No room listed >>> >>> I think the filter should affect only joined content, but it it is >>> affecting the full content. How can I limit to the join? >>> >>> >>> >>> 2015-01-19 16:07 GMT+01:00 Jamie Holly <[email protected]>: >>> >>>> 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. >>>> >>>> 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: >>>> >>>> >>>> https://api.drupal.org/api/views/views.api.php/function/hook_views_que= ry_alter/7 >>>> >>>> Jamie Hollyhttp://hollyit.net >>>> >>>> On 1/19/2015 9:37 AM, Llu=C3=ADs Forns wrote: >>>> >>>> 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, .... >>>> >>>> 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; becau= se >>>> the filter lists the 10 rooms and after remove the occupied ones. >>>> >>>> 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. >>>> >>>> Any idea of how to accomplish this? >>>> >>>> thanks >>>> -- >>>> *Ser freak no =C3=A9s imprescindible per ser inform=C3=A0tic, per=C3= =B2 ajuda. >>>> >>>> >>>> >>>> >>>> -- >>>> [ Drupal support list | http://lists.drupal.org/ ] >>>> >>> >>> >>> >>> -- >>> *Ser freak no =C3=A9s imprescindible per ser inform=C3=A0tic, per=C3=B2= ajuda. >>> *La vida no ha de ser feli=C3=A7, ha de ser plena. >>> *Abans d'imprimir aquest missatge, pensa en el medi ambient. >>> >> >> >> -- >> Steve Kessler >> Owner and Lead Consultant >> Denver DataMan, LLC >> 303-587-4428 >> >> >> -- >> [ Drupal support list | http://lists.drupal.org/ ] >> > > > > -- > *Ser freak no =C3=A9s imprescindible per ser inform=C3=A0tic, per=C3=B2 a= juda. > *La vida no ha de ser feli=C3=A7, ha de ser plena. > *Abans d'imprimir aquest missatge, pensa en el medi ambient. > --=20 *Ser freak no =C3=A9s imprescindible per ser inform=C3=A0tic, per=C3=B2 aju= da. *La vida no ha de ser feli=C3=A7, ha de ser plena. *Abans d'imprimir aquest missatge, pensa en el medi ambient. --e89a8f64335696fc1d050d04197e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">I think the way shoud be adding a filter for NID where: ni= d NOT IN (custom PHP)<div><br></div><div>AND use custom php to select all n= ids with bookings for those days (loading a view)</div></div><div class=3D"= gmail_extra"><br><div class=3D"gmail_quote">2015-01-19 17:46 GMT+01:00 Llu= =C3=ADs Forns <span dir=3D"ltr"><<a href=3D"mailto:[email protected]" tar= get=3D"_blank">[email protected]</a>></span>:<br><blockquote class=3D"gma= il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef= t:1ex"><div dir=3D"ltr">Not working; nearly solved this using:<div>[other f= ilters]</div><div>AND</div><div>[</div><div>filter_start_date > booking_= end_date</div><div>OR</div><div>filter_end_date<booking_start_date</div>= <div>OR</div><div>booking_nid IS NULL</div><div>]</div><div><br></div><div>= But nearly all rooms appear because they have previous bookings outside the= interval.</div><div><br></div></div><div class=3D"HOEnZb"><div class=3D"h5= "><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">2015-01-19 16:5= 2 GMT+01:00 Steve Kessler <span dir=3D"ltr"><<a href=3D"mailto:skessler@= denverdataman.com" target=3D"_blank">[email protected]</a>></sp= an>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border= -left:1px #ccc solid;padding-left:1ex">If you require the relationship it s= hould fix that.<span><span></span><br><br>On Monday, January 19, 2015, Llu= =C3=ADs Forns <<a href=3D"mailto:[email protected]" target=3D"_blank">enb= [email protected]</a>> wrote:<br></span><div><div><blockquote class=3D"gmail= _quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:= 1ex"><div dir=3D"ltr">I was trying to make it without coding a new module; = the steps and the result are:<div><br></div><div>1. created a join, which i= s no required</div><div>I can list all the rooms with the nid of bookings (= if avaliable).</div><div>2. Created a filter per dates:</div><div>only room= s with bookings for that night are available</div><div>3. Filter for NULL r= elated booking nid</div><div>No room listed</div><div><br></div><div>I thin= k the filter should affect only joined content, but it it is affecting the = full content. How can I limit to the join?</div><div><br></div><div><br></d= iv></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">2015-01-= 19 16:07 GMT+01:00 Jamie Holly <span dir=3D"ltr"><<a>hovercrafter@earthl= ink.net</a>></span>:<br><blockquote class=3D"gmail_quote" style=3D"margi= n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> =20 =20 =20 <div bgcolor=3D"#FFFFFF" text=3D"#000000"> <div>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 href=3D"https://api.drupal.org/api/views/views.api.php/function/hook_vie= ws_query_alter/7" target=3D"_blank">https://api.drupal.org/api/views/views.= api.php/function/hook_views_query_alter/7</a><span><font color=3D"#888888">= <br> <br> <pre cols=3D"72">Jamie Holly <a href=3D"http://hollyit.net" target=3D"_blank">http://hollyit.net</a></pr= e></font></span><div><div> On 1/19/2015 9:37 AM, Llu=C3=ADs Forns wrote:<br> </div></div></div><div><div> <blockquote 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 selec= t 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>*Ser freak no =C3=A9s imprescindible per ser inform=C3=A0tic, per=C3=B2 ajuda.<br> </div> </div> </div> <br> <fieldset></fieldset> <br> </blockquote> <br> </div></div></div> <br>--<br> [ Drupal support list | <a href=3D"http://lists.drupal.org/" target=3D"_bla= nk">http://lists.drupal.org/</a> ]<br></blockquote></div><br><br clear=3D"a= ll"><div><br></div>-- <br><div>*Ser freak no =C3=A9s imprescindible per ser= inform=C3=A0tic, per=C3=B2 ajuda.<br>*La vida no ha de ser feli=C3=A7, ha = de ser plena.<br>*Abans d'imprimir aquest missatge, pensa en el medi am= bient.</div> </div> </blockquote><br><br></div></div><div><div>-- <br>Steve Kessler<div>Owner a= nd Lead Consultant=C2=A0</div><div>Denver DataMan, LLC=C2=A0</div><div>303-= 587-4428</div><br> </div></div><br>--<br> [ Drupal support list | <a href=3D"http://lists.drupal.org/" target=3D"_bla= nk">http://lists.drupal.org/</a> ]<br></blockquote></div><br><br clear=3D"a= ll"><div><br></div>-- <br><div>*Ser freak no =C3=A9s imprescindible per ser= inform=C3=A0tic, per=C3=B2 ajuda.<br>*La vida no ha de ser feli=C3=A7, ha = de ser plena.<br>*Abans d'imprimir aquest missatge, pensa en el medi am= bient.</div> </div> </div></div></blockquote></div><br><br clear=3D"all"><div><br></div>-- <br>= <div class=3D"gmail_signature">*Ser freak no =C3=A9s imprescindible per ser= inform=C3=A0tic, per=C3=B2 ajuda.<br>*La vida no ha de ser feli=C3=A7, ha = de ser plena.<br>*Abans d'imprimir aquest missatge, pensa en el medi am= bient.</div> </div> --e89a8f64335696fc1d050d04197e-- --===============0871928555905181422== 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/ ] --===============0871928555905181422==--