juampa Posted September 30, 2021 Share Posted September 30, 2021 Hello, we want to do something by JS, when in the admin area, listing invoices (xxxxx.com/admin/invoices.php), We need to get the id of each invoices (that appears in the pagination) and do some logical, and then mark by js inside the template.. example in red if has some data, or green in other hand And the https://developers.whmcs.com/hooks-reference/admin-area/#adminareapage dont get the id of the invoices in a variable..... Thanks 0 Quote Link to comment Share on other sites More sharing options...
developer _WHM_CS Posted October 1, 2021 Share Posted October 1, 2021 Hi @juampa you can use sample code in your hooks add_hook( 'AdminAreaFooterOutput', 1, function(){ if ( ( $vars['pageicon'] == "xxx" || $vars['pageicon'] == "xxxx" || $vars['pageicon'] == "xxxx" ) && $vars['filename'] == "xxx" ) { // change to custom page data return <<<HTML <script type="text/javascript"> var values = []; if('{$name}' == 'selectedinvoices'){ $("input[name='selectedinvoices[]']").each(function() { values.push($(this).val()); }); check(values); function check(values){ if(window.location.search == ""){ var locat = window.location.href+'?customaction={$vars['pageicon']}'; }else{ var locat = window.location.href+'&customaction={$vars['pageicon']}'; } $.ajax({ url: locat, type: 'POST', data: {values}, success: function(data) { var activelist = JSON.parse(data); if (activelist.result == true){ $("input[name='selectedinvoices[]']").each(function() { var id = parseInt($(this).val()) if ($.inArray(id,activelist.pid) >= 0){ $(this).parents('tr').css("color","blue"); }else { $(this).parents('tr').css("color","") } }); } } }) } </script> HTML; }); }); push like it 1 Quote Link to comment Share on other sites More sharing options...
juans Posted November 30, 2021 Share Posted November 30, 2021 thanks! i have other question. How to put a controller into whmcs that do the action by de ID of the invoice. When i put in ajax:url some file controller inside admin example (admin/includes/controllers/getidinvoice.php) -> i get 404 if this controller return to my JS, i can do this functionality, thanks alot! 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.