Jump to content

Customise clientarea.tpl to display Active Products/Services


ITSNev

Recommended Posts

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.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> </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=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>

 

Thx

Nev

Link to comment
Share on other sites

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

{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:

<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> </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>

Link to comment
Share on other sites

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

 

 

<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> </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>

Link to comment
Share on other sites

Still not quite there, I have

 

{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

 

<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> </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.

 

<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

Link to comment
Share on other sites

Try something like this to make sure you are getting the correct id.

$result = mysql_query("SELECT *,tblhosting.id as serviceid FROM tblhosting,tblproducts WHERE userid =$userid AND tblhosting.packageid= tblproducts.id AND tblhosting.domainstatus='Active'");

 

<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><

Link to comment
Share on other sites

Yes,

 

Thanks jclarke, got it working...

 

$result = mysql_query("SELECT *,tblhosting.id as serviceid FROM tblhosting,tblproducts WHERE userid =$userid AND tblhosting.packageid= tblproducts.id AND tblhosting.domainstatus='Active'");

 

<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>

Link to comment
Share on other sites

  • 6 months later...
  • 2 months 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