JGolder Posted July 10, 2019 Share Posted July 10, 2019 Hello Team, I would like to display the customfield values next to the products. Under the page: clientssummary (picture is attached) Unfortunately, I can not continue. It already works under clientservices. Here is my script for the clientservice site: <?php if ( !defined('WHMCS')) { header("Location: ../../index.php"); } use WHMCS\Database\Capsule; if($_REQUEST['getAll'] == '1') { $newAll = []; $gotCustomFieldID = [1,26,10,11,20,21]; $getCustomFieldID = Capsule::table('tblcustomfields') ->select('id') ->where('tblcustomfields.type','product') ->where('tblcustomfields.fieldname','Location Name') ->where('tblcustomfields.fieldtype','text') ->get(); foreach ($getCustomFieldID as $data) { $gotCustomFieldID[] = $data->id; } foreach ($gotCustomFieldID as $customFieldID) { $all = Capsule::table('tblcustomfieldsvalues') ->join('tblhosting', 'tblcustomfieldsvalues.relid', '=', 'tblhosting.id') ->where('fieldid', $customFieldID ) ->where('userid', $_REQUEST['userid'] ) ->get(); $all = json_decode( json_encode( $all ) , true ); foreach($all as $a) { $newAll[$a['relid']] = $a['value']; } } ob_clean(); echo json_encode(array( "all" => $newAll )); die; } add_hook('AdminAreaPage', 1, function($vars) { if( $vars['filename'] == 'clientsservices' ) { echo '<script> document.addEventListener("DOMContentLoaded", function(){ $.post(window.location, { getAll: 1 }, function(data, status){ var data = JSON.parse(data); var first = []; setInterval(function() { var x = document.querySelectorAll("[data-value]"); for (var i = 1; i < x.length ; i++) { if(typeof first[x[i].dataset.value] === "undefined") { first[x[i].dataset.value] = x[i].innerText; } if(typeof data.all[x[i].dataset.value] !== "undefined" && data.all[x[i].dataset.value] != "") { x[i].innerText = first[x[i].dataset.value] + " - " + data.all[x[i].dataset.value]; } } }, 100); }); }); </script>'; } if( $vars['filename'] == 'clientssummary' ) { echo '<script> document.addEventListener("DOMContentLoaded", function(){ $.post(window.location, { getAll: 1 }, function(data, status){ var data = JSON.parse(data); var first = []; setInterval(function() { var x = document.querySelectorAll("[data-value]"); for (var i = 1; i < x.length ; i++) { first[x[i].dataset.value] = x[i].innerText; x[i].innerText = first[x[i].dataset.value] + " - " + data.all[x[i].dataset.value]; } }, 100); }); }); </script>'; } }); I need a script so I can display the custom field values next to the products. on the side clientssummary (picture is attached) 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.