Best way to format currency in Yii gridview with no decimals - yii

Can Yii formatCurrency be used to format a currency value in cGridView with zero decimal places?
My current code is:
Yii::app()->locale->numberFormatter->'.'formatCurrency($data["'.$columnName.'"],Yii::app()->params->currency)
Which results in:
$50,000.00
And I want the result to be:
$50,000

Same problem discussed in Yii forum. Here I added some points. Please check the relevant link.
This is due to your locale currency settings. Go and check your YII framework folder/i18n/data you will fix the problem there... Find your locale and fix it.
In ii18n/Cnumberformatter.php
change line 162
$value=round($value,$format['maxDecimalDigits']);
to
$value=number_format($value,$format['maxDecimalDigits'],'.','');
refer this forum.
http://www.yiiframework.com/forum/index.php/topic/21002-formatcurrency-broken/

Related

Using datepicker in DotNetNuke-7 module

I'm a DNN beginner. I am currently building a module in which I can display statistics. My DotNetNuke Version is 7.0. The statistic is from Chartjs. For this statistic I would like to implement filters. These filters should be datepickers. As UI element I have now included a textbox with TextMode='Date'. But currently I have problems to set the default value of this field. The default value should be 01.01. of the current year.
I have already tried to set the value via C# server side. Unfortunately without success. I also tried to set the value on the client side via JavaScript. Unfortunately also without success.
These are some lines I tried in JavaScript:
document.getElementById(<%= this.DatumVon.AccessKey %>).value = "01.01.2019";
document.getElementById(<%= this.DatumVon.AccessKey %>).innerText = "01.01.2019";
document.getElementById("DatumVon").value = "01.01.2019";
These are some lines I tried in C# in the method "Page_Load" (server side):
this.DatumVon.Text = "01.01.2019";
I expected the value of the TextBox to be 01.01.2019. However, it currently only contains dd.mmm.yyyy. How can I change this?
Thank you.
There is something wrong with your localization. Please refer to the jQuery UI datepicker documentation (the "Localization" section), this should give you the answer.
wow... I solved it. I made it. Sometimes the solution is right in front of you and you don't see it. Michael Tobisch was absolutely right. When setting the value, the format is very important. I have always used the German format. A DNN TextBox with TextMode="Date" can't handle that. DNN converts this TextBox into an HTML input field. But this input field can only be clear with the format "yyyy-mm-dd". Depending on the geographical position of the client (at least that's what I think) the text displayed in the input field will be formatted. But the value of the input field always has the same format ("yyyy-mm-dd"). So very important here: the displayed text and the actual value have different formats.
Many thanks again to Michael Tobisch for the mental inspiration and the patience with me.
What is also important is that the access to the actual ID of a DNN element works as follows: this.Element.ClientID and not as I assumed before this.Element.AccessKey. This was also buggy.

Change default Culture/Decimal localization

I´m having a problem when trying to use a view Model that as a decimal property. Because my decimal region/culture format uses "," and not "." as decimal separator.
When I try to post that model, I get the following error:
The value xxx is not valid for the "field".
I´m using jquery.unobstrusive and jquery.validation. So when I make the submit the model get validated and a error is shown an a label with the error above.
The thing is, the property does not have any kind of attributes (Required,Regex,Range). So that error is produced by the middleware/framework when trying to parse the string to decimal.
If I type a decimal like: 40.05 the form submit with success.
If I type a decimal like: 40,05 the form submit fails with the above error.
I have already read about Globalization at:
https://docs.asp.net/en/latest/fundamentals/localization.html#globalization-and-localization-terms
but could not find the "path" trought setting my globalization culture.
At MVC4/5 we were used to add a web.config tag at system.web and that's it. But at MVC6 that doesn´t seem to be the way.
Any tips?

Validate a Single line of text column type of list in sharepoint 2010 to accept only numbers?

How to validate a Single line of text column type of list in sharepoint 2010 to enter accept only numbers?
Please don't tell me to use calculated column , I tried it and it didn't work for me as i want.
Please advice, thanks in advance.
This should work:
=ISNUMBER([MyColumn]+0)
Here is what seems to work for me (building on #Rob_Windsor; newlines added for readability):
=AND(
ISNUMBER(Number+0),
ISERR(FIND(".",Number)),
ISERR(FIND(",",Number)),
ISERR(FIND("$",Number)),
ISERR(FIND("+",Number)),
ISERR(FIND("-",Number)),
ISERR(FIND(" ",Number))
)
I went through the available functions and I don't see one that will validate whether a text value is a number.
BTW, is there a reason you are not using a Number field instead of a Single line of text?

Problem with Euro formatting (123.456,78) on Microsoft Access Report

On my report in Microsoft Access for all fields I have set-up this code in Control source:
=Replace(Replace(Replace(Format(Sum([NameOfTheField]),"#,###.00"),".",""),",","."),"",",")
and on this way I managed to replace format "123,456.78" to "123.456,78" because I need to have Euro formatting on report.
This code works ok but problem is when some column contains zero value, then I would like to replace "0" with "-" and I don't know how to achieve this?
And help is appreciated and many thanks for prompt replys!
Cheers:)
According to the docs you can specify a distinct/special format for 0 values; I would at least try if "#,###.00" => "#.###,00" does not 'work'.

Drupal Views - Custom / Modded SQL

I am having an issue with the "Profile Checkboxes" module which stores custom profile fields comma separated.
The issue is if I create a view to filter by a value. The SQL result ends up being something like this:
...AND (profile_values_profile_interests.value in ('Business and Investment'))...
Which will not return any data since the value is stored like this:
"Business and Investment, Case Law, Labor Law, Tax Law"
I just need to adjust the SQL so that it is making sure the field contains the selected value
Is there anything I can do to adjust this?
For a 'quick hack' solution, you could try implementing hook_views_query_alter(&$view, &$query) in a custom module, check $view->name (and eventually also $view->current_display) to ensure you are dealing with the right view/display, and then manipulate $query as needed.
EDIT: Looks like the underlying problem has been addressed by the module maintainer in the meantime - see John's answer ...
I'm the creator and maintainer of Profile Checkboxes and thought you might be interested to know that the new version of the module now stores the values as serialized and includes Views support. The feature is available in the current release version.
Check out the Views modify query module.