James Bott wrote:>I honestly don't understand what your common thread is and what the reservation number has to do with it.
No government requirements.
Do I have to explain on the public forum how I created the NUMPRE field or the INVOICE field?
Exactly, the field is 18 characters and is a string formed by an internal code RR (reservation "or SS" single receipt "or by another code that I would like not to explain in the public forum
and is formed by
Year
the current month
the current time including seconds
are you happy that I explained on public forum how that unique code was created?
Gee, Silvio, you sent me an email specifically requesting that I answer questions about this message thread on the forum, so that is what I did.
I just mentioned the ID since I didn't know there was an ID. If it was traditional (shorter and the first field) I would have assumed it was the ID. I must say you have come up with a unique way of coming up with a new ID--I have never seen anything like it before. As long as it works for you.
>I thought of this code when * someone * insisted telling me that with tdatabase (or tdata)
I couldn't know the record number and adding +1 to the value because in ancient times the reservation number was made up of the record number - strzero (recno, 4) + 1 -
Well, that is not a complete description of that situation. In a multi-user system, you cannot just assign an ID before a record is even entered by the user, since multiple other people could get the same ID before any of the records were saved. Then you will end up with a database having multiple records with the same ID.
>I would have liked not to publicly explain how the code is made, I don't see why this could affect the search I asked for, the order or reservation number must not be changed, it remains the same even when the record is in modification.
I was trying to simplify the search for you--I said nothing about changing a reservation number.
>the customer want another day until 29/07/2021
I cannot automatically add a day I have to have the program search for it if it is free or busy
in fact if you see well there is a record number 12 which is the same element (0006/01) and is occupied on the day 29/07/2021
so I didn't understand your unhealthy idea of adding a day without doing the proper research.
If you re-read the paragraph you are referring to, I said that if you are REMOVING days from a reservation you don't need to do a search. And if you adding them, then you do need to do a search. My exact words were:
Since you are going to free up a week (29/07/2021 is going to be changed to 21/07/2021). So you just change the 29 to 21 and save. No search needed. Of course, if the customer wants to extend their stay, then you will have to search.
James
James,
>Gee, Silvio, you sent me an email specifically requesting that I answer questions about this message thread on the forum, so that is what I did.
I sent you a test with simulation of calls to the Isfree()
this test ( perhaps you not seen it
#include "FiveWin.ch"
#include "dtpicker.ch"
request dbfcdx
request dbffpt
request hb_lang_it
request hb_codepage_itwin
FUNCTION Main()
RddSetDefault( "DBFCDX" )
HB_LANGSELECT( "IT" )
HB_SETCODEPAGE( "ITWIN" )
SetHandleCount( 100 )
FWNumFormat( "E", .t. )
SET DATE FORMAT "dd-mm-yyyy"
SET DELETED ON
SET CENTURY ON
SET EPOCH TO year( date() ) - 20
SET MULTIPLE OFF
Test()
RETURN nil
//---------------------------------------------------------------------------------------//
Function test()
local oPrenotazioni
local cCamera
local cTypeRoom
local dCheck_in
local dCheck_out
local cNumPre:="RR20062313371 "
local oRecPrenota
dCheck_in := ctod("08/07/2021")
dCheck_out := ctod("28/07/2021")
oPrenotazioni := TReserva():New()
// simulation 1 Initial search on Archive from nInvoice number
Msginfo("Now I search on archive the nIvoice number RR20062313371")
// search on archive the record
nInvoice:= alltrim(cNumPre)
oPrenotazioni:setorder("res_pre" )
IF oPrenotazioni:seek(nInvoice)
oRecPrenota:=oPrenotazioni:record() //modify
dFirst := oRecPrenota:check_in
dLast := oRecPrenota:check_out
cCamera := oRecPrenota:ROOMS_ID
cTypeRoom := oRecPrenota:TYPE
ELSE
Msgstop("Reservation not found!!","Attention")
RETURN NIL
Endif
xbrowser oPrenotazioni
// add a day on dLast
Msginfo("Now I add a day")
IsFree(cCamera,dFirst,dLast+1,cTypeRoom,oPrenotazioni) // 29/07/2021
Msginfo("Now I change the number and the type, because the customer want change room (0001) type 02, so the invoice number is the same ")
// simulation 2 // change number and type same rage of dates
cCamera :="0001"
cTypeRoom :="02"
IsFree(cCamera,dFirst,dLast+1,cTypeRoom,oPrenotazioni)
Msginfo("Now I change and return to initial state number room and type")
// simulation 3 // change on number and type initial , date ragnge intial
cCamera :="0006"
cTypeRoom :="01"
IsFree(cCamera,dFirst,dLast,cTypeRoom,oPrenotazioni)
Msginfo("Now I change all numer 0002, type 01, one day 14/7/2021")
// simulation 4 // change on number and type , date range
cCamera :="0002"
cTypeRoom :="01"
dFirst:=ctod("14/07/2021")
dLast :=ctod("14/07/2021")
IsFree(cCamera,dFirst,dLast,cTypeRoom,oPrenotazioni)
Msginfo( "The invoice is seeked right on archive"+CRLF+ ;
"Simulation 1 is ok the range ( 8/07 to 29/07 is not avaible )"+CRLF+ ;
"Simulation 2 is no ok there's no reservation with number 0001"+CRLF+ ;
"Simulation 3 is ok I return to initial search "+CRLF+ ;
"Simulation 4 is no ok for the 14/07 the rooms seem avaible but the function show is not avaible ")
oRecPrenota:end()
oPrenotazioni:close()
return nil
//-----------------------------------------------------------------------------------------------------//
Function IsFree(cCamera,dCheck_in,dCheck_out,cTypeRoom,oPrenotazioni)
local lFree
local cSearch
* ? cCamera
cSearch := oPrenotazioni:ApplyParams( "ROOMS_ID == ? .AND. ALLTRIM(TYPE) == ? .AND. RECNO() != ? .AND. (CHECK_IN > ? .OR. CHECK_OUT < ? )", ;
{ cCamera, ALLTRIM( cTypeRoom ), oPrenotazioni:RecNo(), dCheck_out, dCheck_in } )
if oPrenotazioni:LookUp( cSearch, nil, { || .T. } ) == .T.
lFree:=.t.
Msginfo("room is available"+CRLF+CRLF+;
"Room number : "+cCamera+CRLF+;
"Room ctype : "+cTypeRoom+CRLF+;
"Check in : "+cf(dCheck_in)+CRLF+;
"Check out : "+cf(dCheck_out)+CRLF+;
"No Record : "+ltrim(str(oPrenotazioni:RecNo())) )
else
Msginfo("room is not availble"+CRLF+CRLF+;
"Room number : "+cCamera+CRLF+;
"Room ctype : "+cTypeRoom+CRLF+;
"Check in : "+cf(dCheck_in)+CRLF+;
"Check out : "+cf(dCheck_out)+CRLF+;
"No Record : "+ltrim(str(oPrenotazioni:RecNo())) )
lFree:=.f.
endif
return lFree
//----------------------------------------------------------------------------------//
FUNCTION Cf(dTemp)
LOCAL Meses:="GenFebMarAprMagGiuLugAgoSetOttNovDic"
LOCAL f, m, cMes, dFech
f:=DTOS (dTemp)
m:=MONTH(dTemp)
cMes:=IF(m<>0,SubStr(Meses,(m*3)-2,3),"")
dFech:=IF(m<>0,SubStr(f,7,2)+'-'+cMes+'-'+SubStr(f,1,4),'')
RETURN (dFech)
//---------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------//
CLASS TXData from TDataBase
DATA cDbfPath init cFilePath(GetModuleFileName( GetInstance() )) //for test
ENDCLASS
CLASS TReserva from TXData
METHOD New()
ENDCLASS
METHOD New( lShared ) CLASS TReserva
Default lShared := .t.
::super:Open(,::cDbfPath + "Reserva" ,"DBFCDX", lShared)
if ::use()
::setOrder(1)
::gotop()
endif
RETURN Sel
the invoice and numpre fields must remain so in modification, I thought of it in this way also to create labels with barcodes and qr code.
I don't use any IDs
the reserva file is indexed on
ROOMS_ID + DToS (CHECK_IN)
>If you re-read the paragraph you are referring to, I said that if you are REMOVING days from a reservation you don't need to do a search. And if you adding them, then you do need to do a search. My exact words were:
>Since you are going to free up a week (29/07/2021 is going to be changed to 21/07/2021). So you just change the 29 to 21 and save. No search needed. Of course, if the customer wants to extend their stay, then you will have >to search.
sorry james, but to change the date of the reservation I have to go to "modify reservation" there are no other ways, the user cannot see the archive with a dbu as we see it
so if I open the booking change dialog I have to change the date range that the customer prefers, at the time of changing these dates the procedure must search the archive if the period is free or busy, if the customer he wants a week less or more, or a day more or less or he wants another number, how do I know if he is free or busy for the week in question.
so at any time if the operator being changed changes
1) the type of the element
2) the number
3) the check_in
4) check_out
the procedure must check if it is free or busy
the operator cannot guess
1) if it is free, it can confirm the change
2) if he is busy he must select an alternative of number or dates
or cancel the reservation
there is nothing difficult
I asked
how is it possible that if I call Isfree () several times and with different parameters it gives me an error or exactly does not return a true day value?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com