Results 1 to 14 of 14

Thread: Customise clientarea.tpl to display Active Products/Services

  1. #1
    Join Date
    Jan 2010
    Posts
    32

    Lightbulb Customise clientarea.tpl to display Active Products/Services

    Hi,

    I would like to be able to display the active Products/Services in the main Client Area. I have copied the following code from clientareaproducts.tpl and the table is displayed, but these is no data in the table. Would appreciate if someone could advise what I've missed in order to get the data.

    <table class="zebra-striped">
    <thead>
    <tr>
    <th{if $orderby eq "product"} class="headerSort{$sort}"{/if}><a href="clientarea.php?action=products{if $q}&q={$q}{/if}&orderby=product">{$LANG.orderproduct}</a></th>
    <th{if $orderby eq "price"} class="headerSort{$sort}"{/if}><a href="clientarea.php?action=products{if $q}&q={$q}{/if}&orderby=price">{$LANG.orderprice}</a></th>
    <th{if $orderby eq "billingcycle"} class="headerSort{$sort}"{/if}><a href="clientarea.php?action=products{if $q}&q={$q}{/if}&orderby=billingcycle">{$LANG.orderbillingcycle }</a></th>
    <th{if $orderby eq "nextduedate"} class="headerSort{$sort}"{/if}><a href="clientarea.php?action=products{if $q}&q={$q}{/if}&orderby=nextduedate">{$LANG.clientareahostingn extduedate}</a></th>
    <th{if $orderby eq "status"} class="headerSort{$sort}"{/if}><a href="clientarea.php?action=products{if $q}&q={$q}{/if}&orderby=status">{$LANG.clientareastatus}</a></th>
    <th>&nbsp;</th>
    </tr>
    </thead>
    <tbody>
    {foreach from=$services item=service}
    <tr>
    <td>{$service.group} - {$service.product}{if $service.domain}<br /><a href="http://{$service.domain}" target="_blank">{$service.domain}</a>{/if}</td>
    <td>{$service.amount}</td>
    <td>{$service.billingcycle}</td>
    <td>{$service.nextduedate}</td>
    <td><span class="label {$service.rawstatus}">{$service.statustext}</span></td>
    <td class="textcenter"><form method="post" action="{$smarty.server.PHP_SELF}?action=productde tails"><input type="hidden" name="id" value="{$service.id}" /><input type="submit" value="{$LANG.clientareaviewdetails}" class="btn info" /></form></td>
    </tr>
    {foreachelse}
    <tr>
    <td colspan="6" class="textcenter">{$LANG.norecordsfound}</td>
    </tr>
    {/foreach}
    </tbody>
    </table>

    Thx
    Nev

  2. #2
    Join Date
    Jun 2012
    Posts
    1

    Default

    need something like this too.

  3. #3
    Join Date
    Jun 2012
    Posts
    2

    Default

    i do the same thing with clientareainvoice.tpl to cleitnareaproductsdetails. you see just the table no content.
    its will be great if some one can help

  4. #4
    Join Date
    Jan 2010
    Posts
    32

    Default

    Bump anyone

  5. #5
    Join Date
    Dec 2008
    Location
    Myrtle Beach, SC
    Posts
    386

    Default

    WHMCS doesn't pass this information to the client area home page which is why just pasting in the code from clientareaproducts.tpl doesn't work.

    What you have to do is add some php code to the client area home page template to make a call to the database to get the product information.

    Here is a basic example:

    This would need to be at the top of clientareahome
    Code:
    {php}
    $userid = $this->_tpl_vars['clientsdetails']['id'];
    $result = mysql_query("SELECT * FROM tblhosting,tblproducts WHERE userid =$userid AND tblhosting.packageid= tblproducts.id");
    $services = array();
    while ($data = mysql_fetch_array($result)) {
     array_push($services, $data);
    }
    $this->_tpl_vars['services'] = $services;
    {/php}
    Then you would use something like this to display the data:
    Code:
    <table class="zebra-striped">
    <thead>
    <tr>
    <th>{$LANG.orderproduct}</th>
    <th>{$LANG.orderprice}</th>
    <th>{$LANG.orderbillingcycle}</a></th>
    <th>{$LANG.clientareahostingn extduedate}</th>
    <th>{$LANG.clientareastatus}</th>
    <th>&nbsp;</th>
    </tr>
    </thead>
    <tbody>
    {foreach from=$services item=service}
    <tr>
    <td>{$service.name}{if $service.domain}<br /><a href="http://{$service.domain}" target="_blank">{$service.domain}</a>{/if}</td>
    <td>{$service.amount}</td>
    <td>{$service.billingcycle}</td>
    <td>{$service.nextduedate}</td>
    <td><span class="label {$service.domainstatus}">{$service.domainstatus}</span></td>
    <td class="textcenter"><form method="post" action="{$smarty.server.PHP_SELF}?action=productdetails"><input type="hidden" name="id" value="{$service.id}" /><input type="submit" value="{$LANG.clientareaviewdetails}" class="btn info" /></form></td>
    </tr>
    {foreachelse}
    <tr>
    <td colspan="6" class="textcenter">{$LANG.norecordsfound}</td>
    </tr>
    {/foreach}
    </tbody>
    </table>

  6. #6
    Join Date
    Jan 2010
    Posts
    32

    Default

    Hi jclarke,

    This works, but when I click on "View Details" I get an "Unauthorized Access Attempt", can you help a little more?

    Thx
    Nev

  7. #7
    Join Date
    Dec 2008
    Location
    Myrtle Beach, SC
    Posts
    386

    Default

    Try changing the button to use get instead of post and it should work.


    Code:
    <table class="zebra-striped">
    <thead>
    <tr>
    <th>{$LANG.orderproduct}</th>
    <th>{$LANG.orderprice}</th>
    <th>{$LANG.orderbillingcycle}</a></th>
    <th>{$LANG.clientareahostingn extduedate}</th>
    <th>{$LANG.clientareastatus}</th>
    <th>&nbsp;</th>
    </tr>
    </thead>
    <tbody>
    {foreach from=$services item=service}
    <tr>
    <td>{$service.name}{if $service.domain}<br /><a href="http://{$service.domain}" target="_blank">{$service.domain}</a>{/if}</td>
    <td>{$service.amount}</td>
    <td>{$service.billingcycle}</td>
    <td>{$service.nextduedate}</td>
    <td><span class="label {$service.domainstatus}">{$service.domainstatus}</span></td>
    <td class="textcenter"><form method="get" action="{$smarty.server.PHP_SELF}?action=productdetails"><input type="hidden" name="id" value="{$service.id}" /><input type="submit" value="{$LANG.clientareaviewdetails}" class="btn info" /></form></td>
    </tr>
    {foreachelse}
    <tr>
    <td colspan="6" class="textcenter">{$LANG.norecordsfound}</td>
    </tr>
    {/foreach}
    </tbody>
    </table>

  8. #8
    Join Date
    Jan 2010
    Posts
    32

    Default

    Still not quite there, I have

    Code:
    {php}
    $userid = $this->_tpl_vars['clientsdetails']['id'];
    $result = mysql_query("SELECT * FROM tblhosting,tblproducts WHERE userid =$userid AND tblhosting.packageid= tblproducts.id AND tblhosting.domainstatus='Active'");
    $services = array();
    while ($data = mysql_fetch_array($result)) {
     array_push($services, $data);
    }
    $this->_tpl_vars['services'] = $services;
    {/php}
    Then to display

    Code:
    <div class="styled_title">
        <h3>Active Accounts</h3>
    </div>
    
    
    <table class="zebra-striped">
    <thead>
            <tr>
                <th{if $orderby eq "product"} class="headerSort{$sort}"{/if}><a href="clientarea.php?action=products{if $q}&q={$q}{/if}&orderby=product">{$LANG.orderproduct}</a></th>
                <th{if $orderby eq "price"} class="headerSort{$sort}"{/if}><a href="clientarea.php?action=products{if $q}&q={$q}{/if}&orderby=price">{$LANG.orderprice}</a></th>
                <th{if $orderby eq "billingcycle"} class="headerSort{$sort}"{/if}><a href="clientarea.php?action=products{if $q}&q={$q}{/if}&orderby=billingcycle">{$LANG.orderbillingcycle}</a></th>
                <th{if $orderby eq "nextduedate"} class="headerSort{$sort}"{/if}><a href="clientarea.php?action=products{if $q}&q={$q}{/if}&orderby=nextduedate">{$LANG.clientareahostingnextduedate}</a></th>
                <th{if $orderby eq "status"} class="headerSort{$sort}"{/if}><a href="clientarea.php?action=products{if $q}&q={$q}{/if}&orderby=status">{$LANG.clientareastatus}</a></th>
                <th>&nbsp;</th>
            </tr>
    
    </thead>
    <tbody>
    {foreach from=$services item=service}
    <tr>
    <td>{$service.name}{if $service.domain}<br /><a href="http://{$service.domain}" target="_blank">{$service.domain}</a>{/if}</td>
    <td>{$service.amount}</td>
    <td>{$service.billingcycle}</td>
    <td>{$service.nextduedate}</td>
    <td><span class="label active">{$service.domainstatus}</span></td>
    <td class="textcenter"><form method="get" action="{$smarty.server.PHP_SELF}?action=productdetails"><input type="hidden" name="id" value="{$service.id}" /><input type="submit" value="{$LANG.clientareaviewdetails}" class="btn info" /></form></td>
    </tr>
    I think the problem is with value of {$service.id} as on inspecting the element the value is 3, which so not correct for a service ID.

    HTML Code:
    <form action="/clientarea.php?action=productdetails" method="get"><input type="hidden" value="3" name="id"><input type="submit" class="btn info" value="View Details"></form>
    Thx
    Nev

  9. #9
    Join Date
    Dec 2008
    Location
    Myrtle Beach, SC
    Posts
    386

    Default

    Try something like this to make sure you are getting the correct id.
    Code:
    $result = mysql_query("SELECT *,tblhosting.id as serviceid FROM tblhosting,tblproducts WHERE userid =$userid AND tblhosting.packageid= tblproducts.id AND tblhosting.domainstatus='Active'");
    Code:
    <form method="get" action="{$smarty.server.PHP_SELF}?action=productdetails"><input type="hidden" name="id" value="{$service.serviceid}" /><input type="submit" value="{$LANG.clientareaviewdetails}" class="btn info" /></form><

  10. #10
    Join Date
    Jan 2010
    Posts
    32

    Default

    Yes,

    Thanks jclarke, got it working...

    PHP Code:
    $result mysql_query("SELECT *,tblhosting.id as serviceid FROM tblhosting,tblproducts WHERE userid =$userid AND tblhosting.packageid= tblproducts.id AND tblhosting.domainstatus='Active'"); 
    HTML Code:
    <td class="textcenter"><form method="post" action="{$smarty.server.PHP_SELF}?action=productdetails"><input type="hidden" name="id" value="{$service.serviceid}" /><input type="submit" value="{$LANG.clientareaviewdetails}" class="btn info" /></form></td>

  11. #11

    Default Re: Customise clientarea.tpl to display Active Products/Services

    I have a little question.
    Is it also possible to display suspended and active and pending products?
    Further is this a nice welcome.

  12. #12
    Join Date
    May 2012
    Posts
    5

    Default Re: Customise clientarea.tpl to display Active Products/Services

    The good code? Because when I add , it appears white page... thanks

  13. #13
    Join Date
    Aug 2007
    Posts
    895

    Default Re: Customise clientarea.tpl to display Active Products/Services

    Hi,
    Maybe I'm missing something, but is this not what you're after:
    http://forum.whmcs.com/showthread.ph...inated-etc-%29

    EDIT: Oh I see you're trying to pull items into another tpl. Perhaps Sparkys clientareahome page addon should be considered.

  14. #14
    Join Date
    May 2012
    Posts
    5

    Default Re: Customise clientarea.tpl to display Active Products/Services

    I want to show it "Active Services" in clientarea home...

Similar Threads

  1. Customize clientarea.tpl with product
    By mrmike in forum Customisation & Integration Questions
    Replies: 0
    Last Post: 08-20-11, 06:57 PM
  2. Customise individual products
    By lemusa in forum Customisation & Integration Questions
    Replies: 2
    Last Post: 07-17-11, 12:40 AM
  3. Products & Services Active/Visible or Not
    By Boss in forum Feature Requests
    Replies: 0
    Last Post: 08-22-07, 03:14 AM