Menu

creation of a AttributeCurrency type

schirrms
2024-05-03
2024-05-06
  • schirrms

    schirrms - 2024-05-03

    Hi,

    I am working on an extention that (should) add a cost field on some of our CIs classes. This would be a calculated field based on some values defined in another class, this class containing some 'brick level' cost. While it's not done, I do think that I should be able to that by following this great tutorial : https://www.itophub.io/wiki/page?id=3_0_0:customization:cascade-update

    But I need to be sure that my 'brick level cost' are 'true numeric fields'. For now, I'm using a Decimal type. However, if I want to "localise the display" (for instance 1234.56 shoud be displayed "1,234.56" for an english reader and "1 234,56" for a french reader) I don't see how to do that.

    Those localization parameters are mostly 'naturally' available in PHP (ok, that would be a 'server side' customization, not very useful in case of an international organization). I do suspect that this could also be possible in javascript (so inside the client browser) but this seems to be way over my (limited) coder level.

    Do I miss something easy ? Searching trough the forum, I found references of the 'cost field' for the contrat, but I was a little "surprised" to see that the cost is actually stored as a string… Not the best start for a field used in computation…

    So, any suggestion ?

    By the way, should I decide to create a 'custom display' based on the User choosen Language in iTop, how can I get the User language ?

    TIA,

    Pascal

     
  • Jeffrey Bostoen

    Jeffrey Bostoen - 2024-05-03

    It would be quite difficult indeed. So you actually have users with different language / decimals on one iTop instance? In the read-only value, you could perform some magic. In the frontend, you'd need to find some other trick I suppose; and also make sure iTop processes the data properly.

    I remember something like Dict::GetUserLanguage() - you might want to check out that part. Then again, it depends if you want to make regional settings (decimal notation) dependent on language . Maybe you could add something on the user object, or the related person.

     
    • schirrms

      schirrms - 2024-05-06

      Hi Jeffrey,

      Actually no, we have users on diferrent timezones, but they are all french. So I can do a "crude work" and it will be OK. The question was more general, as if my extension is public, then it could be a problem for other users. But then again, I could imagine that the display format could be a parameter of the extension.

      Thanks,

      Pascal

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.