The following application examples are included in the PowerWeb demo program. Their complete source code is included in the demo download file.
4. Order Reservation - Application for browsing and editing customer reservations. It is an Alaska CXP application example which is developed in the PowerWeb way.
Code: Alles auswählen
FUNCTION Res(oSrv)
**
LOCAL html,style,;
aCCols := {{"customer_i","Customer",,60},;
{"LEFT(company_na,30)","Company",,200},;
{"LEFT(contact_na,25)","Contact",,160},;
{"TRIM(city) + ', ' + TRIM(country)","Location",,160},;
{"discount","Disc",,25,,"@Z"},;
{"res_count","Res",,25,,"@Z",,{clrDRed,clrBeige}}},;
aRCols := {{,"Prod",,30,,,,,"R"},;
{,"Product name",,300},;
{,"Qunty",,30,,,,,"R"}}
**
HASSNSET(oSrv,"Path",HAPATH(oSrv) + "data\reser")
SET PATH TO (HASSNGET(oSrv,"Path"))
DBOPEN("FOXCDX",{{{"Customer"},{"Customer","customer_i"}}},,,.T.)
HASSNSET(oSrv,"Customer","")
HASSNSET(oSrv,"ResId","")
HASSNSET(oSrv,"Operator","John Doe")
**
style = ;
"@media screen and (min-width:1250px)" +;
" {#Div {width:auto; height:650px}" +;
" #ResBrw {position:absolute; left:730px; top:110px}" +;
" #Toolbar {position:absolute; left:730px; top:450px}} " + chrCRLF +;
"@media screen and (max-width:1249px)" +;
" {#Div {width:auto; height:650px}" +;
" #ResBrw {position:absolute; left:730px; top:110px}" +;
" #Toolbar {position:absolute; left:730px; top:450px}} " + chrCRLF +;
"@media screen and (max-width:1200px)" +;
" {#Div {width:95%; height:1070px}" +;
" #ResBrw {position:absolute; left:0px; top:640px}" +;
" #Toolbar {position:absolute; left:0px; top:990px}}"
**
html = HDOCBGN(,{"files/reser.js"},style,,"Reservations - browse",,,,,,,;
{HSETGUI(,.T.)}) +;
HDLGBGN(,{1200},"Order reservation",icoPower,{,{,clrHoneyDew}},;
{,,,clrDefBG},{clrYellow,clrMBrown},,"C") +;
ResHead(oSrv) +;
HDIVBGN({10,,"R"},,,,,,{"Div"}) +;
HHEAD({1},,"Browse reservations",,{,{"mediumblue"}}) +;
HPARAG({,70},,"Click on a customer for reservations.",;
{{,12,"B"},{"brown"},,,,"H"}) +;
HBRWPGN({,110},{,500},"Customer",aCCols,{,,"CustPage"},20,,,;
{"CustResDisp"}) +;
HBRWGEN(,{,310},{{"","",0}},aRCols,,,,,{"ResId"},,{"ResBrw"}) +;
HTOOLBAR(,,;
{{"Add",bmpNewDoc,HTTPREDIR("ResAdd",,"B"),,,{"AddBtn"},.T.},;
{"Edit",icoEditText,HTTPREDIR("ResEdit",,"B"),,,{"EditBtn"},.T.},;
{"Delete",icoTrash,"ResDelClk()",,,{"DelBtn"},.T.}},;
{{110,30},,{,,,clrDefBG}},,{"Toolbar"}) +;
HDIVEND() + HDLGEND() + HDOCEND()
CLOSE ALL
RETURN html
*============================================================================*
FUNCTION ResAdd(oSrv)
**
HASSNSET(oSrv,"ResId","")
RETURN ResEdit(oSrv)
*============================================================================*
FUNCTION ResEdit(oSrv)
**
LOCAL aCat[0],aPrd[0],html,m_cat,m_prd,m_qty,m_pack,m_pri,m_det,;
aPack := {{"Standard","standard"},{"Gift","gift"}},;
cust := HASSNGET(oSrv,"Customer"), res_id := HASSNGET(oSrv,"ResId"),;
is_new := .F.
**
SET PATH TO (HASSNGET(oSrv,"Path"))
DBOPEN("FOXCDX",{{{"Customer"},{"Customer","customer_i"}},;
{{"Category"},{"Category","category_i"}},;
{{"Product"},{"Product","product_id"}},;
{{"Reservation"},{"Reservation","id"}}},,,.T.)
**
SELECT Customer
IF !EMPTY(cust)
SEEK cust
ELSE
cust = customer_i
HASSNSET(oSrv,"Customer",cust)
ENDIF
cust = "Customer: " + TRIM(cust) + " " + UTF8ENC(TRIM(company_na),852)
SELECT Category
DBEVAL({|| AADD(aCat,{TRIM(category_n),category_i})})
IF !EMPTY(res_id)
SELECT Reservation
SEEK res_id
m_prd = product_id; m_qty = quantity; m_pack = packaging
m_pri = IF(priority,"Y","N"); m_det = details
SELECT Product
SEEK m_prd
m_cat = category_i
ELSE
GO TOP
m_cat = category_i
SELECT Product
is_new = .T.
ENDIF
ORDSETFOCUS("category_i")
GO TOP
SEEK m_cat
DO WHILE category_i = m_cat .AND. !EOF()
AADD(aPrd,{UTF8ENC(product_na,852),product_id})
SKIP
ENDDO
CLOSE ALL
**
html = HDOCBGN(,{"files/reser.js"},,,"Reservations - edit",,,,,,,;
{HSETGUI(.T.,.T.)}) +;
HDLGBGN(,{1200},"Order reservation",icoPower,{,{,clrHoneyDew}},;
{,,,clrDefBG},{clrYellow,clrMBrown},,"C") +;
ResHead(oSrv) +;
HHEAD({10,20,"M"},,"Edit reservation",,{,{"mediumblue"}}) +;
HSAY({10,10,"R"},{600},cust,{,12,"B"},{clrBlue},,,"max-width:95%") +;
HFORMBGN({10,20,"R"},,,,,,,,,{"ResForm"},,"max-width:92%") +;
HFORMTBL(,;
{{35,"Category:",{140},"CB",m_cat,aCat,{,!is_new},;
{,"Category"},,,{,"SelFill('Product','Category','ResCatPrd')"}},;
{35,"Product:",{250},"CB",m_prd,aPrd,{,!is_new},{,"Product"}},;
{35,"Quantity:",{60},"SB",m_qty,{1,100},,{,"Quantity"}},;
{35,"Packaging:",,"RB",m_pack,aPack,,{,"Packaging"}},;
{35,"Priority:",,"RB",m_pri,{"No","Yes"},,{,"Priority"}},;
{120,"Notes:",{290,100},"ML",m_det,,,{,"Details"}}},;
{90,300}) +;
HFORMEND() +;
HTOOLBAR({10,50,"M"},,;
{{"Save",bmpSave,"ResSaveClk()"},;
{"Cancel",bmpDelete,HTTPREDIR("Res",,"B")}},;
{{110,30},,{,,,clrDefBG}},{{,,10}}) +;
HBREAK(2) + HDLGEND() + HDOCEND()
RETURN html
*============================================================================*
FUNCTION ResPrdStk(oSrv)
**
LOCAL html, aCat := {{"--- Select ---",""}},;
aCols := {{,"Prod",,30,,,,,"R"},;
{,"Product name",,300},;
{,"InStock",,40,,,,,"R"},;
{,"OnOrder",,40,,,,,"R"},;
{,"Capital",,60,,,,,"R"}}
**
SET PATH TO (HASSNGET(oSrv,"Path"))
DBOPEN("FOXCDX",{{{"Category"},{"Category","category_i"}}},,,.T.)
**
DBEVAL({|| AADD(aCat,{TRIM(category_n),category_i})})
CLOSE
HASSNSET(oSrv,"Img","")
html = HDOCBGN(,{"files/reser.js"},,,"Reservations - product stock",,,,,,,;
{HSETGUI(.T.,.T.)}) +;
HDLGBGN(,{1200},"Order reservation",icoPower,{,{,clrHoneyDew}},;
{,,,clrDefBG},{clrYellow,clrMBrown},,"C") +;
ResHead(oSrv) +;
HDIVBGN({10,,"R"},{,740},{,,,,,"A"},,,,,,"max-width:95%") +;
HHEAD({2},,"Product stock",,{,{"mediumblue"}}) +;
HSAY({,90},,"Category:") +;
HGET({90,90},{140},"CB",,aCat,,{"CatList"},,,{,"CatSelCng()"}) +;
HBRWGEN({,130},{,250},{{"",0,0,0}},aCols,,,,,,,{"PrdBrw"}) +;
HGRAPHRM({,410},{800,300},,{,,{,clrBlue}},{"GrpImg"}) +;
HDIVEND() +;
HTOOLBAR({10,20,"M"},,;
{{"Print",bmpPrint,HTTPREDIR("GrpPrdPrn",,"B")},;
{"Save",bmpSave,"GrpSaveClk()"}},;
{{110,30},,{,,,clrDefBG}},{{,,10}}) +;
HEDITDATA(,{{35,"File name:",{200,,30},,,,,{"File","File"}}},;
{80,220},"Save file",,,,{"SaveDlg"},"GrpSaveAct") +;
HBREAK(2) + HDLGEND() + HDOCEND()
RETURN html
*============================================================================*
FUNCTION GrpPrdPrn(oSrv)
**
LOCAL html, img := HASSNGET(oSrv,"Img")
**
html = IF(EMPTY(img),HHEAD(,,"No graph data",,{,,,,"C"}),;
HHEAD(,,"Category " + HASSNGET(oSrv,"Category"),,{,{clrBlue},,,"C"}) +;
HBREAK() +;
HIMG(,{800,300},img,"Graph",,{,,clrBlue},"C"))
RETURN HDOCBGN(,,,,,,,,,,,{"window.print();"}) + html + HDOCEND()
*============================================================================*
FUNCTION ResHead(oSrv,aCaps)
**
RETURN HMENU({3,3,"R"},,;
{{"Browse",bmpHome,"Res"},;
{"Edit",icoEdit,"ResEdit",,{,,,,.T.}},;
{"Product stock",icoChart,"ResPrdStk"},;
{"Exit",bmpExit,"ResExit"}},;
{,,,{,,,clrDefBG}},,,,"max-width:93%")
*============================================================================*
![Bild](https://www.sd-softdesign.com/gallery/PWEB_Res1.jpg)
![Bild](https://www.sd-softdesign.com/gallery/PWEB_Res2.jpg)
![Bild](https://www.sd-softdesign.com/gallery/PWEB_Res3.jpg)
5. Article Codebook - Application for creating, browsing, searching, editing and printing article codebook with 1.000.000 records. The codebook uses Serbian Latin language.
Code: Alles auswählen
FUNCTION Cb(oSrv)
**
LOCAL style, aHClr := {clrBlack,clrSkyBlue,clrDodgerBlue},;
auth := "SD-SoftDesign;Alaska Software Technology Partner;" +;
"www.sd-softdesign.com;info@sd-softdesign.com;***;" +;
"COBA Systems;www.cobasystems.com;coba@cobasystems.com"
**
HASSNSET(oSrv,"Path",HAPATH(oSrv) + "data\cbook")
SET PATH TO (HASSNGET(oSrv,"Path"))
**
style = ;
"@media screen and (min-width:1250px)" +;
" {#Div0 {height:350px}" +;
" #Div2 {position:absolute; left:390px; top:0px}" +;
" #Toolbar {position:absolute; left:0px; top:160px}}" + chrCRLF +;
"@media screen and (max-width:1249px)" +;
" {#Div0 {height:350px}" +;
" #Div2 {position:absolute; left:390px; top:0px}" +;
" #Toolbar {position:absolute; left:0px; top:160px}}" + chrCRLF +;
"@media screen and (max-width:900px)" +;
" {#Div0 {width:95%; height:860px}" +;
" #Div2 {position:absolute; left:0px; top:180px}" +;
" #Toolbar {position:absolute; left:0px; top:370px}}"
**
RETURN HDOCBGN(,{"files/cbook.js"},style,,"Article codebook",,,,,,,;
{HSETGUI(,.T.)}) +;
HDLGBGN(,{780},"Article codebook",icoPower,;
{,{,clrBeige},,{10,30}},{,,,clrDefBG},,,"C",,,"max-width:93%") +;
HHEAD(,,"Article Codebook",,{{"Verdana",30},{clrBlue},,,"C"}) +;
HDIVBGN({,40,"R"},,,,,,{"Div0"}) +;
HDIVBGN(,{"95%",,"M"},{,,,,,"A"}) +;
HBTN(,{385,150},;
"CREATE BIG DATA;Create a test.dbf database;with 1.000.000 records",;
icoDbf,{{,14,"B"},{{clrWhite,clrHgBG,clrMViolet},,,aHClr}},;
{{,,14},{40,40},,clrDefBG},{2,,,10},,,,,"CbDbfClk()") +;
HDIVEND() +;
HDIVBGN(,{"95%",,"M"},{,,,,,"A"},,,,{"Div2"}) +;
HBTN(,{385,150},;
"BROWSE BIG DATA;Browser with data from test.dbf;" +;
"and standard database operations",;
icoView,{{,14,"B"},{{clrWhite,clrSeaGreen,clrMGold},,,aHClr}},;
{{,,14},{40,40},,clrDefBG},{2,,,10},,,,,HTTPREDIR("CbBrw",,"B")) +;
HDIVEND() +;
HTOOLBAR(,,;
{{"Send mail",icoMail,HTTPREDIR("CbMail",,"B")},;
{"Make QR code",bmpQRCode,"CbQrcClk()"},;
{"Help",icoHelp,HTTPREDIR("CbHelp",,"B")},;
{"Authors",icoAuthor,"MsgInfo('" + auth + "','','Authors')",,;
{,,,,.F.}}},;
{{190,100},{{,14,"B"},{{clrDBlue,clrLBrown,clrMBrown},,,aHClr}},;
{,{32,32},,clrDefBG}},,{"Toolbar"}) +;
HDIVEND() +;
HDLGPOP(HIMG(,{260,260},,,,,,,{"QrcImg"}),"QRCode COBA SYSTEMS",,,;
{"QrcDlg"},"DlgClose('QrcDlg');") +;
PwBack() + HDLGEND() + HDOCEND()
*============================================================================*
FUNCTION CbBrw(oSrv)
**
LOCAL html,style,temp, path := HASSNGET(oSrv,"Path") + "\",;
aCols := {{"IF(flag_,'@8730;','')","St",,10},;
{"mark_","Code",,60},;
{"idname_","Acticle name",,140},;
{"meas_","UoM",,40},;
{"quan_","Stock" + chrLF + "quantity",,100,,"@Z 99,999,999,999.999"},;
{"price4_","Retail" + chrLF +"price",,100,,"9,999,999,999.99"},;
{"price0_","Net invoice" + chrLF +"price",,100,,"9,999,999,999.99"},;
{"price1_","Gross invoice" + chrLF +"price",,100,,"9,999,999,999.99"},;
{"price2_","Purchase" + chrLF +"price",,100,,"9,999,999,999.99"},;
{"price3_","Wholesale" + chrLF +"price",,100,,"9,999,999,999.99"},;
{"taxr_","Tax%",,40,,"999.9"}}
**
IF !FEXISTS(path + "Test.dbf") .OR. !FEXISTS(path + "Test.dbt") .OR. ;
!FEXISTS(path + "Test_s.ntx") .OR. !FEXISTS(path + "Test_n.ntx") .OR. ;
!FEXISTS(path + "Test_q.ntx") .OR. !FEXISTS(path + "Test_p.ntx")
RETURN ""
ENDIF
temp = HASSNGET(oSrv,"Temp")
IF(!EMPTY(temp) .AND. FEXISTS(temp),FERASE(temp),.T.)
HASSNSET(oSrv,"Temp",UNIQFNAME(path,,"DBF"))
HASSNSET(oSrv,"IsTemp",.F.)
**
SET PATH TO (path)
DBOPEN(,{{{"Test"},{"Test_s"}}},,,.T.)
**
style = ;
"@media screen and (min-width:1250px)" +;
" {#Menubar {width:1180px}" + chrCRLF +;
" #Div0 {width:auto; height:730px}" +;
" #Div1 {position:absolute; left:530px; top:110px}" +;
" #Toolbar {position:absolute; top:660px}} " + chrCRLF +;
"@media screen and (max-width:1249px)" +;
" {#Menubar {width:98%}" + chrCRLF +;
" #Div0 {width:auto; height:730px}" +;
" #Div1 {position:absolute; left:530px; top:110px}" +;
" #Toolbar {position:absolute; top:660px}} " + chrCRLF +;
"@media screen and (max-width:1100px)" +;
" {#Menubar {width:95%}" + chrCRLF +;
" #Div0 {width:95%; height:1350px}" +;
" #Div1 {position:absolute; left:0px; top:660px}" +;
" #Toolbar {position:absolute; top:1220px}}"
**
html = HDOCBGN(,{"files/cbook.js"},style,,"Article codebook") +;
HDLGBGN(,{1200},"Article codebook",icoPower,{,{,clrBeige}},;
{,,,clrDefBG},,,"C") +;
HMENU({3,3,"R"},,;
{{"Find code",,"javascript:CbFltClk('C')"},;
{"Find name",,"javascript:CbFltClk('N')"},;
{"Find word",,"javascript:CbFltClk('W')"},;
{"Filter quantity-",,"javascript:CbFltClk('Q-')"},;
{"Filter quantity0",,"javascript:CbFltClk('Q0')"},;
{"Filter quantity+",,"javascript:CbFltClk('Q+')"},;
{"Filter price-",,"javascript:CbFltClk('P-')"},;
{"Filter price+",,"javascript:CbFltClk('P+')"},;
{"Filter off",,"javascript:CbFltClk('OF')"},;
{"Print",,"javascript:CbPrnClk()"},;
{"Reindex",,"javascript:CbIndClk()"},;
{"Exit",,"CbExit"}},,,{"Menubar"}) +;
HDIVBGN({10,,"R"},,,,,,{"Div0"}) +;
HHEAD({1},,"Browse and edit articles",,{,{"mediumblue"}}) +;
HPARAG({,70},,"Click on an article for details.",{{,12,"B"},{"brown"}}) +;
HBRWPGN({,110},{500,510},,aCols,{,,"CbPage"},100,,,{"ArtDetDisp"},,;
{"CbBrw"}) +;
HDIVBGN(,{470,510},{,,,,,"A"},{,,clrMBlue},,,{"Div1"}) +;
HFORMBGN(,,,,,{,{,clrWhite},,5,,"A"},,,,{"ArtForm"}) +;
HFORMTBL(,;
{{35,"Article code:",{,,12,7},,,,,{,"Code"}},;
{35,"Article name:",{,,30,25},,,,,{,"Name"}},;
{35,"Unit of measure:",{,,5,3},,,,,{,"Meas"}},;
{35,"Stock quanitity:",{,,18,15},,,,,{,"Quan"}},;
{35,"Retail price:",{,,15,13},,,,,{,"Price4"}},;
{35,"Net invoice price:",{,,15,13},,,,,{,"Price0"}},;
{35,"Gross invoice price:",{,,15,13},,,,,{,"Price1"}},;
{35,"Purchase price:",{,,15,13},,,,,{,"Price2"}},;
{35,"Wholesale price:",{,,15,13},,,,,{,"Price3"}},;
{35,"Tax (%):",{,,5,5},,,,,{,"Tax"}},;
{35,"Date of change:",,"D",,,,{,"Date"}},;
{35,"ID:",{,,10,5},,,,,{,"Id"}},;
{35,"UUID:",{,,40,36},,,,,{,"Uuid"}},;
{35,"Flag:",,"2S",,,,{,"Flag"}},;
{120,"Description:",{340,,,5},"ML",,,,{,"Desc"}}},;
{130,350}) +;
HFORMEND() + HDIVEND() +;
HTOOLBAR(,,;
{{"Add",bmpNewDoc,"ArtAddClk()",,,{"AddBtn"}},;
{"Edit",icoEditText,"ArtEditClk()",,,{"EditBtn"},.T.},;
{"Delete",icoTrash,"ArtDelClk()",,,{"DelBtn"},.T.},;
{"Save",bmpSave,"ArtSaveClk()",,,{"SaveBtn"},.T.},;
{"Cancel",bmpDelete,"ArtCancClk()",,,{"CancBtn"},.T.}},;
{{110,30},,{,,,clrDefBG}},,{"Toolbar"}) +;
HEDITDATA(,{{35,"Value:",{160,,20},,,,,{"Filter","Filter"}}},;
{50,170},"Filter",,,,{"FltDlg"},"CbFltAct") +;
HEDITDATA(,;
{{35,"From code:",{100,,7},,,,,{"FrCode","FrCode"}},;
{35,"To code:",{100,,7},,,,,{"ToCode","ToCode"}}},;
{80,110},"Print",,,,{"PrnDlg"},"CbPrnAct") +;
HEDITDATA(,{{35,"Code:",{110,,7},,,,,{"Code_","Code_"}}},;
{50,110},"New code",,,,{"NewDlg"},"ArtNewAct") +;
HSCRP(HSETGUI(.T.,.T.) + " GetDisable(1,14); GetDisable(19);") +;
HDIVEND() + HDLGEND() + HDOCEND()
CLOSE
RETURN html
*============================================================================*
![Bild](https://www.sd-softdesign.com/gallery/PWEB_Cbook1.jpg)
![Bild](https://www.sd-softdesign.com/gallery/PWEB_Cbook2.jpg)