Jump to content

A better Cancel Requests page


Recommended Posts

Here is a better way to do the Cancellation Requests page in admin.

 

I did not want to delete the record after I processed the request. I wanted to be able to look back and see why, when and how a customer canceled.

 

I am sure many of you would like to do this a swell.

 

Well, I created a quick solution that does this.

 

First you need to add a status column to the tblcancelrequests table...

 

ALTER TABLE `tblcancelrequests` ADD `status` TINYINT( 1 ) NOT NULL DEFAULT '0';

 

Then here is the code for the actual page that shows the listings...


<?

// Use standard WHMCS db connections
require("dbconnect.php"); 

$my_url = "http://www.yoursite.com"; // your url to whmcs , no ending slash

function who($id){

// Get info from tblhosting
$rs = mysql_query("SELECT userid, domain, packageid FROM tblhosting WHERE id = $id LIMIT 1");
if (mysql_num_rows($rs) > 0) {
	list($userid, $domain, $packageid) = mysql_fetch_array($rs);
	mysql_free_result($rs);

}

// Get info from tblclients
$rs = mysql_query("SELECT firstname, lastname FROM tblclients WHERE id = $userid LIMIT 1");
if (mysql_num_rows($rs) > 0) {
	list($firstname, $lastname) = mysql_fetch_array($rs);
	mysql_free_result($rs);

}

// Get info from tblproducts
$rs = mysql_query("SELECT name FROM tblproducts WHERE id = $packageid LIMIT 1");
if (mysql_num_rows($rs) > 0) {
	list($pkgname) = mysql_fetch_array($rs);
	mysql_free_result($rs);

}

$whoinfo = "[b]<a href=\"$my_url/admin/clientssummary.php?userid=$userid\"  target=\"_blank\">$firstname $lastname</a>[/b]\n";
$whoinfo .= "( <a href=\"$my_url/admin/clientshosting.php?userid=$userid&hostingid=$id\" target=\"_blank\">$domain</a> ) [i]$pkgname[/i]";

return $whoinfo;

}


if($_POST['dothis'] == "process"){

foreach ($_POST['cancel_complete'] as $v) {


mysql_query("UPDATE tblcancelrequests SET status =  1 WHERE id = $v");


}

}


?>
<html>
<head>
<title>WHMCompleteSolution - Cancel Requests</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="admin/style.css" rel="stylesheet" type="text/css">


<style type="text/css">
body{margin:20px;}
.request {margin:4px; background:#FFF; padding:6px; border:1px solid gray; }
   .cancel_reason {margin:4px; color:gray; background:#EEE; padding:6px; border:1px dotted #CCC; }
   .red {color:red; font-style:italic;}
   .green {color:green; font-style:italic;}
 </style>


</head>
<body>

<h1>Cancellations</h1>
<h3>Unresolved Requests</h3>

<form action="<?php echo $PHP_SELF; ?>" method="POST">
<input type="hidden" name="dothis" value="process" />

<?

$sql = "SELECT * FROM tblcancelrequests WHERE status = 0 ORDER BY date DESC";
$rs = mysql_query($sql);

while($row = mysql_fetch_array($rs))
{ 
if($row['status']){
	$status = "<span class=\"green\">Request Complete</span>";
	}else{
	$status ="<span class=\"red\">Request Unresolved</span>";
	}

$who = who($row['relid']);
$str .= "<div class=\"request\">\n";
$str .= $who;
$str .= "
Date: ".$row['date']. "  Status: ".$status."";
$str .= "<div class=\"cancel_reason\">[b]Reason:[/b]
\n";
$str .= $row['reason']."</div>\n\n";
$str .= "<input type=\"checkbox\" name=\"cancel_complete[]\" value=\"".$row['id']."\" /> Request Completed";
$str .= " <input type=\"submit\"></div>";


}


echo $str;

?>

</form>

</body>
</html>

 

Name the page my_cancelrequests.php

 

I added mine as a link on the Browser area of the WHMCS admin.

 

You can mark the requests as processed without deleting the actual record.

 

Enjoy!:-)

Link to comment
Share on other sites

  • 3 weeks later...
I will try and add some search functionaily in a post tomorrow ;)

 

How did that go ?

 

I'm currently logged in as a client in WHMCS and cant even see where you can cancel a product :(

 

And yes, Show Cancellation Link Tick this box to show a cancellation link in package & product details views in the client area - is ticked ;)

Link to comment
Share on other sites

othellotech, when enabled, it usually shows a button when you are viewing the product details

 

if you edited your templates and didn't include the if statement to test for cancellations, then it won't show of course. Maybe that's why?

Link to comment
Share on other sites

  • 4 months later...

does not work for me.... tried finding mc_config.php but where is it located?

 

Warning: main(mc_config.php) [function.main]: failed to open stream: No such file or directory in /home/sgoxygen/domains/sgoxygen.com/public_html/whmcs/cancelrequest.php on line 4

 

Warning: main() [function.include]: Failed opening 'mc_config.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/sgoxygen/domains/sgoxygen.com/public_html/whmcs/cancelrequest.php on line 4

 

Cancellations

Unresolved Requests

Link to comment
Share on other sites

does not work for me.... tried finding mc_config.php but where is it located?

 

Warning: main(mc_config.php) [function.main]: failed to open stream: No such file or directory in /home/sgoxygen/domains/sgoxygen.com/public_html/whmcs/cancelrequest.php on line 4

 

Warning: main() [function.include]: Failed opening 'mc_config.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/sgoxygen/domains/sgoxygen.com/public_html/whmcs/cancelrequest.php on line 4

 

Cancellations

Unresolved Requests

 

Oops, just delete line 4 and it will work.

Link to comment
Share on other sites

  • 4 weeks 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