Folks,
I am still stuck on the seemingly simple task displaying a pdf report based on records selected in a grid.
My setup is this.
I have a data table named �items� which contains items in inventory. The table contains a unique auto number field called �Item_Id�
I have created a Report called �itemsrpt� which is formatted to display the items that are picked in a grid control.
I have a web grid component that is used display the Item_Id in a freeform layout with a checkbox as {Item_Id} "input type="checkbox" name="Item_Id[]" value="{Item_Id}"
Which passes the Item_Id value if the box is checked.
The A5W page containing the grid component is �SelectItem.a5w� and contains two command buttons within the same table as the grid control that are pressed by the user to Print Order or Clear Selections. The source for this page is the following along with the javaS:
"head"
"script language="JavaScript""
function printLabels()
{
var toolbar = 'no';
var menubar = 'no';
var location = 'no';
var statusbar = 'no';
var resizable = 'yes';
var width = 750;
var height = 500;
window.open('PrintLabel.a5w?'+determineItemIdsFromCheckboxes(),'LabelsWindow','location='+location+',menubar='+menubar+',toolbar='+toolbar+',status='+statusbar+',resizable='+resizable+',width='+width+',height='+height)
}
function determineSelectedRadioButton()
{
var retVal = '';
for (i = 0; i " document.SelectItem.Item_Id.length; i++)
{
if (document.SelectItem.Item_Id[i].checked)
{
retVal = document.SelectItem.Item_Id[i].value;
break;
}
}
return retVal;
}
"/script language="JavaScript""
"%a5
Delete tmpl_ItemSelection
DIM tmpl_ItemSelection as P
tmpl_ItemSelection = a5w_load_component("ItemSelection")
'Following code allows you to override settings in the saved component, and specify the component alias (componentName property).
'Tip: Keep the componentName property short because this name is used in page URLs, and it will help keep the URLs short.
'Each component on a page must have a unique alias (componentName property).
with tmpl_ItemSelection
componentName = "ItemSelection"
end with
'=======================================compute the HTML for the Component=======================================
delete x_ItemSelection
dim x_ItemSelection as p
tmpl_ItemSelection.request = request
tmpl_ItemSelection.session = session
tmpl_ItemSelection.response = response
tmpl_ItemSelection.serversetting = serversetting
tmpl_ItemSelection.PageVariables = local_variables()
x_ItemSelection = a5w_run_Component(tmpl_ItemSelection)
'=============================================================================================================
if x_ItemSelection.RedirectURL "" "" then
response.redirect(x_ItemSelection.redirectURL)
end
end if
?x_ItemSelection.Output.Head.JavaScript
?x_ItemSelection.Output.Head.CSS_Link
%"
"!--Alpha Five Temporary Code Start - Will be automatically removed when page is published --"
"!--CSS for tmpl_ItemSelection --"
"link rel="stylesheet" type="text/css" href="file:///C:\Program Files\A5V6/css/Corporate/style.css""
"!--Alpha Five Temporary Code End --"
"meta name="generator" content="Alpha Five HTML Editor""
"title""/title"
"/head"
"body class="CorporatePageBODY" "
"p""br"
"table"
"tr"
"td""%a5 ?x_ItemSelection.Output.Body.Grid_Echo %""/td""/tr"
"tr"
"td""%a5 ?x_ItemSelection.Output.Body.UpdateErrors %""/td""/tr"
"tr"
"td""%a5 ?x_ItemSelection.Output.Body.Search_HTML %""/td""/tr"
"tr"
"form name=SelectItem method=post action="printlabel.a5w""
"td""%a5 ?x_ItemSelection.Output.Body.Grid_HTML %"
"input class="CorporateButton" type=submit value="Print Order"" 
"input class="CorporateButton" type=reset value="Clear Selections""
"/form""/td"
"/tr"
"tr"
"td""%a5 ?x_ItemSelection.Output.Body.DetailView_HTML %""/td""/tr""/table""/p""/form"
"/body"
***********************************************************
The �PrintLabel.a5w� page referenced in the javaS above contains source only.
"%a5
if eval_valid("Item_id")
if Item_id[1] = ""
goto ItemidNotSpecified
end if
dim filter as c
dim order as c
filter = Item_id.dump()
filter = *for_each(x,"Item_id = " + quote(x),filter)
filter = strtran(alltrim(filter), crlf()," .&. ")
order = ""
dim filename as c
filename = session.session_folder + chr(92) + "templabels.pdf"
filename = Report.saveas("Itemsrpt@[PathAlias.ADB_Path]\Items.dbf","PDF",filter,order,filename,.f.)
if file.exists(filename)
response.redirect(session.session_url + "templabels.pdf?" + time("hms3"))
end
end if
else
ItemidNotSpecified:
end if
%"
"head"
"meta name="generator" content="Alpha Five HTML Editor""
"title""/title"
"/head"
"body"
"p"Error: You must call page with a query string that specifies the Item ID(s)."br"
For example: "%a5 ? request.script_name %"?item_id[]=000001&item_id[]=000013"/p"
"p" "/p"
"/body"
**********************************************************
The error I get when trying to display a report after selecting any items (in this case items 68 and 69) is:
500 Internal Server Error
Script Error
Error:Invalid report filter expression: 'Item_id = "68" .&. Item_id = "69"'.
________________________________________
Alpha Five/6.0 Build/1600-2057 at DNMH211 Port 81
Most of this comes from the examples in the Alpha Help files but I am not working with it correctly obviously. Can anyone see the problem with my filter expression because I can�t.
Thanks for you time..
Chuck
I am still stuck on the seemingly simple task displaying a pdf report based on records selected in a grid.
My setup is this.
I have a data table named �items� which contains items in inventory. The table contains a unique auto number field called �Item_Id�
I have created a Report called �itemsrpt� which is formatted to display the items that are picked in a grid control.
I have a web grid component that is used display the Item_Id in a freeform layout with a checkbox as {Item_Id} "input type="checkbox" name="Item_Id[]" value="{Item_Id}"
Which passes the Item_Id value if the box is checked.
The A5W page containing the grid component is �SelectItem.a5w� and contains two command buttons within the same table as the grid control that are pressed by the user to Print Order or Clear Selections. The source for this page is the following along with the javaS:
"head"
"script language="JavaScript""
function printLabels()
{
var toolbar = 'no';
var menubar = 'no';
var location = 'no';
var statusbar = 'no';
var resizable = 'yes';
var width = 750;
var height = 500;
window.open('PrintLabel.a5w?'+determineItemIdsFromCheckboxes(),'LabelsWindow','location='+location+',menubar='+menubar+',toolbar='+toolbar+',status='+statusbar+',resizable='+resizable+',width='+width+',height='+height)
}
function determineSelectedRadioButton()
{
var retVal = '';
for (i = 0; i " document.SelectItem.Item_Id.length; i++)
{
if (document.SelectItem.Item_Id[i].checked)
{
retVal = document.SelectItem.Item_Id[i].value;
break;
}
}
return retVal;
}
"/script language="JavaScript""
"%a5
Delete tmpl_ItemSelection
DIM tmpl_ItemSelection as P
tmpl_ItemSelection = a5w_load_component("ItemSelection")
'Following code allows you to override settings in the saved component, and specify the component alias (componentName property).
'Tip: Keep the componentName property short because this name is used in page URLs, and it will help keep the URLs short.
'Each component on a page must have a unique alias (componentName property).
with tmpl_ItemSelection
componentName = "ItemSelection"
end with
'=======================================compute the HTML for the Component=======================================
delete x_ItemSelection
dim x_ItemSelection as p
tmpl_ItemSelection.request = request
tmpl_ItemSelection.session = session
tmpl_ItemSelection.response = response
tmpl_ItemSelection.serversetting = serversetting
tmpl_ItemSelection.PageVariables = local_variables()
x_ItemSelection = a5w_run_Component(tmpl_ItemSelection)
'=============================================================================================================
if x_ItemSelection.RedirectURL "" "" then
response.redirect(x_ItemSelection.redirectURL)
end
end if
?x_ItemSelection.Output.Head.JavaScript
?x_ItemSelection.Output.Head.CSS_Link
%"
"!--Alpha Five Temporary Code Start - Will be automatically removed when page is published --"
"!--CSS for tmpl_ItemSelection --"
"link rel="stylesheet" type="text/css" href="file:///C:\Program Files\A5V6/css/Corporate/style.css""
"!--Alpha Five Temporary Code End --"
"meta name="generator" content="Alpha Five HTML Editor""
"title""/title"
"/head"
"body class="CorporatePageBODY" "
"p""br"
"table"
"tr"
"td""%a5 ?x_ItemSelection.Output.Body.Grid_Echo %""/td""/tr"
"tr"
"td""%a5 ?x_ItemSelection.Output.Body.UpdateErrors %""/td""/tr"
"tr"
"td""%a5 ?x_ItemSelection.Output.Body.Search_HTML %""/td""/tr"
"tr"
"form name=SelectItem method=post action="printlabel.a5w""
"td""%a5 ?x_ItemSelection.Output.Body.Grid_HTML %"
"input class="CorporateButton" type=submit value="Print Order"" 
"input class="CorporateButton" type=reset value="Clear Selections""
"/form""/td"
"/tr"
"tr"
"td""%a5 ?x_ItemSelection.Output.Body.DetailView_HTML %""/td""/tr""/table""/p""/form"
"/body"
***********************************************************
The �PrintLabel.a5w� page referenced in the javaS above contains source only.
"%a5
if eval_valid("Item_id")
if Item_id[1] = ""
goto ItemidNotSpecified
end if
dim filter as c
dim order as c
filter = Item_id.dump()
filter = *for_each(x,"Item_id = " + quote(x),filter)
filter = strtran(alltrim(filter), crlf()," .&. ")
order = ""
dim filename as c
filename = session.session_folder + chr(92) + "templabels.pdf"
filename = Report.saveas("Itemsrpt@[PathAlias.ADB_Path]\Items.dbf","PDF",filter,order,filename,.f.)
if file.exists(filename)
response.redirect(session.session_url + "templabels.pdf?" + time("hms3"))
end
end if
else
ItemidNotSpecified:
end if
%"
"head"
"meta name="generator" content="Alpha Five HTML Editor""
"title""/title"
"/head"
"body"
"p"Error: You must call page with a query string that specifies the Item ID(s)."br"
For example: "%a5 ? request.script_name %"?item_id[]=000001&item_id[]=000013"/p"
"p" "/p"
"/body"
**********************************************************
The error I get when trying to display a report after selecting any items (in this case items 68 and 69) is:
500 Internal Server Error
Script Error
Error:Invalid report filter expression: 'Item_id = "68" .&. Item_id = "69"'.
________________________________________
Alpha Five/6.0 Build/1600-2057 at DNMH211 Port 81
Most of this comes from the examples in the Alpha Help files but I am not working with it correctly obviously. Can anyone see the problem with my filter expression because I can�t.
Thanks for you time..
Chuck
Comment