Jump to content

About custom search for services in invoice in whmcs


rahulkg

Recommended Posts

When we view a particular invoice in whmcs , is it possible to click the services in the invoice description and it directs to that service details . ( I mean when we search a particular service in the search bar above in whmcs admin side we get directed to that particular service page in whmcs admin side) and similarly , can we show the services /products included in the invoice page with links and on clicking them direct to that particular service page? ( ie I mean We need to be able to locate a product/service when viewing some invoice, so it goes directly to that service that is related to a particular invoice.)

Link to comment
Share on other sites

18 minutes ago, rahulkg said:

When we view a particular invoice in whmcs, is it possible to click the services in the invoice description and it directs to that service details.

out of the box, no.

20 minutes ago, rahulkg said:

I mean when we search a particular service in the search bar above in whmcs admin side we get directed to that particular service page in whmcs admin side and similarly , can we show the services /products included in the invoice page with links and on clicking them direct to that particular service page? ( ie I mean We need to be able to locate a product/service when viewing some invoice, so it goes directly to that service that is related to a particular invoice.

I think you're ultimately looking at using one of three custom solutions...

  1. coding an admin addon module to create a customised invoice line items output.
  2. writing a custom report to add links to the description field of the invoiceitems table.
  3. use an Intelligent Search action hook to enhance the search capabilities of the admin area search box.

whichever path you choose, you're basically querying the tblinvoiceitems table to get the service ID, and then linking to the appropriate page - though you'd first have to determine whether the ID is for a hosting service, a domain, an addon etc before knowing the correct link to use for each line item... and they'll be some line items that won't have links, e.g custom invoices.

Link to comment
Share on other sites

ok thank you very much for the reply, but please let me know if I choose the first method -how can it be done, I see the invoice.tpl fetches the info from an encrypted php file and so how do I get the data or how to modify it? or if I am using a hook as you said in 3rd solution, how can it be done using hook-I mean which hook I need to choose and how can I edit the invoice shown in admin side from inside hook? can you provide a sample hook ?

Link to comment
Share on other sites

  • 3 weeks later...
On 11/06/2019 at 12:16, rahulkg said:

ok thank you very much for the reply, but please let me know if I choose the first method -how can it be done, I see the invoice.tpl fetches the info from an encrypted php file and so how do I get the data or how to modify it?

forget about the encrypted files - they're irrelevant... besides, it's the encrypted file that gets the data from the database and the template just displays the results.

with regards to creating addons - the docs are available here... in over six years here, I can't recall anyone creating a sample addon module in reply to a question, so i'm not going to change that tradition. 🙂

On 11/06/2019 at 12:16, rahulkg said:

or if I am using a hook as you said in 3rd solution, how can it be done using hook-I mean which hook I need to choose and how can I edit the invoice shown in admin side from inside hook?

aaahh - you never mentioned editing the invoice before - just pulling additional information... the hook that I mentioned previously, Intelligent Search, would have been an option for that - but not really for editing the invoice.

On 11/06/2019 at 12:16, rahulkg said:

can you provide a sample hook ?

as I said in my first post, it's fundamentally just pulling the info from the database (via any number of methods) and then updating back to it (if you intend to edit the information returned)... as a 4th option, I guess that you could even do it on the Client Summary page (as it already has a template) and write a hook to get the invoiceitems data and output in a table,with links to any applicable service...

however, since a month or two back, I decided to take a break from writing & posting new hooks in the community - but others should be able to help you with this. thanks.png

Link to comment
Share on other sites

  • 3 weeks later...

Hi, I need to know the template file associated with invoices.php?action=edit&id=xx (whmcs admin side page) Also Please let me know how additional info about a product to be passed to this template file. so that I can try working for this.

Link to comment
Share on other sites

I see the invoice items and under its description I see many servernames there  . What actually I need is to add links to those server names and make it clickable , so on clicking a servername shown in that page. it automatically directs to that server page. so please explain how can it be done.

Link to comment
Share on other sites

With javascript / jQuery in AdminAreaHeaderOutput. See the example below:

<?php

add_hook('AdminAreaHeaderOutput', 1, function($vars)
{
    if ($vars['filename'] == 'configgeneral')
    {
        $output .= '<script type="text/javascript">
        	        $(document).ready(function(){
                        $("#tab1").prepend("<div class=\"alert alert-info\"><h4><strong>I\'m sexy...</strong></h4><p>And I know it!</p></div>");
        	        });
        	        </script>';

        return $output;
    }
});

Result:

adminareaheaderoutput.png.997645105202d14c080cea9b24283ad6.png

Use the same approach to add your href next to server names.

Edited by Kian
Link to comment
Share on other sites

But I need that particular invoice id, whether it is a server or not , and if and only if it s a server, I need hosting id of that service in the invoice and userid of that invoice, (only then I can write the link to direct him to that particular service  But hook AdminAreaHeaderOutput doesnt provide this details,  Also the description under invoice items in invoices.php?action=edit&id=xxxx page  ( also please let me know the file name of this page) is given in a textarea, so how should I prepend a href to only server name shown there.

Edited by rahulkg
Link to comment
Share on other sites

You can get all information you need from invoice ID. For example...

SELECT t1.userid, t1.relid AS hostingid FROM tblinvoiceitems AS t1 LEFT JOIN tblhosting AS t2 ON t1.relid = t2.id WHERE t1.invoiceid = '917' AND t1.type = "Hosting" AND t2.packageid IN ("4", "5", "6")

I'm selecting from invoice "917" all "Hosting" items with package ID equal to 4, 5 or 6 (eg. VPS silver, VPS gold, VPS platinum). This way I can get an array that looks like follows:

Array
(
    [userID] => 18
    [hostingID] => Array
    (
        [0] => 117
        [1] => 118
        [2] => 120
    )
)

 

Link to comment
Share on other sites

47 minutes ago, rahulkg said:

I can write the link to direct him to that particular service

hold on - what is it exactly that you're trying to do and where... i'm really confused as you've talked about the admin area, you've talked about editing the invoice and now you seem to be saying that you just want to send a link to the client... 😕

On 07/06/2019 at 14:36, rahulkg said:

When we view a particular invoice in whmcs , is it possible to click the services in the invoice description and it directs to that service details .

if you are wanting the html invoice shown to the client (e.g six/viewinvoice.tpl) to add a link to the services page for any services (e.g hosting, not domains) in the invoice items, then you can do that already without the need for any hooks - you'd just need to edit the layout in viewinvoice.tpl to show the link... how much work that involves depends on how much you want to change the layout (e.g adding another column) - but ultimately it's just one line of Smarty.

Edited by brian!
Link to comment
Share on other sites

Hi brian,

I talk about whmcs admin side-you know that in admin side, an admin can view a client's invoice in /invoices.php?action=edit&id=xxxx page. ( We dont want anything to show clients or send them anything) . In this page an admin can see the details of invoice like what are the invoice items. And we need to give links to services of invoice items there. so that an admin can easily navigate to the services pages from the invoice items shown in that page . And as we have a lot of invoices its quite easy for admins to check any services in the invoice page by clicking that service and going to that particular service page.

Edited by rahulkg
Link to comment
Share on other sites

Hi,

5 hours ago, rahulkg said:

I talk about whmcs admin side-you know that in admin side, an admin can view a client's invoice in /invoices.php?action=edit&id=xxxx page. ( We dont want anything to show clients or send them anything) . In this page an admin can see the details of invoice like what are the invoice items. And we need to give links to services of invoice items there. so that an admin can easily navigate to the services pages from the invoice items shown in that page . And as we have a lot of invoices its quite easy for admins to check any services in the invoice page by clicking that service and going to that particular service page. 

the problem is not what you're trying to do - it's your insistence on trying to do from the existing invoices page... if you wanted to tweak the page to add some buttons, text etc then you could do that with hooks, but effectively adding new data to the query, hyperlinking based on certain values...

as I said previously, it would be easier to create a custom solution rather than try to edit that page.

On 07/06/2019 at 16:29, brian! said:

2. writing a custom report to add links to the description field of the invoiceitems table.

i've previously posted an invoiceitems report, so it wouldn't be difficult to enhance it for your purposes...

so the enhanced report below will allow you to view invoiceitems (most of the fields within that table and the invoices table); it will link invoiceitems that are hosting/services to the appropriate services page; it will link domains to their domains page, and the same for product addons - everything else will be left unlinked... all links will open in a new tab and only the "Type" field is hyperlinked.

itoqHOC.png

obviously, as with other reports, you don't need to include all columns in the output, you can choose only those that you need; you can also filter on all fields, so if you only want to check one invoice, then you can add it's invoice number to the search terms and the report will show all invoice items for that invoice, linking any domain/service/addon to the appropriate page.... similarly, if you only want to look at invoices from 2019, you could use the above settings.

to install the report, you should just need to upload the attached file to /modules/reports and then select it from the WHMCS reports page.

I doubt that v7.8 will break this report, but there's no guarantees what will happen in v8 - though that looks unlikely to appear now until the end of the year.

I haven't encrypted the file, so you can edit it as necessary should any changes become required.

enhanced_invoice_items.php

Link to comment
Share on other sites

7 minutes ago, rahulkg said:

Hi Brian, It looks good, but I also  need to be able to filter using a date range.

and you only mention that now after 2 months ? 🙄

9 minutes ago, rahulkg said:

And how could this be possible?

if it's just for a specific month, e.g July 2019, then you can use "due date" "containing" "2019-07"... if you're going to want returns between two specific dates, then use a date picker from one of the other reports and incorporate that into it.

Link to comment
Share on other sites

Hi Brian ,

Now I feel its more helpful when we can search by date.

But in which file I had to add the date picker and how should we can incorporate datepicker and use it for selecting between two dates. which files I needed to edit . please explain.

Link to comment
Share on other sites

On 30/07/2019 at 09:32, rahulkg said:

Now I feel its more helpful when we can search by date.

searching by Due Date is by far the easiest option - as it's the only date field in the tblinvoiceitems database table... searching by other dates would require coding changes that it would currently be pointless to do.

On 30/07/2019 at 09:32, rahulkg said:

But in which file I had to add the date picker and how should we can incorporate datepicker and use it for selecting between two dates. which files I needed to edit.

I was suggesting that you take the code from one of the other reports that has a date picker, e.g Credits Reviewer and incorporate it into the above report - nether are encrypted.

On 30/07/2019 at 09:32, rahulkg said:

please explain. 

it would take far longer to explain to you how to do it than it actually would for me to code it myself. ⏲️

i've sent you a PM with the updated v2 file - upload it to the same folder and you'll be able to use either... 🙂

Cy1u9dh.png

because it's using a date picker, the chances are this might report might need to be rewritten for v7.8 - but there's no point worrying about that until it gets a full release in a month's time.

Link to comment
Share on other sites

  • 1 month later...

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