rango dates

Re: rango dates

Postby Otto » Tue Jun 16, 2009 5:32 pm

Hello James,

with your filter you are testing if there is a booking exactly in this period.
If you change for example the booking
00002 Cliente H 3 1 01-01-2009 31-12-2009 .F. 1 0434 A 24-07-2002 GIOVANNI BIANCHI to a whole year booking your code still returns 1.

If think what I posted is the right filter:

set filter to ( dIniziale < AL .AND. dFinale > dal )

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: rango dates

Postby James Bott » Tue Jun 16, 2009 5:51 pm

Otto,

>with your filter you are testing if there is a booking exactly in this period.

No, I am testing to see if the new date range overlaps any existing date range.

>If you change for example the booking
>00002 Cliente H 3 1 01-01-2009 31-12-2009 .F. 1 0434 A 24-07-2002 GIOVANNI BIANCHI to a whole >year booking your code still returns 1.

As it should. There is one record that overlaps the new range.

>If think what I posted is the right filter:

>set filter to ( dIniziale < AL .AND. dFinale > dal )

No, this is not correct. Here is an eample:

We want to book from 14/06/2009 - 15/06/2009 (dIniziale - dFinale)

There is a record with a booking from 13/06/2009 - 14/06/2009 (DAL - AL). By your example:

set filter to 14/06/2009 < 14/06/2009 .and. 15/06/2009 > 13/06/2009

The first condition will fail (leaving no record meeting the filter), yet you cannot book 14/06/2009-15/06/2009 because 14/06/2009 is already booked.

What we really want to know is if dIniziale is within any existing date range OR if dFinale is within any existing date range. This would actually be a better way to write the filter (it makes it more clear).

Code: Select all  Expand view
 set filter to alltrim(tipoattrez) == cTipoAttrez .AND. CAMERA == nCamera  ;
      .AND. ;
      (;
      ( dIniziale >= DAL .AND. dIniziale <= AL ) .OR.;
      ( dFinale >= DAL .AND. dFinale <= AL );
      )



James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: rango dates

Postby Otto » Tue Jun 16, 2009 6:24 pm

Jamse,

>00002 Cliente H 3 1 01-01-2009 31-12-2009 .F. 1 0434 A 24-07-2002 GIOVANNI BIANCHI to a whole >year booking your code still returns 1.

As it should. There is one record that overlaps the new range.

but if you change this record to a booking over the whole season shouldn'd there then be 2:
the whole season booking and the booking from 14-15.6.2009

I am not clear what the msginfo should report: the free places or the occupied one?

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: rango dates

Postby James Bott » Wed Jun 17, 2009 5:27 am

Otto,

>but if you change this record to a booking over the whole season shouldn'd there then be 2:
>the whole season booking and the booking from 14-15.6.2009

Other than the dates, there are two other criteria which that record (recno 2) doesn't meet.

>I am not clear what the msginfo should report: the free places or the occupied one?

msgInfo() is returning the number of records that exist that overlap the desired booking date. If nRec>0 then you cannot make the booking.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: rango dates

Postby Otto » Wed Jun 17, 2009 7:38 am

Hello james,

I try to understand the conditions.
( DAL >= dIniziale .AND. DAL <= dFinale ) .OR. ( AL >= dIniziale .AND. AL <= dFinale )


Here a little graphic showing what I mean:

Image


FALSE ( DAL >= dIniziale .AND. DAL <= dFinale )
FALSE ( AL >= dIniziale .AND. AL <= dFinale )

Both parts of the condition return false but the period is occupied.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: rango dates

Postby Silvio » Wed Jun 17, 2009 8:03 am

James ,
I try with this :

Code: Select all  Expand view


 If   aData[nY,nX]== "O"
           cTipoAttrez:="O"
            cTipoSol :=""
            cPosNome := ""
            nOmbrellone :=  (oDBeach)->camera
            nFila:=  (oDBeach)->Y
            cCaption2:="Ombrellone n.:"+str(nOmbrellone)+CRLF+"Fila:"+str(nFila)
            n:= nOmbrellone
            (oDPre)->(OrdSetFocus(3))
        set filter to alltrim((oDPre)->tipoattrez) == cTipoAttrez .AND. (oDPre)->CAMERA == n  ;
      .AND. ;
      (;
      ( (oDPre)->DAL >= dDataIniziale .AND. (oDPre)->DAL <= dDataFinale  ) .OR.;
      ( (oDPre)->AL >= dDataIniziale .AND. (oDPre)->AL <= dDataFinale  );
  )
            (oDPre)->(DbGoTop())
            DO WHILE !(oDPre)->(EoF())
                cPosNome := alltrim( (oDPre)->RAZSOC)
                cTipoSol := alltrim( (oDPre)->TIPSOL)
                nStato:=((oDPre)->stato)
                (oDPre)->(DbSkip())
             ENDDO
       endif
 


I try , it seem run but I not made all tests I 'm working with my friend to make all tests
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: rango dates

Postby Silvio » Wed Jun 17, 2009 11:07 am

Otto,
How You control if a room is free in your Whotel application ?
I want a room from 16.08.2009 to 20.08.2009 : your application not control it ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: rango dates

Postby James Bott » Wed Jun 17, 2009 12:41 pm

Otto,

>Both parts of the condition return false but the period is occupied.

While trying to fall asleep last night, I realized that my previous filter was not covering all conditions. You have pointed out one of those conditions and you are correct. There are more conditions also.

I am going to think about this some more this morning and run more tests. This is more complicated than it at first seemed. Now that I have had some sleep, maybe the little gray cells will be working better.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: rango dates

Postby James Bott » Wed Jun 17, 2009 1:00 pm

Silvio and Otto,

OK, after one cup of coffee (but no testing), I think this filter covers all conditions:

Code: Select all  Expand view
  set filter to alltrim(tipoattrez) == cTipoAttrez .AND. CAMERA == nCamera  ;
      .AND. ;
      (;
      ( dIniziale >= DAL .AND. dIniziale <= AL ) .OR.;
      ( dFinale >= DAL .AND. dFinale <= AL ) .OR. ;
      ( dIniziale < DAL .AND.  dFinale > AL ) ;
      )


Otto, it seems that we were both right and we were both wrong--the filter needs to include both of our filters.

Now I am going to do have another cup of coffee and do some testing.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: rango dates

Postby James Bott » Wed Jun 17, 2009 1:24 pm

OK, testing seems to confirm that the filter is working. If you use these test dates:

dIniziale:= ctod("14/01/2009")
dFinale := ctod("15/12/2009")

You will get nRecs=6 which is all records in the database that also meet the first two criteria (the non-date criteria). Before adding Otto's filter, nRecs would have been 0. Thanks Otto!

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: rango dates

Postby James Bott » Wed Jun 17, 2009 1:36 pm

Otto,

>Here a little graphic showing what I mean:

>FALSE ( DAL >= dIniziale .AND. DAL <= dFinale )
>FALSE ( AL >= dIniziale .AND. AL <= dFinale )

>Both parts of the condition return false but the period is occupied.

You are referring to my first filter, note that I changed it later to:

Code: Select all  Expand view
    ( dIniziale >= DAL .AND. dIniziale <= AL ) .OR.;
      ( dFinale >= DAL .AND. dFinale <= AL )

This would trap the condition in your graphic, but it was still missing the oposite of your graphic--when dIniziale <= DAL and dFinale was >= AL. These are now covered in the new filter.

Code: Select all  Expand view
     ( dIniziale >= DAL .AND. dIniziale <= AL ) .OR.;
      ( dFinale >= DAL .AND. dFinale <= AL ) .OR. ;
      ( dIniziale < DAL .AND.  dFinale > AL )


James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: rango dates

Postby Otto » Wed Jun 17, 2009 1:51 pm

Hello James,

why do you think that the condition I posted should not work?

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: rango dates

Postby James Bott » Wed Jun 17, 2009 2:10 pm

Otto,

>why do you think that the condition I posted should not work?

>( dIniziale < AL .AND. dFinale > DAL )

Well because I tested it and it didn't as I pointed out in a previous message.

I have looked at it again and I realized that I was not seeing it properly. I was confusing DAL and AL. What I was thinking you had was this:

( dIniziale < DAL .AND. dFinale > AL )

But after looking at your filter again and making a slight modification this seems to work:

( dIniziale <= AL .AND. dFinale >= DAL )

It is important to add the = signs. It works the same as my previous filter but it is much simpler. I like it!

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: rango dates

Postby Otto » Wed Jun 17, 2009 2:50 pm

Hello James,
thank you for your answer.
> I was confusing DAL and AL.
James, therefore I ask what you show in the msginfo.
It was not clear from the question Silvio posted what he really wants:
the free umbrellas or the occupied.

This with the equal signs is much depending of the purpose.
Silvio needs free umbrellas during the day in my case with WINHOTEL
I check if the night is free.
Best regards,

Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: rango dates

Postby James Bott » Wed Jun 17, 2009 3:22 pm

Otto,

>> I was confusing DAL and AL.
>James, therefore I ask what you show in the msginfo.
>It was not clear from the question Silvio posted what he really wants:
>the free umbrellas or the occupied.

It appears that he was looking to tell if an umbrella was reserved for a date range. However, it would seem to be a better user interface to just select a date and show all umbrellas that are not reserved. Maybe that is what he wants. Silvio?

Howerver, msgInfo() was just a quick test of the filter.

>This with the equal signs is much depending of the purpose.
>Silvio needs free umbrellas during the day in my case with WINHOTEL
>I check if the night is free.

Hmm. But, wouldn't it be the same? If a room is occupied for the night of the 15th, don't you consider the room occupied on the 15th? So, wouldn't you need the same filter?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], jair and 91 guests