Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This will work, create a hook file and add the following code.
- -----------
- <?php
- use WHMCS\Database\Capsule;
- function decrypt_ticket_password_custom_fields($vars) {
- $ticketID = Capsule::table('tbltickets')->where('tid', $_GET['tid'])->first()->id;
- $script = "<script type='text/javascript'>
- $(document).ready(function() {
- ";
- foreach ($vars['customfields'] as $field) {
- if ($field['type'] !== 'password') {
- continue;
- }
- $value = Capsule::table('tblcustomfieldsvalues')->where(['fieldid' => $field['id'], 'relid' => $ticketID])->first();
- if (count($value)) {
- $request = localAPI('DecryptPassword', ['password2' => $value->value]);
- $password = $request['password'];
- $script .= "
- $('div[menuitemname=\"{$field['name']}\"]').children('div').eq(1).html('{$password}');
- ";
- } else {
- $script .= "
- $('div[menuitemname=\"{$field['name']}\"]').children('div').eq(1).html('N/A');
- ";
- }
- }
- $script .= " });
- </script>
- ";
- $output['customfieldjavascript'] = $script;
- return $output;
- }
- add_hook('ClientAreaPageViewTicket', 1, 'decrypt_ticket_password_custom_fields');
- ---------------
- Then open your viewticket.tpl file in whatever theme you use and add the following variable at the bottom:
- {$customfieldjavascript}
- This will work for multiple custom fields that are of the type password. Other custom fields will remain untouched.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement