mohammad50 Posted January 15, 2016 Share Posted January 15, 2016 hi at version 5 of whmcs for converting dates from Gregorian to solar(Jalali) in viewinvoice.tpl file first i add this line at top of viewinvoice.tpl file: {php}include('jdf.php');{/php} then i replace {$datecreated} by folowing line {php}echo $shamsi = jdate("Y/m/d", strtotime($this->_tpl_vars["datecreated"]));{/php} but i cant use this method at version 6 do you have any solution for this problem ? download jdf.php link ---> jdf.scr.ir/download/dl.php ------------------------ code to convert Gregorian to Solar(Jalali) include('jdf.php'); $Gregorian_date = "2016/01/16"; $Gregorian_date = strtotime($Gregorian_date); $solar_date = jdate("Y/m/d", $Gregorian_date); echo $solar_date; ------------------------ thank you excuse me for my poor english 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 16, 2016 Share Posted January 16, 2016 try using the following... {php}echo $shamsi = jdate("Y/m/d", strtotime($template->getVariable('datecreated')));{/php} 0 Quote Link to comment Share on other sites More sharing options...
mohammad50 Posted January 16, 2016 Author Share Posted January 16, 2016 i cant use {php} tag in .tpl file in version 6: http://docs.whmcs.com/Version_6_Template_Migration_Guide#.7Bphp.7D_Block_Syntax "An option was added to WHMCS 6 to enable use of the potentially dangerous {php} tag in custom templates. This option is disabled by default but can be enabled if required in Setup > General Settings > Security. We strongly encourage using hook functions over php code blocks inside of templates for backend interaction." i dont want to enable php tag... can i convert date without use of php tag in template? 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted January 16, 2016 Share Posted January 16, 2016 i cant use {php} tag in .tpl file in version 6: you can - you just don't want to! can i convert date without use of php tag in template? if it were me, i'd carry on using your {php} solution - you know it works and how to use it, and it's no more "dangerous" in v6 than it was in v5... one day, you'll need an alternative solution, but not necessarily today. there is a Smarty plugin that seems to work - though it comes with no instructions and i've no knowledge of farsi! https://code.google.com/p/smartyjalaliplugin/downloads/list if you upload all five files to /vendor/smarty/smarty/libs/plugins you should then be able to edit the template to show jalali dates without the use of PHP... today's date - {$smarty.now|date_format:"%d/%m/%Y"} iranian date - {$smarty.now|jdate_format} iranian date - {$smarty.now|jdate_format:"%Y/%m/%d"} you will probably need to play with the output to get it right, using the date format options at... http://php.net/manual/en/function.strftime.php alternatively, you could post in Marketplace and pay someone to convert the PHP code to a hook. but as I said previously, I would personally carry on using the {php} solution for now and try alternatives so that you are ready when {php} is disabled. 0 Quote Link to comment Share on other sites More sharing options...
mohammad50 Posted January 16, 2016 Author Share Posted January 16, 2016 you can - you just don't want to! :)i i mean i dont want. ok i prefer use php tag now, but i dont khow why whmcs dont support jalali date! 0 Quote Link to comment Share on other sites More sharing options...
mohammad50 Posted March 25, 2016 Author Share Posted March 25, 2016 (edited) i write a plugin to change date without changing .tpl files and it work... but finding array data arrays is very difficult in this method. add_hook('ClientAreaPageProductsServices', 1, function ($templateVariables) { /*foreach ($templateVariables as $Variables_name) { print_r($Variables_name); }*/ $date = $templateVariables['services']['0']['nextduedate'] ; $date2 = jdate( 'Y/m/d', strtotime( $date )) ; $replacements = $templateVariables['services']['0']; $convetred = array( "nextduedate" => $date2); $templateVariables['services']['0'] = array_replace($replacements, $convetred); return($templateVariables); } ); can some one help me to use folowing code to replace date ? how can i use getChild('') to get date value for example getChild('nextduedate') use WHMCS\View\Menu\Item as MenuItem; @add_hook('ClientAreaPrimaryNavbar', 1, function (MenuItem $primaryNavbar) { if (!is_null($primaryNavbar->getChild('Support'))) { $primaryNavbar->getChild('Support') ->addChild('sms_module', array( 'label' => 'sms_notification', 'uri' => 'index.php?m=sms_module', 'order' => '100', )); } }); Edited March 25, 2016 by mohammad50 add php tag 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 25, 2016 Share Posted March 25, 2016 i'm not sure I see what the navigation hook code has to do with your jalali hook... it'd probably be easier to query the database and regenerate the arrays again; manipulate the date format and send them back to Smarty - rather than trying to import the Smarty arrays in the hook.. btw - did you try the Smarty plugin? it works fine... <td class="text-center"><span class="hidden">{$service.normalisedNextDueDate}</span>{$service.nextduedate}{if $service.nextduedate neq '-'} ... {$service.nextduedate|jdate_format:"%Y/%m/%d"}{/if}</td> yes, you'll have to edit the templates to use it - but you were doing that with the previous {php} solution... anywhere there is a template, client or admin area, you can use the plugin. 0 Quote Link to comment Share on other sites More sharing options...
mohammad50 Posted March 25, 2016 Author Share Posted March 25, 2016 (edited) i want use getChild('') to get date array for example getChild('nextduedate') please dont offer me to edit .tpl files, because when i update whmcs, i must edit all .tpl files again for all my customer. Edited March 25, 2016 by mohammad50 0 Quote Link to comment Share on other sites More sharing options...
brian! Posted March 25, 2016 Share Posted March 25, 2016 i want use getChild('') to get date arrayfor example getChild('nextduedate') why?? getChild is used in navigation menus and sidebars hooks - it is NOT used to get Smarty arrays. please dont offer me to edit .tpl files, because when i update whmcs, i must edit all .tpl files again for all my customer. then post in Marketplace and pay someone to write it for you... seriously, a WHMCS developer who is familiar with hooks could write this quickly and save you a lot of time. on Google, I can see a WHMCS addon that claims to do what you want - have you tried it? http://shop.vbiran.ir/jalali-shamsi-date-whmcs-plugin/ 0 Quote Link to comment Share on other sites More sharing options...
vahid goudini Posted November 14, 2020 Share Posted November 14, 2020 Hello i donwload version 8.0.4 and i want change my calendar to SHAMSI what do i do ? 0 Quote Link to comment Share on other sites More sharing options...
Hossein Khorsandi Posted June 19 Share Posted June 19 Hi, you can use the plugin jalalidate pro touska to convert date to Solar(Jalali) your whmcs😍👇 https://www.rtl-theme.com/touska-whmcs-module/ 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.