ITSNev Posted June 19, 2012 Share Posted June 19, 2012 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 0 Quote Link to comment Share on other sites More sharing options...
irwan Posted June 19, 2012 Share Posted June 19, 2012 need something like this too. 0 Quote Link to comment Share on other sites More sharing options...
Raed H Posted June 19, 2012 Share Posted June 19, 2012 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 0 Quote Link to comment Share on other sites More sharing options...
ITSNev Posted June 24, 2012 Author Share Posted June 24, 2012 Bump anyone 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted June 25, 2012 Share Posted June 25, 2012 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> 0 Quote Link to comment Share on other sites More sharing options...
ITSNev Posted June 25, 2012 Author Share Posted June 25, 2012 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 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted June 26, 2012 Share Posted June 26, 2012 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> 0 Quote Link to comment Share on other sites More sharing options...
ITSNev Posted June 26, 2012 Author Share Posted June 26, 2012 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 0 Quote Link to comment Share on other sites More sharing options...
jclarke Posted June 28, 2012 Share Posted June 28, 2012 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>< 0 Quote Link to comment Share on other sites More sharing options...
ITSNev Posted July 1, 2012 Author Share Posted July 1, 2012 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> 0 Quote Link to comment Share on other sites More sharing options...
mjwebhosting Posted January 18, 2013 Share Posted January 18, 2013 I have a little question. Is it also possible to display suspended and active and pending products? Further is this a nice welcome. 0 Quote Link to comment Share on other sites More sharing options...
acosaburca_1 Posted March 24, 2013 Share Posted March 24, 2013 The good code? Because when I add , it appears white page... thanks 0 Quote Link to comment Share on other sites More sharing options...
Si Posted March 24, 2013 Share Posted March 24, 2013 Hi, Maybe I'm missing something, but is this not what you're after: http://forum.whmcs.com/showthread.php?52278-Hide-Services-in-My-Services-by-Status-%28Cancelled-Terminated-etc-%29 EDIT: Oh I see you're trying to pull items into another tpl. Perhaps Sparkys clientareahome page addon should be considered. 0 Quote Link to comment Share on other sites More sharing options...
acosaburca_1 Posted March 24, 2013 Share Posted March 24, 2013 I want to show it "Active Services" in clientarea home... 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.