Page 1 of 2

Booking xbrowse example

PostPosted: Mon Jul 10, 2023 6:13 am
by Antonio Linares
Original idea by Silvio, implemented by Mr. Rao

You can drag & drop the reservations using the mouse

booking.prg
Code: Select all  Expand view
#include "fivewin.ch"

function Main()

   local oDlg, oBrw, oFont, oCur
   local aData := Array( 6, 11 )
   local n
   local aColors := { METRO_AMBER, METRO_OLIVE, CLR_HMAGENTA, CLR_HBLUE, CLR_HRED, CLR_HGREEN, CLR_RED, CLR_MAGENTA, CLR_GREEN }
   AEval( aData, { |a,i| AFill( a, 0 ), a[ 1 ] := "Camera n." + Str(i,1,0) } )

   SET DATE ITALIAN

   DEFINE CURSOR oCur DRAG
   DEFINE FONT oFont NAME "VERDANA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 760,430 PIXEL TRUEPIXEL ;
      RESIZABLE FONT oFont

   @ 5,5 XBROWSE oBrw SIZE 0,400 PIXEL OF oDlg DATASOURCE aData ;
      COLUMNS 1,2,3,4,5,6,7,8,9,10,11 ;
      HEADERS "", "AM","PM","AM","PM","AM","PM","AM","PM","AM","PM" ;
      NOBORDER STYLE FLAT

   WITH OBJECT oBrw
      :nWidths             := 60
      :nRowHeight          := 60
      :nHeaderHeight       := 60
      :nColDividerStyle    := ;
      :nRowDividerStyle    := LINESTYLE_LIGHTGRAY
      :nMarqueeStyle       := MARQSTYLE_SOLIDCELL
      :lDrawBorder         := .t.
      :nDataStrAligns      := AL_CENTER
      :lDisplayZeros       := .f.
      :nFreeze             := 1
      :lLockFreeze         := .t.
      :lAllowColSwapping   := .f.
      :lAllowColHiding     := .f.
      :lAllowRowSizing     := .f.
      :lAllowSizings       := .f.
      :lColChangeNotify    := .t.

      :bClrStd := <|b,oCol|
         local nClr  := CLR_WHITE
         if oCol != nil .and. !Empty( oCol:Value )
            nClr  := aColors[ oCol:Value ]
         endif
         return { ContrastClr( nClr ), nClr }
         >

      for n := 2 to 10 step 2
         :SetGroupHeader( DTOC( Date() + n/2 - 1 ), n, n + 1, nil, nil, 30 )
      next
      WITH OBJECT :aCols[ 1 ]
         :nWidth     := aData[ 1, 1 ] + "9999"
         :bClrStd    := ;
         :bClrHeader := { || { CLR_BLACK, RGB(125,135,249) } }
         :nDataStrAlign := AL_CENTER
      END

      :bPopUp     := { |oCol| CellMenu( oCol ) }
      :lRecordSelector  := .f.
      :lFitGridHeight   := .t.

      // drag and drop

      :bChange       := < ||
                           local oCol := oBrw:SelectedCol()
                           if oCol:nArrayCol > 1 .and. !Empty( oCol:Value )
                              oBrw:oDragCursor := oCur
                           else
                              oBrw:oDragCursor := nil
                           endif
                           return nil
                           >

      :bDragBegin    := < |r,c,f|
                           SetDropInfo( { oBrw:nArrayAt, oBrw:SelectedCol():nArrayCol } )
                           return nil
                           >
      :bDropOver     := < |u,r,c,f|
                           oBrw:SetPos( r, c, .t. )
                           oBrw:SelectedCol():Value := aData[ u[ 1 ], u[ 2 ] ]
                           aData[ u[ 1 ], u[ 2 ] ] := 0
                           XEval( oBrw:bChange, oBrw )
                           oBrw:Refresh()
                           return nil
                        >

      //

      :nColSel    := 2
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont
   RELEASE CURSOR oCur

return nil
   
   //----------------------------------------------------------------------------//
   
   static function CellMenu( oCol )
   
      local oPop, oItem, oBrw, nVal, n
   
      if oCol:nCreationOrder > 1
         nVal  := oCol:Value
         oBrw  := oCol:oBrw
         MENU oPop POPUP 2010
            MENUITEM "Reserve To:"
            MENU
            for n := 1 to 9
               MENUITEM "Customer-" + Str(n,1,0) BLOCK Reserve( oCol, n )
            next
            ENDMENU
            MENUITEM "Cancel" WHEN nVal > 0 ACTION ;
               ( oCol:Value := 0, oBrw:RefreshCurrent() )
         ENDMENU
   
      endif
   
   return oPop
   
   static function Reserve( oCol, n )
   return { || oCol:Value := n, oCol:oBrw:RefreshCurrent() }

Image

Re: Booking xbrowse example

PostPosted: Wed Jul 12, 2023 9:18 am
by Detlef
This works great, Antonio.
It demonstrates the power of xbrowse and fwh.
Thanks for this great example. :D

Only a little glitch...
When the program starts and you reserve a first cell to a customer you can not immediately drag and drop this cell.
First you must click at an other cell. Then after drag and drop works well.

Regards,
Detlef

Re: Booking xbrowse example

PostPosted: Wed Jul 12, 2023 9:26 am
by Antonio Linares
Thank you dear Detlef,

Mr. Rao is working on an enhanced version. Lets wait a little for him to deliver it

Its another great work from Mr. Rao :-)

Re: Booking xbrowse example

PostPosted: Wed Jul 12, 2023 9:46 am
by Detlef
Its another great work from Mr. Rao :-)

That's true! :D

Re: Booking xbrowse example

PostPosted: Fri Jul 21, 2023 9:25 am
by Silvio.Falconi
As I told you, I use on reserva.dbf a field "type" to show the type of Rome, so I need this visualizzation, there are rooms with the same number buy with type different.

sample:

Camera n.1 SS
Camera n.1 DD

For evening or morning (AM -PM) I use two logic field.

Re: Booking xbrowse example

PostPosted: Tue Sep 19, 2023 7:19 am
by Silvio.Falconi
Antonio Linares wrote:Thank you dear Detlef,

Mr. Rao is working on an enhanced version. Lets wait a little for him to deliver it

Its another great work from Mr. Rao :-)


Antonio,

when a an enhanced version ?

Re: Booking xbrowse example

PostPosted: Tue Sep 19, 2023 9:21 am
by Antonio Linares
Dear Silvio,

I just asked Mr. Rao

waiting for his answer

Re: Booking xbrowse example

PostPosted: Fri Dec 29, 2023 3:32 pm
by Detlef
Is there some progress? I'm very interested too about this topic.

I wish you all a very happy, healthy and successful new year.
Regards, Detlef

Re: Booking xbrowse example

PostPosted: Fri Dec 29, 2023 3:40 pm
by Antonio Linares
Dear Detlef,

I just asked Mr. Rao about it

wish you too a very happy, healthy and successful new year :-)

Re: Booking xbrowse example

PostPosted: Sat Dec 30, 2023 7:46 am
by Otto
Hello friends,

Why not try recreating this example as a proof of concept to demonstrate the power of WebView as a WebView example?

Best regards,
Otto

Re: Booking xbrowse example

PostPosted: Sat Dec 30, 2023 8:25 am
by Antonio Linares
Dear Otto,

thats a nice idea :-)

Surely you may be able to help us with some existing web code to start with

Re: Booking xbrowse example

PostPosted: Sat Dec 30, 2023 12:32 pm
by Silvio.Falconi
Antonio Linares wrote:Dear Otto,

thats a nice idea :-)

Surely you may be able to help us with some existing web code to start with


Yes but before It Need to have a usefull prg in Windows with the features i list above and the possibilty to insert a reservation clickinking with the mouse One or more cells , or moving the reservation to another room or period.


in this way the example of nages is nice but in Italy it is unusable at least for what I need and what they require both for hotels and for other businesses in the sector

Re: Booking xbrowse example

PostPosted: Sat Dec 30, 2023 6:28 pm
by Otto
Silvio,

Webview allows the use of prg programs, just as you create them, while still utilizing web technologies.
You should really look at the examples in the FIVEWIN samples.

Best regards,
Otto

Re: Booking xbrowse example

PostPosted: Sat Dec 30, 2023 6:54 pm
by Otto
Dear Antonio,
I am glad you like the idea. I have indeed already developed a planner with html/javascript for mod harbour.

I have not integrated anything except bootstrap and jquery.

Therefore, I believe one would only need to embed the html into a Fivewin webview.

I have already posted several webview examples.

Best regards,
Otto


https://forums.fivetechsupport.com/viewtopic.php?f=3&t=11204&p=265558&hilit=planner&sid=c439ca4174db5684c6b3d89dd21ba93f&sid=c439ca4174db5684c6b3d89dd21ba93f#p265558

Image

Image




Image

Image

Image

Image

Re: Booking xbrowse example

PostPosted: Sat Dec 30, 2023 11:00 pm
by Silvio.Falconi
Otto wrote:Silvio,

Webview allows the use of prg programs, just as you create them, while still utilizing web technologies.
You should really look at the examples in the FIVEWIN samples.

Best regards,
Otto


As I told you many times I not want make web application
HTML/JavaScript and others languages