grails charts with sparklines/zingchart - grails

I'm looking to make a bar graph for my webapp that takes data from a mySQL server. I want to use either sparklines or zinchart for my webapp. I've already tried to use them myself but I keep getting stuck. For sparklines I am using this in inside my body tads:
<sparklines:bar id="id" values="threads" />
where id is the id of my table and threads is the column with the relevant data. ID would be on the x axis and threads on the y. The sparkline code above compiled and seemed to work, except that where my graph was supposed to be there was just one word "Loading..."
As for zingapp I used the example in the plugin page:
<zing:chart type="area" width="700" height="350"
container="acceptToConvertChart" data="${data}" xLabels="${labels}" effect="4" />
but just changed data to dbContent, which is mapped from my controller to my view like so:
def appProjects = Threadcount.list()
[dbContent: appProjects]
and for "labels" I used dbContent.id. When I ran the zingChart code I got the following error:
No signature of method:
zingchart.ZingChartTagLib$_closure2_closure3.doCall() is applicable
for argument types: (threadsapp.Threadcount) values:
[threadsapp.Threadcount : 1] Possible solutions:
doCall(java.lang.Object, java.lang.Object), call(),
call([Ljava.lang.Object;), call(java.lang.Object),
call(java.lang.Object, java.lang.Object), findAll()
it also says that the line: container="acceptToConvertChart" data="${data}" xLabels="${labels}" effect="4"/>
is the culprit.
Does anyone know the proper syntax to make either of the two code snipets work? Or if you have had the same problem or something very similar, how did you fix it?

Related

Acumatica Customization: Add PO Nbr column to SO Line

I am trying to create a customization to add the PO Nbr associated in the PO Link graph to a column in the SO Line. I know the link is made in the SOLineSplit table, but I am struggling with how to actually show that field in the SO Line. I have made a custom Usr field for PO Nbr, but not sure what I should be entering in the attributes (or DAC extension, whatever is the best way) in order to show the PO Nbr data from the SOLineSplit table.
I remember struggling with this early on, so it's an excellent question. The challenge is that you mention getting to the PO from the SO LINE, but an SO Line can be split across multiple PO's. That's why you end up having to dig into the SOLineSplit for the link. Let's take a look at the link from SOLineSplit to PO...
There are a couple of possibilities when you look into the SOOrderEntry graph. The following code snippets show relationships. Your SOLineSplit may have a direct reference to the PO/POLine as shown here:
PXSelectBase<POLine> selectlinkedDropShips = new PXSelectJoin<POLine,
InnerJoin<SOLineSplit, On<SOLineSplit.pOType, Equal<POLine.orderType>,
And<SOLineSplit.pONbr, Equal<POLine.orderNbr>,
And<SOLineSplit.pOLineNbr, Equal<POLine.lineNbr>>>>>,
Where<SOLineSplit.orderType, Equal<Current<SOOrder.orderType>>,
And<SOLineSplit.orderNbr, Equal<Current<SOOrder.orderNbr>>,
And<POLine.orderType, Equal<POOrderType.dropShip>>>>>(this);
If that simple path doesn't get you there, the more detailed path of an SO to a PO lies in the INItemPlan reflecting the demand of the SOLineSplit (via the PlanID) and then tied to POLine via POLine.PlanID = INItemPlan.SupplyPlanID as shown in the following snippet.
foreach (PXResult<POLine, POOrder, INItemPlan, SOLineSplit> res in PXSelectJoin<POLine,
InnerJoin<POOrder, On<POLine.FK.Order>,
InnerJoin<INItemPlan, On<INItemPlan.supplyPlanID, Equal<POLine.planID>>,
InnerJoin<SOLineSplit, On<SOLineSplit.planID, Equal<INItemPlan.planID>,
And<SOLineSplit.pOType, Equal<POLine.orderType>,
And<SOLineSplit.pONbr, Equal<POLine.orderNbr>,
And<SOLineSplit.pOLineNbr, Equal<POLine.lineNbr>>>>>>>>,
Where<POLine.orderType, Equal<Required<POLine.orderType>>,
And<POLine.orderNbr, Equal<Required<POLine.orderNbr>>,
And2<Where<POLine.cancelled, Equal<boolTrue>,
Or<POLine.completed, Equal<boolTrue>>>,
And2<Where<POOrder.orderType, NotEqual<POOrderType.dropShip>,
Or<POOrder.isLegacyDropShip, Equal<True>>>,
And<SOLineSplit.receivedQty, Less<SOLineSplit.qty>,
And<SOLineSplit.pOCancelled, NotEqual<boolTrue>,
And<SOLineSplit.completed, NotEqual<boolTrue>>>>>>>>>
.Select(graph, poOrder.OrderType, poOrder.OrderNbr))
{...
As you can imagine, you would have to set some rules around restricting an SO Line to a single PO, but that honestly would be more trouble than it's worth as the standard functionality is valuable in being more robust. I would suggest either putting your link in the Allocations list (or Line Details in more recent versions of Acumatica ERP) or produce a smart panel popup to show all the PO links per splits of the current SO Line.

How to exclude multiple values in OData call?

I am creating a SAPUI5 application. This application is connected to a backend SAP system via OData. In the SAPUI5 application I use a smart chart control. Out of the box the smart chart lets the user create filters for the underlying data. This works fine - except if you try to use multiple 'not equals' for one property. Is there a way to accomplish this?
I found out that all properties within an 'and_expression' (including nested or_expressions) must have unique name.
The reason why two parameters with the same property don't get parsed into the select options:
/IWCOR/CL_ODATA_EXPR_UTILS=>GET_FILTER_SELECT_OPTIONS takes the expression you pass and parses it into a table of select options.
The select option table returned is of type /IWCOR/IF_ODATA_TYPES=>EDM_SELECT_OPTION_T which is a HASHED TABLE .. WITH UNIQUE KEY property.
From: https://archive.sap.com/discussions/thread/3170195
The problem is that you cannot combine NE terms with OR. Because both parameters after the NE should not be shown in the result set.
So at the end the it_filter_select_options is empty and only the iv_filter_string is filled.
Is there a manual way of facing this problem (evaluation of the iv_filter_string) to handle multiple NE terms?
This would be an example request:
XYZ/SmartChartSet?$filter=(Category%20ne%20%27Smartphone%27%20and%20Category%20ne%20%27Notebook%27)%20and%20Purchaser%20eq%20%27CompanyABC%27%20and%20BuyDate%20eq%20datetime%272018-10-12T02%3a00%3a00%27&$inlinecount=allpages
Normally I want this to exclude items with the category 'Notebook' and 'Smartphone' from my result set that I retrieve from the backend.
If there is a bug inside /iwcor/cl_odata_expr_utils=>get_filter_select_options which makes it unable to treat multiple NE filters of the same component, and you cannot wait for an OSS. I would suggest to wrap it inside a new static method that will make the following logic (if you will be stuck with the ABAP implementation i would try to at least partially implement it when i get time):
Get all instances of <COMPONENT> ne '<VALUE>' inside a () (using REGEX).
Replace each <COMPONENT> with <COMPONENT>_<i> so there will be ( <COMPONENT>_1 ne '<VALUE_1>' and <COMPONENT>_2 ne '<VALUE_2>' and... <COMPONENT>_<n> ne '<VALUE_n>' ).
Call /iwcor/cl_odata_expr_utils=>get_filter_select_options with the modified query.
Modify the rt_select_options result by changing COMPONENT_<i> to <COMPONENT> again.
I can't find the source but I recall that multiple "ne" isn't supported. Isn't that the same thing that happens when you do multiple negatives in SE16, some warning is displayed?
I found this extract for Business ByDesign:
Excluding two values using the OR operator (for example: $filter=CACCDOCTYPE ne ‘1000’ or CACCDOCTYPE ne ‘4000’) is not possible.
The workaround I see is to select the Categories you actively want, not the ones you don't in the UI5 app.
I can also confirm that my code snippet I've used a long time for filtering also has the same problem...
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_MGW_ABS_DATA->FILTERING
* +-------------------------------------------------------------------------------------------------+
* | [--->] IO_TECH_REQUEST_CONTEXT TYPE REF TO /IWBEP/IF_MGW_REQ_ENTITYSET
* | [<-->] CR_ENTITYSET TYPE REF TO DATA
* | [!CX!] /IWBEP/CX_MGW_BUSI_EXCEPTION
* | [!CX!] /IWBEP/CX_MGW_TECH_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD FILTERING.
FIELD-SYMBOLS <lt_entityset> TYPE STANDARD TABLE.
ASSIGN cr_entityset->* TO <lt_entityset>.
CHECK: cr_entityset IS BOUND,
<lt_entityset> IS ASSIGNED.
DATA(lo_filter) = io_tech_request_context->get_filter( ).
/iwbep/cl_mgw_data_util=>filtering(
exporting it_select_options = lo_filter->get_filter_select_options( )
changing ct_data = <lt_entityset> ).
ENDMETHOD.

Prestashop all translatable-field display none for product page

Just new in Prestashop (1.6.0.6), I've a problem with my product page in admin. All translatable-field are to display:none (I inspect the code with chrome).
So when I want to create a new product I can't because the name field is required.
I thought that it was simple to find the .js whose do that but it isn't.
If somebody could help me, I would be happy.
Thank you for your help
Hi,
I make some searches and see that the function hideOtherLanguage(id) hide and show translatable-field element.
function hideOtherLanguage(id)
{
console.log(id_language);
$('.translatable-field').hide();
$('.lang-' + id).show();
var id_old_language = id_language;
id_language = id;
if (id_old_language != id)
changeEmployeeLanguage();
updateCurrentText();
}
When I set the Id to 1 (default language), it works. It seems that when I load the page, the function is called twice and the last calling, the id value is undefined. So the show() function will not work.
If somebody could help me. Thank you.
In my console, I see only one error
undefined is not a function.
under index.php / Line 1002
...
$("#product_form").validate({
...
But I find the form.tpl template and set this lines in comment but nothing change.
EDIT: According to comment on this link http://forge.prestashop.com/browse/PSCFV-2928 this can possibly be caused by corrupted installation file(s) - so when on clean install - try to re-download and reinstall...
...otherwise:
I got into a similar problem - in module admin page, when creating configuration form using PrestaShop's HelperForm. I will provide most probable cases and their possible solutions.
The solution for HelperForm was tested on PS 1.6.0.14
Generally there are 2 cases when this will happen.
First, you have to check what html you recieve.
=> Display source code - NOT in developer tools/firebug/etc...!
=> I really mean the pure recieved (JavaScript untouched) html.
Check if your translatable-fields have already the inline style "display: none":
Case 1 - fields already have inline style(s) for "display: none"
This means the template/html was already prepared this way - most probably in some TPL file I saw codes similar to these:
<div class="translatable-field lang-{$language.id_lang}"
{if $language.id_lang != $id_lang_default}style="display:none"{/if}>
Or particularly in HelperForm template:
<div class="translatable-field lang-{$language.id_lang}"
{if $language.id_lang != $defaultFormLanguage}style="display:none"{/if}>
Case 1 is the most easy to solve, you just have to find, where to set this default language.
Solutions
HelperForm
Look where you've (or someone else) prepared the HelperForm object - something like:
$formHelper = new HelperForm();
...
Somewhere there will be something like $formHelper->default_form_language = ...;
My wrong first solution was to get default form language from context - which might not be set:
$this->context->controller->default_form_language; //THIS IS WRONG!
The correct way is to get the default language from configuration - something like:
$default_lang = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
$formHelper->default_form_language = $default_lang->id;
...this particularly solved my problem...
Other form-creations
If there is something else than HelperForm used for form creations, the problem is still very similar.
You have to find where in files(probably tpls) is a condition for printing display:none for your case - then find where is the check-against-variable set and set it correctly yourself.
Case 2 - fields don't have inline style(s) for "display: none"
This means it is done after loading HTML by JavaScript. There are two options:
There is a call for hideOtherLanguage(), but there is wrongly set input language - that means no language will be displayed and all hidden.Solution for this one can be often solved by solving Case 1 (see above). In addition there can be programming error in not setting the after-used language id variable at all... then you would have to set it yourself (assign in JavaScript).
Some script calls some sort of .hide() on .translatable-field - you will have to search for it the hard way and remove/comment it out.
PS: Of course you can set the language to whatever you want, it is just common to set it to default language, because it is the most easier and the most clear way how to set it.

Orbeon : how to set the href of a <xhtml:a> tag, based on the current node in a <xforms:repeat>?

I'm trying to set a href attribute of a tag, based on the value of a leaf of the current node in a xforms:repeat. I've tried different syntax, but can't make it work. This is my last try (with a xforms:var). NOTE : the iteration and the list are ok, just the href is not (null pointer exception).
<xforms:repeat id="sous_menu_branches" nodeset="./Branches/Branche">
<xhtml:li>
<xforms:var name="brancheId" value="./BrancheId"/>
<xhtml:a href="/notes-saisie/?brancheId={$brancheId}">
<xforms:output ref="Nom" mediatype="text/html"/>
</xhtml:a>
</xhtml:li>
</xforms:repeat>
Actually, when I try to use xforms:var in my view (view.xsl), I always got a java null pointer error. As example, in the code snippet bellow, the first xforms:output throw an exception, but not the second one (which is supposed to access the same value) :
<xforms:repeat id="sous_menu_branches" nodeset="./Branches/Branche">
<xhtml:li>
<xforms:var name="current-item" value="."/>
<xforms:output id="my-count" ref="$current-item/Nom"/>
<xhtml:a href="/notes-saisie/?brancheId=888">
<xforms:output ref="./Nom" mediatype="text/html"/>
</xhtml:a>
</xhtml:li>
</xforms:repeat>
Can anybody tell me what am I doing wrong ? Thanks in advance !
You don't say which version of Orbeon Forms you are using, but I suspect you are using one which doesn't yet support xforms:var. Try using xxforms:variable instead.

XSLT 2.0. Loop inside a Function

Hitting my wall here...
I've got the following data where a Primary Employee may have multiple dependents. I need to create a function that will match the Employee's SSN (ab:SSN) against the Dependent_SSN and determine if one of them is a 'Spouse'. If so, then we'll return the Dependent_SSN of the 'Spouse'.
If not, we'll move on and return the next non-'Spouse' Dependent_SSN.
I'm trying to create a function as I think I'll need this more than once. The code snippet resides inside of an existing template that is doing other looping functionality.
I've tried this but Oxygen returns an error:
<xsl:function name="ab:PQB">
<xsl:param name="EE_SSN">
</xsl:param>
<xsl:for-each select="/ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]/ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]ab:dependents/ab:Dependent_SSN">
</xsl:for-each>
The Error returned is :
"Engine name: Saxon-PE 9.3.0.5
Severity: fatal
Description: Unexpected token name "wd:dependents" beyond end of expression"
I know I need to test the higher level SSN against looping through the dependents, but like I said "I'm against my wall" :)
Data is here:
<ab:Report_Entry>
<ab:SSN>888881006</ab:SSN>
<ab:Last_Name>Smith</ab:Last_Name>
<ab:First_Name>Kimberly</ab:First_Name>
<ab:dependents>
<ab:Dependent_SSN>888881009</ab:Dependent_SSN>
<ab:Relation ab:Descriptor="Spouse">
</ab:Relation>
</ab:dependents>
<ab:dependents>
<ab:Dependent_SSN>888881004</ab:Dependent_SSN>
<ab:Relation ab:Descriptor="Child">
</ab:Relation>
</ab:dependents>
<ab:dependents>
<ab:Dependent_SSN>888881003</ab:Dependent_SSN>
<ab:Relation ab:Descriptor="Child">
<ab:ID ab:type="Related_Person_Relationship_ID">Child</ab:ID>
</ab:Relation>
</ab:dependents>
<ab:dependents>
<ab:Dependent_SSN>888881001</ab:Dependent_SSN>
<ab:Dependent_ID>1032D-4</ab:Dependent_ID>
<ab:Relation ab:Descriptor="Child">
<ab:ID ab:type="Related_Person_Relationship_ID">Child</ab:ID>
</ab:Relation>
</ab:dependents>
</ab:Report_Entry>
Thank you to any advice!
You might want to define the type of the input parameter and the type of the function result and then you should write a function body returning a value of that type. Currently your description sounds rather procedural, that is not going to work with XSLT/XPath.
As for the error, I think in the path /ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]/ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]ab:dependents/ab:Dependent_SSN you need one more slash /ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]/ab:Report_Data/ab:Report_Entry[ab:Employee_ID=$EE_SSN]/ab:dependents/ab:Dependent_SSN to have a syntactically correct path. That should avoid the syntax error you get but is not likely to return the result you want.

Resources