Jump to content

Unable to Get Support ticket count


techwthquestion

Recommended Posts

Hello

I am not sure why I am unable to get support ticket count. Here is my code 

<?php

use WHMCS\View\Menu\Item;
use Illuminate\Database\Capsule\Manager as Capsule;

add_hook('ClientAreaHomepagePanels', 1, function (Item $homePagePanels)
{
   $clientemail = Capsule::table('tblclients')
    ->select('email')
    ->where('tblclients.id', '=', $vars['userid'])
    ->first();
     $servername = "localhost";
    $username = "XXXXX";
    $password = "XXXXX;";
    $dbname = "XXXXX";
 // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    
    $sql = "select * from swtickets where email = '".$clientemail->email."' order by ticketid desc limit 3";
   // echo $sql;exit;
    $result = $conn->query($sql);
    while ($data = mysql_fetch_array($result)) {
    $tid = $data["ticketmaskid"];
       $title = $data["subject"];
       $department = $data["departmenttitle"];
       $date = fromMySQLDate($date);
   
	$bodyhtml = '<p class="mytitleannoun"><i class="fa fa-file-text-o" aria-hidden="true" style="margin-right:15px;"></i><a style="margin-right:15px;" href="/viewticket.php?tid='.$tid.'">'.$title.'</a><span>'.$department.'</span><span>'.$tid.'</span><font color="#b3b3b3">'.$date.'</font></p>';

}

    $examplePanel = $homePagePanels->addChild( 'Recent Support Ticket', array(
			'label' => Lang::trans('Support Ticket'),
			'icon' => 'fa-example'
			'bodyHtml' => $bodyhtml . '</p>'
			));
});

 

Link to comment
Share on other sites

17 hours ago, techwthquestion said:

I am not sure why I am unable to get support ticket count.

looking at that code, you're not wanting a ticket count (which you could get with two lines of code), but to output a list of tickets with links - there are 5 obvious issues I can see from a quick look at the code (but there may be more)..

1. you won't have access to $vars in the panels hook so you'll never be able to get the email address with that capsule query - but you know that the client will be logged in and therefore you can use...

GLOBAL $smarty;
$clientemail = $smarty->getTemplateVars()['clientsdetails']['email'];

2. you would then use $clientemail in the $sql definition rather than $clientemail->email

3. the $date variable is defined incorrectly, e.g it's referencing itself.

4. the $bodyhtml definition should use .= rather than = (otherwise you'll just be outputting the last ticket of the query and not all of them).

5. there is a comma missing after 'fa-example',

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