ST4R Posted February 24, 2016 Share Posted February 24, 2016 Currently, when a client enter his account and go to his Tickets/Invoices/Services/etc lists such as (supportticketslist.tpl), the latest answer on the tickets will be sorted by full date, example: Example 1: Latest update: 8th Nov 2013 (14:06) But I want it to show the time since the last answer, example: Example 2: Latest Answer: 0h 52m How can I do it? Thanks for your time. 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 24, 2016 Share Posted February 24, 2016 the variable you want doesn't exist on that page, so you'd have to create it using PHP - ideally as an action hook or (only if you have to) using {php} tags in the template - you can't do it with Smarty. http://forum.whmcs.com/showthread.php?81367-Show-time-since-ticket-last-answer 0 Quote Link to comment Share on other sites More sharing options...
ST4R Posted February 24, 2016 Author Share Posted February 24, 2016 Yeah, but as WHMCS uses this function already in the admin area, then this code already exists, right? I and do not tell me that the function code exists in an encrypted file, because this isn't the answer! 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 24, 2016 Share Posted February 24, 2016 Yeah, but as WHMCS uses this function already in the admin area, then this code already exists, right? and do not tell me that the function code exists in an encrypted file, because this isn't the answer! it's an answer - it may not be the one you want to hear, but it's definitely an answer! so if the code already exists in an encrypted file, you want me to share the code with you? seriously?? if it's encrypted, it's because WHMCS don't want that code shared - it's not for me to decrypt it for you. anyway, we're not even talking about some complex bit of PHP programming - i've already explained the process... you have one date (the last reply Smarty variable); you can easily get today's date in PHP; take one from the other and convert it to days, hours and minutes... then pass it back to Smarty or echo it -> job done. if you're not a programmer and don't know how to do that (or use Google to find out!), then it's ok to admit that and ask for further help - but don't ask me to reveal code that I didn't write and is not mine to share! I take it that's all you want to do - convert the date to calculate the difference between the last reply and now? the above was done without reference to any WHMCS code, uses date_diff and is only ten lines long - simple! http://php.net/manual/en/datetime.diff.php 0 Quote Link to comment Share on other sites More sharing options...
cloudhopping Posted February 24, 2016 Share Posted February 24, 2016 Hey - I'm interested ... mind sharing the loved code (and ps - I absolutely your answer Brian! ) i got a kick out of it... needed the laugh today 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted February 24, 2016 Share Posted February 24, 2016 seeing as you asked... <td class="text-center"><span class="hidden">{$ticket.normalisedLastReply}</span>{php} $smartyvars = $template->getTemplateVars(); $lastreplydate = $smartyvars['ticket']['normalisedLastReply']; $datetime1 = date_create($lastreplydate); $datetime2 = date_create(); $interval = date_diff($datetime1, $datetime2); $result = ""; if ($interval->d) { $result .= $interval->format("%ad "); } if ($interval->h) { $result .= $interval->format("%hh "); } if ($interval->i) { $result .= $interval->format("%im "); } echo $result; {/php}</td> as a rule, I prefer not to use {php} tags these days, but i'm not writing a hook for him - anyway, it works! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.