yabado Posted May 14, 2007 Share Posted May 14, 2007 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! 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 14, 2007 Share Posted May 14, 2007 nice. if something like this could be added to the distribution, that's be nice. 0 Quote Link to comment Share on other sites More sharing options...
Patty Posted May 14, 2007 Share Posted May 14, 2007 Yeap. Love that! Tks for sharing. 0 Quote Link to comment Share on other sites More sharing options...
yabado Posted May 14, 2007 Author Share Posted May 14, 2007 My hope was that Matt will see this and make it part of the regular distribution 0 Quote Link to comment Share on other sites More sharing options...
tracktor Posted May 14, 2007 Share Posted May 14, 2007 My hope was that Matt will see this and make it part of the regular distribution yess, thanks for the contribution 0 Quote Link to comment Share on other sites More sharing options...
yabado Posted May 14, 2007 Author Share Posted May 14, 2007 I will try and add some search functionaily in a post tomorrow 0 Quote Link to comment Share on other sites More sharing options...
othellotech Posted May 31, 2007 Share Posted May 31, 2007 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 0 Quote Link to comment Share on other sites More sharing options...
trine Posted May 31, 2007 Share Posted May 31, 2007 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? 0 Quote Link to comment Share on other sites More sharing options...
congkai Posted October 23, 2007 Share Posted October 23, 2007 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 0 Quote Link to comment Share on other sites More sharing options...
yabado Posted October 23, 2007 Author Share Posted October 23, 2007 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. 0 Quote Link to comment Share on other sites More sharing options...
congkai Posted October 24, 2007 Share Posted October 24, 2007 why does it shows this now? what happen? lol.. or rather, how to use it? Cancellations Unresolved Requests 0 Quote Link to comment Share on other sites More sharing options...
WHMCS CEO Matt Posted November 19, 2007 WHMCS CEO Share Posted November 19, 2007 A completed and pending list of cancellation requests is now present in the system by default as of V3.4.1. Matt 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.