00001  def new global shared var prog-started as log.
00002  def new global shared var u-name as char.
00003  
00004  def shared var screen-title as char.
00005  
00006  def shared var total-floor-no as int init 4.
00007  def shared var room-types as char extent 5.
00008  
00009  def shared var res-state as char extent 4.
00010  def shared var res-state-ch as char extent 4.
00011  
00012  def shared var res-state-placed as int init 1.
00013  def shared var res-state-canceled as int init 2.
00014  def shared var res-state-checked-in as int init 3.
00015  def shared var res-state-checked-out as int init 4.
00016  
00017  prog-started = true. 
00018  def var h-time as char.
00019  
00020  form u-name view-as text
00021       screen-title view-as text
00022       h-time view-as text
00023       with frame f-main-header size 80 by 1 no-box no-underline no-labels at row 1 col 1.
00024   
00025  
00026  screen-title = "Rates Listing".
00027  
00028  def var by-room as log init no.
00029  def var room-type like rate.type-of-room format ">>>,>>>,>>>".
00030  def var start-date like rate.start-date.
00031  def var end-date like rate.end-date.
00032  def var output-to as log format "Terminal/File".
00033  def var by-floor as log format "Floor/Room Type".
00034  def var i as int.
00035  def var c-rate like rate.rate label "Current".
00036  
00037  form  start-date label "Start Date" at row 1 col 20 colon-aligned help "Leave blank for all before"
00038        end-date label "End Date" at row 2 col 20 colon-aligned help "Leave blank for all after"
00039        by-floor label "Group by" at row 3 col 20 colon-aligned help "Group by (F)loor or (R)oom-type"
00040        by-room label "Set room type?" at row 4 col 20 colon-aligned view-as toggle-box
00041        room-type view-as combo-box inner-lines 5  label "Room type" at row 5 col 20 colon-aligned
00042        with frame f1 centered side-labels.
00043  
00044  run set-room-types-combo (input room-type:handle in frame f1).
00045  
00046  def temp-table t-floor field floor like room.floor.
00047  
00048  def temp-table t-room-type field type like room.type-of-room field name as char format "x(20)"  label "Room Type".
00049  do i = 1 to total-floor-no transaction:
00050     create t-floor.
00051     t-floor.floor = i.
00052  end.
00053  
00054  do i = 1 to extent(room-types) transaction:
00055     create t-room-type.
00056     t-room-type.type = i.
00057     t-room-type.name = room-types[i].
00058  end.
00059  
00060  repeat on endkey undo, leave:
00061     if u-name = ? or u-name = "" then do:
00062     message "You are not logged in - access denied" view-as alert-box.
00063     quit.
00064  end.
00065  
00066  h-time = string(now, "99/99/99 HH:MM:SS").
00067  h-time = substring(h-time, 10).
00068  
00069  do with frame f-main-header:
00070     u-name:column = 1.
00071     screen-title:column = u-name:column + length(u-name) + (frame f-main-header:width-chars - length(u-name) - length(screen-title) - length(h-time)) / 2.
00072     h-time:column = frame f-main-header:width-chars - length(h-time).
00073     screen-title:format = "x(" + string(length(screen-title)) + ")".
00074  end.
00075  
00076  display u-name screen-title h-time with frame f-main-header.
00077   
00078  
00079     on "value-changed" of by-room do:
00080        room-type:sensitive in frame f1 = by-room:input-value.
00081     end.
00082  
00083     update start-date end-date by-floor by-room with frame f1.
00084     assign room-type.
00085     
00086     message "Output (T)erminal or (F)ile" update output-to.
00087     
00088     hide frame f1 no-pause.
00089     
00090     if output-to
00091     then do:
00092        
00093        if by-floor then do:
00094  
00095           form t-floor.floor
00096                t-room-type.name
00097                rate.start-date 
00098                rate.end-date
00099                rate.rate
00100                with frame rt-1 down.
00101           
00102           clear frame rt-1 all no-pause.
00103           
00104           for each t-floor, 
00105              each t-room-type 
00106                 where (if by-room then t-room-type.type = room-type else true),
00107              each rate
00108                 where rate.floor = t-floor.floor and
00109                       rate.type-of-room = t-room-type.type and
00110                       (if start-date = ? then true else rate.start-date <= start-date) and
00111                       (if end-date = ? then true else rate.end-date >= end-date)
00112                 no-lock
00113              break by t-floor.floor
00114                    by t-room-type.type:
00115  
00116                 if first-of(t-room-type.type) then c-rate = ?.
00117                 
00118                 if c-rate = ? and rate.end-date >= today then c-rate = rate.rate.
00119  
00120                 display t-floor.floor when first-of(t-floor.floor)
00121                         t-room-type.name when first-of(t-room-type.type)
00122                         rate.start-date 
00123                         rate.end-date
00124                         rate.rate
00125                         with frame rt-1.
00126                 down with frame rt-1.
00127  
00128                 if last-of(t-room-type.type) then do:
00129                    display "Current Rate" @ t-room-type.name 
00130                            c-rate @ rate.rate 
00131                            with frame rt-1.
00132                    down with frame rt-1.
00133                 end.
00134           end.
00135  
00136        end.
00137        else do:
00138           form t-room-type.name
00139                t-floor.floor
00140                rate.start-date 
00141                rate.end-date
00142                rate.rate
00143                with frame rt-2 down.
00144           
00145           clear frame rt-2 all no-pause.
00146           
00147           for each t-room-type 
00148                 where (if by-room then t-room-type.type = room-type else true),
00149              each t-floor,
00150              each rate
00151                 where rate.floor = t-floor.floor and
00152                       rate.type-of-room = t-room-type.type and
00153                       (if start-date = ? then true else rate.start-date <= start-date) and
00154                       (if end-date = ? then true else rate.end-date >= end-date)
00155                 no-lock
00156              break by t-room-type.type
00157                    by t-floor.floor:
00158  
00159                 if first-of(t-floor.floor) then c-rate = ?.
00160                 
00161                 if c-rate = ? and rate.end-date >= today then c-rate = rate.rate.
00162  
00163                 display t-room-type.name when first-of(t-room-type.type)
00164                         t-floor.floor when first-of(t-floor.floor)
00165                         rate.start-date 
00166                         rate.end-date
00167                         rate.rate
00168                         with frame rt-2.
00169                 down with frame rt-2.
00170  
00171                 if last-of(t-floor.floor) then do:
00172                    display "Current Rate" @ t-room-type.name 
00173                            c-rate @ rate.rate 
00174                            with frame rt-2.
00175                    down with frame rt-2.
00176                 end.
00177           end.
00178        end.
00179  
00180        pause message "Press any key to return".
00181     end.
00182     else do:
00183        def var f-name as char.
00184        f-name = "".
00185        repeat while f-name = "":
00186           message "Enter file name" update f-name format "x(20)".
00187        end.
00188        
00189        def stream rpt.
00190        output stream rpt to value(f-name) paged page-size 20.
00191        
00192        form header
00193           u-name 
00194           space(40)
00195           "H O T E L"
00196           space(40)
00197           today format "99/99/9999" at 114
00198           string(time, "hh:mm:ss") skip
00199           skip
00200           screen-title at 40 format "x(40)"
00201           page-number(rpt) format "Page: >>>>>9"     to 132
00202           skip(2)
00203           with frame gf-header width 132 no-attr-space no-underline no-box page-top.
00204        form header
00205           "Floor" at 1
00206           "Type of Room" at 10
00207           "Start Date" at 40
00208           "End Date" at 60
00209           "Rate" at 80 
00210           skip 
00211           fill("-", 9) at 1 format "x(8)"
00212           fill("-", 29) at 10 format "x(28)"
00213           fill("-", 19) at 40 format "x(18)"
00214           fill("-", 19) at 60 format "x(18)"
00215           fill("-", 19) at 80 format "x(18)"
00216           with frame hf-1 width 132 no-attr-space no-underline no-box page-top. 
00217  
00218        form header
00219           "Type of Room" at 1
00220           "Floor" at 30
00221           "Start Date" at 40
00222           "End Date" at 60
00223           "Rate" at 80 
00224           skip 
00225           fill("-", 29) at  1 format "x(28)"
00226           fill("-", 9)  at 30 format "x(8)"
00227           fill("-", 19) at 40 format "x(18)"
00228           fill("-", 19) at 60 format "x(18)"
00229           fill("-", 19) at 80 format "x(18)"
00230           with frame hf-2 width 132 no-attr-space no-underline no-box page-top. 
00231  
00232        view stream rpt frame gf-header.
00233        
00234        if by-floor then do:
00235           view stream rpt frame hf-1.
00236        end.
00237        else do:
00238           view stream rpt frame hf-2.
00239        end.
00240  
00241        if by-floor then do:
00242  
00243           form t-floor.floor at 1
00244                t-room-type.name at 10
00245                rate.start-date  at 40
00246                rate.end-date at 60
00247                rate.rate at 80
00248                with frame rf-1 width 132 no-attr-space no-underline down no-labels no-box.
00249  
00250           clear frame rf-1 all no-pause.
00251           
00252           for each t-floor, 
00253              each t-room-type 
00254                 where (if by-room then t-room-type.type = room-type else true),
00255              each rate
00256                 where rate.floor = t-floor.floor and
00257                       rate.type-of-room = t-room-type.type and
00258                       (if start-date = ? then true else rate.start-date <= start-date) and
00259                       (if end-date = ? then true else rate.end-date >= end-date)
00260                 no-lock
00261              break by t-floor.floor
00262                    by t-room-type.type:
00263  
00264                 if first-of(t-room-type.type) then c-rate = ?.
00265                 
00266                 if c-rate = ? and rate.end-date >= today then c-rate = rate.rate.
00267  
00268                 display stream rpt t-floor.floor when first-of(t-floor.floor)
00269                         t-room-type.name when first-of(t-room-type.type)
00270                         rate.start-date 
00271                         rate.end-date
00272                         rate.rate
00273                         with frame rf-1.
00274                 down stream rpt with frame rf-1.
00275  
00276                 if last-of(t-room-type.type) then do:
00277                    display stream rpt "Current Rate" @ t-room-type.name 
00278                            c-rate @ rate.rate 
00279                            with frame rf-1.
00280                    down stream rpt 1 with frame rf-1.
00281                 end.
00282           end.
00283  
00284        end.
00285        else do:
00286           form t-room-type.name at 1
00287                t-floor.floor at 30
00288                rate.start-date at 40
00289                rate.end-date at 60
00290                rate.rate at 80
00291                with frame rf-2 width 132 no-attr-space no-underline down no-labels no-box.
00292           
00293           clear frame rf-2 all no-pause.
00294           
00295           for each t-room-type 
00296                 where (if by-room then t-room-type.type = room-type else true),
00297              each t-floor,
00298              each rate
00299                 where rate.floor = t-floor.floor and
00300                       rate.type-of-room = t-room-type.type and
00301                       (if start-date = ? then true else rate.start-date <= start-date) and
00302                       (if end-date = ? then true else rate.end-date >= end-date)
00303                 no-lock
00304              break by t-room-type.type
00305                    by t-floor.floor:
00306                 if first-of(t-floor.floor) then c-rate = ?.
00307                 
00308                 if c-rate = ? and rate.end-date >= today then c-rate = rate.rate.
00309  
00310                 display stream rpt t-room-type.name when first-of(t-room-type.type)
00311                         t-floor.floor when first-of(t-floor.floor)
00312                         rate.start-date 
00313                         rate.end-date
00314                         rate.rate
00315                         with frame rf-2.
00316                 down stream rpt with frame rf-2.
00317  
00318                 if last-of(t-floor.floor) then do:
00319                    display stream rpt "Current Rate" @ t-room-type.name 
00320                            c-rate @ rate.rate 
00321                            with frame rf-2.
00322                    down stream rpt 1 with frame rf-2.
00323                 end.
00324           end.
00325        end.
00326        
00327        message "Report completed - " + string(page-number(rpt)) + " pages".
00328        pause.
00329        output stream rpt close.
00330     end.
00331     
00332     hide all no-pause.
00333  end.
00334  
00335  publish "pop-program".