Jump to content

AdminArea Invoices, get each ID to make some logic


juampa

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 1 month later...

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!

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated