static function mailbulk()
local oDlg, oFont, oBrw,cfactart := "dial", nWild := 2
local cList, aFlds, aHdrs, oBold
local nChoice, uDataSource, nCombo1:= 1 , nCombo2:= 1
local aBtn:= {} ,aBtn2:= {}
local aGroepen:={}, aBron:={}
local lDubbel := .f., Ldeleted := .t.
local lUseFilter := .f.
PUBLIC aMailgroepen:= {}
use acties NEW
USE GROEPEN new
aMail:= groepen->(FW_DbfToArray())
aMailgroepen:= ArrTranspose( aMail )[ 2 ]
close groepen
ASize( aBtn, len(aMailgroepen))
ASize( aBtn2, len(aMailgroepen))
use mailbulk NEW VIA "DBFCDX"
mailbulk->(dbsetorder("email"))
//SET FILTER TO !DELETED() I pack all delete from now on !!
mailbulk->(dbgotop())
DBEVAL( { || If( AScan( aGroepen, FIELD->groep ) == 0, AAdd( aGroepen, FIELD->groep ), nil ) } )
ASORT( aGroepen )
mailbulk->(dbgotop())
DBEVAL( { || If( AScan( aBron, FIELD->nacebel ) == 0, AAdd( aBron, FIELD->nacebel ), nil ) } )
ASORT( aBron )
countselection()
//DBSELECTAREA( "mailbulk" )
DEFINE FONT oBold NAME 'CALIBRI' SIZE 0,-12 BOLD
DEFINE FONT oFont NAME "CALIBRI" SIZE 0,-12
DEFINE DIALOG oDlg SIZE 1600,800 PIXEL TRUEPIXEL ;
TITLE "Mailings : ";
GRADIENT { { 1, nRGB( 125, 155, 175 ), nRGB( 125, 155, 175 ) } }
DEFINE BUTTONBAR oBar OF oDlg SIZE 56,56 2007
///////////////////////////////////////////////////////////////// BRW /////////////////////////////////////////////////
/*
{ "klantcode" , "Klant" ,nil, 45 }, ; // 1
{ "Adres" , "Straat" ,nil, 75 }, ; // 1
{ "Postcode" , "Post" ,nil, 35 }, ; // 1
{ "Gemeente" , "Gemeente" ,nil, 75 }, ; // 1
{ "Personen" , "Pers" ,nil, 40 }, ; // 3
{ "Totomzet" , "Omzet" ,nil, 50 }, ; // 3
{ "Dat_lst" , "Dat_Lst" ,nil, 50 }, ; // 3
*/
aVelden := { ;
{ "email" , "Email" ,nil, 150 }, ; // 7
{ "naam" , "Naam" ,nil, 100 }, ; // 1
{ "optout" , "Optout" ,nil, 50 }, ; // 1
{ "nomails" , "Nooit" ,nil, 50 }, ; // 1
{ "klanttype" , "Type" ,nil, 35 }, ; // 1
{ "Nacebel" , "Activiteit" ,nil, 150 }, ; // 1
{ "Groep" , "Groep" ,nil, 150 }, ; // 4
{ "Bron" , "Bron" ,nil, 150 }, ; // 3
{ "selectie" , "Sel" ,nil, 35 }, ; // 5
{ "dubbel" , "Dub" ,nil, 35 }, ; // 5
{ "mail001" , "M1" ,nil, 40 }, ; // 6
{ "mail002" , "M2" ,nil, 40 }, ; // 6
{ "mail003" , "M3" ,nil, 40 }, ; // 6
{ "mail004" , "M4" ,nil, 40 }, ; // 6
{ "mail005" , "M5" ,nil, 40 }, ; // 6
{ "mail006" , "M6" ,nil, 40 }, ; // 6
{ "mail007" , "M7" ,nil, 40 }, ; // 6
{ "mail008" , "M8" ,nil, 40 }, ; // 6
{ "mail009" , "M9" ,nil, 40 }} // 19
@ 70,10 XBROWSE oBrw size 1400,500 PIXEL OF oDlg font oFont ;
DATASOURCE "mailbulk";
COLUMNS aVelden;
AUTOSORT CELL LINES NOBORDER FOOTERS
//FASTEDIT
// oBrw:bRClicked := { || changeindex_klant ( oBrw ),oBrw:refresh() }
//oBrw:nEditTypes = EDIT_GET
// oBrw:aCols[1]:bRClickHeader := {|| oBrw:Seek( "" ), DBSETORDER("klantnum"),oBrw:refresh()}
oBrw:nEditTypes = EDIT_GET
oBrw:lF2KeyToEdit := .t. // Edit when F2 is pressed
oBrw:bRClickHeaders := { || XbrColSelector( oBrw ) }
// oBrw:bRClicked := { || XbrShowSizes( oBrw ) }
oBrw:SetChecks()
//oBrw:bKeychar := {|nkey| iif(nkey=VK_ADD,MsgInfo("Mi Funcion"),)}
//oBrw:bKeyDown = { | nKey |(IIF(nKey = VK_INSERT, MsgInfo("Insert") ,IIF(nKey = VK_ADD , MsgInfo("ADD") , ) , ) oBrw:Refresh()) }
oBrw:bKeyDown := {|nkey| iif(nkey=VK_ADD, iif(oBrw:sel:VALUE=.t.,oBrw:sel:VarPut( .F. ),oBrw:sel:VarPut( .t. )) ,)}
oBrw:bron:bClrStd := { || showcolors(oBrw:bron:Value) }
//oBrw:nRowSel := 1 and oBrw:Refresh() should bring the current row to top.
//oBrw:M1:bLClickHeader := { |r,c,f,oCol| countacties(M1),oBrw:refresh() }
// Relevant Code
/*
oBrw:M9:nFooterType := AGGR_COUNT
oBrw:M9:bSumCondition := { || mailbulk->mail009 }
oBrw:MakeTotals()
*/
for n := 1 to Len( oBrw:aCols )
WITH OBJECT oBrw:aCols[ n ]
if :cDataType != 'L'
:uBarGetVal := uValBlank( :Value )
:cBarGetPic := :cEditPicture
endif
END
next
/*
for n := 1 to Len( oBrw:aCols )
WITH OBJECT oBrw:aCols[ n ]
if FieldType( n ) != 'L'
:uBarGetVal := uValBlank( fieldGet( n ) )
if FieldType( n ) == 'N'
:cBarGetPic := NumPict( FieldLen( n ), FieldDec( n ) )
endif
endif
END
next
oBrw:lGetBar := .F.
//oBrw:lSeekWild := .t.
*/
//
/*
WITH OBJECT oBrw:InsCol( 1 )
:bEditValue := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
:SetCheck()
:nHeadBmpNo := 2
END
*/
WITH OBJECT oBrw
/*
WITH OBJECT oBrw
:Sel:SetCheck( nil, nil, { 'Si', 'No' } )
END
*/
// :M7:bLClickHeader := { |r,c,f,oCol| ShowCount( oCol ) }
// :M6:bLClickHeader := { |r,c,f,oCol| ShowCount( oCol ) }
WITH OBJECT:Groep
:nEditType := EDIT_LISTBOX
:aEditListTxt := aGroepen
:uBarGetVal := uValBlank( :Value )
:aBarGetList:= aGroepen
END
WITH OBJECT:activiteit
:nEditType := EDIT_LISTBOX
:aEditListTxt := aBron
:uBarGetVal := uValBlank( :Value )
:aBarGetList:= aBron
END
:SetGroupHeader( "Mailings", oBrw:oCol("M1"):nCreationOrder, oBrw:oCol("M9"):nCreationOrder )
:bRClicked := {|nRow, nCol| MenuPop( nRow,nCol, oBrw ),oBrw:refresh() }
*/
// :nFreeze:=11
:nFreeze:=4
:lSeekbar := .T.
:lFooter := .t.
:email:bFooter := { | oCol | Len( oBrw:aSelected ) }
:bRecSelHeader := { || "RowNo" }
:bRecSelData := { |o| o:KeyNo }
:bRecSelFooter := { |o| o:nLen }
:oRecSelFont := oFont // optional
:nRecSelWidth := "999999" // required size
//:bKeyChar := { |nKey| If( nKey == VK_ADD, ( msginfo(nKey), oBrw:selectie:VarPut( .t. )) , nil ) }
// :bKeyChar := { |nKey| If( nKey == VK_RETURN,;
// ( oBrw:sel:VarPut( .t. ) , oBrw:refresh() ), nil ) }
// :bOnChange := { |oCol,uOldVal| oBrw:kleur:VarPut( tempfoto->foto ) }
//:nStretchCol := 10
//:lDisplayZeros := .f.
//:nStretchCol := 4
/*
:lIncrFilter := .t.
:lSeekWild := ( nWild == 2 )
:cFilterFld := "Klant_nr"
*/
:bClrEdits := { || { CLR_BLACK, CLR_YELLOW }}
:bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
// Searchbalk
//:lIncrFilter := .t.
//:lSeekWild := ( nWild == 2 )
//:cFilterFld := "naam"
//:bFooters := { |oCol| If( Empty( oCol:cOrder ), "", oBrw:cSeek("") ) }
//:oSeek := TSeek():New( oBrw )
//:bChange := { || SET_SCOPE_mailings(aMails),oStru:Refresh(),oBrw:setfocus(),odlg:update() }
END
BrwBarBtns( oBar, oBrw )
oBrw:CreateFromCode()
///////////////////////////////////////////////////////////////// BRW2 /////////////////////////////////////////////////
aVelden2 := { ;
{ "Code" , "Code" ,nil, 60 }, ; // 7
{ "Lijst" , "Lijst" ,nil, 35 }, ; // 1
{ "Datum" , "Datum" ,nil, 110 }, ; // 1
{ "Benaming" , "Omschrijving" ,nil, 150 }, ; // 1
{ "Verzonden" , "Send" ,nil, 60 }, ; // 1
{ "Opens" , "Open" ,nil, 60 }, ; // 1
{ "Bounced" , "Bounce" ,nil, 60 }, ; // 1
{ "Optout" , "OptOut" ,nil, 60 }, ; // 1
{ "Noopen" , "No_Open" ,nil, 60 }, ; // 19
{ "Titel" , "Mailing Titel" ,nil, 350 }} // 19
@ 590,10 XBROWSE oBrw2 size 1400,150 PIXEL OF oDlg font oFont ;
DATASOURCE "acties";
COLUMNS aVelden2;
AUTOSORT CELL LINES NOBORDER FOOTERS
//FASTEDIT
oBrw2:nEditTypes = EDIT_GET
oBrw2:lF2KeyToEdit := .t. // Edit when F2 is pressed
oBrw2:bRClickHeaders := { || XbrColSelector( oBrw ) }
oBrw2:bRClicked := { || XbrShowSizes( oBrw ) }
//oBrw:M1:bLClickHeader := { |r,c,f,oCol| countacties(M1),oBrw:refresh() }
WITH OBJECT oBrw2
*/
:lFooter := .t.
:bRecSelHeader := { || "RowNo" }
:bRecSelData := { |o| o:KeyNo }
:bRecSelFooter := { |o| o:nLen }
:oRecSelFont := oFont // optional
:nRecSelWidth := "999999" // required size
:bClrEdits := { || { CLR_BLACK, CLR_YELLOW }}
:bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
END
oBrw2:CreateFromCode()
///////////////////////////////////////////////// KNOPPEN VOOR PLOEGEN FILTER /////////////////////////////////////////////////////////////////
/*
@ 60, 1450 CHECKBOX lDubbel PROMPT "Dubbels" SIZE 60,20 PIXEL OF oDlg ;
ON CHANGE ( oDlg:AEvalWhen(), ;
oBrw:cAlias )->( SetFilterLogical( oBrw, lDubbel, lUseFilter ) )
*/
@ 60, 1550 CHECKBOX lDeleted PROMPT "Deleted" SIZE 60,20 PIXEL OF oDlg ;
ON CHANGE ( oDlg:AEvalWhen(), ;
oBrw:cAlias )->( SetFilterDeleted( oBrw, lDeleted ) )
nMove:=0
nTop:= 80
nLeft:= 1450
for ib = 1 to len(aMailgroepen)
nMove+=30
if ib = 16
nMove:=30
nTop:= 80
nLeft:= 1350
endif
@ nTop+nMove,nLeft BTNBMP aBtn[ib] OF oDlg SIZE 150, 25 NOBORDER PROMPT alltrim(aMailgroepen[ib]) 2007 ACTION (SET_SCOPE_mailbulk(::cCaption), oBrw:GoTop(),oBrw:setfocus(), oBrw:Refresh() ) font oBold CENTER
next
nMove+=30
@ nTop+nMove,nLeft BTNBMP aBtnall OF oDlg SIZE 150, 25 NOBORDER PROMPT "Alle Mails" 2007 ACTION (("mailbulk")->( ORDSCOPE(0, "" )) ,("mailbulk")->( ORDSCOPE(1, "" ) ), oBrw:GoTop(), oBrw:Refresh(),oBrw:setfocus() ) font oBold CENTER
nMove+=30
@ nTop+nMove,nLeft BTNBMP aBtnGemeente OF oDlg SIZE 150, 25 NOBORDER PROMPT "Deze gemeente" 2007 ACTION (SET_SCOPE_gemeente(), oBrw:GoTop(), oBrw:Refresh(),oBrw:setfocus() ) font oBold CENTER
nMove+=30
@ nTop+nMove,nLeft BTNBMP aBtnimport OF oDlg SIZE 150, 25 NOBORDER PROMPT "Read YMLP" 2007 ACTION (readymlp(), oBrw:GoTop(), oBrw:Refresh(),oBrw:setfocus() ) font oBold CENTER
nMove+=30
@ nTop+nMove,nLeft BTNBMP aBtnexport OF oDlg SIZE 150, 25 NOBORDER PROMPT "Export YMLP" 2007 ACTION (exportymlp(), oBrw:GoTop(), oBrw:Refresh(),oBrw:setfocus() ) font oBold CENTER
@ 590,1450 BTNBMP oBtn OF oDlg SIZE 100, 35 NOBORDER ;
PROMPT { || If( oBrw:lGetBar, "Hide GetBar", "ShowGetBar" ) } 2007 ;
ACTION ( oBrw:lGetBar := ! oBrw:lGetBar, oBrw:Refresh() ) FONT oBold CENTER
@ 630,1450 BTNBMP oBtn OF oDlg SIZE 100, 35 NOBORDER PROMPT "Set Filter" 2007 ;
ACTION ( oBrw:cAlias )->( SetFilter( oBrw ) ) FONT oBold CENTER
@ 670,1450 BTNBMP oBtn OF oDlg SIZE 100, 35 NOBORDER PROMPT "Clear Filter" 2007 ACTION ( oBrw:cAlias )->( DBCLEARFILTER(),oBrw:Refresh(), oBrw:SetFocus() ) FONT oBold CENTER
@ 710,1450 BTNBMP oBtn OF oDlg SIZE 100, 35 NOBORDER PROMPT "Wis Selectie" 2007 ;
ACTION ( Clearselection(),oBrw:refresh(),oBtntot:refresh() ) FONT oBold CENTER
@ 750,1450 BTNBMP oBtntot OF oDlg SIZE 100, 35 NOBORDER PROMPT { || c_totselected } 2007 ;
ACTION ( countselection(),oBrw:refresh(),oBtntot:refresh() ) FONT oBold CENTER UPDATE
@ 750,1100 BTNBMP oBtnSend OF oDlg SIZE 100, 35 NOBORDER PROMPT { || c_totsend } 2007 ;
ACTION ( countselection(),oBrw:refresh(),oBtntot:refresh() ) FONT oBold CENTER UPDATE
/*
@ 150,1250 BTNBMP oBtn OF oDlg SIZE 120, 25 NOBORDER PROMPT " Clear en Zoek" 2007 ACTION (oBrw:seek(""),('klant')->(DBGOTOP()),oBrw:SetFocus())
@ 180,1250 BTNBMP oBtn2 OF oDlg SIZE 120, 25 NOBORDER PROMPT " Email Rappel 1" 2007 ACTION ( druk_rappel(1),sendmail(1), oBrw:SetFocus() )
@ 210,1250 BTNBMP oBtn2 OF oDlg SIZE 120, 25 NOBORDER PROMPT " Email Rappel 2" 2007 ACTION ( druk_rappel(2),sendmail(2), oBrw:SetFocus() )
@ 240,1250 BTNBMP oBtn2 OF oDlg SIZE 120, 25 NOBORDER PROMPT " Facturen" 2007 ACTION xbrowse("factboek")
@ 270,1250 BTNBMP oBtn2 OF oDlg SIZE 120, 25 NOBORDER PROMPT " Copy Mail" 2007 ACTION (changeemail(),oBrw:refresh() )
*/
///////////////////////////////////////////////// KNOPPEN VOOR PLOEGEN TOEWIJZEN /////////////////////////////////////////////////////////////////
nMove:=0
nTop:= 755
nLeft:= -100
nBtnsize = 100
for i = 1 to len(aMailgroepen)
nMove+=105
@ nTop,nLeft+nMove BTNBMP aBtn2[i] OF oDlg SIZE nBtnsize, 25 NOBORDER PROMPT aMailgroepen[i] 2007 ACTION (setgroep(oBrw,::cCaption),oBrw:GoTop(),oBrw:refresh(),oBrw:setfocus()) font oBold CENTER
aBtn2[i]:bClrGrad := { | lMouseOver | If( ! lMouseOver,{ { 0.1, 16764573, 16764573 },{ 0.1, 16764573, 16764573 } },{ { 0.1, 11524015, 11524015 },{ 0.1, 11524015, 11524015 } } ) }
next
ACTIVATE DIALOG oDlg CENTERED
//on init ( SET_SCOPE_mailings(aMails),oBrw:gotop(),oBrw:setfocus(),oStru:refresh(),odlg:update() )
RELEASE FONT oFont
close all
return nil
function showcolors(cVeld)
local cKleur:=""
local aColorPairs := { ;
{ CLR_BLACK, MY_LIGHTGREEN },; //1
{ CLR_BLACK, MY_GREEN},; //2
{ CLR_BLACK, MY_PAARS},; //3
{ CLR_BLACK, MY_LIGHTYELLOW },; //4
{ CLR_BLACK, MY_YELLOW }} //5
do case
case cVeld = "MAVECO"
cKleur = aColorPairs[2]
case cVeld = "YMLP"
cKleur = aColorPairs[3]
case left(cVeld,6) = "ONLINE"
cKleur = aColorPairs[5]
otherwise
cKleur = aColorPairs[1]
endcase
return cKleur
static function SetFilter( oBrw )
local cFilter := ""
local n, oCol, uVal, cType
cursorwait()
for n := 1 to Len( oBrw:aCols )
oCol := oBrw:aCols[ n ]
if ! Empty( uVal := oCol:uBarGetVal )
if !Empty( cFilter )
cFilter += " .AND. "
endif
cType := ValType( uVal )
do case
case cType == 'C'
uVal := Upper( AllTrim( uVal ) )
// cFilter += '"' + uVal + '" $ UPPER( ' + FieldName( n ) + " )"
cFilter += '"' + uVal + '" $ UPPER( ' + oCol:CExpr + " )"
otherwise
// cFilter += FieldName( n ) + " == " + cValToChar( uVal )
cFilter += oCol:cExpr + " == " + cValToChar( uVal )
endcase
endif
next
*******************************
*/
//msginfo(cFilter)
if Empty( cFilter )
if ! Empty( DBFILTER() )
DBCLEARFILTER()
oBrw:Refresh()
endif
else
if !( DBFILTER() == cFilter )
SET FILTER TO &cFilter
GO TOP
oBrw:Refresh()
endif
endif
oBrw:SetFocus()
return nil
The indexes are like this :
function mailreorganisatie()
field email,groep,naam,gemeente,klanttype,mail001,nacebel,postcode,mail002,mail003,mail004,mail005,bron,selectie,totomzet
field mail006,mail007,mail008,mail009,dubbel
cursorwait()
erase mailbulk.cdx
use mailbulk NEW VIA "DBFCDX" EXCLUSIVE
select mailbulk
PACK
index on upper(email) tag email
INDEX on upper(groep)+upper(naam) tag groep
INDEX on upper(naam) tag naam
INDEX on upper(gemeente)+upper(groep) tag Nacebel
INDEX on upper(gemeente)+upper(nacebel) tag gemeente
INDEX on upper(klanttype)+upper(email) tag type
INDEX on upper(mail001) tag Mail001
INDEX on upper(mail002) tag Mail002
INDEX on upper(mail003) tag Mail003
INDEX on upper(mail004)+upper(bron) tag Mail004
INDEX on upper(mail005)+upper(bron) tag Mail005
INDEX on upper(mail006)+upper(bron) tag Mail006
INDEX on upper(mail007)+upper(bron) tag Mail007
INDEX on upper(mail008)+upper(bron) tag Mail008
INDEX on upper(mail009)+upper(bron) tag Mail009
INDEX on upper(bron) tag bron
INDEX on str(totomzet) tag omzet
INDEX on selectie tag selectie
INDEX on upper(nacebel)+upper(postcode) tag nacebel
INDEX ON dubbel TAG dubbel
INDEX ON DELETED() TAG DELETED
close mailbulk
msginfo("Reindexering gedaan")
return NIL