Arithmetic operations in dtl

Moderator: crythias

Post Reply
cbravo
Znuny advanced
Posts: 113
Joined: 18 Nov 2010, 00:33
Znuny Version: 3.0

Arithmetic operations in dtl

Post by cbravo »

Hello guys, I am currently modifying the AgentTicketZoom.dtl file so I can get extra info under the Ticket information block on the upper right corner. I have 2 TicketFreeTIme fields that I use, and I would like to show the difference between them two. I've tried doing the following $QData{"TIcketFreeTime1"} - $QData{"TIcketFreeTime2"} but the output is the following: 2011-08-31 11:45 - 2011-08-31 13:00 instead of the substraction. is there a special tag that I need to use for the dtl parser to do the operation instead of just showing the text? By the way, if you know a better way than mine to do what I want I would appreciate it.

Thank you for all your help.

Greetings,

C.
OTRS: 3.08
OS: Ubuntu
Apache2/MySQL 5
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Arithmetic operations in dtl

Post by crythias »

Since javascript renders after the dtl is generated (it's [almost] obvious that you're getting static information rather than actionable information)...

http://stackoverflow.com/questions/8003 ... -timestamp

Concepts may similarly be applied, though you may need to adjust for the format you'll see.

"What's it mean?"

basically, you'll probably want to convert things to seconds or epoch time http://www.epochconverter.com/programming/ and subtract, then convert the result to something that makes sense to display (with units).
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
cbravo
Znuny advanced
Posts: 113
Joined: 18 Nov 2010, 00:33
Znuny Version: 3.0

Re: Arithmetic operations in dtl

Post by cbravo »

Appreciate your help and quick response. I think I'm doing something wrong tho, I tried to do something like that and when I write something like: use Date::Parse;
it gets render too instead of include the referenced module. I'm sorry but I'm just getting started with perl (I find it quite powerful) is there a special tag I should use so it won't get rendered but the equivalent operation would be applied?

Thank you,

C.
OTRS: 3.08
OS: Ubuntu
Apache2/MySQL 5
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Arithmetic operations in dtl

Post by crythias »

:) No worries. I'm working on a premise that you'd create a javascript script and assign the values to variables within javascript, do the manipulations, and use a document.write to put the result where you want it.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
cbravo
Znuny advanced
Posts: 113
Joined: 18 Nov 2010, 00:33
Znuny Version: 3.0

Re: Arithmetic operations in dtl

Post by cbravo »

sorry to be bothering again. I created the javascript and it works like a charm, but I'm having a problem still. Currently I can make the script execute when the user presses a button, but can't get it to work by itself. Is there a special place where I should put the script for it to get automatically executed? I thought it would be between the tag: <!--dtl:js_on_document_complete--> so it would execute once the page was done loading, but didn't work. Any ideas that could help me?

Appreciate it, thank you.

By the way, I'm modifying the AgentTicketZoom.dtl file.
OTRS: 3.08
OS: Ubuntu
Apache2/MySQL 5
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Re: Arithmetic operations in dtl

Post by crythias »

If you provide a function, you must call a function. If you put the code directly in javascript, it will run as soon as it loads, which tends to mean to put the run script at the end of the HTML.

Or, simply at the documentload bottom
<script>
put exactly the code you'd attach to the onchange/onclick/onmouseup event here.
</script>
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
cbravo
Znuny advanced
Posts: 113
Joined: 18 Nov 2010, 00:33
Znuny Version: 3.0

Re: Arithmetic operations in dtl

Post by cbravo »

awesome thank you. Just run some tests and works like a charm Will be updating this post with info on how to do it later on.

Thanks again.
OTRS: 3.08
OS: Ubuntu
Apache2/MySQL 5
Post Reply