Re: Views filter rooms by occupacy
LluĂs Forns <[email protected]> Mon, 19 Jan 2015 17:46:42 +0100
| Newsgroups | gmane.comp.php.drupal.support |
|---|---|
| Message-ID | <CAGTZhB57xmJMvv=k3F9CFH_q9-DYY=SU03QETeNjsuu1zBcPhg@mail.gmail.com> |
--===============1192176263691243758== Content-Type: multipart/alternative; boundary=089e01493ada575656050d0412df --089e01493ada575656050d0412df Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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_quer= y_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; becaus= e >>> 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/ ] > --=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. --089e01493ada575656050d0412df Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr">Not working; nearly solved this using:<div>[other filters]= </div><div>AND</div><div>[</div><div>filter_start_date > booking_end_dat= e</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 nea= rly all rooms appear because they have previous bookings outside the interv= al.</div><div><br></div></div><div class=3D"gmail_extra"><br><div class=3D"= gmail_quote">2015-01-19 16:52 GMT+01:00 Steve Kessler <span dir=3D"ltr"><= ;<a href=3D"mailto:[email protected]" target=3D"_blank">skessler@d= enverdataman.com</a>></span>:<br><blockquote class=3D"gmail_quote" style= =3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">If you r= equire the relationship it should fix that.<span class=3D"im HOEnZb"><span>= </span><br><br>On Monday, January 19, 2015, Llu=C3=ADs Forns <<a href=3D= "mailto:[email protected]" target=3D"_blank">[email protected]</a>> wrote:= <br></span><div class=3D"HOEnZb"><div class=3D"h5"><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">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= is 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 ro= oms with bookings for that night are available</div><div>3. Filter for NULL= related booking nid</div><div>No room listed</div><div><br></div><div>I th= ink the filter should affect only joined content, but it it is affecting th= e full content. How can I limit to the join?</div><div><br></div><div><br><= /div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">2015-0= 1-19 16:07 GMT+01:00 Jamie Holly <span dir=3D"ltr"><<a>hovercrafter@eart= hlink.net</a>></span>:<br><blockquote class=3D"gmail_quote" style=3D"mar= gin: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 class=3D"HOEnZb"><div class=3D"h5">--= <br>Steve Kessler<div>Owner and Lead Consultant=C2=A0</div><div>Denver Dat= aMan, 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 class=3D"gmail_signature">*Ser freak no =C3= =A9s imprescindible per ser inform=C3=A0tic, per=C3=B2 ajuda.<br>*La vida n= o ha de ser feli=C3=A7, ha de ser plena.<br>*Abans d'imprimir aquest mi= ssatge, pensa en el medi ambient.</div> </div> --089e01493ada575656050d0412df-- --===============1192176263691243758== 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/ ] --===============1192176263691243758==--