REBOL [ Title: "DevCon 2005 Registration" Purpose: { Allow users to register for the REBOL Developer Conference 2005 } Author: "Gabriele Santilli" EMail: giesse@rebol.it File: %register.r License: { Copyright (C) 2005 Gabriele Santilli This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. http://www.gnu.org/copyleft/gpl.html } Date: 1-Aug-2005 Version: 1.6.0 ; majorv.minorv.status ; status: 0: unfinished; 1: testing; 2: stable History: [ 19-Jul-2005 1.1.0 "History start" 20-Jul-2005 1.2.0 "Added personalized badge info and badge preview" 20-Jul-2005 1.3.0 "Added local save/load, send via HTTP" 20-Jul-2005 1.4.0 "Bugfixes" 21-Jul-2005 1.5.0 "Better look" 1-Aug-2005 1.6.0 "Removed Hotel reservation options" ] ] view-prefs: does [ if block? ctx-viewtop [ ctx-viewtop: context ctx-viewtop bind dtw-keymap ctx-viewtop ] ctx-viewtop/view-prefs ] check-cost: func [arrival departure price prices] [ arrival: attempt [to date! arrival/text] departure: attempt [to date! departure/text] price: index? find price/texts price/text price: pick prices price if not all [arrival departure price] [ alert "You need to fill in arrival date, departure date and kind of room." exit ] inform layout [ Banner join "Total: € " departure - arrival * price ] ] check-cost-rome: does [ check-cost arrival-rome departure-rome room-rome [90 45 90 36.67 73.33 110] ] check-cost-milan: does [ check-cost arrival-milan departure-milan room-milan [52 26 52] ] note-milan: does [ inform layout [ Text 300 {Subject to room availability; there are other hotels in the area in case we exceed the available rooms. Please note, however, that the price may be different in that case. This means that the price listed here is only an estimate. We will provide more informations as soon as they are available to us. Make sure to check the site often.} ] ] bold: make face/font [name: "Arial Black" size: 480] rebol-logo: [ transform 0 0.04 0.04 0x0 10x10 pen none fill-pen black shape [ move 50x0 'hline 1780 'arc -330 0x600 'hline -1780 'arc -50x-50 'vline -500 'arc 50x-50 'move 2020x0 'hline 700 'arc 50x50 'vline 500 'arc -50x50 'hline -700 'arc -330 0x-600 ] circle 1950x300 185 fill-pen white font bold text 1 150x0 "R E B" text 1 2340x0 "L" circle 1950x300 75 ] font-normal: make face/font [name: "Verdana" size: 18] font-bold: make font-normal [style: 'bold size: 20] font-name: make font-bold [size: 36] font-name-big: make font-name [size: 48] font-text: make font-normal [name: "Times New Roman" style: 'italic size: 20] text-size?: func [text' font'] [ first size-text make face [ font: font' text: text' size: 1000x1000 ] ] preview-badge: has [pos badge' name' lastname line1 line2 dev-scale conf-scale year-scale name-pos ln-pos line1-pos line2-pos] [ badge': [ push rebol-logo font font-normal pen none fill-pen black line-width 0 push [ translate 10x0 scale dev-scale 1 text vectorial 0x35 "Developer" ] push [ translate 10x0 scale conf-scale 1 text vectorial 0x53 "Conference" ] push [ translate 10x0 scale year-scale 1 font font-bold text vectorial 0x71 "2005" ] pen black font font-name-big text name-pos name' font font-name text ln-pos lastname font font-text text line1-pos line1 text line2-pos line2 ] name': uppercase copy/part name/text pos: any [find name/text " " tail name/text] lastname: uppercase copy next pos set [line1 line2] parse/all badge/text "^/" dev-scale: text-size? "Developer" font-normal dev-scale: 113 / dev-scale conf-scale: text-size? "Conference" font-normal conf-scale: 113 / conf-scale year-scale: text-size? "2005" font-bold year-scale: 113 / year-scale name-pos: 140x70 ln-pos: 140x120 line1-pos: 140x170 line2-pos: 140x190 name-pos/x: (540 - text-size? name' font-name-big) / 2 ln-pos/x: (540 - text-size? lastname font-name) / 2 line1-pos/x: (540 - text-size? line1 font-text) / 2 line2-pos/x: (540 - text-size? line2 font-text) / 2 inform layout [ box 400x250 white effect [draw badge'] ] ] pick-date: func [face] [ face/text: form request-date show face ] win: center-face layout [ Across pan: Panel [ Style Label Text 150 right font-name "Verdana" Style Drop-Down Drop-Down with [flag-face self input] font-name "Georgia" edge [color: 200.200.200] black snow Style Text Text 500 font-name "Georgia" font-size 16 Style Link Text font [colors: reduce [black blue] style: [underline]] font-size 12 Style Area Area 200x90 font-name "Georgia" edge [color: 200.200.200] Style Field Field font-name "Georgia" edge [color: 200.200.200] Style Check-Line Check-Line font-name "Verdana" Style Info Info edge [color: 200.200.200] 210.210.210 font-name "Georgia" Banner font-name "Georgia" font-size 36 linen "DevCon 2005 Registration" Text {If you intend to attend the REBOL Developer Conference 2005, you must fill in the following form.}; Please note that if you decide to reserve ;hotel rooms with this registration, your data will be provided to the ;hotels to allow for the reservation.} Link {This form can send this data via HTTP or EMail. Please make sure that your proxy settings are correct; if you use EMail please make sure that your email settings are correct. Click here to set up proxy or email settings.} bold font-size 16 [view-prefs] Pad 50 Across Label "Full name:" name: Field Return Label "EMail address:" email: Field Return Label "Address:" address: Area Return Pad 0x20 ;Text navy "Fill in the following data if you intend to visit Rome with us." Return ;Label visit-rome: Check-Line "I'd like to visit Rome" Return ;Label reserve-rome: Check-Line "Reserve a room with this registration" ; Link -1x24 "Hotel Virginia" [browse http://www.hotelvirginiaroma.com/] Return ;Label "Arrival date:" arrival-rome: Field Btn "Pick" [pick-date arrival-rome] Return ;Label "Departure date:" departure-rome: Field "29-Sep-2005" Btn "Pick" [pick-date departure-rome] Return ;Label "Room / no. of persons:" room-rome: Drop-Down 250 "Double, single use (€ 90)" "Double, shared (€ 45)" ; "Double, two persons (€ 90)" "Triple, shared, 1 person (€ 36.67)" "Triple, shared, 2 persons (€ 73.33)" ; "Triple, 3 persons (€ 110)" "Other (please specify in notes)" Return ;Label sharing-rome: Check-Line "Suggest me other people to share the room with" Return ;Label Btn "Check hotel total cost" [check-cost-rome] Return ;Label train: Check-Line "I will take the train to Milan (about € 47)" Return ;Label "Number of seats:" train-seats: Field Return ;Pad 0x20 ;Text navy "Fill in the following data if you intend to reserve a room in Treviglio." Return ;Label reserve-milan: Check-Line "Reserve a room with this registration" ; Link -1x24 "Read note" [face/font/color: first face/font/colors note-milan] Return ;Label "Arrival date:" arrival-milan: Field "29-Sep-2005" Btn "Pick" [pick-date arrival-milan] Return ;Label "Departure date:" departure-milan: Field "2-Oct-2005" Btn "Pick" [pick-date departure-milan] Return ;Label "Room / no. of persons:" room-milan: Drop-Down 250 "Double, single use (€ 52)" "Double, shared (€ 26)" ; "Double, two persons (€ 52)" "Other (please specify in notes)" Return ;Label sharing-milan: Check-Line "Suggest me other people to share the room with" Return ;Label Btn "Check hotel total cost" [check-cost-milan] Return ;Pad 0x20 Text navy "Other" Return Label banquet: Check-Line "I will join the banquet (€ 25)" Return Label "Number of meals:" banquet-seats: Field Return Text "Please note that details of the banquet are still to be determined." Return Pad 0x20 Label "Conference fee:" Info "€ 50" Return Label "Number of tickets:" tickets: Field "1" Return Label "Notes:" notes: Area Return Pad 0x20 Text navy "Personalized badge" Return Label "Text for the badge:" badge: Area Btn "Preview Badge" [preview-badge] Return Pad 0x20 Label Btn-Enter "Send" [send-data] Btn-Enter "Send EMail" [send-data/email] Btn "Save locally" [save-data] Btn "Load" [load-data] Btn-Cancel "Cancel" [quit] ] do [old-size: pan/size/y pan/size/y: 600 ofs: 600 - old-size] sc: Scroller 16x600 [pan/offset/y: value * ofs + 20 pan/changes: 'offset show pan] do [sc/redrag 600 / old-size] at 20x0 box 200.200.200 as-pair pan/size/x 20 at 20x620 box 200.200.200 as-pair pan/size/x 20 ] win/size/y: win/size/y - 20 pan/size/y: old-size save-data: does [ data: context get-face pan if error? try [write request-file/only/save form data] [ alert "Error while saving!" ] ] load-data: does [ if error? try [ data: construct load request-file/only set-face pan next second data show pan ] [ alert "Error while loading!" ] ] send-data: func [/email] [ data: context get-face pan either all [ msg: "Missing name." string? data/name not empty? data/name msg: "Missing EMail address." string? data/email not empty? data/email msg: "Missing address." string? data/address not empty? data/address ;msg: "You need to fill in arrival and departure date for Rome." ;any [ ; not data/reserve-rome ; all [ ; data/arrival-rome: attempt [to date! data/arrival-rome] ; data/departure-rome: attempt [to date! data/departure-rome] ; ] ;] ;msg: "Missing number of seats for the train." ;any [ ; not data/train ; data/train-seats: attempt [to integer! data/train-seats] ;] ;msg: "You need to fill in arrival and departure date for Milan." ;any [ ; not data/reserve-milan ; all [ ; data/arrival-milan: attempt [to date! data/arrival-milan] ; data/departure-milan: attempt [to date! data/departure-milan] ; ] ;] msg: "Missing number of seats for the banquet." any [ not data/banquet data/banquet-seats: attempt [to integer! data/banquet-seats] ] msg: "You need to fill in the number of conference tickets you wish to buy." data/tickets: attempt [to integer! data/tickets] ] [ price: 50 * data/tickets if data/banquet [ price: 25 * data/banquet-seats + price ] data: make data [total-fee: price] inform layout [ Banner join "Total fee: € " price Text 300 {Please note that the registration will not be considered valid until we receive the payment. Also please note that this fee only contains the conference fee and, if applicable, the banquet fee. Hotel costs will be payed directly to the Hotel at check-out time. Other costs (transportation, and so on) may apply.} Text 300 bold {You will receive a payment request via PayPal. Please follow the instructions in the email to send your payment. If you wish to use other forms of payment, please contact us via email at devcon@colellachiara.com.} ] either email [ if error? try [send/subject devcon@colellachiara.com form data "DevCon 2005 Registration"] [ alert "Problem sending form data. Please try again later." exit ] ] [ any [ attempt [read/custom http://www.colellachiara.com/cgi-bin/devcon-reg.cgi compose [post (form data) [Content-Type: "text/x-rebol"]]] attempt [read/custom http://www.rebol.net/cgi-bin/devcon.r compose [post (form data)]] (alert "Problem sending form data. Please try again later." exit) ] ] quit ] [ alert join "Please check your form: " msg ] ] view win